aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-19 15:31:10 -0700
committerAllan Wang <me@allanwang.ca>2017-06-19 15:31:10 -0700
commit382433780c3f4403723a78e409cb161c9fad5034 (patch)
tree1138696bdd6e04d2227acaa4ab19ee8b85b4d2f8 /app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
parent0720413ee859762fc4c2d8748ba10402dffd0be7 (diff)
downloadfrost-382433780c3f4403723a78e409cb161c9fad5034.tar.gz
frost-382433780c3f4403723a78e409cb161c9fad5034.tar.bz2
frost-382433780c3f4403723a78e409cb161c9fad5034.zip
Parse header badges
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt38
1 files changed, 32 insertions, 6 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
index 0a9732b4..b55b2a10 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
@@ -6,16 +6,18 @@ import ca.allanwang.kau.kpref.KPrefAdapterBuilder
import ca.allanwang.kau.utils.*
import ca.allanwang.kau.views.RippleCanvas
import com.pitchedapps.frost.utils.*
+import org.jetbrains.anko.toast
/**
* Created by Allan Wang on 2017-06-06.
*/
class SettingsActivity : KPrefActivity() {
+
override fun onCreateKPrefs(savedInstanceState: android.os.Bundle?): KPrefAdapterBuilder.() -> Unit = {
textColor = { Prefs.textColor }
accentColor = { Prefs.textColor }
header(R.string.settings)
- text<Int>(R.string.theme, { Prefs.theme }, { Prefs.theme = it }) {
+ text(R.string.theme, { Prefs.theme }, { Prefs.theme = it }) {
onClick = {
_, _, item ->
this@SettingsActivity.materialDialogThemed {
@@ -65,16 +67,40 @@ class SettingsActivity : KPrefActivity() {
allowCustom = true
}
- colorPicker(R.string.icon_color, { Prefs.customIconColor }, { Prefs.customIconColor = it; toolbar.setTitleTextColor(it) }) {
- enabler = { Prefs.isCustomTheme }
- onDisabledClick = { itemView, _, _ -> itemView.snackbar(R.string.requires_custom_theme); true }
- allowCustomAlpha = false
- allowCustom = true
+ fun Long.timeToText(): String =
+ if (this == -1L) string(R.string.none)
+ else if (this == 60L) string(R.string.one_hour)
+ else if (this == 1440L) string(R.string.one_day)
+ else if (this % 1440L == 0L) String.format(string(R.string.x_days), this / 1440L)
+ else if (this % 60L == 0L) String.format(string(R.string.x_hours), this / 60L)
+ else String.format(string(R.string.x_minutes), this)
+
+ text(R.string.notifications, { Prefs.notificationFreq }, { Prefs.notificationFreq = it; reloadByTitle(R.string.notifications) }) {
+ val options = longArrayOf(-1, 15, 30, 60, 120, 180, 300, 1440, 2880)
+ val texts = options.map { it.timeToText() }
+ onClick = {
+ _, _, item ->
+ this@SettingsActivity.materialDialogThemed {
+ title(R.string.notifications)
+ items(texts)
+ itemsCallbackSingleChoice(options.indexOf(item.pref), {
+ _, _, which, text ->
+ item.pref = options[which]
+ this@SettingsActivity.scheduleNotifications(item.pref)
+ this@SettingsActivity.toast(text)
+ true
+ })
+ }
+ true
+ }
+ textGetter = { it.timeToText() }
}
+
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
+ setFrostTheme()
themeExterior(false)
}