aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/settings
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-08-06 22:16:33 -0700
committerAllan Wang <me@allanwang.ca>2019-08-06 22:16:33 -0700
commit81d357ce0a17a5b11bfb17d3762540c2bd7f11be (patch)
treec8e452cdffef61b267b9ad2b06d2cd9af3848cdb /app/src/main/kotlin/com/pitchedapps/frost/settings
parent281124b649304741dd1ad508b90bf056dba1192e (diff)
downloadfrost-81d357ce0a17a5b11bfb17d3762540c2bd7f11be.tar.gz
frost-81d357ce0a17a5b11bfb17d3762540c2bd7f11be.tar.bz2
frost-81d357ce0a17a5b11bfb17d3762540c2bd7f11be.zip
Reduce notification update frequency
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/settings')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt19
2 files changed, 12 insertions, 12 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
index c4fa4c4d..1ab53a56 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
@@ -83,7 +83,10 @@ fun SettingsActivity.getBehaviourPrefs(): KPrefAdapterBuilder.() -> Unit = {
descRes = R.string.exit_confirmation_desc
}
- checkbox(R.string.web_only, Prefs::webOnly, { Prefs.webOnly = it }) {
+ checkbox(R.string.web_only, Prefs::webOnly, {
+ Prefs.webOnly = it
+ shouldRestartMain()
+ }) {
descRes = R.string.web_only_desc
}
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 baf2949f..ccf04935 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt
@@ -36,8 +36,8 @@ import com.pitchedapps.frost.activities.SettingsActivity
import com.pitchedapps.frost.db.FrostDatabase
import com.pitchedapps.frost.db.deleteAll
import com.pitchedapps.frost.services.fetchNotifications
-import com.pitchedapps.frost.services.scheduleNotifications
import com.pitchedapps.frost.utils.Prefs
+import com.pitchedapps.frost.utils.REQUEST_NOTIFICATION
import com.pitchedapps.frost.utils.frostSnackbar
import com.pitchedapps.frost.utils.frostUri
import com.pitchedapps.frost.views.Keywords
@@ -46,6 +46,10 @@ import kotlinx.coroutines.launch
/**
* Created by Allan Wang on 2017-06-29.
*/
+
+val Prefs.hasNotifications: Boolean
+ get() = !webOnly && (notificationsGeneral || notificationsInstantMessages)
+
@SuppressLint("InlinedApi")
fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
@@ -56,7 +60,7 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
message(R.string.leave_web_only_desc)
positiveButton(R.string.kau_yes) {
Prefs.webOnly = false
- reloadList()
+ reload()
}
negativeButton(R.string.kau_no)
}
@@ -78,21 +82,14 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = {
initialSelection = options.indexOf(item.pref)
) { _, index, _ ->
item.pref = options[index]
- scheduleNotifications(item.pref)
+ setFrostResult(REQUEST_NOTIFICATION)
}
}
}
onDisabledClick = {
leaveWebOnlyDialog()
}
- enabler = {
- val enabled =
- !Prefs.webOnly && (Prefs.notificationsGeneral || Prefs.notificationsInstantMessages)
- if (!enabled) {
- scheduleNotifications(-1)
- }
- enabled
- }
+ enabler = { Prefs.hasNotifications }
textGetter = { minuteToText(it) }
}