aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-01-10 22:13:28 -0500
committerGitHub <noreply@github.com>2018-01-10 22:13:28 -0500
commitfd5f2a82eb968b5d50f586925ebb705249062446 (patch)
tree7e2cb3edad1e2398d74eb2780a912ed05188db41 /app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
parentad97b4ff946b4ba3a3f7ac880575eed9de810166 (diff)
downloadfrost-fd5f2a82eb968b5d50f586925ebb705249062446.tar.gz
frost-fd5f2a82eb968b5d50f586925ebb705249062446.tar.bz2
frost-fd5f2a82eb968b5d50f586925ebb705249062446.zip
Misc (#614)
* Add locale log * Add flyweight design for authenticator * Add option to have instant messages only * Update interceptor * Add hd image model loader (#613) * Launch image view for view full image * Update changelog * Greatly improve ImageActivity loading * Update hashes * Add back keyword filter * Clean up
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt51
1 files changed, 41 insertions, 10 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
index 1108f5d4..2ee086c0 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
@@ -23,7 +23,7 @@ import com.pitchedapps.frost.views.Keywords
fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
text(R.string.notification_frequency, Prefs::notificationFreq, { Prefs.notificationFreq = it }) {
- val options = longArrayOf(-1, 15, 30, 60, 120, 180, 300, 1440, 2880)
+ val options = longArrayOf(15, 30, 60, 120, 180, 300, 1440, 2880)
val texts = options.map { if (it <= 0) string(R.string.no_notifications) else minuteToText(it) }
onClick = {
materialDialogThemed {
@@ -36,6 +36,12 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
})
}
}
+ enabler = {
+ val enabled = Prefs.notificationsGeneral || Prefs.notificationsInstantMessages
+ if (!enabled)
+ scheduleNotifications(-1)
+ enabled
+ }
textGetter = { minuteToText(it) }
}
@@ -52,15 +58,34 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
}
}
- checkbox(R.string.notification_all_accounts, Prefs::notificationAllAccounts, { Prefs.notificationAllAccounts = it }) {
- descRes = R.string.notification_all_accounts_desc
+ checkbox(R.string.notification_general, Prefs::notificationsGeneral,
+ {
+ Prefs.notificationsGeneral = it
+ reloadByTitle(R.string.notification_general_all_accounts)
+ if (!Prefs.notificationsInstantMessages)
+ reloadByTitle(R.string.notification_frequency)
+ }) {
+ descRes = R.string.notification_general_desc
+ }
+
+ checkbox(R.string.notification_general_all_accounts, Prefs::notificationAllAccounts,
+ { Prefs.notificationAllAccounts = it }) {
+ descRes = R.string.notification_general_all_accounts_desc
+ enabler = Prefs::notificationsGeneral
}
- checkbox(R.string.notification_messages, Prefs::notificationsInstantMessages, { Prefs.notificationsInstantMessages = it; reloadByTitle(R.string.notification_messages_all_accounts) }) {
+ checkbox(R.string.notification_messages, Prefs::notificationsInstantMessages,
+ {
+ Prefs.notificationsInstantMessages = it
+ reloadByTitle(R.string.notification_messages_all_accounts)
+ if (!Prefs.notificationsGeneral)
+ reloadByTitle(R.string.notification_frequency)
+ }) {
descRes = R.string.notification_messages_desc
}
- checkbox(R.string.notification_messages_all_accounts, Prefs::notificationsImAllAccounts, { Prefs.notificationsImAllAccounts = it }) {
+ checkbox(R.string.notification_messages_all_accounts, Prefs::notificationsImAllAccounts,
+ { Prefs.notificationsImAllAccounts = it }) {
descRes = R.string.notification_messages_all_accounts_desc
enabler = Prefs::notificationsInstantMessages
}
@@ -91,22 +116,28 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
}
}
- text(R.string.notification_ringtone, Prefs::notificationRingtone, { Prefs.notificationRingtone = it }) {
+ text(R.string.notification_ringtone, Prefs::notificationRingtone,
+ { Prefs.notificationRingtone = it }) {
ringtone(SettingsActivity.REQUEST_NOTIFICATION_RINGTONE)
}
- text(R.string.message_ringtone, Prefs::messageRingtone, { Prefs.messageRingtone = it }) {
+ text(R.string.message_ringtone, Prefs::messageRingtone,
+ { Prefs.messageRingtone = it }) {
ringtone(SettingsActivity.REQUEST_MESSAGE_RINGTONE)
}
- checkbox(R.string.notification_vibrate, Prefs::notificationVibrate, { Prefs.notificationVibrate = it })
+ checkbox(R.string.notification_vibrate, Prefs::notificationVibrate,
+ { Prefs.notificationVibrate = it })
- checkbox(R.string.notification_lights, Prefs::notificationLights, { Prefs.notificationLights = it })
+ checkbox(R.string.notification_lights, Prefs::notificationLights,
+ { Prefs.notificationLights = it })
plainText(R.string.notification_fetch_now) {
descRes = R.string.notification_fetch_now_desc
onClick = {
- val text = if (fetchNotifications()) R.string.notification_fetch_success else R.string.notification_fetch_fail
+ val text =
+ if (fetchNotifications()) R.string.notification_fetch_success
+ else R.string.notification_fetch_fail
frostSnackbar(text)
}
}