diff options
author | Allan Wang <me@allanwang.ca> | 2020-02-23 16:06:45 -0800 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2020-02-23 16:06:45 -0800 |
commit | c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc (patch) | |
tree | 0841d112c8c00504ce10ca72ef39e403b69c595c /app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt | |
parent | 4d5aaf541dbfa7d521ebbc5f011a642c83c4b9c5 (diff) | |
download | frost-c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc.tar.gz frost-c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc.tar.bz2 frost-c8b54fd10a08ed53eb7d21578a4fe990fe14e3bc.zip |
Move prefs to service locator
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt index 3ab954c6..6013dbf6 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt @@ -34,6 +34,8 @@ import com.pitchedapps.frost.utils.isFacebookUrl import java.io.File import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext +import org.koin.core.KoinComponent +import org.koin.core.inject /** * Created by Allan Wang on 2018-01-05. @@ -44,8 +46,9 @@ class DebugWebView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : WebView(context, attrs, defStyleAttr) { +) : WebView(context, attrs, defStyleAttr), KoinComponent { + private val prefs: Prefs by inject() var onPageFinished: (String?) -> Unit = {} init { @@ -93,7 +96,7 @@ class DebugWebView @JvmOverloads constructor( private fun injectBackgroundColor() { setBackgroundColor( - if (url.isFacebookUrl) Prefs.bgColor.withAlpha(255) + if (url.isFacebookUrl) prefs.bgColor.withAlpha(255) else Color.WHITE ) } @@ -104,15 +107,16 @@ class DebugWebView @JvmOverloads constructor( if (url.isFacebookUrl) view.jsInject( // CssHider.CORE, - CssHider.COMPOSER.maybe(!Prefs.showComposer), - CssHider.STORIES.maybe(!Prefs.showStories), - CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!Prefs.showSuggestedFriends), - CssHider.SUGGESTED_GROUPS.maybe(!Prefs.showSuggestedGroups), - Prefs.themeInjector, + CssHider.COMPOSER.maybe(!prefs.showComposer), + CssHider.STORIES.maybe(!prefs.showStories), + CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!prefs.showSuggestedFriends), + CssHider.SUGGESTED_GROUPS.maybe(!prefs.showSuggestedGroups), + prefs.themeInjector, CssHider.NON_RECENT.maybe( (url?.contains("?sk=h_chr") ?: false) && - Prefs.aggressiveRecents - ) + prefs.aggressiveRecents + ), + prefs= prefs ) } } |