Use `robius-android-env`
Signed-off-by: Klim Tsoutsman <klim@tsoutsman.com>
This commit is contained in:
parent
f7af70d444
commit
2f6f326134
|
@ -41,9 +41,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|||
|
||||
[[package]]
|
||||
name = "combine"
|
||||
version = "4.6.6"
|
||||
version = "4.6.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4"
|
||||
checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"memchr",
|
||||
|
@ -126,13 +126,21 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.35"
|
||||
version = "1.0.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
||||
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "robius-android-env"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/project-robius/robius-android-env#2444b9d9b430ae365e012e94b005444c48db8ae0"
|
||||
dependencies = [
|
||||
"jni",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "robius-open"
|
||||
version = "0.1.0"
|
||||
|
@ -141,6 +149,7 @@ dependencies = [
|
|||
"icrate",
|
||||
"jni",
|
||||
"objc2",
|
||||
"robius-android-env",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
15
Cargo.toml
15
Cargo.toml
|
@ -3,10 +3,6 @@ name = "robius-open"
|
|||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
#crate-type = ["staticlib"]
|
||||
crate-type = ["dylib"]
|
||||
|
||||
[dependencies]
|
||||
cfg-if = "1.0.0"
|
||||
|
||||
|
@ -14,13 +10,16 @@ cfg-if = "1.0.0"
|
|||
version = "0.21.1"
|
||||
default-features = false
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies.robius-android-env]
|
||||
git = "https://github.com/project-robius/robius-android-env"
|
||||
|
||||
[target.'cfg(target_os = "ios")'.dependencies.icrate]
|
||||
version = "0.1.0"
|
||||
features = ["Foundation", "Foundation_NSString", "Foundation_NSURL"]
|
||||
|
||||
[target.'cfg(target_os = "ios")'.dependencies.objc2]
|
||||
version = "0.5.0"
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies.icrate]
|
||||
version = "0.1.0"
|
||||
features = ["AppKit", "AppKit_NSWorkspace", "Foundation", "Foundation_NSString", "Foundation_NSURL"]
|
||||
|
||||
[target.'cfg(target_os = "ios")'.dependencies.icrate]
|
||||
version = "0.1.0"
|
||||
features = ["Foundation", "Foundation_NSString", "Foundation_NSURL"]
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use jni::{
|
||||
objects::{JClass, JValueGen},
|
||||
JNIEnv,
|
||||
};
|
||||
use jni::objects::JValueGen;
|
||||
use robius_android_env::{current_activity, vm};
|
||||
|
||||
pub(crate) struct Uri<'a, 'b> {
|
||||
inner: &'a str,
|
||||
|
@ -21,8 +19,8 @@ impl<'a, 'b> Uri<'a, 'b> {
|
|||
}
|
||||
|
||||
pub(crate) fn open(self) {
|
||||
let mut env: JNIEnv = todo!();
|
||||
let context: JClass = todo!();
|
||||
let mut env = vm().unwrap().get_env().unwrap();
|
||||
let current_activity = current_activity().unwrap();
|
||||
|
||||
let action = env
|
||||
.get_static_field("android/content/Intent", self.action, "Ljava/lang/String;")
|
||||
|
@ -50,11 +48,8 @@ impl<'a, 'b> Uri<'a, 'b> {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
let activity = env.new_object("android/app/Activity", "()V", &[]).unwrap();
|
||||
|
||||
env.call_method(
|
||||
// activity,
|
||||
context,
|
||||
current_activity,
|
||||
"startActivity",
|
||||
"(Landroid/content/Intent;)V",
|
||||
&[JValueGen::Object(&intent)],
|
||||
|
|
Loading…
Reference in New Issue