Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/quick_actions/quick_actions_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.19

* Updates `pigeon` dependency to version 24.

## 1.0.18

* Updates Java compatibility version to 11.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Autogenerated from Pigeon (v11.0.1), do not edit directly.
// Autogenerated from Pigeon (v24.0.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon

package io.flutter.plugins.quickactions;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.CLASS;

import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -14,10 +17,13 @@
import io.flutter.plugin.common.MessageCodec;
import io.flutter.plugin.common.StandardMessageCodec;
import java.io.ByteArrayOutputStream;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/** Generated class from Pigeon. */
@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression", "serial"})
Expand All @@ -41,7 +47,7 @@ public FlutterError(@NonNull String code, @Nullable String message, @Nullable Ob

@NonNull
protected static ArrayList<Object> wrapError(@NonNull Throwable exception) {
ArrayList<Object> errorList = new ArrayList<Object>(3);
ArrayList<Object> errorList = new ArrayList<>(3);
if (exception instanceof FlutterError) {
FlutterError error = (FlutterError) exception;
errorList.add(error.code);
Expand All @@ -56,6 +62,16 @@ protected static ArrayList<Object> wrapError(@NonNull Throwable exception) {
return errorList;
}

@NonNull
protected static FlutterError createConnectionError(@NonNull String channelName) {
return new FlutterError(
"channel-error", "Unable to establish connection on channel: " + channelName + ".", "");
}

@Target(METHOD)
@Retention(CLASS)
@interface CanIgnoreReturnValue {}

/**
* Home screen quick-action shortcut item.
*
Expand Down Expand Up @@ -104,24 +120,46 @@ public void setIcon(@Nullable String setterArg) {
/** Constructor is non-public to enforce null safety; use Builder. */
ShortcutItemMessage() {}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ShortcutItemMessage that = (ShortcutItemMessage) o;
return type.equals(that.type)
&& localizedTitle.equals(that.localizedTitle)
&& Objects.equals(icon, that.icon);
}

@Override
public int hashCode() {
return Objects.hash(type, localizedTitle, icon);
}

public static final class Builder {

private @Nullable String type;

@CanIgnoreReturnValue
public @NonNull Builder setType(@NonNull String setterArg) {
this.type = setterArg;
return this;
}

private @Nullable String localizedTitle;

@CanIgnoreReturnValue
public @NonNull Builder setLocalizedTitle(@NonNull String setterArg) {
this.localizedTitle = setterArg;
return this;
}

private @Nullable String icon;

@CanIgnoreReturnValue
public @NonNull Builder setIcon(@Nullable String setterArg) {
this.icon = setterArg;
return this;
Expand All @@ -138,41 +176,34 @@ public static final class Builder {

@NonNull
ArrayList<Object> toList() {
ArrayList<Object> toListResult = new ArrayList<Object>(3);
ArrayList<Object> toListResult = new ArrayList<>(3);
toListResult.add(type);
toListResult.add(localizedTitle);
toListResult.add(icon);
return toListResult;
}

static @NonNull ShortcutItemMessage fromList(@NonNull ArrayList<Object> list) {
static @NonNull ShortcutItemMessage fromList(@NonNull ArrayList<Object> pigeonVar_list) {
ShortcutItemMessage pigeonResult = new ShortcutItemMessage();
Object type = list.get(0);
Object type = pigeonVar_list.get(0);
pigeonResult.setType((String) type);
Object localizedTitle = list.get(1);
Object localizedTitle = pigeonVar_list.get(1);
pigeonResult.setLocalizedTitle((String) localizedTitle);
Object icon = list.get(2);
Object icon = pigeonVar_list.get(2);
pigeonResult.setIcon((String) icon);
return pigeonResult;
}
}

public interface Result<T> {
@SuppressWarnings("UnknownNullness")
void success(T result);

void error(@NonNull Throwable error);
}
private static class PigeonCodec extends StandardMessageCodec {
public static final PigeonCodec INSTANCE = new PigeonCodec();

private static class AndroidQuickActionsApiCodec extends StandardMessageCodec {
public static final AndroidQuickActionsApiCodec INSTANCE = new AndroidQuickActionsApiCodec();

private AndroidQuickActionsApiCodec() {}
private PigeonCodec() {}

@Override
protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) {
switch (type) {
case (byte) 128:
case (byte) 129:
return ShortcutItemMessage.fromList((ArrayList<Object>) readValue(buffer));
default:
return super.readValueOfType(type, buffer);
Expand All @@ -182,51 +213,82 @@ protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) {
@Override
protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) {
if (value instanceof ShortcutItemMessage) {
stream.write(128);
stream.write(129);
writeValue(stream, ((ShortcutItemMessage) value).toList());
} else {
super.writeValue(stream, value);
}
}
}

/** Asynchronous error handling return type for non-nullable API method returns. */
public interface Result<T> {
/** Success case callback method for handling returns. */
void success(@NonNull T result);

/** Failure case callback method for handling errors. */
void error(@NonNull Throwable error);
}
/** Asynchronous error handling return type for nullable API method returns. */
public interface NullableResult<T> {
/** Success case callback method for handling returns. */
void success(@Nullable T result);

/** Failure case callback method for handling errors. */
void error(@NonNull Throwable error);
}
/** Asynchronous error handling return type for void API method returns. */
public interface VoidResult {
/** Success case callback method for handling returns. */
void success();

/** Failure case callback method for handling errors. */
void error(@NonNull Throwable error);
}
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
public interface AndroidQuickActionsApi {
/** Checks for, and returns the action that launched the app. */
@Nullable
String getLaunchAction();
/** Sets the dynamic shortcuts for the app. */
void setShortcutItems(
@NonNull List<ShortcutItemMessage> itemsList, @NonNull Result<Void> result);
void setShortcutItems(@NonNull List<ShortcutItemMessage> itemsList, @NonNull VoidResult result);
/** Removes all dynamic shortcuts. */
void clearShortcutItems();

/** The codec used by AndroidQuickActionsApi. */
static @NonNull MessageCodec<Object> getCodec() {
return AndroidQuickActionsApiCodec.INSTANCE;
return PigeonCodec.INSTANCE;
}
/**
* Sets up an instance of `AndroidQuickActionsApi` to handle messages through the
* `binaryMessenger`.
*/
static void setup(
static void setUp(
@NonNull BinaryMessenger binaryMessenger, @Nullable AndroidQuickActionsApi api) {
setUp(binaryMessenger, "", api);
}

static void setUp(
@NonNull BinaryMessenger binaryMessenger,
@NonNull String messageChannelSuffix,
@Nullable AndroidQuickActionsApi api) {
messageChannelSuffix = messageChannelSuffix.isEmpty() ? "" : "." + messageChannelSuffix;
{
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.getLaunchAction",
"dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.getLaunchAction"
+ messageChannelSuffix,
getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
ArrayList<Object> wrapped = new ArrayList<Object>();
ArrayList<Object> wrapped = new ArrayList<>();
try {
String output = api.getLaunchAction();
wrapped.add(0, output);
} catch (Throwable exception) {
ArrayList<Object> wrappedError = wrapError(exception);
wrapped = wrappedError;
wrapped = wrapError(exception);
}
reply.reply(wrapped);
});
Expand All @@ -238,17 +300,18 @@ static void setup(
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.setShortcutItems",
"dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.setShortcutItems"
+ messageChannelSuffix,
getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
ArrayList<Object> wrapped = new ArrayList<Object>();
ArrayList<Object> wrapped = new ArrayList<>();
ArrayList<Object> args = (ArrayList<Object>) message;
List<ShortcutItemMessage> itemsListArg = (List<ShortcutItemMessage>) args.get(0);
Result<Void> resultCallback =
new Result<Void>() {
public void success(Void result) {
VoidResult resultCallback =
new VoidResult() {
public void success() {
wrapped.add(0, null);
reply.reply(wrapped);
}
Expand All @@ -269,18 +332,18 @@ public void error(Throwable error) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.clearShortcutItems",
"dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsApi.clearShortcutItems"
+ messageChannelSuffix,
getCodec());
if (api != null) {
channel.setMessageHandler(
(message, reply) -> {
ArrayList<Object> wrapped = new ArrayList<Object>();
ArrayList<Object> wrapped = new ArrayList<>();
try {
api.clearShortcutItems();
wrapped.add(0, null);
} catch (Throwable exception) {
ArrayList<Object> wrappedError = wrapError(exception);
wrapped = wrappedError;
wrapped = wrapError(exception);
}
reply.reply(wrapped);
});
Expand All @@ -293,30 +356,45 @@ public void error(Throwable error) {
/** Generated class from Pigeon that represents Flutter messages that can be called from Java. */
public static class AndroidQuickActionsFlutterApi {
private final @NonNull BinaryMessenger binaryMessenger;
private final String messageChannelSuffix;

public AndroidQuickActionsFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) {
this.binaryMessenger = argBinaryMessenger;
this(argBinaryMessenger, "");
}

/** Public interface for sending reply. */
@SuppressWarnings("UnknownNullness")
public interface Reply<T> {
void reply(T reply);
public AndroidQuickActionsFlutterApi(
@NonNull BinaryMessenger argBinaryMessenger, @NonNull String messageChannelSuffix) {
this.binaryMessenger = argBinaryMessenger;
this.messageChannelSuffix = messageChannelSuffix.isEmpty() ? "" : "." + messageChannelSuffix;
}
/** The codec used by AndroidQuickActionsFlutterApi. */

/** Public interface for sending reply. The codec used by AndroidQuickActionsFlutterApi. */
static @NonNull MessageCodec<Object> getCodec() {
return new StandardMessageCodec();
return PigeonCodec.INSTANCE;
}
/** Sends a string representing a shortcut from the native platform to the app. */
public void launchAction(@NonNull String actionArg, @NonNull Reply<Void> callback) {
public void launchAction(@NonNull String actionArg, @NonNull VoidResult result) {
final String channelName =
"dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsFlutterApi.launchAction"
+ messageChannelSuffix;
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(
binaryMessenger,
"dev.flutter.pigeon.quick_actions_android.AndroidQuickActionsFlutterApi.launchAction",
getCodec());
new BasicMessageChannel<>(binaryMessenger, channelName, getCodec());
channel.send(
new ArrayList<Object>(Collections.singletonList(actionArg)),
channelReply -> callback.reply(null));
new ArrayList<>(Collections.singletonList(actionArg)),
channelReply -> {
if (channelReply instanceof List) {
List<Object> listReply = (List<Object>) channelReply;
if (listReply.size() > 1) {
result.error(
new FlutterError(
(String) listReply.get(0), (String) listReply.get(1), listReply.get(2)));
} else {
result.success();
}
} else {
result.error(createConnectionError(channelName));
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import androidx.core.graphics.drawable.IconCompat;
import io.flutter.plugins.quickactions.Messages.AndroidQuickActionsApi;
import io.flutter.plugins.quickactions.Messages.FlutterError;
import io.flutter.plugins.quickactions.Messages.Result;
import io.flutter.plugins.quickactions.Messages.ShortcutItemMessage;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -30,7 +29,7 @@
import java.util.concurrent.TimeUnit;

final class QuickActions implements AndroidQuickActionsApi {
protected static final String EXTRA_ACTION = "some unique action key";
static final String EXTRA_ACTION = "some unique action key";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was flagged as using protected in a final class. I'm not actually sure how this was compiling before though; QuickActionsPlugin uses this, but isn't a subclass of QuickActions.


private final Context context;
private Activity activity;
Expand All @@ -56,9 +55,9 @@ boolean isVersionAllowed() {

@Override
public void setShortcutItems(
@NonNull List<ShortcutItemMessage> itemsList, @NonNull Result<Void> result) {
@NonNull List<ShortcutItemMessage> itemsList, @NonNull Messages.VoidResult result) {
if (!isVersionAllowed()) {
result.success(null);
result.success();
return;
}
List<ShortcutInfoCompat> shortcuts = shortcutItemMessageToShortcutInfo(itemsList);
Expand All @@ -82,7 +81,7 @@ public void setShortcutItems(
uiThreadExecutor.execute(
() -> {
if (didSucceed) {
result.success(null);
result.success();
} else {
result.error(
new FlutterError(
Expand Down
Loading