diff options
author | Allan Wang <me@allanwang.ca> | 2018-01-07 02:43:57 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-07 02:43:57 -0500 |
commit | 8aece5e3f9209d7c161410c304655f0aec2d6054 (patch) | |
tree | 1a68d7289a7e67dfaba37a9152fc3942f944bc5e /app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt | |
parent | 726d2a4dc3d3158490ca94b660b195898becb30a (diff) | |
download | frost-8aece5e3f9209d7c161410c304655f0aec2d6054.tar.gz frost-8aece5e3f9209d7c161410c304655f0aec2d6054.tar.bz2 frost-8aece5e3f9209d7c161410c304655f0aec2d6054.zip |
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
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 | 54 |
1 files changed, 54 insertions, 0 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 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 |