feat(android): add flag to opt out of automatic back navigation (#1622)

needed by https://github.com/tauri-apps/tauri/pull/14133
see https://github.com/tauri-apps/tauri/pull/14133#issuecomment-3361224695
This commit is contained in:
Lucas Fernandes Nogueira
2025-10-06 15:41:24 -03:00
committed by GitHub
parent 48e5e9903f
commit 093856a2a5
2 changed files with 7 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"wry": patch
---
Add flag to opt out of automatic back navigation handling on Android via `WryActivity#handleBackNavigation`.

View File

@@ -14,6 +14,7 @@ import androidx.appcompat.app.AppCompatActivity
abstract class WryActivity : AppCompatActivity() {
private lateinit var mWebView: RustWebView
open val handleBackNavigation: Boolean = true
open fun onWebViewCreate(webView: WebView) { }
@@ -102,7 +103,7 @@ abstract class WryActivity : AppCompatActivity() {
}
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
if (keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) {
if (handleBackNavigation && keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) {
mWebView.goBack()
return true
}