From ba458a612610512e28b65bafcf74177ddc77bbbe Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 21 Nov 2021 23:56:20 -0800 Subject: Improve menu loading when going back --- .../com/pitchedapps/frost/fragments/WebFragments.kt | 16 ---------------- .../kotlin/com/pitchedapps/frost/injectors/CssAsset.kt | 7 ++++++- .../kotlin/com/pitchedapps/frost/injectors/JsAssets.kt | 2 +- .../com/pitchedapps/frost/web/FrostWebViewClients.kt | 13 ++++++++++++- app/src/main/play/en-US/whatsnew | 3 ++- app/src/main/res/xml/frost_changelog.xml | 2 +- 6 files changed, 22 insertions(+), 21 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragments.kt b/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragments.kt index 3cac92af..29473461 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragments.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/fragments/WebFragments.kt @@ -61,20 +61,4 @@ class WebFragment : BaseFragment() { } super.updateFab(contract) } - - override fun onBackPressed(): Boolean { - if (baseEnum == FbItem.MENU) { - val core = core - val web = core as? WebView - if (web != null && web.canGoBack() && !web.canGoBackOrForward(-2)) { - // If menu item + we are at the second last entry, reload the base - // To properly inflate the menu - // Related to https://github.com/AllanWang/Frost-for-Facebook/issues/1593 - core.clearHistory() - core.reloadBase(true) - return true - } - } - return super.onBackPressed() - } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAsset.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAsset.kt index b384efad..a1f66520 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAsset.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAsset.kt @@ -23,7 +23,12 @@ import com.pitchedapps.frost.prefs.Prefs * Small misc inline css assets */ enum class CssAsset(private val content: String) : InjectorContract { - FullSizeImage("div._4prr[style*=\"max-width\"][style*=\"max-height\"]{max-width:none !important;max-height:none !important}") + FullSizeImage("div._4prr[style*=\"max-width\"][style*=\"max-height\"]{max-width:none !important;max-height:none !important}"), + + /* + * Remove top margin and hide some contents from the top bar and notification page (as it's our base url) + */ + Menu("#bookmarks_flyout{margin-top:0 !important}#notifications_list{display:none !important}") ; val injector: JsInjector by lazy { diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt index bceb9b3e..f1c958bc 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsAssets.kt @@ -34,7 +34,7 @@ import java.util.Locale * The enum name must match the css file name */ enum class JsAssets(private val singleLoad: Boolean = true) : InjectorContract { - MENU, CLICK_A, CONTEXT_A, MEDIA, HEADER_BADGES, TEXTAREA_LISTENER, NOTIF_MSG, + MENU, MENU_QUICK(singleLoad = false), CLICK_A, CONTEXT_A, MEDIA, HEADER_BADGES, TEXTAREA_LISTENER, NOTIF_MSG, DOCUMENT_WATCHER, HORIZONTAL_SCROLLING, AUTO_RESIZE_TEXTAREA(singleLoad = false), SCROLL_STOP, ; 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 3e906a23..ad7f7858 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -302,7 +302,7 @@ class FrostWebViewClientMenu(web: FrostWebView) : FrostWebViewClient(web) { * Instead, we remove the flyout margins within the js script so that it covers the header. */ override val facebookJsInjectors: List = - super.facebookJsInjectors - CssHider.HEADER + super.facebookJsInjectors - CssHider.HEADER + CssAsset.Menu override fun emit(flag: Int) { super.emit(flag) @@ -313,6 +313,17 @@ class FrostWebViewClientMenu(web: FrostWebView) : FrostWebViewClient(web) { } } + /* + * Facebook doesn't properly load back to the menu even in standard browsers. + * Instead, if we detect the base soft url, we will manually click the menu item + */ + override fun doUpdateVisitedHistory(view: WebView, url: String?, isReload: Boolean) { + super.doUpdateVisitedHistory(view, url, isReload) + if (url?.startsWith(FbItem.MENU.url) == true) { + jsInject(JsAssets.MENU_QUICK, prefs = prefs) + } + } + override fun onPageFinishedActions(url: String) { // Skip } diff --git a/app/src/main/play/en-US/whatsnew b/app/src/main/play/en-US/whatsnew index 2e50ba70..b60f93c3 100644 --- a/app/src/main/play/en-US/whatsnew +++ b/app/src/main/play/en-US/whatsnew @@ -1,3 +1,4 @@ v3.1.2 -* Fix loading full size images \ No newline at end of file +* Fix loading full size images +* Fix menu tab \ No newline at end of file diff --git a/app/src/main/res/xml/frost_changelog.xml b/app/src/main/res/xml/frost_changelog.xml index 9bc126fb..146346b5 100644 --- a/app/src/main/res/xml/frost_changelog.xml +++ b/app/src/main/res/xml/frost_changelog.xml @@ -8,7 +8,7 @@ - + -- cgit v1.2.3