Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions app/src/main/java/org/servalproject/ui/help/HtmlHelp.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,32 @@ public void onCreate(Bundle savedInstanceState) {
helpBrowser.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
helpBrowser.setBackgroundColor(Color.BLACK);
helpBrowser.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);

// Issue #136: previously every onResume cleared history and
// reloaded the start page, so pressing Home and re-entering the
// app dropped the user back to helpindex.html. Load once on
// fresh creation, restore the saved snapshot otherwise, and let
// onResume be a no-op for navigation state.
if (savedInstanceState != null) {
helpBrowser.restoreState(savedInstanceState);
} else {
Intent intent = this.getIntent();
startPage = assetPrefix + intent.getStringExtra("page");
helpBrowser.loadUrl(startPage);
Comment on lines +98 to +100

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

startPage is now only assigned and immediately used in this branch. Consider making it a local variable (or removing the field entirely) to avoid keeping an unused instance field that can be null in the restored-state path.

Copilot uses AI. Check for mistakes.
}
Comment on lines +95 to +101

Copilot AI Apr 25, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WebView.restoreState() can return null when there’s no WebView state in the Bundle. If that happens, the current code won’t load the start page and the WebView may stay blank. Consider checking the return value and falling back to loading the intent page when restore fails.

Copilot uses AI. Check for mistakes.
}

@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (helpBrowser != null) {
helpBrowser.saveState(outState);
}
}

@Override
protected void onResume() {
super.onResume();
Intent intent = this.getIntent();
startPage = assetPrefix + intent.getStringExtra("page");
helpBrowser.clearHistory();
helpBrowser.loadUrl(startPage);
}

@Override
Expand Down
Loading