Skip to content

Commit

Permalink
refactor: rename TauriActivity to WryActivity (#926)
Browse files Browse the repository at this point in the history
* refactor: rename `TauriActivity` to `WryActivity`

* use `WryActivity` instead of `AppCompatActivity`

* update to tao 0.19
  • Loading branch information
amrbashir authored Apr 17, 2023
1 parent 8c680ef commit d560981
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changes/tao-0.19.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"wry": minor
---

Update `tao` to `0.19`
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ serde = { version = "1.0", features = [ "derive" ] }
serde_json = "1.0"
thiserror = "1.0"
url = "2.3"
tao = { version = "0.18.0", default-features = false, features = [ "serde" ] }
tao = { version = "0.19", default-features = false, features = [ "serde" ] }
http = "0.2.9"

[dev-dependencies]
Expand Down
6 changes: 2 additions & 4 deletions src/webview/android/kotlin/RustWebChromeClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@ import androidx.activity.result.ActivityResult
import androidx.activity.result.ActivityResultCallback
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.core.content.FileProvider
import java.io.File
import java.io.IOException
import java.text.SimpleDateFormat
import java.util.*


class RustWebChromeClient(appActivity: AppCompatActivity) : WebChromeClient() {
class RustWebChromeClient(appActivity: WryActivity) : WebChromeClient() {
private interface PermissionListener {
fun onPermissionSelect(isGranted: Boolean?)
}
Expand All @@ -46,7 +44,7 @@ class RustWebChromeClient(appActivity: AppCompatActivity) : WebChromeClient() {
fun onActivityResult(result: ActivityResult?)
}

private val activity: AppCompatActivity
private val activity: WryActivity
private var permissionLauncher: ActivityResultLauncher<Array<String>>
private var activityLauncher: ActivityResultLauncher<Intent>
private var permissionListener: PermissionListener? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import android.webkit.WebView
import android.view.KeyEvent
import androidx.appcompat.app.AppCompatActivity

abstract class TauriActivity : AppCompatActivity() {
abstract class WryActivity : AppCompatActivity() {
lateinit var m_webview: RustWebView

val version: String
Expand Down Expand Up @@ -112,7 +112,7 @@ abstract class TauriActivity : AppCompatActivity() {
}
}

private external fun create(activity: TauriActivity)
private external fun create(activity: WryActivity)
private external fun start()
private external fun resume()
private external fun pause()
Expand Down
3 changes: 3 additions & 0 deletions src/webview/android/main_pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ impl MainPipe<'_> {
WebViewMessage::CreateWebView(attrs) => {
let CreateWebViewAttributes {
url,
#[cfg(any(debug_assertions, feature = "devtools"))]
devtools,
transparent,
background_color,
headers,
on_webview_created,
autoplay,
..
} = attrs;
// Create webview
let rust_webview_class = find_class(
Expand Down Expand Up @@ -275,6 +277,7 @@ pub(crate) enum WebViewMessage {

pub(crate) struct CreateWebViewAttributes {
pub url: String,
#[cfg(any(debug_assertions, feature = "devtools"))]
pub devtools: bool,
pub transparent: bool,
pub background_color: Option<RGBA>,
Expand Down
10 changes: 6 additions & 4 deletions src/webview/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ pub struct Context<'a> {

#[macro_export]
macro_rules! android_binding {
($domain:ident, $package:ident, $main: ident) => {
($domain:ident, $package:ident, $main:ident) => {
android_binding!($domain, $package, $main, ::wry)
};
($domain:ident, $package:ident, $main: ident, $wry: path) => {
($domain:ident, $package:ident, $main:ident, $wry:path) => {
use $wry::{
application::{
android_binding as tao_android_binding, android_fn, generate_package_name,
platform::android::ndk_glue::*,
},
webview::prelude::*,
};
tao_android_binding!($domain, $package, setup, $main);
tao_android_binding!($domain, $package, WryActivity, setup, $main);
android_fn!(
$domain,
$package,
Expand Down Expand Up @@ -131,7 +131,7 @@ pub unsafe fn setup(env: JNIEnv, looper: &ForeignLooper, activity: GlobalRef) {
let webchrome_client = env
.new_object(
rust_webchrome_client_class,
"(Landroidx/appcompat/app/AppCompatActivity;)V",
&format!("(L{}/WryActivity;)V", PACKAGE.get().unwrap()),
&[activity.as_obj().into()],
)
.unwrap();
Expand Down Expand Up @@ -175,6 +175,7 @@ impl InnerWebView {
url,
initialization_scripts,
ipc_handler,
#[cfg(any(debug_assertions, feature = "devtools"))]
devtools,
custom_protocols,
background_color,
Expand Down Expand Up @@ -202,6 +203,7 @@ impl InnerWebView {

MainPipe::send(WebViewMessage::CreateWebView(CreateWebViewAttributes {
url: url_string,
#[cfg(any(debug_assertions, feature = "devtools"))]
devtools,
background_color,
transparent,
Expand Down

0 comments on commit d560981

Please sign in to comment.