-
Notifications
You must be signed in to change notification settings - Fork 72
fix(pm): preserve message WebView state across recreation (#691) #811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -107,6 +107,16 @@ public void onCreate(Bundle savedInstanceState){ | |||||||||||||||||||||||||||||||
| super.onCreate(savedInstanceState); | ||||||||||||||||||||||||||||||||
| setHasOptionsMenu(true); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||
| public void onSaveInstanceState(@androidx.annotation.NonNull Bundle outState) { | ||||||||||||||||||||||||||||||||
| super.onSaveInstanceState(outState); | ||||||||||||||||||||||||||||||||
| // Issue #691: persist the message WebView so re-entering the | ||||||||||||||||||||||||||||||||
| // fragment after the settings activity does not redraw blank. | ||||||||||||||||||||||||||||||||
| if (messageWebView != null) { | ||||||||||||||||||||||||||||||||
| messageWebView.saveState(outState); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+114
to
+118
|
||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| public View onCreateView(LayoutInflater aInflater, ViewGroup aContainer, Bundle aSavedState) { | ||||||||||||||||||||||||||||||||
| super.onCreateView(aInflater, aContainer, aSavedState); | ||||||||||||||||||||||||||||||||
|
|
@@ -134,9 +144,16 @@ public View onCreateView(LayoutInflater aInflater, ViewGroup aContainer, Bundle | |||||||||||||||||||||||||||||||
| messageWebView.setJavascriptHandler(new WebViewJsInterface()); | ||||||||||||||||||||||||||||||||
| messageWebView.setContent(AwfulHtmlPage.getContainerHtml(mPrefs, null, false)); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Issue #691: restore the saved WebView snapshot when the | ||||||||||||||||||||||||||||||||
| // fragment is recreated so the message body does not come back | ||||||||||||||||||||||||||||||||
| // blank after popping back from the settings activity. | ||||||||||||||||||||||||||||||||
| if (aSavedState != null) { | ||||||||||||||||||||||||||||||||
| messageWebView.restoreState(aSavedState); | ||||||||||||||||||||||||||||||||
|
Comment on lines
145
to
+151
|
||||||||||||||||||||||||||||||||
| messageWebView.setContent(AwfulHtmlPage.getContainerHtml(mPrefs, null, false)); | |
| // Issue #691: restore the saved WebView snapshot when the | |
| // fragment is recreated so the message body does not come back | |
| // blank after popping back from the settings activity. | |
| if (aSavedState != null) { | |
| messageWebView.restoreState(aSavedState); | |
| // Issue #691: restore the saved WebView snapshot when the | |
| // fragment is recreated so the message body does not come back | |
| // blank after popping back from the settings activity. | |
| if (aSavedState != null) { | |
| messageWebView.restoreState(aSavedState); | |
| } else { | |
| messageWebView.setContent(AwfulHtmlPage.getContainerHtml(mPrefs, null, false)); |
Copilot
AI
Apr 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using aSavedState == null as the only gate for syncPM() can skip the network fetch even when no WebView state was actually restored (e.g., saveState returned null / state missing in the Bundle). Consider gating on “restore succeeded” (e.g., restoreState return value != null, or presence of a dedicated saved Bundle) rather than just Bundle non-nullness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style consistency: elsewhere in the codebase
@NonNullis imported (import androidx.annotation.NonNull) rather than using the fully-qualified@androidx.annotation.NonNullin method signatures. ImportingNonNullhere would match the existing convention.