aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt120
1 files changed, 99 insertions, 21 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
index 79e65621..cf20aa0f 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
@@ -3,17 +3,22 @@ package com.pitchedapps.frost
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
+import ca.allanwang.kau.changelog.showChangelog
import ca.allanwang.kau.email.sendEmail
import ca.allanwang.kau.kpref.CoreAttributeContract
import ca.allanwang.kau.kpref.KPrefActivity
import ca.allanwang.kau.kpref.KPrefAdapterBuilder
import ca.allanwang.kau.kpref.items.KPrefColorPicker
+import ca.allanwang.kau.kpref.items.KPrefItemBase
import ca.allanwang.kau.utils.*
import ca.allanwang.kau.views.RippleCanvas
+import com.mikepenz.community_material_typeface_library.CommunityMaterial
import com.mikepenz.google_material_typeface_library.GoogleMaterial
+import com.pitchedapps.frost.facebook.FeedSort
import com.pitchedapps.frost.injectors.CssAssets
import com.pitchedapps.frost.utils.*
-import com.pitchedapps.frost.utils.iab.openPlayPurchase
+import com.pitchedapps.frost.utils.iab.IS_FROST_PRO
+import com.pitchedapps.frost.utils.iab.openPlayProPurchase
import com.pitchedapps.frost.views.Keywords
@@ -32,27 +37,39 @@ class SettingsActivity : KPrefActivity() {
descRes = R.string.appearance_desc
iicon = GoogleMaterial.Icon.gmd_palette
}
+
+ subItems(R.string.newsfeed, subPrefsFeed()) {
+ descRes = R.string.newsfeed_desc
+ iicon = CommunityMaterial.Icon.cmd_newspaper
+ }
+
subItems(R.string.notifications, subPrefsNotifications()) {
descRes = R.string.notifications_desc
iicon = GoogleMaterial.Icon.gmd_notifications
}
+ if (BuildConfig.DEBUG) {
+ checkbox(R.string.custom_pro, { Prefs.debugPro }, { Prefs.debugPro = it })
+ }
}
fun subPrefsAppearance(): KPrefAdapterBuilder.() -> Unit = {
- header(R.string.base_customization)
+ header(R.string.theme_customization)
text(R.string.theme, { Prefs.theme }, { Prefs.theme = it }) {
onClick = {
_, _, item ->
this@SettingsActivity.materialDialogThemed {
title(R.string.theme)
- items(Theme.values().map { this@SettingsActivity.string(it.textRes) })
+ items(Theme.values()
+ .map { if (it == Theme.CUSTOM && !IS_FROST_PRO) R.string.custom_pro else it.textRes }
+ .map { this@SettingsActivity.string(it) })
itemsCallbackSingleChoice(item.pref, {
_, _, which, text ->
if (item.pref != which) {
- if (which == Theme.CUSTOM.ordinal) {
- this@SettingsActivity.openPlayPurchase("asdf", 9)
+ if (which == Theme.CUSTOM.ordinal && !IS_FROST_PRO) {
+ this@SettingsActivity.openPlayProPurchase(9)
+ return@itemsCallbackSingleChoice true
}
item.pref = which
shouldRestartMain()
@@ -68,8 +85,7 @@ class SettingsActivity : KPrefActivity() {
true
}
textGetter = {
- this@SettingsActivity.string(if (it == Theme.CUSTOM.ordinal)
- R.string.kau_custom else Theme(it).textRes)
+ this@SettingsActivity.string(Theme(it).textRes)
}
}
@@ -83,21 +99,33 @@ class SettingsActivity : KPrefActivity() {
CssAssets.CUSTOM.injector = null
}
- colorPicker(R.string.text_color, { Prefs.customTextColor }, { Prefs.customTextColor = it; reload(); invalidateCustomTheme() }) {
+ colorPicker(R.string.text_color, { Prefs.customTextColor }, {
+ Prefs.customTextColor = it
+ reload()
+ invalidateCustomTheme()
+ shouldRestartMain()
+ }) {
dependsOnCustom()
allowCustomAlpha = false
}
- colorPicker(R.string.background_color, { Prefs.customBackgroundColor },
- { Prefs.customBackgroundColor = it; bgCanvas.ripple(it, duration = 500L); invalidateCustomTheme() }) {
+ colorPicker(R.string.background_color, { Prefs.customBackgroundColor }, {
+ Prefs.customBackgroundColor = it
+ bgCanvas.ripple(it, duration = 500L)
+ invalidateCustomTheme()
+ setFrostTheme(true)
+ shouldRestartMain()
+ }) {
dependsOnCustom()
allowCustomAlpha = true
}
colorPicker(R.string.header_color, { Prefs.customHeaderColor }, {
Prefs.customHeaderColor = it
- this@SettingsActivity.navigationBarColor = it
+ if (Prefs.tintNavBar) this@SettingsActivity.frostNavigationBar()
toolbarCanvas.ripple(it, RippleCanvas.MIDDLE, RippleCanvas.END, duration = 500L)
+ reload()
+ shouldRestartMain()
}) {
dependsOnCustom()
allowCustomAlpha = true
@@ -106,32 +134,82 @@ class SettingsActivity : KPrefActivity() {
colorPicker(R.string.icon_color, { Prefs.customIconColor }, {
Prefs.customIconColor = it
invalidateOptionsMenu()
+ shouldRestartMain()
}) {
dependsOnCustom()
allowCustomAlpha = false
}
- checkbox(R.string.rounded_icons, { Prefs.showRoundedIcons }, { Prefs.showRoundedIcons = it })
+ header(R.string.global_customization)
+
+ checkbox(R.string.rounded_icons, { Prefs.showRoundedIcons }, {
+ Prefs.showRoundedIcons = it
+ setResult(MainActivity.REQUEST_REFRESH)
+ }) {
+ descRes = R.string.rounded_icons_desc
+ }
checkbox(R.string.fancy_animations, { Prefs.animate }, { Prefs.animate = it; animate = it }) {
descRes = R.string.fancy_animations_desc
}
- header(R.string.feed_customization)
+ checkbox(R.string.tint_nav, { Prefs.tintNavBar }, {
+ Prefs.tintNavBar = it
+ this@SettingsActivity.frostNavigationBar()
+ setResult(MainActivity.REQUEST_NAV)
+ }) {
+ descRes = R.string.tint_nav_desc
+ }
+ }
+
+ fun KPrefItemBase.BaseContract<*>.dependsOnPro() {
+ onDisabledClick = { _, _, _ -> openPlayProPurchase(0); true }
+ enabler = { IS_FROST_PRO }
+ }
- checkbox(R.string.suggested_friends, { Prefs.showSuggestedFriends }, { Prefs.showSuggestedFriends = it }) {
+ fun subPrefsFeed(): KPrefAdapterBuilder.() -> Unit = {
+
+ text(R.string.newsfeed_sort, { Prefs.feedSort }, { Prefs.feedSort = it }) {
+ descRes = R.string.newsfeed_sort_desc
+ onClick = {
+ _, _, item ->
+ this@SettingsActivity.materialDialogThemed {
+ title(R.string.newsfeed_sort)
+ items(FeedSort.values().map { this@SettingsActivity.string(it.textRes) })
+ itemsCallbackSingleChoice(item.pref, {
+ _, _, which, text ->
+ if (item.pref != which) {
+ item.pref = which
+ shouldRestartMain()
+ }
+ true
+ })
+ }
+ true
+ }
+ textGetter = { string(FeedSort(it).textRes) }
+ }
+
+ checkbox(R.string.suggested_friends, { Prefs.showSuggestedFriends }, {
+ Prefs.showSuggestedFriends = it
+ setResult(MainActivity.REQUEST_REFRESH)
+ }) {
descRes = R.string.suggested_friends_desc
+ dependsOnPro()
}
- checkbox(R.string.facebook_ads, { Prefs.showFacebookAds }, { Prefs.showFacebookAds = it }) {
+ checkbox(R.string.facebook_ads, { Prefs.showFacebookAds }, {
+ Prefs.showFacebookAds = it
+ setResult(MainActivity.REQUEST_REFRESH)
+ }) {
descRes = R.string.facebook_ads_desc
+ dependsOnPro()
}
-
}
fun subPrefsNotifications(): KPrefAdapterBuilder.() -> Unit = {
- text(R.string.notification_frequency, { Prefs.notificationFreq }, { Prefs.notificationFreq = it; reloadByTitle(R.string.notification_frequency) }) {
+ text(R.string.notification_frequency, { Prefs.notificationFreq }, { Prefs.notificationFreq = it }) {
val options = longArrayOf(-1, 15, 30, 60, 120, 180, 300, 1440, 2880)
val texts = options.map { this@SettingsActivity.minuteToText(it) }
onClick = {
@@ -140,7 +218,7 @@ class SettingsActivity : KPrefActivity() {
title(R.string.notification_frequency)
items(texts)
itemsCallbackSingleChoice(options.indexOf(item.pref), {
- _, _, which, text ->
+ _, _, which, _ ->
item.pref = options[which]
this@SettingsActivity.scheduleNotifications(item.pref)
true
@@ -151,7 +229,7 @@ class SettingsActivity : KPrefActivity() {
textGetter = { this@SettingsActivity.minuteToText(it) }
}
- text<String?>(R.string.notification_keywords, { null }, { }) {
+ plainText(R.string.notification_keywords) {
descRes = R.string.notification_keywords_desc
onClick = {
_, _, _ ->
@@ -184,7 +262,7 @@ class SettingsActivity : KPrefActivity() {
else bgCanvas.set(Prefs.bgColor)
if (animate) toolbarCanvas.ripple(Prefs.headerColor, RippleCanvas.MIDDLE, RippleCanvas.END)
else toolbarCanvas.set(Prefs.headerColor)
- this.navigationBarColor = Prefs.headerColor
+ frostNavigationBar()
}
override fun onBackPressed() {
@@ -208,7 +286,7 @@ class SettingsActivity : KPrefActivity() {
R.id.action_email -> sendEmail(R.string.dev_email, R.string.frost_feedback) {
addItem("Random Frost ID", Prefs.frostId)
}
- R.id.action_changelog -> showChangelog(R.xml.changelog, { theme() })
+ R.id.action_changelog -> showChangelog(R.xml.changelog, Prefs.textColor) { theme() }
else -> return super.onOptionsItemSelected(item)
}
return true