From da63f00eb50a8c413ee55652eff8a4fcc5f83e5a Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 6 Nov 2018 22:35:58 -0500 Subject: Fix/duplicate back (#1177) * Merge potential fix for text zoom * Actually fix the duplicate back * Prepare fixing dependent notifications * Add notification fallback url * Add back acontext to url, fixes #1137 --- .../kotlin/com/pitchedapps/frost/views/FrostWebView.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'app/src/main/kotlin/com/pitchedapps/frost/views') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt index 14596935..8230c338 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt @@ -11,6 +11,7 @@ import ca.allanwang.kau.utils.AnimHolder import com.pitchedapps.frost.contracts.FrostContentContainer import com.pitchedapps.frost.contracts.FrostContentCore import com.pitchedapps.frost.contracts.FrostContentParent +import com.pitchedapps.frost.facebook.FB_HOME_URL import com.pitchedapps.frost.facebook.USER_AGENT_BASIC import com.pitchedapps.frost.fragments.WebFragment import com.pitchedapps.frost.utils.Prefs @@ -88,8 +89,20 @@ class FrostWebView @JvmOverloads constructor( loadUrl(parent.baseUrl, animate) } + /** + * By 2018-10-17, facebook automatically adds their home page to the back stack, + * regardless of the loaded url. We will make sure we skip it when going back. + */ override fun onBackPressed(): Boolean { - if (canGoBack()) { + if (canGoBackOrForward(-2)) { + goBack() + return true + } + val list = copyBackForwardList() + if (list.currentIndex == 1 && list.getItemAtIndex(0).url == FB_HOME_URL) { + return false + } + if (list.currentIndex > 0) { goBack() return true } -- cgit v1.2.3