diff options
author | Allan Wang <me@allanwang.ca> | 2021-01-12 20:46:02 -0800 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2021-01-12 20:46:02 -0800 |
commit | 0e5c1ab2dd2b574970883576e18f9a119b058788 (patch) | |
tree | ba715d7a5e0537b9598722e203956fb56d3d5c53 /app/src/main/kotlin/com/pitchedapps/frost/web | |
parent | 82fa4c5d6c75e245e74d903328b3e5d96b01b5ca (diff) | |
download | frost-0e5c1ab2dd2b574970883576e18f9a119b058788.tar.gz frost-0e5c1ab2dd2b574970883576e18f9a119b058788.tar.bz2 frost-0e5c1ab2dd2b574970883576e18f9a119b058788.zip |
Create themeprovider
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web')
3 files changed, 14 insertions, 5 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 c68d3f57..a454584e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt @@ -24,9 +24,11 @@ import android.util.AttributeSet import android.view.View import android.webkit.WebView import ca.allanwang.kau.utils.withAlpha +import com.pitchedapps.frost.enums.ThemeCategory import com.pitchedapps.frost.facebook.USER_AGENT -import com.pitchedapps.frost.injectors.CssHider import com.pitchedapps.frost.injectors.CssAsset +import com.pitchedapps.frost.injectors.CssHider +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.injectors.jsInject import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L @@ -50,6 +52,7 @@ class DebugWebView @JvmOverloads constructor( ) : WebView(context, attrs, defStyleAttr), KoinComponent { private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() var onPageFinished: (String?) -> Unit = {} init { @@ -112,7 +115,7 @@ class DebugWebView @JvmOverloads constructor( CssHider.STORIES.maybe(!prefs.showStories), CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!prefs.showSuggestedFriends), CssHider.SUGGESTED_GROUPS.maybe(!prefs.showSuggestedGroups), - prefs.themeInjector, + themeProvider.injector(ThemeCategory.FACEBOOK), CssHider.NON_RECENT.maybe( (url?.contains("?sk=h_chr") ?: false) && prefs.aggressiveRecents diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt index cf248baf..fce4c75a 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -23,15 +23,17 @@ import android.webkit.WebResourceResponse import android.webkit.WebView import android.webkit.WebViewClient import ca.allanwang.kau.utils.withAlpha +import com.pitchedapps.frost.enums.ThemeCategory import com.pitchedapps.frost.facebook.FACEBOOK_BASE_COM import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.facebook.FbItem import com.pitchedapps.frost.facebook.WWW_FACEBOOK_COM import com.pitchedapps.frost.facebook.formattedFbUrl -import com.pitchedapps.frost.injectors.CssHider import com.pitchedapps.frost.injectors.CssAsset +import com.pitchedapps.frost.injectors.CssHider import com.pitchedapps.frost.injectors.JsActions import com.pitchedapps.frost.injectors.JsAssets +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.injectors.jsInject import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L @@ -70,6 +72,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { private val fbCookie: FbCookie get() = web.fbCookie private val prefs: Prefs get() = web.prefs + private val themeProvider: ThemeProvider get() = web.themeProvider private val refresh: SendChannel<Boolean> = web.parent.refreshChannel private val isMain = web.parent.baseEnum != null @@ -110,7 +113,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { CssHider.STORIES.maybe(!prefs.showStories), CssHider.PEOPLE_YOU_MAY_KNOW.maybe(!prefs.showSuggestedFriends), CssHider.SUGGESTED_GROUPS.maybe(!prefs.showSuggestedGroups), - prefs.themeInjector, + themeProvider.injector(ThemeCategory.FACEBOOK), CssHider.NON_RECENT.maybe( (web.url?.contains("?sk=h_chr") ?: false) && prefs.aggressiveRecents diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt index 1a081d2e..fadbadf9 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt @@ -30,12 +30,14 @@ import ca.allanwang.kau.utils.fadeIn import ca.allanwang.kau.utils.isVisible import ca.allanwang.kau.utils.launchMain import com.pitchedapps.frost.db.CookieEntity +import com.pitchedapps.frost.enums.ThemeCategory import com.pitchedapps.frost.facebook.FB_LOGIN_URL import com.pitchedapps.frost.facebook.FB_USER_MATCHER import com.pitchedapps.frost.facebook.FbCookie import com.pitchedapps.frost.facebook.USER_AGENT import com.pitchedapps.frost.facebook.get import com.pitchedapps.frost.injectors.CssHider +import com.pitchedapps.frost.injectors.ThemeProvider import com.pitchedapps.frost.injectors.jsInject import com.pitchedapps.frost.prefs.Prefs import com.pitchedapps.frost.utils.L @@ -56,6 +58,7 @@ class LoginWebView @JvmOverloads constructor( private val fbCookie: FbCookie by inject() private val prefs: Prefs by inject() + private val themeProvider: ThemeProvider by inject() private val completable: CompletableDeferred<CookieEntity> = CompletableDeferred() private lateinit var progressCallback: (Int) -> Unit @@ -105,7 +108,7 @@ class LoginWebView @JvmOverloads constructor( if (url.isFacebookUrl) view.jsInject( CssHider.CORE, - prefs.themeInjector, + themeProvider.injector(ThemeCategory.FACEBOOK), prefs = prefs ) } |