From 04fb50b33c4be7f5b9c70ea209c16e40bac521b9 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 23 Feb 2020 17:06:05 -0800 Subject: Remove koincomponent for ActivityThemeUtils --- .../main/kotlin/com/pitchedapps/frost/utils/Utils.kt | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/utils') 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 854f315c..1f266eb9 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -81,8 +81,6 @@ import org.apache.commons.text.StringEscapeUtils import org.jsoup.Jsoup import org.jsoup.nodes.Document import org.jsoup.nodes.Element -import org.koin.core.KoinComponent -import org.koin.core.inject /** * Created by Allan Wang on 2017-06-03. @@ -125,7 +123,10 @@ fun Activity.cookies(): ArrayList { * Note that most requests may need to first check if the url can be launched as an overlay * See [requestWebOverlay] to verify the launch */ -private inline fun Context.launchWebOverlayImpl(url: String, fbCookie: FbCookie) { +private inline fun Context.launchWebOverlayImpl( + url: String, + fbCookie: FbCookie +) { val prefs = Prefs.get() val argUrl = url.formattedFbUrl L.v { "Launch received: $url\nLaunch web overlay: $argUrl" } @@ -141,10 +142,12 @@ private inline fun Context.launchWebOverlay } } -fun Context.launchWebOverlay(url: String, fbCookie: FbCookie) = launchWebOverlayImpl(url, fbCookie) +fun Context.launchWebOverlay(url: String, fbCookie: FbCookie) = + launchWebOverlayImpl(url, fbCookie) // 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) = + launchWebOverlay(url, fbCookie) fun Context.launchWebOverlayMobile(url: String, fbCookie: FbCookie) = launchWebOverlayImpl(url, fbCookie) @@ -186,14 +189,13 @@ fun Activity.setFrostTheme(forceTransparent: Boolean = false) { } } -class ActivityThemeUtils : KoinComponent { +class ActivityThemeUtils(val prefs: Prefs) { private var toolbar: Toolbar? = null var themeWindow = true private var texts = mutableListOf() private var headers = mutableListOf() private var backgrounds = mutableListOf() - private val prefs: Prefs by inject() fun toolbar(toolbar: Toolbar) { this.toolbar = toolbar @@ -226,8 +228,8 @@ class ActivityThemeUtils : KoinComponent { } } -inline fun Activity.setFrostColors(builder: ActivityThemeUtils.() -> Unit) { - val themer = ActivityThemeUtils() +inline fun Activity.setFrostColors(prefs: Prefs, builder: ActivityThemeUtils.() -> Unit) { + val themer = ActivityThemeUtils(prefs) themer.builder() themer.theme(this) } -- cgit v1.2.3