feat(core): back button event on Android, closes #8142 - #6
Open
Conversation
Greptile OverviewGreptile SummaryImplements Android back button event handling by creating a new Key changes:
Issues found:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant AndroidOS
participant TauriActivity
participant AppPlugin
participant WebView
participant JSApp
User->>AndroidOS: Presses back button
AndroidOS->>TauriActivity: onBackPressed event
TauriActivity->>AppPlugin: handleOnBackPressed callback
alt Has back-button event listener
AppPlugin->>WebView: Check canGoBack()
WebView-->>AppPlugin: canGoBack status
AppPlugin->>JSApp: Trigger 'back-button' event with {canGoBack}
JSApp->>JSApp: Execute custom handler
else No listener registered
AppPlugin->>WebView: Check canGoBack()
WebView-->>AppPlugin: true
AppPlugin->>WebView: goBack()
WebView->>WebView: Navigate to previous page
else No listener and cannot go back
AppPlugin->>AppPlugin: Disable callback temporarily
AppPlugin->>TauriActivity: activity.onBackPressed()
TauriActivity->>AndroidOS: Default back behavior (exit app)
AppPlugin->>AppPlugin: Re-enable callback
end
|
Comment on lines
+31
to
+32
| if (this@AppPlugin.webView?.canGoBack() == true) { | ||
| this@AppPlugin.webView!!.goBack() |
There was a problem hiding this comment.
null-safety check followed by non-null assertion (!!) can still throw NPE if webView becomes null between the check and the call
Suggested change
| if (this@AppPlugin.webView?.canGoBack() == true) { | |
| this@AppPlugin.webView!!.goBack() | |
| this@AppPlugin.webView?.goBack() |
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/tauri/mobile/android/src/main/java/app/tauri/AppPlugin.kt
Line: 31:32
Comment:
null-safety check followed by non-null assertion (`!!`) can still throw NPE if webView becomes null between the check and the call
```suggestion
this@AppPlugin.webView?.goBack()
```
How can I resolve this? If you propose a fix, please make it concise.|
|
||
| abstract class TauriActivity : WryActivity() { | ||
| var pluginManager: PluginManager = PluginManager(this) | ||
| override val handleBackNavigation: Boolean = true |
There was a problem hiding this comment.
verify that WryActivity defines handleBackNavigation as an overridable property - if not defined in the parent class, this will cause a compilation error
Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/tauri/mobile/android-codegen/TauriActivity.kt
Line: 15:15
Comment:
verify that `WryActivity` defines `handleBackNavigation` as an overridable property - if not defined in the parent class, this will cause a compilation error
How can I resolve this? If you propose a fix, please make it concise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Benchmark PR from agentic-review-benchmarks#6