From 5e48fe8daf7d0fa7ff498b8e11cc87ea9b803d32 Mon Sep 17 00:00:00 2001 From: Andrey Epin Date: Tue, 27 Dec 2022 15:40:34 -0800 Subject: [PATCH] Open new Chooser custom actions API. Open new Chooser custom actions API, address linter errors. Bug: 259947071 Test: presubmit Change-Id: I49408d70644edbb9ad4d27316c67a37d81f2ec3d --- core/api/current.txt | 15 +++++++++++++++ core/java/android/content/Intent.java | 5 ++--- .../android/service/chooser/ChooserAction.java | 8 ++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index b63b0aa9784a7..c819d010ff150 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -10626,6 +10626,7 @@ package android.content { field public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST = "android.intent.extra.changed_component_name_list"; field public static final String EXTRA_CHANGED_PACKAGE_LIST = "android.intent.extra.changed_package_list"; field public static final String EXTRA_CHANGED_UID_LIST = "android.intent.extra.changed_uid_list"; + field public static final String EXTRA_CHOOSER_CUSTOM_ACTIONS = "android.intent.extra.CHOOSER_CUSTOM_ACTIONS"; field public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER"; field public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS"; field public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT"; @@ -39358,6 +39359,20 @@ package android.service.carrier { package android.service.chooser { + public final class ChooserAction implements android.os.Parcelable { + method public int describeContents(); + method @NonNull public android.app.PendingIntent getAction(); + method @NonNull public android.graphics.drawable.Icon getIcon(); + method @NonNull public CharSequence getLabel(); + method public void writeToParcel(@NonNull android.os.Parcel, int); + field @NonNull public static final android.os.Parcelable.Creator CREATOR; + } + + public static final class ChooserAction.Builder { + ctor public ChooserAction.Builder(@NonNull android.graphics.drawable.Icon, @NonNull CharSequence, @NonNull android.app.PendingIntent); + method @NonNull public android.service.chooser.ChooserAction build(); + } + @Deprecated public final class ChooserTarget implements android.os.Parcelable { ctor @Deprecated public ChooserTarget(CharSequence, android.graphics.drawable.Icon, float, android.content.ComponentName, @Nullable android.os.Bundle); method @Deprecated public int describeContents(); diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 7ee8f604dd4f5..245b0e4304fb7 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -5830,10 +5830,9 @@ public class Intent implements Parcelable, Cloneable { /** * A Parcelable[] of {@link ChooserAction} objects to provide the Android Sharesheet with * app-specific actions to be presented to the user when invoking {@link #ACTION_CHOOSER}. - * @hide */ public static final String EXTRA_CHOOSER_CUSTOM_ACTIONS = - "android.intent.extra.EXTRA_CHOOSER_CUSTOM_ACTIONS"; + "android.intent.extra.CHOOSER_CUSTOM_ACTIONS"; /** * Optional argument to be used with {@link #ACTION_CHOOSER}. @@ -5844,7 +5843,7 @@ public class Intent implements Parcelable, Cloneable { * @hide */ public static final String EXTRA_CHOOSER_PAYLOAD_RESELECTION_ACTION = - "android.intent.extra.EXTRA_CHOOSER_PAYLOAD_RESELECTION_ACTION"; + "android.intent.extra.CHOOSER_PAYLOAD_RESELECTION_ACTION"; /** * An {@code ArrayList} of {@code String} annotations describing content for diff --git a/core/java/android/service/chooser/ChooserAction.java b/core/java/android/service/chooser/ChooserAction.java index 3010049633d41..cabf4eda5b05b 100644 --- a/core/java/android/service/chooser/ChooserAction.java +++ b/core/java/android/service/chooser/ChooserAction.java @@ -27,11 +27,9 @@ import java.util.Objects; /** * A ChooserAction is an app-defined action that can be provided to the Android Sharesheet to - * be shown to the user when {@link android.content.Intent.ACTION_CHOOSER} is invoked. + * be shown to the user when {@link android.content.Intent#ACTION_CHOOSER} is invoked. * - * @see android.content.Intent.EXTRA_CHOOSER_CUSTOM_ACTIONS - * @see android.content.Intent.EXTRA_CHOOSER_PAYLOAD_RESELECTION_ACTION - * @hide + * @see android.content.Intent#EXTRA_CHOOSER_CUSTOM_ACTIONS */ public final class ChooserAction implements Parcelable { private final Icon mIcon; @@ -88,6 +86,7 @@ public final class ChooserAction implements Parcelable { return "ChooserAction {" + "label=" + mLabel + ", intent=" + mAction + "}"; } + @NonNull public static final Parcelable.Creator CREATOR = new Creator() { @Override @@ -137,6 +136,7 @@ public final class ChooserAction implements Parcelable { * object. * @return the built action */ + @NonNull public ChooserAction build() { return new ChooserAction(mIcon, mLabel, mAction); }