From dd391481881683e7b58a69ef2b9b671fb6197208 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 4 Aug 2019 22:45:18 -0700 Subject: Switch theme when selected in intro --- .../com/pitchedapps/frost/activities/IntroActivity.kt | 2 ++ .../com/pitchedapps/frost/intro/IntroMainFragments.kt | 2 +- .../main/kotlin/com/pitchedapps/frost/utils/Utils.kt | 18 +++++++++++------- app/src/main/res/layout/intro_analytics.xml | 2 +- app/src/main/res/layout/intro_end.xml | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) (limited to 'app') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt index 2844d833..94f8d6c1 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/IntroActivity.kt @@ -55,6 +55,7 @@ import com.pitchedapps.frost.utils.Prefs import com.pitchedapps.frost.utils.cookies import com.pitchedapps.frost.utils.launchNewTask import com.pitchedapps.frost.utils.loadAssets +import com.pitchedapps.frost.utils.setFrostTheme import com.pitchedapps.frost.widgets.NotificationWidget import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.launch @@ -113,6 +114,7 @@ class IntroActivity : KauBaseActivity(), ViewPager.PageTransformer, ViewPager.On indicator.setColour(Prefs.textColor) indicator.invalidate() fragments.forEach { it.themeFragment() } + setFrostTheme(true) } /** diff --git a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroMainFragments.kt b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroMainFragments.kt index 635bcfa5..22dd086b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroMainFragments.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/intro/IntroMainFragments.kt @@ -139,7 +139,7 @@ class IntroFragmentWelcome : BaseIntroFragment(R.layout.intro_welcome) { class IntroFragmentAnalytics : BaseIntroFragment(R.layout.intro_analytics) { - val container: ConstraintLayout by bindViewResettable(R.id.intro_end_container) + val container: ConstraintLayout by bindViewResettable(R.id.intro_analytics_container) override fun viewArray(): Array> = arrayOf( arrayOf(title), arrayOf(image), diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt index 0574aeae..8544aac3 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -137,7 +137,8 @@ private inline fun Context.launchWebOverlay fun Context.launchWebOverlay(url: String) = launchWebOverlayImpl(url) -fun Context.launchWebOverlayDesktop(url: String) = launchWebOverlayImpl(url) +fun Context.launchWebOverlayDesktop(url: String) = + launchWebOverlayImpl(url) private fun Context.fadeBundle() = ActivityOptions.makeCustomAnimation( this, @@ -154,9 +155,11 @@ fun Context.launchImageActivity(imageUrl: String, text: String? = null, cookie: } fun Activity.launchTabCustomizerActivity() { - startActivityForResult(SettingsActivity.ACTIVITY_REQUEST_TABS, bundleBuilder = { - with(fadeBundle()) - }) + startActivityForResult( + SettingsActivity.ACTIVITY_REQUEST_TABS, + bundleBuilder = { + with(fadeBundle()) + }) } fun WebOverlayActivity.url(): String { @@ -165,11 +168,12 @@ fun WebOverlayActivity.url(): String { fun Activity.setFrostTheme(forceTransparent: Boolean = false) { val isTransparent = - (Color.alpha(Prefs.bgColor) != 255) || (Color.alpha(Prefs.headerColor) != 255) || forceTransparent - if (Prefs.bgColor.isColorDark) + forceTransparent || (Color.alpha(Prefs.bgColor) != 255) || (Color.alpha(Prefs.headerColor) != 255) + if (Prefs.bgColor.isColorDark) { setTheme(if (isTransparent) R.style.FrostTheme_Transparent else R.style.FrostTheme) - else + } else { setTheme(if (isTransparent) R.style.FrostTheme_Light_Transparent else R.style.FrostTheme_Light) + } } class ActivityThemeUtils { diff --git a/app/src/main/res/layout/intro_analytics.xml b/app/src/main/res/layout/intro_analytics.xml index e0998721..a62a0b0f 100644 --- a/app/src/main/res/layout/intro_analytics.xml +++ b/app/src/main/res/layout/intro_analytics.xml @@ -2,7 +2,7 @@ diff --git a/app/src/main/res/layout/intro_end.xml b/app/src/main/res/layout/intro_end.xml index 501cf1a9..fbaa2042 100644 --- a/app/src/main/res/layout/intro_end.xml +++ b/app/src/main/res/layout/intro_end.xml @@ -2,8 +2,8 @@