aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-12-24 01:47:03 -0500
committerGitHub <noreply@github.com>2018-12-24 01:47:03 -0500
commit697d01882ba8b1dbb85484ba3bf6e810e32448fc (patch)
treef59d2407ffbd724200e3c79eb366a8da1efe0829 /app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt
parentc45b30e28f451699f3be828a1201260ed27e321e (diff)
downloadfrost-697d01882ba8b1dbb85484ba3bf6e810e32448fc.tar.gz
frost-697d01882ba8b1dbb85484ba3bf6e810e32448fc.tar.bz2
frost-697d01882ba8b1dbb85484ba3bf6e810e32448fc.zip
Enhancement/ktlint (#1259)
* Add spotless * Reformat code * Apply license header * Add remaining license headers
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.kt48
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 4ce6f005..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 androidx.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
+}