Skip to content

Commit 73884dc

Browse files
committed
chore: updates for tao 0.36
ref tauri-apps/tao#1209
1 parent 44e26ef commit 73884dc

3 files changed

Lines changed: 21 additions & 24 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wry": minor
3+
---
4+
5+
Updated Android lifecycle JNI calls to pass the `WryActivity` instance for `start`, `resume`, `pause`, and `stop`, allowing Tao to emit window-specific lifecycle events.

src/android/kotlin/Rust.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ object Rust {
2424
@JvmStatic external fun onNewIntent(intent: Intent)
2525

2626
@JvmStatic external fun create()
27-
@JvmStatic external fun start()
28-
@JvmStatic external fun resume()
29-
@JvmStatic external fun pause()
30-
@JvmStatic external fun stop()
27+
@JvmStatic external fun start(activity: WryActivity)
28+
@JvmStatic external fun resume(activity: WryActivity)
29+
@JvmStatic external fun pause(activity: WryActivity)
30+
@JvmStatic external fun stop(activity: WryActivity)
3131

3232
@JvmStatic external fun wryCreate()
3333
@JvmStatic external fun onWebviewDestroy(activity: WryActivity, webviewId: String)

src/android/kotlin/WryActivity.kt

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,6 @@ object WryLifecycleObserver : DefaultLifecycleObserver {
2424
Rust.create()
2525
Rust.wryCreate()
2626
}
27-
28-
override fun onStart(owner: LifecycleOwner) {
29-
super.onStart(owner)
30-
Rust.start()
31-
}
32-
33-
override fun onResume(owner: LifecycleOwner) {
34-
super.onResume(owner)
35-
Rust.resume()
36-
}
37-
38-
override fun onPause(owner: LifecycleOwner) {
39-
super.onPause(owner)
40-
Rust.pause()
41-
}
42-
43-
override fun onStop(owner: LifecycleOwner) {
44-
super.onStop(owner)
45-
Rust.stop()
46-
}
4727
}
4828

4929
abstract class WryActivity : AppCompatActivity() {
@@ -116,6 +96,11 @@ abstract class WryActivity : AppCompatActivity() {
11696
Rust.onActivityCreate(this)
11797
}
11898

99+
override fun onStart() {
100+
super.onStart()
101+
Rust.start(this)
102+
}
103+
119104
override fun onWindowFocusChanged(hasFocus: Boolean) {
120105
super.onWindowFocusChanged(hasFocus)
121106
Rust.onWindowFocusChanged(this, hasFocus)
@@ -129,18 +114,25 @@ abstract class WryActivity : AppCompatActivity() {
129114

130115
override fun onPause() {
131116
super.onPause()
117+
Rust.pause(this)
132118
if (::mWebView.isInitialized) {
133119
mWebView.onPause()
134120
}
135121
}
136122

137123
override fun onResume() {
138124
super.onResume()
125+
Rust.resume(this)
139126
if (::mWebView.isInitialized) {
140127
mWebView.onResume()
141128
}
142129
}
143130

131+
override fun onStop() {
132+
super.onStop()
133+
Rust.stop(this)
134+
}
135+
144136
override fun onDestroy() {
145137
super.onDestroy()
146138
Rust.onActivityDestroy(this)

0 commit comments

Comments
 (0)