From c129a7595e4a05f87befa8a9e3cef316bb614f47 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Mon, 14 Oct 2019 23:37:15 -0700 Subject: Fix backstack by removing home page additions --- .../kotlin/com/pitchedapps/frost/views/FrostWebView.kt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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 5b564102..de4e414b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt @@ -33,6 +33,7 @@ import com.pitchedapps.frost.db.currentCookie import com.pitchedapps.frost.facebook.FB_HOME_URL import com.pitchedapps.frost.facebook.USER_AGENT import com.pitchedapps.frost.fragments.WebFragment +import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.Prefs import com.pitchedapps.frost.utils.ctxCoroutine import com.pitchedapps.frost.utils.frostDownload @@ -130,15 +131,23 @@ class FrostWebView @JvmOverloads constructor( } /** - * By 2018-10-17, facebook automatically adds their home page to the back stack, + * 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. + * + * 2019-10-14. Looks like facebook now randomly populates some links with the home page, + * especially those that are launched with a blank target... + * In some cases, there can be more than one home target in a row. */ override fun onBackPressed(): Boolean { - if (canGoBackOrForward(-2)) { - goBack() + val list = copyBackForwardList() + if (list.currentIndex >= 2) { + val skipCount = (1..list.currentIndex).firstOrNull { + list.getItemAtIndex(list.currentIndex - it).url != FB_HOME_URL + } ?: return false // If no non home url is found, we will treat the stack as empty + L.v { "onBackPress: going back ${if (skipCount == 1) "one page" else "$skipCount pages"}" } + goBackOrForward(-skipCount) return true } - val list = copyBackForwardList() if (list.currentIndex == 1 && list.getItemAtIndex(0).url == FB_HOME_URL) { return false } -- cgit v1.2.3 From 4f7ba30690438d69c75c92530e7a78bd20fa9a24 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Mon, 14 Oct 2019 23:45:10 -0700 Subject: Enforce super destroy for webviews --- app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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 de4e414b..b76f0134 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/views/FrostWebView.kt @@ -211,10 +211,7 @@ class FrostWebView @JvmOverloads constructor( } override fun destroy() { - val parent = getParent() as? ViewGroup - if (parent != null) { - parent.removeView(this) - super.destroy() - } + (getParent() as? ViewGroup)?.removeView(this) + super.destroy() } } -- cgit v1.2.3 From cdddb88d53e86561179daf97af825a86aa41c1b1 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 15 Oct 2019 00:02:38 -0700 Subject: Update changelog --- app/src/main/play/en-US/whatsnew | 10 ++-------- app/src/main/res/xml/frost_changelog.xml | 6 +++++- docs/Changelog.md | 3 +++ 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/main/play/en-US/whatsnew b/app/src/main/play/en-US/whatsnew index f286cb6f..d9c37fbc 100644 --- a/app/src/main/play/en-US/whatsnew +++ b/app/src/main/play/en-US/whatsnew @@ -1,9 +1,3 @@ -v2.4.1 +v2.4.2 -* Add better support for mobile url conversions -* Notification tab will keep first page in the same window; fixes marking notifications as read -* Fix nav and status bar icon colors for custom themes (Android O+) -* Fix biometric prompt, and prompt on activity resume -* Fix notification title -* Add option to open overlay links in browser -* Disable swipe to refresh for composer and sharer pages \ No newline at end of file +* Fix back stack history \ 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 e8856b03..0b77ad1d 100644 --- a/app/src/main/res/xml/frost_changelog.xml +++ b/app/src/main/res/xml/frost_changelog.xml @@ -6,6 +6,11 @@ --> + + + + + @@ -14,7 +19,6 @@ - diff --git a/docs/Changelog.md b/docs/Changelog.md index 849170bf..f511c6ed 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,5 +1,8 @@ # Changelog +## v2.4.2 +* Fix back stack history + ## v2.4.1 * Add better support for mobile url conversions * Notification tab will keep first page in the same window; fixes marking notifications as read -- cgit v1.2.3