From 8aece5e3f9209d7c161410c304655f0aec2d6054 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 7 Jan 2018 02:43:57 -0500 Subject: Feature/website debug (#603) * Create beginning of web downloader * Clean up * Update KAU for reified activity launching * Update web attachments and setFrostColor * Test other zipper * Test simpler image saving model * Finish up image activity * Restore aggressive overlays * Try new zipper * Test again * Fix tests * Add working build * Rename * Support cancellation --- .../com/pitchedapps/frost/web/DebugWebView.kt | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt new file mode 100644 index 00000000..3cc10236 --- /dev/null +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt @@ -0,0 +1,54 @@ +package com.pitchedapps.frost.web + +import android.annotation.SuppressLint +import android.content.Context +import android.graphics.Color +import android.util.AttributeSet +import android.view.View +import android.webkit.CookieManager +import android.webkit.WebResourceRequest +import android.webkit.WebView +import com.pitchedapps.frost.facebook.FB_USER_MATCHER +import com.pitchedapps.frost.facebook.USER_AGENT_BASIC +import com.pitchedapps.frost.facebook.get +import com.pitchedapps.frost.injectors.CssHider +import com.pitchedapps.frost.injectors.jsInject +import com.pitchedapps.frost.utils.L +import com.pitchedapps.frost.utils.Prefs +import com.pitchedapps.frost.utils.isFacebookUrl +import org.jetbrains.anko.doAsync +import org.jetbrains.anko.uiThread + +/** + * Created by Allan Wang on 2018-01-05. + * + * A barebone webview with a refresh listener + */ +class DebugWebView @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 +) : WebView(context, attrs, defStyleAttr) { + + var onPageFinished: (String?) -> Unit = {} + + init { + setupWebview() + } + + @SuppressLint("SetJavaScriptEnabled") + fun setupWebview() { + settings.javaScriptEnabled = true + settings.userAgentString = USER_AGENT_BASIC + setLayerType(View.LAYER_TYPE_HARDWARE, null) + webViewClient = DebugClient() + } + + private inner class DebugClient : BaseWebViewClient() { + + override fun onPageFinished(view: WebView, url: String?) { + super.onPageFinished(view, url) + onPageFinished(url) + } + + } + +} \ No newline at end of file -- cgit v1.2.3