From e64c30732b5156144f18db41fcf5a713b1d11deb Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 6 Aug 2019 23:01:43 -0700 Subject: Fix up menu web view look --- .../com/pitchedapps/frost/injectors/JsInjector.kt | 13 +++++++++---- .../pitchedapps/frost/web/FrostWebViewClients.kt | 21 +++++++++++++++------ app/src/main/res/values/strings_pref_behaviour.xml | 9 +++++---- app/src/web/scss/core/_core_bg.scss | 2 +- app/src/web/ts/menu.ts | 3 +++ 5 files changed, 33 insertions(+), 15 deletions(-) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt index 00c7bcfc..13032479 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt @@ -52,14 +52,19 @@ class JsBuilder { val cssMin = css.replace(Regex("\\s*\n\\s*"), "") append("var a=document.createElement('style');") append("a.innerHTML='$cssMin';") - if (tag != null) append("a.id='$tag';") + if (tag != null) { + append("a.id='$tag';") + } append("document.head.appendChild(a);") } - if (js.isNotBlank()) + if (js.isNotBlank()) { append(js) + } } var content = builder.append("}()").toString() - if (tag != null) content = singleInjector(tag, content) + if (tag != null) { + content = singleInjector(tag, content) + } return content } @@ -101,4 +106,4 @@ fun FrostWebViewClient.jsInject(vararg injectors: InjectorContract) = web.jsInje class JsInjector(val function: String) : InjectorContract { override fun inject(webView: WebView) = webView.evaluateJavascript(function, null) -} +} \ No newline at end of file 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 ecedc997..025119aa 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -91,7 +91,7 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { override fun onPageCommitVisible(view: WebView, url: String?) { super.onPageCommitVisible(view, url) injectBackgroundColor() - if (url.isFacebookUrl) + if (url.isFacebookUrl) { view.jsInject( // CssHider.CORE, CssHider.HEADER, @@ -111,8 +111,9 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { JsAssets.CONTEXT_A, JsAssets.MEDIA ) - else + } else { refresh.offer(false) + } } override fun onPageFinished(view: WebView, url: String?) { @@ -212,19 +213,27 @@ class FrostWebViewClientMenu(web: FrostWebView) : FrostWebViewClient(web) { override fun onPageFinished(view: WebView, url: String?) { super.onPageFinished(view, url) - if (url == null) return - if (url.shouldInjectMenu) jsInject(JsAssets.MENU) + if (url == null) { + return + } + if (url.shouldInjectMenu) { + jsInject(JsAssets.MENU) + } } override fun emit(flag: Int) { super.emit(flag) when (flag) { - EMIT_FINISH -> super.injectAndFinish() + EMIT_FINISH -> { + super.injectAndFinish() + } } } override fun onPageFinishedActions(url: String) { v { "Should inject ${url.shouldInjectMenu}" } - if (!url.shouldInjectMenu) injectAndFinish() + if (!url.shouldInjectMenu) { + injectAndFinish() + } } } diff --git a/app/src/main/res/values/strings_pref_behaviour.xml b/app/src/main/res/values/strings_pref_behaviour.xml index 890a7531..d7043aa7 100644 --- a/app/src/main/res/values/strings_pref_behaviour.xml +++ b/app/src/main/res/values/strings_pref_behaviour.xml @@ -19,10 +19,11 @@ When loading a message thread, trigger a scroll to the bottom of the page rather than loading the page as is. Enable PIP Enable picture in picture videos - Web Only - Having troubles? Enable to use web exclusive features. All parsing and background services will be disabled. - Leave web only mode - Currently in web only mode. Would you like to disable it to continue? + + Web Only + Having troubles? Enable to use web exclusive features. All parsing and background services will be disabled. + Leave web only mode + Currently in web only mode. Would you like to disable it to continue? Autoplay Settings Open Facebook\'s auto play settings. Note that it must be disabled for PIP to work. Exit Confirmation diff --git a/app/src/web/scss/core/_core_bg.scss b/app/src/web/scss/core/_core_bg.scss index 17c93b7b..2c76cfaf 100644 --- a/app/src/web/scss/core/_core_bg.scss +++ b/app/src/web/scss/core/_core_bg.scss @@ -6,7 +6,7 @@ html, body, :root, #root, #header, #MComposer, ._1upc, input, ._2f9r, ._59e9, ._ ._5lp5, .container, .subpage, ._5n_f, #static_templates, ._22_8, ._1t4h, ._uoq, ._3qdh, ._8ca, ._3h8i, ._6-l ._2us7, ._6-l ._6-p:not([style*="background-image:"]), ._333v, div.sharerSelector, ._529j, ._305j, ._1pph, ._3t_l, ._4pvz, ._1g05, .acy, ._51-g, ._533c, ._ib-, .sharerAttachmentEmpty, .sharerBottomWrapper, ._24e1, -._3bg5 ._56do, ._5hfh, ._52e-, .mQuestionsPollResultsBar, ._5hoc, ._5oxw, ._32_4, ._1hiz, +._3bg5 ._56do, ._5hfh, ._52e-, .mQuestionsPollResultsBar, ._5hoc, ._5oxw, ._32_4, ._1hiz, ._53_-, ._38do, .bo, .cq, ._234-, ._a-5, ._2zh4, ._15ks, ._3oyc, ._36dc, ._3iyw ._3iyx, ._6bes, ._55wo, ._4-dy, .tlBody, #timelineBody, .timelineX, .timeline, .feed, .tlPrelude, .tlFeedPlaceholder, ._4_d0, .al, ._1gkq, ._5c5b, ._1qxg, ._5luf, ._2new, ._cld, ._3zvb, ._2nk0, .btnD, .btnI, ._2bdb, ._3ci9, diff --git a/app/src/web/ts/menu.ts b/app/src/web/ts/menu.ts index 6f9dbf16..b26e9cc9 100644 --- a/app/src/web/ts/menu.ts +++ b/app/src/web/ts/menu.ts @@ -20,6 +20,9 @@ return } + /* + * Required to remove height restrictions + */ const y = new MutationObserver(() => { viewport.removeAttribute('style'); root.removeAttribute('style'); -- cgit v1.2.3