diff options
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 | 48 |
1 files changed, 34 insertions, 14 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 ac62f142..bb196221 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt @@ -1,13 +1,29 @@ +/* + * Copyright 2018 Allan Wang + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package com.pitchedapps.frost.web import android.annotation.SuppressLint import android.content.Context import android.graphics.Bitmap import android.graphics.Color -import android.support.annotation.WorkerThread import android.util.AttributeSet import android.view.View import android.webkit.WebView +import androidx.annotation.WorkerThread import com.pitchedapps.frost.facebook.USER_AGENT_BASIC import com.pitchedapps.frost.injectors.CssAssets import com.pitchedapps.frost.injectors.CssHider @@ -25,7 +41,9 @@ import java.io.File * A barebone webview with a refresh listener */ class DebugWebView @JvmOverloads constructor( - context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 ) : WebView(context, attrs, defStyleAttr) { var onPageFinished: (String?) -> Unit = {} @@ -71,25 +89,27 @@ class DebugWebView @JvmOverloads constructor( private fun injectBackgroundColor() { setBackgroundColor( - if (url.isFacebookUrl) Prefs.bgColor.withAlpha(255) - else Color.WHITE) + if (url.isFacebookUrl) Prefs.bgColor.withAlpha(255) + else Color.WHITE + ) } - override fun onPageCommitVisible(view: WebView, url: String?) { super.onPageCommitVisible(view, url) injectBackgroundColor() if (url.isFacebookUrl) view.jsInject( - CssAssets.ROUND_ICONS.maybe(Prefs.showRoundedIcons), + CssAssets.ROUND_ICONS.maybe(Prefs.showRoundedIcons), // CssHider.CORE, - CssHider.COMPOSER.maybe(!Prefs.showComposer), - 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)) + CssHider.COMPOSER.maybe(!Prefs.showComposer), + 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 + ) + ) } } - -}
\ No newline at end of file +} |