1
- use jni:: {
2
- errors:: Error ,
3
- objects:: { JObject , JString } ,
4
- JNIEnv ,
5
- } ;
1
+ use jni:: { errors:: Error , objects:: JObject , JNIEnv } ;
6
2
7
3
struct Inner < ' env > {
8
4
env : JNIEnv < ' env > ,
@@ -33,8 +29,7 @@ impl<'env> Intent<'env> {
33
29
let action_view =
34
30
env. get_static_field ( intent_class, action. as_ref ( ) , "Ljava/lang/String;" ) ?;
35
31
36
- let intent =
37
- env. new_object ( intent_class, "(Ljava/lang/String;)V" , & [ action_view. into ( ) ] ) ?;
32
+ let intent = env. new_object ( intent_class, "(Ljava/lang/String;)V" , & [ action_view] ) ?;
38
33
39
34
Ok ( Inner {
40
35
env,
@@ -51,7 +46,7 @@ impl<'env> Intent<'env> {
51
46
uri_class,
52
47
"parse" ,
53
48
"(Ljava/lang/String;)Landroid/net/Uri;" ,
54
- & [ JString :: from ( url_string) . into ( ) ] ,
49
+ & [ url_string. into ( ) ] ,
55
50
) ?;
56
51
57
52
let intent_class = env. find_class ( "android/content/Intent" ) ?;
@@ -61,7 +56,7 @@ impl<'env> Intent<'env> {
61
56
let intent = env. new_object (
62
57
intent_class,
63
58
"(Ljava/lang/String;Landroid/net/Uri;)V" ,
64
- & [ action_view. into ( ) , uri. into ( ) ] ,
59
+ & [ action_view, uri] ,
65
60
) ?;
66
61
67
62
Ok ( Inner {
@@ -77,10 +72,14 @@ impl<'env> Intent<'env> {
77
72
///
78
73
/// # android_intent::with_current_env(|env| {
79
74
/// let intent = Intent::new(env, Action::Send);
80
- /// intent.set_class_name("com.excample", "IntentTarget")
75
+ /// let intent = intent .set_class_name("com.excample", "IntentTarget");
81
76
/// # })
82
77
/// ```
83
- pub fn set_class_name ( self , package_name : impl AsRef < str > , class_name : impl AsRef < str > ) -> Self {
78
+ pub fn set_class_name (
79
+ self ,
80
+ package_name : impl AsRef < str > ,
81
+ class_name : impl AsRef < str > ,
82
+ ) -> Self {
84
83
self . and_then ( |inner| {
85
84
let package_name = inner. env . new_string ( package_name) ?;
86
85
let class_name = inner. env . new_string ( class_name) ?;
@@ -102,7 +101,7 @@ impl<'env> Intent<'env> {
102
101
///
103
102
/// # android_intent::with_current_env(|env| {
104
103
/// let intent = Intent::new(env, Action::Send);
105
- /// intent.push_extra (Extra::Text, "Hello World!")
104
+ /// let intent = intent.with_extra (Extra::Text, "Hello World!");
106
105
/// # })
107
106
/// ```
108
107
pub fn with_extra ( self , key : impl AsRef < str > , value : impl AsRef < str > ) -> Self {
@@ -121,12 +120,12 @@ impl<'env> Intent<'env> {
121
120
} )
122
121
}
123
122
124
- /// Builds a new [`Action::Chooser`] Intent that wraps the given target intent.
123
+ /// Builds a new [`super:: Action::Chooser`] Intent that wraps the given target intent.
125
124
/// ```no_run
126
125
/// use android_intent::{Action, Intent};
127
126
///
128
127
/// # android_intent::with_current_env(|env| {
129
- /// let intent = Intent::new(env, Action::Send).into_chhoser ();
128
+ /// let intent = Intent::new(env, Action::Send).into_chooser ();
130
129
/// # })
131
130
/// ```
132
131
pub fn into_chooser ( self ) -> Self {
@@ -161,7 +160,7 @@ impl<'env> Intent<'env> {
161
160
///
162
161
/// # android_intent::with_current_env(|env| {
163
162
/// let intent = Intent::new(env, Action::Send);
164
- /// intent.set_type ("text/plain");
163
+ /// let intent = intent.with_type ("text/plain");
165
164
/// # })
166
165
/// ```
167
166
pub fn with_type ( self , type_name : impl AsRef < str > ) -> Self {
0 commit comments