Merge pull request #3761 from wiktor-k/notification-settings

Notification settings
This commit is contained in:
cketti 2018-12-01 21:27:10 +01:00 committed by GitHub
commit 328b7a1d11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 0 deletions

View file

@ -1,6 +1,7 @@
package com.fsck.k9.ui.settings.account
import android.content.Intent
import android.os.Build
import android.os.Bundle
import android.support.v14.preference.SwitchPreference
import android.support.v7.preference.ListPreference
@ -65,6 +66,7 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
initializeLocalStorageProvider()
initializeCryptoSettings(account)
initializeFolderSettings(account)
initializeNotifications()
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
@ -162,6 +164,14 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
}
}
private fun initializeNotifications() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
PRE_SDK26_NOTIFICATION_PREFERENCES.forEach { findPreference(it).remove() }
} else {
findPreference(PREFERENCE_OPEN_NOTIFICATION_SETTINGS).remove()
}
}
private fun initializeCryptoSettings(account: Account) {
findPreference(PREFERENCE_OPENPGP)?.let {
configureCryptoPreferences(account)
@ -315,7 +325,11 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
private const val PREFERENCE_SENT_FOLDER = "sent_folder"
private const val PREFERENCE_SPAM_FOLDER = "spam_folder"
private const val PREFERENCE_TRASH_FOLDER = "trash_folder"
private const val PREFERENCE_OPEN_NOTIFICATION_SETTINGS = "open_notification_settings"
private const val DELETE_POLICY_MARK_AS_READ = "MARK_AS_READ"
private val PRE_SDK26_NOTIFICATION_PREFERENCES = arrayOf("account_ringtone", "account_vibrate",
"account_vibrate_pattern", "account_vibrate_times", "account_led",
"led_color");
fun create(accountUuid: String, rootKey: String?) = AccountSettingsFragment().withArguments(
ARG_ACCOUNT_UUID to accountUuid,

View file

@ -0,0 +1,37 @@
package com.fsck.k9.ui.settings.account
import android.annotation.SuppressLint
import android.content.Context
import android.content.Intent
import android.provider.Settings
import android.support.v4.app.DialogFragment
import android.support.v4.content.ContextCompat.startActivity
import android.support.v4.content.res.TypedArrayUtils
import android.support.v7.preference.Preference
import android.util.AttributeSet
import com.takisoft.fix.support.v7.preference.PreferenceFragmentCompat
@SuppressLint("RestrictedApi")
class NotificationsPreference
@JvmOverloads
constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = TypedArrayUtils.getAttr(context, android.support.v7.preference.R.attr.preferenceStyle,
android.R.attr.preferenceStyle),
defStyleRes: Int = 0
) : Preference(context, attrs, defStyleAttr, defStyleRes) {
override fun onClick() {
val intent = Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
intent.putExtra(Settings.EXTRA_APP_PACKAGE, this.context.packageName)
startActivity(this.context, intent, null)
}
companion object {
init {
PreferenceFragmentCompat.registerPreferenceFragment(
NotificationsPreference::class.java, DialogFragment::class.java)
}
}
}

View file

@ -558,6 +558,8 @@ Please submit bug reports, contribute new features and ask questions at
<string name="account_settings_notification_opens_unread_summary">Searches for unread messages when Notification is opened</string>
<string name="account_settings_mark_message_as_read_on_view_label">Mark as read when opened</string>
<string name="account_settings_mark_message_as_read_on_view_summary">Mark a message as read when it is opened for viewing</string>
<string name="account_settings_notification_open_system_notifications_label">Notification settings</string>
<string name="account_settings_notification_open_system_notifications_summary">Open system notification settings</string>
<string name="account_settings_show_pictures_label">Always show images</string>
<string name="account_settings_show_pictures_never">No</string>

View file

@ -392,6 +392,11 @@
android:summary="@string/account_settings_notification_opens_unread_summary"
android:title="@string/account_settings_notification_opens_unread_label" />
<com.fsck.k9.ui.settings.account.NotificationsPreference
android:key="open_notification_settings"
android:summary="@string/account_settings_notification_open_system_notifications_summary"
android:title="@string/account_settings_notification_open_system_notifications_label" />
</PreferenceScreen>
<PreferenceScreen