From 010b7bc6728f862ecb03090df2f9e6a7dd87d8fa Mon Sep 17 00:00:00 2001 From: Dimitris Dafnis <68849116+jim-daf@users.noreply.github.com> Date: Sat, 25 Apr 2026 22:45:22 +0200 Subject: [PATCH 1/3] fix(webview): preserve internal WebView state across rotation (#47) --- .../activities/InternalWebViewActivity.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/kidozh/discuzhub/activities/InternalWebViewActivity.java b/app/src/main/java/com/kidozh/discuzhub/activities/InternalWebViewActivity.java index 38c11ff..c2018f8 100644 --- a/app/src/main/java/com/kidozh/discuzhub/activities/InternalWebViewActivity.java +++ b/app/src/main/java/com/kidozh/discuzhub/activities/InternalWebViewActivity.java @@ -47,10 +47,21 @@ protected void onCreate(Bundle savedInstanceState) { getIntentInfo(); configureActionBar(); - configureWebview(); + configureWebview(savedInstanceState); } + @Override + protected void onSaveInstanceState(@NonNull Bundle outState) { + super.onSaveInstanceState(outState); + // Issue #47: persist the WebView so rotation does not throw + // away navigation history and dump the user back at the URL + // they entered the activity with. + if (binding != null) { + binding.webview.saveState(outState); + } + } + private void getIntentInfo(){ Intent intent = getIntent(); discuz = (Discuz) intent.getSerializableExtra(ConstUtils.PASS_BBS_ENTITY_KEY); From 89782ab4e82614f7e3b5203ab1d8bb38a6740da7 Mon Sep 17 00:00:00 2001 From: Dimitris Dafnis <68849116+jim-daf@users.noreply.github.com> Date: Sat, 25 Apr 2026 22:45:24 +0200 Subject: [PATCH 2/3] fix(webview): preserve internal WebView state across rotation (#47) --- .../activities/InternalWebViewActivity.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/kidozh/discuzhub/activities/InternalWebViewActivity.java b/app/src/main/java/com/kidozh/discuzhub/activities/InternalWebViewActivity.java index c2018f8..3da1a47 100644 --- a/app/src/main/java/com/kidozh/discuzhub/activities/InternalWebViewActivity.java +++ b/app/src/main/java/com/kidozh/discuzhub/activities/InternalWebViewActivity.java @@ -47,21 +47,10 @@ protected void onCreate(Bundle savedInstanceState) { getIntentInfo(); configureActionBar(); - configureWebview(savedInstanceState); + configureWebview(); } - @Override - protected void onSaveInstanceState(@NonNull Bundle outState) { - super.onSaveInstanceState(outState); - // Issue #47: persist the WebView so rotation does not throw - // away navigation history and dump the user back at the URL - // they entered the activity with. - if (binding != null) { - binding.webview.saveState(outState); - } - } - private void getIntentInfo(){ Intent intent = getIntent(); discuz = (Discuz) intent.getSerializableExtra(ConstUtils.PASS_BBS_ENTITY_KEY); @@ -79,7 +68,7 @@ void configureActionBar(){ } - void configureWebview(){ + void configureWebview(Bundle savedInstanceState){ WebSettings webSettings = binding.webview.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setUseWideViewPort(true); From b42b4b3ebad006ee904b16f7920eb691efbd8277 Mon Sep 17 00:00:00 2001 From: Dimitris Dafnis <68849116+jim-daf@users.noreply.github.com> Date: Sat, 25 Apr 2026 22:45:27 +0200 Subject: [PATCH 3/3] fix(webview): preserve internal WebView state across rotation (#47) --- .../discuzhub/activities/InternalWebViewActivity.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/kidozh/discuzhub/activities/InternalWebViewActivity.java b/app/src/main/java/com/kidozh/discuzhub/activities/InternalWebViewActivity.java index 3da1a47..bba3229 100644 --- a/app/src/main/java/com/kidozh/discuzhub/activities/InternalWebViewActivity.java +++ b/app/src/main/java/com/kidozh/discuzhub/activities/InternalWebViewActivity.java @@ -68,7 +68,7 @@ void configureActionBar(){ } - void configureWebview(Bundle savedInstanceState){ + void configureWebview(){ WebSettings webSettings = binding.webview.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setUseWideViewPort(true); @@ -96,8 +96,13 @@ void configureWebview(Bundle savedInstanceState){ binding.webview.setWebViewClient(cookieClient); - binding.webview.loadUrl(startURL); - + if (savedInstanceState != null) { + // Issue #47: restore the saved WebView state on rotation + // instead of force-reloading the original URL. + binding.webview.restoreState(savedInstanceState); + } else { + binding.webview.loadUrl(startURL); + } }