aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/web
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-01-07 02:43:57 -0500
committerGitHub <noreply@github.com>2018-01-07 02:43:57 -0500
commit8aece5e3f9209d7c161410c304655f0aec2d6054 (patch)
tree1a68d7289a7e67dfaba37a9152fc3942f944bc5e /app/src/main/kotlin/com/pitchedapps/frost/web
parent726d2a4dc3d3158490ca94b660b195898becb30a (diff)
downloadfrost-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')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/DebugWebView.kt54
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt4
3 files changed, 57 insertions, 3 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
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
index 8eec3402..9a3dc331 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostUrlOverlayValidator.kt
@@ -46,7 +46,7 @@ fun FrostWebView.requestWebOverlay(url: String): Boolean {
//already overlay; manage user agent
if (userAgentString != USER_AGENT_BASIC && url.formattedFbUrl.shouldUseBasicAgent) {
L.i { "Switch to basic agent overlay" }
- context.launchWebOverlay(url, WebOverlayBasicActivity::class.java)
+ context.launchWebOverlayBasic(url)
return true
}
if (context is WebOverlayBasicActivity && !url.formattedFbUrl.shouldUseBasicAgent) {
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 a826066d..9e5f4996 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt
@@ -55,9 +55,9 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() {
fun launchLogin(c: Context) {
if (c is MainActivity && c.cookies().isNotEmpty())
- c.launchNewTask(SelectorActivity::class.java, c.cookies())
+ c.launchNewTask<SelectorActivity>(c.cookies())
else
- c.launchNewTask(LoginActivity::class.java)
+ c.launchNewTask<LoginActivity>()
}
private fun injectBackgroundColor() {