Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 145b0cad authored by Ben Lin's avatar Ben Lin Committed by Jorim Jaggi
Browse files

Adding an Extra field for Intents so chooser show up even if one app.

By design, ChooserActivity (the activity that shows up when there's an
intent sent that can be handled by multiple apps) always default to not
show if there's only one app available to choose from. This adds the
extra in Intent such that if passed in, the parent activity can choose
to override the behavior and force show the chooser even if there's only
one app. Default is still skipping the chooser.

Bug: 31830662
Change-Id: I17d676e77094cded4af99c7433f511e8c6c58164
(cherry picked from commit 2c5adbdf1942898baa97a3c8a7976fc7c0627902)
parent 5bc2953f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -4195,6 +4195,16 @@ public class Intent implements Parcelable, Cloneable {
    public static final String EXTRA_MEDIA_RESOURCE_TYPE =
            "android.intent.extra.MEDIA_RESOURCE_TYPE";

    /**
     * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
     * whether to show the chooser or not when there is only one application available
     * to choose from.
     *
     * @hide
     */
    public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
            "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";

    /**
     * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
     * to represent that a video codec is allowed to use.
+7 −0
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import com.android.internal.R;
import com.android.internal.app.ResolverActivity.TargetInfo;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.google.android.collect.Lists;
@@ -344,6 +345,12 @@ public class ChooserActivity extends ResolverActivity {
        return true;
    }

    @Override
    public boolean shouldAutoLaunchSingleChoice(TargetInfo target) {
        return getIntent().getBooleanExtra(Intent.EXTRA_AUTO_LAUNCH_SINGLE_CHOICE,
                super.shouldAutoLaunchSingleChoice(target));
    }

    @Override
    public void showTargetDetails(ResolveInfo ri) {
        ComponentName name = ri.activityInfo.getComponentName();