diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web')
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() { |