diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/web')
4 files changed, 20 insertions, 16 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt index 8c016e5c..4afdd8d2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostChromeClients.kt @@ -30,14 +30,13 @@ class FrostChromeClient(web: FrostWebView) : WebChromeClient() { private val context = web.context!! override fun onConsoleMessage(consoleMessage: ConsoleMessage): Boolean { - if (consoleBlacklist.any { consoleMessage.message().contains(it) }) return true L.v { "Chrome Console ${consoleMessage.lineNumber()}: ${consoleMessage.message()}" } return true } override fun onReceivedTitle(view: WebView, title: String) { super.onReceivedTitle(view, title) - if (title.contains("http") || this.title.value == title) return + if (title.startsWith("http") || this.title.value == title) return this.title.onNext(title) } 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 9264ea52..d735fd50 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostJSI.kt @@ -17,6 +17,7 @@ class FrostJSI(val web: FrostWebView) { private val context = web.context private val activity = context as? MainActivity private val header: Subject<String>? = activity?.headerBadgeObservable + private val refresh: Subject<Boolean> = web.parent.refreshObservable private val cookies = activity?.cookies() ?: arrayListOf() /** @@ -89,6 +90,11 @@ class FrostJSI(val web: FrostWebView) { } @JavascriptInterface + fun isReady() { + refresh.onNext(false) + } + + @JavascriptInterface fun handleHtml(html: String?) { html ?: return web.post { web.frostWebClient.handleHtml(html) } 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 d0f7d490..f1b30795 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -73,7 +73,10 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { CssHider.SUGGESTED_GROUPS.maybe(!Prefs.showSuggestedGroups && IS_FROST_PRO), Prefs.themeInjector, CssHider.NON_RECENT.maybe((web.url?.contains("?sk=h_chr") ?: false) - && Prefs.aggressiveRecents)) + && Prefs.aggressiveRecents), + JsAssets.DOCUMENT_WATCHER) + else + refresh.onNext(false) } override fun onPageFinished(view: WebView, url: String?) { @@ -142,7 +145,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { return true } if (path.startsWith("/composer/")) return launchRequest(request) - if (url.contains("scontent-sea1-1.xx.fbcdn.net") && (path.endsWith(".jpg") || path.endsWith(".png"))) + if (url.isImageUrl) return launchImage(url) if (Prefs.linksInDefaultApp && view.context.resolveActivityForUri(request.url)) return true return super.shouldOverrideUrlLoading(view, request) @@ -150,6 +153,11 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { } +private const val EMIT_THEME = 0b1 +private const val EMIT_ID = 0b10 +private const val EMIT_COMPLETE = EMIT_THEME or EMIT_ID +private const val EMIT_FINISH = 0 + /** * Client variant for the menu view */ @@ -171,7 +179,9 @@ class FrostWebViewClientMenu(web: FrostWebView) : FrostWebViewClient(web) { override fun emit(flag: Int) { super.emit(flag) - super.injectAndFinish() + when (flag) { + EMIT_FINISH -> super.injectAndFinish() + } } override fun onPageFinishedActions(url: String) { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/WebStates.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/WebStates.kt deleted file mode 100644 index d07e67df..00000000 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/WebStates.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.pitchedapps.frost.web - -/** - * Created by Allan Wang on 2017-08-08. - * - * Global variables that are define states or constants for web contents - */ -const val WEB_LOAD_DELAY = 50L -//var shouldLoadImages = false - -val consoleBlacklist = setOf("edge-chat")
\ No newline at end of file |