aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/web
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-01 00:21:04 -0700
committerAllan Wang <me@allanwang.ca>2017-06-01 00:21:04 -0700
commit4cbcabb122e4bdf5d8e3eb67213ec7270d7aa9f0 (patch)
tree93ed7ff19412da306c6e7abf7f38fe035ab88e10 /app/src/main/kotlin/com/pitchedapps/frost/web
parent8618670b82641d5fbaec9c333f1290bab429ce27 (diff)
downloadfrost-4cbcabb122e4bdf5d8e3eb67213ec7270d7aa9f0.tar.gz
frost-4cbcabb122e4bdf5d8e3eb67213ec7270d7aa9f0.tar.bz2
frost-4cbcabb122e4bdf5d8e3eb67213ec7270d7aa9f0.zip
working injectors and redid tabs db
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt15
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt13
3 files changed, 27 insertions, 3 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt
new file mode 100644
index 00000000..8367255a
--- /dev/null
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClient.kt
@@ -0,0 +1,15 @@
+package com.pitchedapps.frost.web
+
+import android.webkit.ConsoleMessage
+import android.webkit.WebChromeClient
+import com.pitchedapps.frost.utils.L
+
+/**
+ * Created by Allan Wang on 2017-05-31.
+ */
+class FrostChromeClient:WebChromeClient() {
+ override fun onConsoleMessage(consoleMessage: ConsoleMessage): Boolean {
+ L.d("Console ${consoleMessage.lineNumber()}: ${consoleMessage.message()}")
+ return super.onConsoleMessage(consoleMessage)
+ }
+} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt
index 27312763..de7860da 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt
@@ -49,8 +49,10 @@ class FrostWebView @JvmOverloads constructor(
@SuppressLint("SetJavaScriptEnabled")
fun setupWebview() {
settings.javaScriptEnabled = true
+ settings.domStorageEnabled = true
setLayerType(View.LAYER_TYPE_HARDWARE, null)
setWebViewClient(FrostWebViewClient(observable))
+ setWebChromeClient(FrostChromeClient())
}
override fun loadUrl(url: String?) {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt
index 14fcc22a..379bb22d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt
@@ -1,8 +1,11 @@
package com.pitchedapps.frost.web
import android.graphics.Bitmap
+import android.view.View
import android.webkit.*
+import com.pitchedapps.frost.facebook.FACEBOOK_COM
import com.pitchedapps.frost.facebook.FbCookie
+import com.pitchedapps.frost.injectors.CssAssets
import com.pitchedapps.frost.utils.L
import io.reactivex.subjects.Subject
@@ -11,11 +14,10 @@ import io.reactivex.subjects.Subject
*/
class FrostWebViewClient(val observable: Subject<WebStatus>) : WebViewClient() {
- private var injectionCount: Int = 0
-
companion object {
//Collections of jewels mapped with url match -> id
val jewelMap: Map<String, String> = mapOf("a" to "b")
+
fun test() {
}
@@ -29,16 +31,21 @@ class FrostWebViewClient(val observable: Subject<WebStatus>) : WebViewClient() {
override fun onPageStarted(view: WebView, url: String, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)
- injectionCount = 0
observable.onNext(WebStatus.LOADING)
L.d("FWV Loading $url")
+ if (!url.contains(FACEBOOK_COM)) return
if (url.contains("logout.php")) FbCookie.logout()
+ view.visibility = View.INVISIBLE
}
override fun onPageFinished(view: WebView, url: String) {
super.onPageFinished(view, url)
+ if (!url.contains(FACEBOOK_COM)) return
observable.onNext(WebStatus.LOADED)
FbCookie.checkUserId(url, CookieManager.getInstance().getCookie(url))
+ CssAssets.BASE.inject(view, {
+ view.visibility = View.VISIBLE
+ })
}
fun logout() {