Merge "Send stacked apps through full standard start flow."
This commit is contained in:
committed by
Android (Google) Code Review
commit
cd87f72f02
@@ -1439,20 +1439,22 @@ public class ChooserActivity extends ResolverActivity implements
|
||||
|
||||
final long selectionCost = System.currentTimeMillis() - mChooserShownTime;
|
||||
|
||||
// Stacked apps get a disambiguation first
|
||||
if (targetInfo instanceof MultiDisplayResolveInfo) {
|
||||
MultiDisplayResolveInfo mti = (MultiDisplayResolveInfo) targetInfo;
|
||||
CharSequence[] labels = new CharSequence[mti.getTargets().size()];
|
||||
int i = 0;
|
||||
for (TargetInfo ti : mti.getTargets()) {
|
||||
labels[i++] = ti.getResolveInfo().loadLabel(getPackageManager());
|
||||
}
|
||||
ChooserStackedAppDialogFragment f = new ChooserStackedAppDialogFragment(
|
||||
targetInfo.getDisplayLabel(),
|
||||
((MultiDisplayResolveInfo) targetInfo).getTargets(), labels);
|
||||
if (!mti.hasSelected()) {
|
||||
// Stacked apps get a disambiguation first
|
||||
CharSequence[] labels = new CharSequence[mti.getTargets().size()];
|
||||
int i = 0;
|
||||
for (TargetInfo ti : mti.getTargets()) {
|
||||
labels[i++] = ti.getResolveInfo().loadLabel(getPackageManager());
|
||||
}
|
||||
ChooserStackedAppDialogFragment f = new ChooserStackedAppDialogFragment(
|
||||
targetInfo.getDisplayLabel(),
|
||||
((MultiDisplayResolveInfo) targetInfo), labels, which);
|
||||
|
||||
f.show(getFragmentManager(), TARGET_DETAILS_FRAGMENT_TAG);
|
||||
return;
|
||||
f.show(getFragmentManager(), TARGET_DETAILS_FRAGMENT_TAG);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
super.startSelected(which, always, filtered);
|
||||
|
||||
@@ -24,10 +24,7 @@ import android.content.DialogInterface;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.internal.app.chooser.DisplayResolveInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.android.internal.app.chooser.MultiDisplayResolveInfo;
|
||||
|
||||
/**
|
||||
* Shows individual actions for a "stacked" app target - such as an app with multiple posting
|
||||
@@ -38,24 +35,20 @@ public class ChooserStackedAppDialogFragment extends DialogFragment
|
||||
private static final String TITLE_KEY = "title";
|
||||
private static final String PINNED_KEY = "pinned";
|
||||
|
||||
private List<DisplayResolveInfo> mTargetInfos = new ArrayList<>();
|
||||
private MultiDisplayResolveInfo mTargetInfos;
|
||||
private CharSequence[] mLabels;
|
||||
private int mParentWhich;
|
||||
|
||||
public ChooserStackedAppDialogFragment() {
|
||||
}
|
||||
|
||||
public ChooserStackedAppDialogFragment(CharSequence title) {
|
||||
Bundle args = new Bundle();
|
||||
args.putCharSequence(TITLE_KEY, title);
|
||||
setArguments(args);
|
||||
}
|
||||
|
||||
public ChooserStackedAppDialogFragment(CharSequence title,
|
||||
List<DisplayResolveInfo> targets, CharSequence[] labels) {
|
||||
MultiDisplayResolveInfo targets, CharSequence[] labels, int parentWhich) {
|
||||
Bundle args = new Bundle();
|
||||
args.putCharSequence(TITLE_KEY, title);
|
||||
mTargetInfos = targets;
|
||||
mLabels = labels;
|
||||
mParentWhich = parentWhich;
|
||||
setArguments(args);
|
||||
}
|
||||
|
||||
@@ -72,7 +65,8 @@ public class ChooserStackedAppDialogFragment extends DialogFragment
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
final Bundle args = getArguments();
|
||||
mTargetInfos.get(which).start(getActivity(), null);
|
||||
mTargetInfos.setSelected(which);
|
||||
((ChooserActivity) getActivity()).startSelected(mParentWhich, false, true);
|
||||
dismiss();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
|
||||
package com.android.internal.app.chooser;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import com.android.internal.app.ResolverActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -27,6 +33,8 @@ public class MultiDisplayResolveInfo extends DisplayResolveInfo {
|
||||
List<DisplayResolveInfo> mTargetInfos = new ArrayList<>();
|
||||
// We'll use this DRI for basic presentation info - eg icon, name.
|
||||
final DisplayResolveInfo mBaseInfo;
|
||||
// Index of selected target
|
||||
private int mSelected = -1;
|
||||
|
||||
/**
|
||||
* @param firstInfo A representative DRI to use for the main icon, title, etc for this Info.
|
||||
@@ -57,4 +65,30 @@ public class MultiDisplayResolveInfo extends DisplayResolveInfo {
|
||||
return mTargetInfos;
|
||||
}
|
||||
|
||||
public void setSelected(int selected) {
|
||||
mSelected = selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the user has selected a specific target for this MultiInfo.
|
||||
*/
|
||||
public boolean hasSelected() {
|
||||
return mSelected >= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start(Activity activity, Bundle options) {
|
||||
return mTargetInfos.get(mSelected).start(activity, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startAsCaller(ResolverActivity activity, Bundle options, int userId) {
|
||||
return mTargetInfos.get(mSelected).startAsCaller(activity, options, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startAsUser(Activity activity, Bundle options, UserHandle user) {
|
||||
return mTargetInfos.get(mSelected).startAsUser(activity, options, user);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user