Skip to content

Commit dc4e107

Browse files
committed
feat(android): add flag to opt out of automatic back navigation
needed by tauri-apps/tauri#14133 see tauri-apps/tauri#14133 (comment)
1 parent 48e5e99 commit dc4e107

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wry": patch
3+
---
4+
5+
Add flag to opt out of automatic back navigation handling on Android via `WryActivity#handleBackNavigation`.

src/android/kotlin/WryActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import androidx.appcompat.app.AppCompatActivity
1414

1515
abstract class WryActivity : AppCompatActivity() {
1616
private lateinit var mWebView: RustWebView
17+
open val handleBackNavigation: Boolean = true
1718

1819
open fun onWebViewCreate(webView: WebView) { }
1920

@@ -102,7 +103,7 @@ abstract class WryActivity : AppCompatActivity() {
102103
}
103104

104105
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
105-
if (keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) {
106+
if (handleBackNavigation && keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) {
106107
mWebView.goBack()
107108
return true
108109
}

0 commit comments

Comments
 (0)