Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/android/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,7 @@ fn handle_request(

#[allow(non_snake_case)]
pub unsafe fn wryCreate(env: JNIEnv, _: JClass) {
let mut main_pipe = MainPipe {
env,
package: super::PACKAGE.get().unwrap(),
};
let mut main_pipe = MainPipe { env };

let looper = ThreadLooper::for_thread().unwrap();

Expand Down
15 changes: 9 additions & 6 deletions src/android/main_pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::{
sync::{Arc, Mutex},
};

use super::{find_class, EvalCallback, WebviewId, EVAL_CALLBACKS, EVAL_ID_GENERATOR};
use super::{find_class, EvalCallback, WebviewId, EVAL_CALLBACKS, EVAL_ID_GENERATOR, PACKAGE};

pub type ActivityId = i32;

Expand Down Expand Up @@ -126,7 +126,6 @@ pub fn get_webview(activity_id: ActivityId) -> Option<GlobalRef> {

pub struct MainPipe<'a> {
pub env: JNIEnv<'a>,
pub package: &'static str,
}

impl<'a> MainPipe<'a> {
Expand Down Expand Up @@ -193,7 +192,7 @@ impl<'a> MainPipe<'a> {
let rust_webview_class = find_class(
&mut self.env,
&activity,
format!("{}/RustWebView", self.package),
format!("{}/RustWebView", PACKAGE.get().unwrap()),
)?;
let webview = self.env.new_object(
&rust_webview_class,
Expand Down Expand Up @@ -242,7 +241,7 @@ impl<'a> MainPipe<'a> {
)?;
}

let webview_class_name = format!("{}/RustWebView", self.package);
let webview_class_name = format!("{}/RustWebView", PACKAGE.get().unwrap());
self.env.call_method(
&activity,
"setWebView",
Expand Down Expand Up @@ -273,7 +272,7 @@ impl<'a> MainPipe<'a> {
set_background_color(&mut self.env, &webview, color)?;
}
// Create and set webview client
let client_class_name = format!("{}/RustWebViewClient", self.package);
let client_class_name = format!("{}/RustWebViewClient", PACKAGE.get().unwrap());
let rust_webview_client_class =
find_class(&mut self.env, &activity, client_class_name.clone())?;
let webview_client = self.env.new_object(
Expand All @@ -296,7 +295,11 @@ impl<'a> MainPipe<'a> {
)?;

// Add javascript interface (IPC)
let ipc_class = find_class(&mut self.env, &activity, format!("{}/Ipc", self.package))?;
let ipc_class = find_class(
&mut self.env,
&activity,
format!("{}/Ipc", PACKAGE.get().unwrap()),
)?;
let ipc = self.env.new_object(
ipc_class,
format!("(L{webview_class_name};L{client_class_name};)V"),
Expand Down
2 changes: 1 addition & 1 deletion src/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub unsafe fn android_setup(
_looper: &ThreadLooper,
activity: GlobalRef,
) {
let package = PACKAGE.get_or_init(|| package.to_string());
PACKAGE.get_or_init(|| package.to_string());

let vm = env.get_java_vm().unwrap();

Expand Down
Loading