diff options
author | Allan Wang <me@allanwang.ca> | 2017-06-19 15:31:10 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-06-19 15:31:10 -0700 |
commit | 382433780c3f4403723a78e409cb161c9fad5034 (patch) | |
tree | 1138696bdd6e04d2227acaa4ab19ee8b85b4d2f8 /app/src/main/kotlin/com/pitchedapps/frost/web | |
parent | 0720413ee859762fc4c2d8748ba10402dffd0be7 (diff) | |
download | frost-382433780c3f4403723a78e409cb161c9fad5034.tar.gz frost-382433780c3f4403723a78e409cb161c9fad5034.tar.bz2 frost-382433780c3f4403723a78e409cb161c9fad5034.zip |
Parse header badges
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web')
3 files changed, 16 insertions, 3 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt index 36193b8b..532b9f82 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt @@ -10,12 +10,16 @@ import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.cookies import com.pitchedapps.frost.utils.launchNewTask import com.pitchedapps.frost.utils.launchWebOverlay +import io.reactivex.subjects.Subject /** * Created by Allan Wang on 2017-06-01. */ class FrostJSI(val context: Context, val webView: FrostWebViewCore) { + + val headerObservable: Subject<String>? = (context as? MainActivity)?.headerBadgeObservable + val cookies: ArrayList<CookieModel> get() = (context as? MainActivity)?.cookies() ?: arrayListOf() @@ -51,4 +55,9 @@ class FrostJSI(val context: Context, val webView: FrostWebViewCore) { webView.post { webView.frostWebClient!!.handleHtml(html) } } + @JavascriptInterface + fun handleHeader(html: String) { + headerObservable?.onNext(html) + } + }
\ No newline at end of file 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 0fe3304a..d015e22e 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClient.kt @@ -3,7 +3,10 @@ package com.pitchedapps.frost.web import android.content.Context import android.graphics.Bitmap import android.view.KeyEvent -import android.webkit.* +import android.webkit.WebResourceRequest +import android.webkit.WebResourceResponse +import android.webkit.WebView +import android.webkit.WebViewClient import com.pitchedapps.frost.LoginActivity import com.pitchedapps.frost.MainActivity import com.pitchedapps.frost.SelectorActivity @@ -50,7 +53,7 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : WebViewClient() { refreshObservable.onNext(false) return } - JsActions.LOGIN_CHECK.inject(view) + view.jsInject(JsActions.LOGIN_CHECK, JsAssets.HEADER_BADGES.maybe(webCore.baseEnum != null)) onPageFinishedActions(url) } @@ -62,7 +65,7 @@ open class FrostWebViewClient(val webCore: FrostWebViewCore) : WebViewClient() { L.d("Page finished reveal") webCore.jsInject(CssHider.HEADER, Prefs.themeInjector, -// JsAssets.CLICK_INTERCEPTOR, + // JsAssets.CLICK_INTERCEPTOR, callback = { refreshObservable.onNext(false) }) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewCore.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewCore.kt index b6353252..6e9e956f 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewCore.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewCore.kt @@ -41,6 +41,7 @@ class FrostWebViewCore @JvmOverloads constructor( val refreshObservable: PublishSubject<Boolean> // Only emits on page loads val titleObservable: BehaviorSubject<String> // Only emits on different non http titles + var baseUrl: String? = null var baseEnum: FbTab? = null internal var frostWebClient: FrostWebViewClient? = null |