-
Notifications
You must be signed in to change notification settings - Fork 0
Coder Agent: Fix an Android SDK bug where tapping the chat text input field causes the chat UI to crash into a lo #23
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: master
Are you sure you want to change the base?
Changes from 1 commit
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 | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |||||||||||||||||||||||||||||||
| import android.content.Intent; | ||||||||||||||||||||||||||||||||
| import android.content.pm.ActivityInfo; | ||||||||||||||||||||||||||||||||
| import android.content.pm.PackageManager; | ||||||||||||||||||||||||||||||||
| import android.content.res.Configuration; | ||||||||||||||||||||||||||||||||
| import android.graphics.Bitmap; | ||||||||||||||||||||||||||||||||
| import android.graphics.BitmapFactory; | ||||||||||||||||||||||||||||||||
| import android.graphics.Color; | ||||||||||||||||||||||||||||||||
|
|
@@ -197,7 +198,12 @@ public void handleOnBackPressed() { | |||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| this.requestWindowFeature(Window.FEATURE_NO_TITLE); | ||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||
| getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); | ||||||||||||||||||||||||||||||||
| // SOFT_INPUT_ADJUST_RESIZE is deprecated on API 30+ and ignored on API 35+. | ||||||||||||||||||||||||||||||||
| // On API 30+ we rely solely on the WindowInsetsCompat listener for keyboard | ||||||||||||||||||||||||||||||||
| // handling; on older versions we keep the legacy flag for compatibility. | ||||||||||||||||||||||||||||||||
| if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { | ||||||||||||||||||||||||||||||||
| getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| if (getSupportActionBar() != null) { | ||||||||||||||||||||||||||||||||
| getSupportActionBar().hide(); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
@@ -285,9 +291,19 @@ public void invoke() { | |||||||||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||||||||||
| public void run() { | ||||||||||||||||||||||||||||||||
| url += GleapURLGenerator.generateURL(); | ||||||||||||||||||||||||||||||||
| initBrowser(); | ||||||||||||||||||||||||||||||||
| if (savedInstanceState != null) { | ||||||||||||||||||||||||||||||||
| webView.restoreState(savedInstanceState); | ||||||||||||||||||||||||||||||||
| // Activity was recreated (e.g. process killed in background). | ||||||||||||||||||||||||||||||||
| // Set up WebView clients/settings but skip loading a new URL; | ||||||||||||||||||||||||||||||||
| // restoreState will navigate back to the previous page. | ||||||||||||||||||||||||||||||||
| initBrowserSettings(); | ||||||||||||||||||||||||||||||||
| android.webkit.WebBackForwardList restored = webView.restoreState(savedInstanceState); | ||||||||||||||||||||||||||||||||
| if (restored == null) { | ||||||||||||||||||||||||||||||||
| // restoreState failed — fall back to a full reload. | ||||||||||||||||||||||||||||||||
| webView.loadUrl(url); | ||||||||||||||||||||||||||||||||
|
Comment on lines
+299
to
+301
|
||||||||||||||||||||||||||||||||
| if (restored == null) { | |
| // restoreState failed — fall back to a full reload. | |
| webView.loadUrl(url); | |
| if (restored == null || restored.getSize() == 0) { | |
| // restoreState failed — fall back to a full reload. | |
| webView.loadUrl(url); | |
| } else { | |
| // Successfully restored a previous page. Ensure that the | |
| // WebView is visible and the loader is hidden, since the | |
| // restored content might not re-emit the JS "ping". | |
| webView.setVisibility(View.VISIBLE); | |
| View loader = findViewById(R.id.loader); | |
| if (loader != null) { | |
| loader.setVisibility(View.GONE); | |
| } |
Copilot
AI
Mar 3, 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.
webView.restoreState(savedInstanceState) is invoked in the webView.post(...) runnable (saved-state branch) and again in onRestoreInstanceState(). Restoring twice can lead to redundant work and can overwrite state after clients/settings have been attached, making behavior harder to reason about. Consider choosing a single restore location (either rely on onRestoreInstanceState or gate the second call with a flag).
| webView.restoreState(savedInstanceState); | |
| // WebView state is restored in onCreate via the savedInstanceState branch. |
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.
The activity now claims to handle a very broad set of
configChanges(includingdensityanduiMode). When these are listed, Android will not recreate the Activity and will also not automatically re-apply updated resources for those configuration changes, which can cause incorrect theming/scaling after dark-mode changes or display-size/density changes. Consider narrowing this list to only the minimum needed to prevent the keyboard-related recreation (and leave other changes to the default recreation behavior).