summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/app/src/main/java/org/terst/doot/widget/ui/DashboardActivity.kt19
1 files changed, 19 insertions, 0 deletions
diff --git a/android/app/src/main/java/org/terst/doot/widget/ui/DashboardActivity.kt b/android/app/src/main/java/org/terst/doot/widget/ui/DashboardActivity.kt
index c7cdfaa..597d06b 100644
--- a/android/app/src/main/java/org/terst/doot/widget/ui/DashboardActivity.kt
+++ b/android/app/src/main/java/org/terst/doot/widget/ui/DashboardActivity.kt
@@ -119,6 +119,20 @@ class DashboardActivity : ComponentActivity() {
canGoBack = view.canGoBack()
}
}
+ // The dashboard's tab switch never does a real navigation --
+ // it's HTMX swapping #tab-content client-side and recording
+ // the tab via history.pushState (?tab=shopping etc). Without
+ // restoring that here, an Activity recreation (Android
+ // reclaiming a backgrounded Activity, a rotation, anything
+ // that reruns this factory with a fresh WebView) had nothing
+ // to fall back on except the bare server URL in `update`
+ // below, which always lands on the default tab -- reported as
+ // "shopping randomly jumps back to timeline," but not actually
+ // tied to being on shopping specifically, just to whichever
+ // tab you weren't on by default. No-ops harmlessly if
+ // savedInstanceState has no WebView state to restore (e.g. the
+ // very first launch).
+ savedInstanceState?.let { restoreState(it) }
}
},
update = { webView ->
@@ -144,6 +158,11 @@ class DashboardActivity : ComponentActivity() {
}
}
+ override fun onSaveInstanceState(outState: Bundle) {
+ super.onSaveInstanceState(outState)
+ webViewRef?.saveState(outState)
+ }
+
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
if (keyCode == KeyEvent.KEYCODE_BACK && webViewRef?.canGoBack() == true) {
webViewRef?.goBack()