diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt | 112 |
1 files changed, 67 insertions, 45 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt index 64d9dba2..34f1ba1c 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt @@ -33,7 +33,6 @@ import com.pitchedapps.frost.utils.frostEvent import com.pitchedapps.frost.utils.frostNavigationBar import com.pitchedapps.frost.utils.frostSnackbar import com.pitchedapps.frost.utils.launchTabCustomizerActivity -import com.pitchedapps.frost.utils.setFrostTheme import com.pitchedapps.frost.views.KPrefTextSeekbar /** @@ -43,7 +42,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { header(R.string.theme_customization) - text(R.string.theme, prefs::theme, { prefs.theme = it }) { + text(R.string.theme, prefs::theme, { themeProvider.setTheme(it) }) { onClick = { materialDialog { title(R.string.theme) @@ -55,7 +54,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { item.pref = index shouldRestartMain() reload() - setFrostTheme(themeProvider, true) + activityThemer.setFrostTheme(forceTransparent = true) themeExterior() invalidateOptionsMenu() frostEvent("Theme", "Count" to Theme(index).name) @@ -70,7 +69,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { fun KPrefColorPicker.KPrefColorContract.dependsOnCustom() { enabler = themeProvider::isCustomTheme - onDisabledClick = { frostSnackbar(R.string.requires_custom_theme) } + onDisabledClick = { frostSnackbar(R.string.requires_custom_theme, themeProvider) } allowCustom = true } @@ -78,53 +77,68 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { themeProvider.reset() } - colorPicker(R.string.text_color, prefs::customTextColor, { - prefs.customTextColor = it - reload() - invalidateCustomTheme() - shouldRestartMain() - }) { + colorPicker( + R.string.text_color, prefs::customTextColor, + { + prefs.customTextColor = it + reload() + invalidateCustomTheme() + shouldRestartMain() + } + ) { dependsOnCustom() allowCustomAlpha = false } - colorPicker(R.string.accent_color, prefs::customAccentColor, { - prefs.customAccentColor = it - reload() - invalidateCustomTheme() - shouldRestartMain() - }) { + colorPicker( + R.string.accent_color, prefs::customAccentColor, + { + prefs.customAccentColor = it + reload() + invalidateCustomTheme() + shouldRestartMain() + } + ) { dependsOnCustom() allowCustomAlpha = false } - colorPicker(R.string.background_color, prefs::customBackgroundColor, { - prefs.customBackgroundColor = it - bgCanvas.ripple(it, duration = 500L) - invalidateCustomTheme() - setFrostTheme(themeProvider, true) - shouldRestartMain() - }) { + colorPicker( + R.string.background_color, prefs::customBackgroundColor, + { + prefs.customBackgroundColor = it + bgCanvas.ripple(it, duration = 500L) + invalidateCustomTheme() + activityThemer.setFrostTheme(forceTransparent = true) + shouldRestartMain() + } + ) { dependsOnCustom() allowCustomAlpha = true } - colorPicker(R.string.header_color, prefs::customHeaderColor, { - prefs.customHeaderColor = it - frostNavigationBar(prefs, themeProvider) - toolbarCanvas.ripple(it, RippleCanvas.MIDDLE, RippleCanvas.END, duration = 500L) - reload() - shouldRestartMain() - }) { + colorPicker( + R.string.header_color, prefs::customHeaderColor, + { + prefs.customHeaderColor = it + frostNavigationBar(prefs, themeProvider) + toolbarCanvas.ripple(it, RippleCanvas.MIDDLE, RippleCanvas.END, duration = 500L) + reload() + shouldRestartMain() + } + ) { dependsOnCustom() allowCustomAlpha = true } - colorPicker(R.string.icon_color, prefs::customIconColor, { - prefs.customIconColor = it - invalidateOptionsMenu() - shouldRestartMain() - }) { + colorPicker( + R.string.icon_color, prefs::customIconColor, + { + prefs.customIconColor = it + invalidateOptionsMenu() + shouldRestartMain() + } + ) { dependsOnCustom() allowCustomAlpha = false } @@ -134,7 +148,8 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { text( R.string.main_activity_layout, prefs::mainActivityLayoutType, - { prefs.mainActivityLayoutType = it }) { + { prefs.mainActivityLayoutType = it } + ) { textGetter = { string(prefs.mainActivityLayout.titleRes) } onClick = { materialDialog { @@ -158,11 +173,14 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { onClick = { launchTabCustomizerActivity() } } - checkbox(R.string.tint_nav, prefs::tintNavBar, { - prefs.tintNavBar = it - frostNavigationBar(prefs, themeProvider) - setFrostResult(REQUEST_NAV) - }) { + checkbox( + R.string.tint_nav, prefs::tintNavBar, + { + prefs.tintNavBar = it + frostNavigationBar(prefs, themeProvider) + setFrostResult(REQUEST_NAV) + } + ) { descRes = R.string.tint_nav_desc } @@ -174,12 +192,16 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { ) { prefs.webTextScaling = it setFrostResult(REQUEST_TEXT_ZOOM) - }) + } + ) ) - checkbox(R.string.enforce_black_media_bg, prefs::blackMediaBg, { - prefs.blackMediaBg = it - }) { + checkbox( + R.string.enforce_black_media_bg, prefs::blackMediaBg, + { + prefs.blackMediaBg = it + } + ) { descRes = R.string.enforce_black_media_bg_desc } } |