diff options
author | Allan Wang <me@allanwang.ca> | 2020-02-29 19:29:09 -0800 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2020-02-29 19:29:09 -0800 |
commit | c5d38e5122bcb452b1e61ea6526434cf62e9da8c (patch) | |
tree | 3b31b15cd40fc81738592b8cb8af15fe23450d65 /app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt | |
parent | a93cdf52cc3b7eff1e2d4cf436b8f8dbc3cf14a2 (diff) | |
download | frost-c5d38e5122bcb452b1e61ea6526434cf62e9da8c.tar.gz frost-c5d38e5122bcb452b1e61ea6526434cf62e9da8c.tar.bz2 frost-c5d38e5122bcb452b1e61ea6526434cf62e9da8c.zip |
Update koin usage
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt | 22 |
1 files changed, 10 insertions, 12 deletions
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 1f266eb9..6db7179d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -125,9 +125,9 @@ fun Activity.cookies(): ArrayList<CookieEntity> { */ private inline fun <reified T : WebOverlayActivityBase> Context.launchWebOverlayImpl( url: String, - fbCookie: FbCookie + fbCookie: FbCookie, + prefs: Prefs ) { - val prefs = Prefs.get() val argUrl = url.formattedFbUrl L.v { "Launch received: $url\nLaunch web overlay: $argUrl" } if (argUrl.isFacebookUrl && argUrl.contains("/logout.php")) { @@ -142,15 +142,15 @@ private inline fun <reified T : WebOverlayActivityBase> Context.launchWebOverlay } } -fun Context.launchWebOverlay(url: String, fbCookie: FbCookie) = - launchWebOverlayImpl<WebOverlayActivity>(url, fbCookie) +fun Context.launchWebOverlay(url: String, fbCookie: FbCookie, prefs: Prefs) = + launchWebOverlayImpl<WebOverlayActivity>(url, fbCookie, prefs) // TODO Currently, default is overlay. Switch this if default changes -fun Context.launchWebOverlayDesktop(url: String, fbCookie: FbCookie) = - launchWebOverlay(url, fbCookie) +fun Context.launchWebOverlayDesktop(url: String, fbCookie: FbCookie, prefs: Prefs) = + launchWebOverlay(url, fbCookie, prefs) -fun Context.launchWebOverlayMobile(url: String, fbCookie: FbCookie) = - launchWebOverlayImpl<WebOverlayMobileActivity>(url, fbCookie) +fun Context.launchWebOverlayMobile(url: String, fbCookie: FbCookie, prefs: Prefs) = + launchWebOverlayImpl<WebOverlayMobileActivity>(url, fbCookie, prefs) private fun Context.fadeBundle() = ActivityOptions.makeCustomAnimation( this, @@ -178,8 +178,7 @@ fun WebOverlayActivity.url(): String { return intent.getStringExtra(ARG_URL) ?: FbItem.FEED.url } -fun Activity.setFrostTheme(forceTransparent: Boolean = false) { - val prefs = Prefs.get() +fun Activity.setFrostTheme(prefs: Prefs, forceTransparent: Boolean = false) { val isTransparent = forceTransparent || (Color.alpha(prefs.bgColor) != 255) || (Color.alpha(prefs.headerColor) != 255) if (prefs.bgColor.isColorDark) { @@ -267,8 +266,7 @@ private inline fun frostSnackbar(crossinline builder: Snackbar.() -> Unit): Snac } } -fun Activity.frostNavigationBar() { - val prefs = Prefs.get() +fun Activity.frostNavigationBar(prefs: Prefs) { navigationBarColor = if (prefs.tintNavBar) prefs.headerColor else Color.BLACK } |