1- use jni:: {
2- errors:: Error ,
3- objects:: { JObject , JString } ,
4- JNIEnv ,
5- } ;
1+ use jni:: { errors:: Error , objects:: JObject , JNIEnv } ;
62
73struct Inner < ' env > {
84 env : JNIEnv < ' env > ,
@@ -33,8 +29,7 @@ impl<'env> Intent<'env> {
3329 let action_view =
3430 env. get_static_field ( intent_class, action. as_ref ( ) , "Ljava/lang/String;" ) ?;
3531
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] ) ?;
3833
3934 Ok ( Inner {
4035 env,
@@ -51,7 +46,7 @@ impl<'env> Intent<'env> {
5146 uri_class,
5247 "parse" ,
5348 "(Ljava/lang/String;)Landroid/net/Uri;" ,
54- & [ JString :: from ( url_string) . into ( ) ] ,
49+ & [ url_string. into ( ) ] ,
5550 ) ?;
5651
5752 let intent_class = env. find_class ( "android/content/Intent" ) ?;
@@ -61,7 +56,7 @@ impl<'env> Intent<'env> {
6156 let intent = env. new_object (
6257 intent_class,
6358 "(Ljava/lang/String;Landroid/net/Uri;)V" ,
64- & [ action_view. into ( ) , uri. into ( ) ] ,
59+ & [ action_view, uri] ,
6560 ) ?;
6661
6762 Ok ( Inner {
@@ -77,10 +72,14 @@ impl<'env> Intent<'env> {
7772 ///
7873 /// # android_intent::with_current_env(|env| {
7974 /// 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");
8176 /// # })
8277 /// ```
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 {
8483 self . and_then ( |inner| {
8584 let package_name = inner. env . new_string ( package_name) ?;
8685 let class_name = inner. env . new_string ( class_name) ?;
@@ -102,7 +101,7 @@ impl<'env> Intent<'env> {
102101 ///
103102 /// # android_intent::with_current_env(|env| {
104103 /// 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!");
106105 /// # })
107106 /// ```
108107 pub fn with_extra ( self , key : impl AsRef < str > , value : impl AsRef < str > ) -> Self {
@@ -121,12 +120,12 @@ impl<'env> Intent<'env> {
121120 } )
122121 }
123122
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.
125124 /// ```no_run
126125 /// use android_intent::{Action, Intent};
127126 ///
128127 /// # 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 ();
130129 /// # })
131130 /// ```
132131 pub fn into_chooser ( self ) -> Self {
@@ -161,7 +160,7 @@ impl<'env> Intent<'env> {
161160 ///
162161 /// # android_intent::with_current_env(|env| {
163162 /// let intent = Intent::new(env, Action::Send);
164- /// intent.set_type ("text/plain");
163+ /// let intent = intent.with_type ("text/plain");
165164 /// # })
166165 /// ```
167166 pub fn with_type ( self , type_name : impl AsRef < str > ) -> Self {
0 commit comments