1
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// 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.
5
5
// See also: https://pub.dev/packages/pigeon
6
6
7
7
package io .flutter .plugins .quickactions ;
8
8
9
+ import static java .lang .annotation .ElementType .METHOD ;
10
+ import static java .lang .annotation .RetentionPolicy .CLASS ;
11
+
9
12
import android .util .Log ;
10
13
import androidx .annotation .NonNull ;
11
14
import androidx .annotation .Nullable ;
14
17
import io .flutter .plugin .common .MessageCodec ;
15
18
import io .flutter .plugin .common .StandardMessageCodec ;
16
19
import java .io .ByteArrayOutputStream ;
20
+ import java .lang .annotation .Retention ;
21
+ import java .lang .annotation .Target ;
17
22
import java .nio .ByteBuffer ;
18
23
import java .util .ArrayList ;
19
24
import java .util .Collections ;
20
25
import java .util .List ;
26
+ import java .util .Objects ;
21
27
22
28
/** Generated class from Pigeon. */
23
29
@ SuppressWarnings ({"unused" , "unchecked" , "CodeBlock2Expr" , "RedundantSuppression" , "serial" })
@@ -41,7 +47,7 @@ public FlutterError(@NonNull String code, @Nullable String message, @Nullable Ob
41
47
42
48
@ NonNull
43
49
protected static ArrayList <Object > wrapError (@ NonNull Throwable exception ) {
44
- ArrayList <Object > errorList = new ArrayList <Object >(3 );
50
+ ArrayList <Object > errorList = new ArrayList <>(3 );
45
51
if (exception instanceof FlutterError ) {
46
52
FlutterError error = (FlutterError ) exception ;
47
53
errorList .add (error .code );
@@ -56,6 +62,16 @@ protected static ArrayList<Object> wrapError(@NonNull Throwable exception) {
56
62
return errorList ;
57
63
}
58
64
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
+
59
75
/**
60
76
* Home screen quick-action shortcut item.
61
77
*
@@ -104,24 +120,46 @@ public void setIcon(@Nullable String setterArg) {
104
120
/** Constructor is non-public to enforce null safety; use Builder. */
105
121
ShortcutItemMessage () {}
106
122
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
+
107
142
public static final class Builder {
108
143
109
144
private @ Nullable String type ;
110
145
146
+ @ CanIgnoreReturnValue
111
147
public @ NonNull Builder setType (@ NonNull String setterArg ) {
112
148
this .type = setterArg ;
113
149
return this ;
114
150
}
115
151
116
152
private @ Nullable String localizedTitle ;
117
153
154
+ @ CanIgnoreReturnValue
118
155
public @ NonNull Builder setLocalizedTitle (@ NonNull String setterArg ) {
119
156
this .localizedTitle = setterArg ;
120
157
return this ;
121
158
}
122
159
123
160
private @ Nullable String icon ;
124
161
162
+ @ CanIgnoreReturnValue
125
163
public @ NonNull Builder setIcon (@ Nullable String setterArg ) {
126
164
this .icon = setterArg ;
127
165
return this ;
@@ -138,41 +176,34 @@ public static final class Builder {
138
176
139
177
@ NonNull
140
178
ArrayList <Object > toList () {
141
- ArrayList <Object > toListResult = new ArrayList <Object >(3 );
179
+ ArrayList <Object > toListResult = new ArrayList <>(3 );
142
180
toListResult .add (type );
143
181
toListResult .add (localizedTitle );
144
182
toListResult .add (icon );
145
183
return toListResult ;
146
184
}
147
185
148
- static @ NonNull ShortcutItemMessage fromList (@ NonNull ArrayList <Object > list ) {
186
+ static @ NonNull ShortcutItemMessage fromList (@ NonNull ArrayList <Object > pigeonVar_list ) {
149
187
ShortcutItemMessage pigeonResult = new ShortcutItemMessage ();
150
- Object type = list .get (0 );
188
+ Object type = pigeonVar_list .get (0 );
151
189
pigeonResult .setType ((String ) type );
152
- Object localizedTitle = list .get (1 );
190
+ Object localizedTitle = pigeonVar_list .get (1 );
153
191
pigeonResult .setLocalizedTitle ((String ) localizedTitle );
154
- Object icon = list .get (2 );
192
+ Object icon = pigeonVar_list .get (2 );
155
193
pigeonResult .setIcon ((String ) icon );
156
194
return pigeonResult ;
157
195
}
158
196
}
159
197
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 ();
166
200
167
- private static class AndroidQuickActionsApiCodec extends StandardMessageCodec {
168
- public static final AndroidQuickActionsApiCodec INSTANCE = new AndroidQuickActionsApiCodec ();
169
-
170
- private AndroidQuickActionsApiCodec () {}
201
+ private PigeonCodec () {}
171
202
172
203
@ Override
173
204
protected Object readValueOfType (byte type , @ NonNull ByteBuffer buffer ) {
174
205
switch (type ) {
175
- case (byte ) 128 :
206
+ case (byte ) 129 :
176
207
return ShortcutItemMessage .fromList ((ArrayList <Object >) readValue (buffer ));
177
208
default :
178
209
return super .readValueOfType (type , buffer );
@@ -182,51 +213,82 @@ protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) {
182
213
@ Override
183
214
protected void writeValue (@ NonNull ByteArrayOutputStream stream , Object value ) {
184
215
if (value instanceof ShortcutItemMessage ) {
185
- stream .write (128 );
216
+ stream .write (129 );
186
217
writeValue (stream , ((ShortcutItemMessage ) value ).toList ());
187
218
} else {
188
219
super .writeValue (stream , value );
189
220
}
190
221
}
191
222
}
192
223
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
+ }
193
248
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
194
249
public interface AndroidQuickActionsApi {
195
250
/** Checks for, and returns the action that launched the app. */
196
251
@ Nullable
197
252
String getLaunchAction ();
198
253
/** 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 );
201
255
/** Removes all dynamic shortcuts. */
202
256
void clearShortcutItems ();
203
257
204
258
/** The codec used by AndroidQuickActionsApi. */
205
259
static @ NonNull MessageCodec <Object > getCodec () {
206
- return AndroidQuickActionsApiCodec .INSTANCE ;
260
+ return PigeonCodec .INSTANCE ;
207
261
}
208
262
/**
209
263
* Sets up an instance of `AndroidQuickActionsApi` to handle messages through the
210
264
* `binaryMessenger`.
211
265
*/
212
- static void setup (
266
+ static void setUp (
213
267
@ 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 ;
214
276
{
215
277
BasicMessageChannel <Object > channel =
216
278
new BasicMessageChannel <>(
217
279
binaryMessenger ,
218
- "dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.getLaunchAction" ,
280
+ "dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.getLaunchAction"
281
+ + messageChannelSuffix ,
219
282
getCodec ());
220
283
if (api != null ) {
221
284
channel .setMessageHandler (
222
285
(message , reply ) -> {
223
- ArrayList <Object > wrapped = new ArrayList <Object >();
286
+ ArrayList <Object > wrapped = new ArrayList <>();
224
287
try {
225
288
String output = api .getLaunchAction ();
226
289
wrapped .add (0 , output );
227
290
} catch (Throwable exception ) {
228
- ArrayList <Object > wrappedError = wrapError (exception );
229
- wrapped = wrappedError ;
291
+ wrapped = wrapError (exception );
230
292
}
231
293
reply .reply (wrapped );
232
294
});
@@ -238,17 +300,18 @@ static void setup(
238
300
BasicMessageChannel <Object > channel =
239
301
new BasicMessageChannel <>(
240
302
binaryMessenger ,
241
- "dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.setShortcutItems" ,
303
+ "dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.setShortcutItems"
304
+ + messageChannelSuffix ,
242
305
getCodec ());
243
306
if (api != null ) {
244
307
channel .setMessageHandler (
245
308
(message , reply ) -> {
246
- ArrayList <Object > wrapped = new ArrayList <Object >();
309
+ ArrayList <Object > wrapped = new ArrayList <>();
247
310
ArrayList <Object > args = (ArrayList <Object >) message ;
248
311
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 () {
252
315
wrapped .add (0 , null );
253
316
reply .reply (wrapped );
254
317
}
@@ -269,18 +332,18 @@ public void error(Throwable error) {
269
332
BasicMessageChannel <Object > channel =
270
333
new BasicMessageChannel <>(
271
334
binaryMessenger ,
272
- "dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.clearShortcutItems" ,
335
+ "dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.clearShortcutItems"
336
+ + messageChannelSuffix ,
273
337
getCodec ());
274
338
if (api != null ) {
275
339
channel .setMessageHandler (
276
340
(message , reply ) -> {
277
- ArrayList <Object > wrapped = new ArrayList <Object >();
341
+ ArrayList <Object > wrapped = new ArrayList <>();
278
342
try {
279
343
api .clearShortcutItems ();
280
344
wrapped .add (0 , null );
281
345
} catch (Throwable exception ) {
282
- ArrayList <Object > wrappedError = wrapError (exception );
283
- wrapped = wrappedError ;
346
+ wrapped = wrapError (exception );
284
347
}
285
348
reply .reply (wrapped );
286
349
});
@@ -293,30 +356,45 @@ public void error(Throwable error) {
293
356
/** Generated class from Pigeon that represents Flutter messages that can be called from Java. */
294
357
public static class AndroidQuickActionsFlutterApi {
295
358
private final @ NonNull BinaryMessenger binaryMessenger ;
359
+ private final String messageChannelSuffix ;
296
360
297
361
public AndroidQuickActionsFlutterApi (@ NonNull BinaryMessenger argBinaryMessenger ) {
298
- this . binaryMessenger = argBinaryMessenger ;
362
+ this ( argBinaryMessenger , "" ) ;
299
363
}
300
364
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 ;
305
369
}
306
- /** The codec used by AndroidQuickActionsFlutterApi. */
370
+
371
+ /** Public interface for sending reply. The codec used by AndroidQuickActionsFlutterApi. */
307
372
static @ NonNull MessageCodec <Object > getCodec () {
308
- return new StandardMessageCodec () ;
373
+ return PigeonCodec . INSTANCE ;
309
374
}
310
375
/** 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 ;
312
380
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 ());
317
382
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
+ });
320
398
}
321
399
}
322
400
}
0 commit comments