11// Copyright 2013 The Flutter Authors. All rights reserved.
22// Use of this source code is governed by a BSD-style license that can be
33// found in the LICENSE file.
4- // Autogenerated from Pigeon (v11 .0.1 ), do not edit directly.
4+ // Autogenerated from Pigeon (v24 .0.0 ), do not edit directly.
55// See also: https://pub.dev/packages/pigeon
66
77package io .flutter .plugins .quickactions ;
88
9+ import static java .lang .annotation .ElementType .METHOD ;
10+ import static java .lang .annotation .RetentionPolicy .CLASS ;
11+
912import android .util .Log ;
1013import androidx .annotation .NonNull ;
1114import androidx .annotation .Nullable ;
1417import io .flutter .plugin .common .MessageCodec ;
1518import io .flutter .plugin .common .StandardMessageCodec ;
1619import java .io .ByteArrayOutputStream ;
20+ import java .lang .annotation .Retention ;
21+ import java .lang .annotation .Target ;
1722import java .nio .ByteBuffer ;
1823import java .util .ArrayList ;
1924import java .util .Collections ;
2025import java .util .List ;
26+ import java .util .Objects ;
2127
2228/** Generated class from Pigeon. */
2329@ SuppressWarnings ({"unused" , "unchecked" , "CodeBlock2Expr" , "RedundantSuppression" , "serial" })
@@ -41,7 +47,7 @@ public FlutterError(@NonNull String code, @Nullable String message, @Nullable Ob
4147
4248 @ NonNull
4349 protected static ArrayList <Object > wrapError (@ NonNull Throwable exception ) {
44- ArrayList <Object > errorList = new ArrayList <Object >(3 );
50+ ArrayList <Object > errorList = new ArrayList <>(3 );
4551 if (exception instanceof FlutterError ) {
4652 FlutterError error = (FlutterError ) exception ;
4753 errorList .add (error .code );
@@ -56,6 +62,16 @@ protected static ArrayList<Object> wrapError(@NonNull Throwable exception) {
5662 return errorList ;
5763 }
5864
65+ @ NonNull
66+ protected static FlutterError createConnectionError (@ NonNull String channelName ) {
67+ return new FlutterError (
68+ "channel-error" , "Unable to establish connection on channel: " + channelName + "." , "" );
69+ }
70+
71+ @ Target (METHOD )
72+ @ Retention (CLASS )
73+ @interface CanIgnoreReturnValue {}
74+
5975 /**
6076 * Home screen quick-action shortcut item.
6177 *
@@ -104,24 +120,46 @@ public void setIcon(@Nullable String setterArg) {
104120 /** Constructor is non-public to enforce null safety; use Builder. */
105121 ShortcutItemMessage () {}
106122
123+ @ Override
124+ public boolean equals (Object o ) {
125+ if (this == o ) {
126+ return true ;
127+ }
128+ if (o == null || getClass () != o .getClass ()) {
129+ return false ;
130+ }
131+ ShortcutItemMessage that = (ShortcutItemMessage ) o ;
132+ return type .equals (that .type )
133+ && localizedTitle .equals (that .localizedTitle )
134+ && Objects .equals (icon , that .icon );
135+ }
136+
137+ @ Override
138+ public int hashCode () {
139+ return Objects .hash (type , localizedTitle , icon );
140+ }
141+
107142 public static final class Builder {
108143
109144 private @ Nullable String type ;
110145
146+ @ CanIgnoreReturnValue
111147 public @ NonNull Builder setType (@ NonNull String setterArg ) {
112148 this .type = setterArg ;
113149 return this ;
114150 }
115151
116152 private @ Nullable String localizedTitle ;
117153
154+ @ CanIgnoreReturnValue
118155 public @ NonNull Builder setLocalizedTitle (@ NonNull String setterArg ) {
119156 this .localizedTitle = setterArg ;
120157 return this ;
121158 }
122159
123160 private @ Nullable String icon ;
124161
162+ @ CanIgnoreReturnValue
125163 public @ NonNull Builder setIcon (@ Nullable String setterArg ) {
126164 this .icon = setterArg ;
127165 return this ;
@@ -138,41 +176,34 @@ public static final class Builder {
138176
139177 @ NonNull
140178 ArrayList <Object > toList () {
141- ArrayList <Object > toListResult = new ArrayList <Object >(3 );
179+ ArrayList <Object > toListResult = new ArrayList <>(3 );
142180 toListResult .add (type );
143181 toListResult .add (localizedTitle );
144182 toListResult .add (icon );
145183 return toListResult ;
146184 }
147185
148- static @ NonNull ShortcutItemMessage fromList (@ NonNull ArrayList <Object > list ) {
186+ static @ NonNull ShortcutItemMessage fromList (@ NonNull ArrayList <Object > pigeonVar_list ) {
149187 ShortcutItemMessage pigeonResult = new ShortcutItemMessage ();
150- Object type = list .get (0 );
188+ Object type = pigeonVar_list .get (0 );
151189 pigeonResult .setType ((String ) type );
152- Object localizedTitle = list .get (1 );
190+ Object localizedTitle = pigeonVar_list .get (1 );
153191 pigeonResult .setLocalizedTitle ((String ) localizedTitle );
154- Object icon = list .get (2 );
192+ Object icon = pigeonVar_list .get (2 );
155193 pigeonResult .setIcon ((String ) icon );
156194 return pigeonResult ;
157195 }
158196 }
159197
160- public interface Result <T > {
161- @ SuppressWarnings ("UnknownNullness" )
162- void success (T result );
163-
164- void error (@ NonNull Throwable error );
165- }
198+ private static class PigeonCodec extends StandardMessageCodec {
199+ public static final PigeonCodec INSTANCE = new PigeonCodec ();
166200
167- private static class AndroidQuickActionsApiCodec extends StandardMessageCodec {
168- public static final AndroidQuickActionsApiCodec INSTANCE = new AndroidQuickActionsApiCodec ();
169-
170- private AndroidQuickActionsApiCodec () {}
201+ private PigeonCodec () {}
171202
172203 @ Override
173204 protected Object readValueOfType (byte type , @ NonNull ByteBuffer buffer ) {
174205 switch (type ) {
175- case (byte ) 128 :
206+ case (byte ) 129 :
176207 return ShortcutItemMessage .fromList ((ArrayList <Object >) readValue (buffer ));
177208 default :
178209 return super .readValueOfType (type , buffer );
@@ -182,51 +213,82 @@ protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) {
182213 @ Override
183214 protected void writeValue (@ NonNull ByteArrayOutputStream stream , Object value ) {
184215 if (value instanceof ShortcutItemMessage ) {
185- stream .write (128 );
216+ stream .write (129 );
186217 writeValue (stream , ((ShortcutItemMessage ) value ).toList ());
187218 } else {
188219 super .writeValue (stream , value );
189220 }
190221 }
191222 }
192223
224+ /** Asynchronous error handling return type for non-nullable API method returns. */
225+ public interface Result <T > {
226+ /** Success case callback method for handling returns. */
227+ void success (@ NonNull T result );
228+
229+ /** Failure case callback method for handling errors. */
230+ void error (@ NonNull Throwable error );
231+ }
232+ /** Asynchronous error handling return type for nullable API method returns. */
233+ public interface NullableResult <T > {
234+ /** Success case callback method for handling returns. */
235+ void success (@ Nullable T result );
236+
237+ /** Failure case callback method for handling errors. */
238+ void error (@ NonNull Throwable error );
239+ }
240+ /** Asynchronous error handling return type for void API method returns. */
241+ public interface VoidResult {
242+ /** Success case callback method for handling returns. */
243+ void success ();
244+
245+ /** Failure case callback method for handling errors. */
246+ void error (@ NonNull Throwable error );
247+ }
193248 /** Generated interface from Pigeon that represents a handler of messages from Flutter. */
194249 public interface AndroidQuickActionsApi {
195250 /** Checks for, and returns the action that launched the app. */
196251 @ Nullable
197252 String getLaunchAction ();
198253 /** Sets the dynamic shortcuts for the app. */
199- void setShortcutItems (
200- @ NonNull List <ShortcutItemMessage > itemsList , @ NonNull Result <Void > result );
254+ void setShortcutItems (@ NonNull List <ShortcutItemMessage > itemsList , @ NonNull VoidResult result );
201255 /** Removes all dynamic shortcuts. */
202256 void clearShortcutItems ();
203257
204258 /** The codec used by AndroidQuickActionsApi. */
205259 static @ NonNull MessageCodec <Object > getCodec () {
206- return AndroidQuickActionsApiCodec .INSTANCE ;
260+ return PigeonCodec .INSTANCE ;
207261 }
208262 /**
209263 * Sets up an instance of `AndroidQuickActionsApi` to handle messages through the
210264 * `binaryMessenger`.
211265 */
212- static void setup (
266+ static void setUp (
213267 @ NonNull BinaryMessenger binaryMessenger , @ Nullable AndroidQuickActionsApi api ) {
268+ setUp (binaryMessenger , "" , api );
269+ }
270+
271+ static void setUp (
272+ @ NonNull BinaryMessenger binaryMessenger ,
273+ @ NonNull String messageChannelSuffix ,
274+ @ Nullable AndroidQuickActionsApi api ) {
275+ messageChannelSuffix = messageChannelSuffix .isEmpty () ? "" : "." + messageChannelSuffix ;
214276 {
215277 BasicMessageChannel <Object > channel =
216278 new BasicMessageChannel <>(
217279 binaryMessenger ,
218- "dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.getLaunchAction" ,
280+ "dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.getLaunchAction"
281+ + messageChannelSuffix ,
219282 getCodec ());
220283 if (api != null ) {
221284 channel .setMessageHandler (
222285 (message , reply ) -> {
223- ArrayList <Object > wrapped = new ArrayList <Object >();
286+ ArrayList <Object > wrapped = new ArrayList <>();
224287 try {
225288 String output = api .getLaunchAction ();
226289 wrapped .add (0 , output );
227290 } catch (Throwable exception ) {
228- ArrayList <Object > wrappedError = wrapError (exception );
229- wrapped = wrappedError ;
291+ wrapped = wrapError (exception );
230292 }
231293 reply .reply (wrapped );
232294 });
@@ -238,17 +300,18 @@ static void setup(
238300 BasicMessageChannel <Object > channel =
239301 new BasicMessageChannel <>(
240302 binaryMessenger ,
241- "dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.setShortcutItems" ,
303+ "dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.setShortcutItems"
304+ + messageChannelSuffix ,
242305 getCodec ());
243306 if (api != null ) {
244307 channel .setMessageHandler (
245308 (message , reply ) -> {
246- ArrayList <Object > wrapped = new ArrayList <Object >();
309+ ArrayList <Object > wrapped = new ArrayList <>();
247310 ArrayList <Object > args = (ArrayList <Object >) message ;
248311 List <ShortcutItemMessage > itemsListArg = (List <ShortcutItemMessage >) args .get (0 );
249- Result < Void > resultCallback =
250- new Result < Void > () {
251- public void success (Void result ) {
312+ VoidResult resultCallback =
313+ new VoidResult () {
314+ public void success () {
252315 wrapped .add (0 , null );
253316 reply .reply (wrapped );
254317 }
@@ -269,18 +332,18 @@ public void error(Throwable error) {
269332 BasicMessageChannel <Object > channel =
270333 new BasicMessageChannel <>(
271334 binaryMessenger ,
272- "dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.clearShortcutItems" ,
335+ "dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.clearShortcutItems"
336+ + messageChannelSuffix ,
273337 getCodec ());
274338 if (api != null ) {
275339 channel .setMessageHandler (
276340 (message , reply ) -> {
277- ArrayList <Object > wrapped = new ArrayList <Object >();
341+ ArrayList <Object > wrapped = new ArrayList <>();
278342 try {
279343 api .clearShortcutItems ();
280344 wrapped .add (0 , null );
281345 } catch (Throwable exception ) {
282- ArrayList <Object > wrappedError = wrapError (exception );
283- wrapped = wrappedError ;
346+ wrapped = wrapError (exception );
284347 }
285348 reply .reply (wrapped );
286349 });
@@ -293,30 +356,45 @@ public void error(Throwable error) {
293356 /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */
294357 public static class AndroidQuickActionsFlutterApi {
295358 private final @ NonNull BinaryMessenger binaryMessenger ;
359+ private final String messageChannelSuffix ;
296360
297361 public AndroidQuickActionsFlutterApi (@ NonNull BinaryMessenger argBinaryMessenger ) {
298- this . binaryMessenger = argBinaryMessenger ;
362+ this ( argBinaryMessenger , "" ) ;
299363 }
300364
301- /** Public interface for sending reply. */
302- @ SuppressWarnings ( "UnknownNullness" )
303- public interface Reply < T > {
304- void reply ( T reply ) ;
365+ public AndroidQuickActionsFlutterApi (
366+ @ NonNull BinaryMessenger argBinaryMessenger , @ NonNull String messageChannelSuffix ) {
367+ this . binaryMessenger = argBinaryMessenger ;
368+ this . messageChannelSuffix = messageChannelSuffix . isEmpty () ? "" : "." + messageChannelSuffix ;
305369 }
306- /** The codec used by AndroidQuickActionsFlutterApi. */
370+
371+ /** Public interface for sending reply. The codec used by AndroidQuickActionsFlutterApi. */
307372 static @ NonNull MessageCodec <Object > getCodec () {
308- return new StandardMessageCodec () ;
373+ return PigeonCodec . INSTANCE ;
309374 }
310375 /** Sends a string representing a shortcut from the native platform to the app. */
311- public void launchAction (@ NonNull String actionArg , @ NonNull Reply <Void > callback ) {
376+ public void launchAction (@ NonNull String actionArg , @ NonNull VoidResult result ) {
377+ final String channelName =
378+ "dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsFlutterApi.launchAction"
379+ + messageChannelSuffix ;
312380 BasicMessageChannel <Object > channel =
313- new BasicMessageChannel <>(
314- binaryMessenger ,
315- "dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsFlutterApi.launchAction" ,
316- getCodec ());
381+ new BasicMessageChannel <>(binaryMessenger , channelName , getCodec ());
317382 channel .send (
318- new ArrayList <Object >(Collections .singletonList (actionArg )),
319- channelReply -> callback .reply (null ));
383+ new ArrayList <>(Collections .singletonList (actionArg )),
384+ channelReply -> {
385+ if (channelReply instanceof List ) {
386+ List <Object > listReply = (List <Object >) channelReply ;
387+ if (listReply .size () > 1 ) {
388+ result .error (
389+ new FlutterError (
390+ (String ) listReply .get (0 ), (String ) listReply .get (1 ), listReply .get (2 )));
391+ } else {
392+ result .success ();
393+ }
394+ } else {
395+ result .error (createConnectionError (channelName ));
396+ }
397+ });
320398 }
321399 }
322400}
0 commit comments