Merge "Add NEW_TASK flag to intent if metadata matches"
This commit is contained in:
committed by
Android (Google) Code Review
commit
72a7e8b310
@@ -35,8 +35,7 @@ public class ActivityTile extends Tile {
|
||||
private static final String TAG = "ActivityTile";
|
||||
|
||||
public ActivityTile(ActivityInfo info, String category) {
|
||||
super(info, category);
|
||||
setMetaData(info.metaData);
|
||||
super(info, category, info.metaData);
|
||||
}
|
||||
|
||||
ActivityTile(Parcel in) {
|
||||
|
||||
@@ -43,8 +43,7 @@ public class ProviderTile extends Tile {
|
||||
private String mKey;
|
||||
|
||||
public ProviderTile(ProviderInfo info, String category, Bundle metaData) {
|
||||
super(info, category);
|
||||
setMetaData(metaData);
|
||||
super(info, category, metaData);
|
||||
mAuthority = info.authority;
|
||||
mKey = metaData.getString(META_DATA_PREFERENCE_KEYHINT);
|
||||
}
|
||||
|
||||
@@ -71,16 +71,19 @@ public abstract class Tile implements Parcelable {
|
||||
private Bundle mMetaData;
|
||||
private String mCategory;
|
||||
|
||||
public Tile(ComponentInfo info, String category) {
|
||||
public Tile(ComponentInfo info, String category, Bundle metaData) {
|
||||
mComponentInfo = info;
|
||||
mComponentPackage = mComponentInfo.packageName;
|
||||
mComponentName = mComponentInfo.name;
|
||||
mCategory = category;
|
||||
mMetaData = metaData;
|
||||
mIntent = new Intent().setClassName(mComponentPackage, mComponentName);
|
||||
if (isNewTask()) {
|
||||
mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
}
|
||||
}
|
||||
|
||||
Tile(Parcel in) {
|
||||
final boolean isProviderTile = in.readBoolean();
|
||||
mComponentPackage = in.readString();
|
||||
mComponentName = in.readString();
|
||||
mIntent = new Intent().setClassName(mComponentPackage, mComponentName);
|
||||
@@ -90,6 +93,9 @@ public abstract class Tile implements Parcelable {
|
||||
}
|
||||
mCategory = in.readString();
|
||||
mMetaData = in.readBundle();
|
||||
if (isNewTask()) {
|
||||
mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -332,8 +338,7 @@ public abstract class Tile implements Parcelable {
|
||||
/**
|
||||
* Whether the {@link Activity} should be launched in a separate task.
|
||||
*/
|
||||
public boolean isNewTask(Context context) {
|
||||
ensureMetadataNotStale(context);
|
||||
public boolean isNewTask() {
|
||||
if (mMetaData != null
|
||||
&& mMetaData.containsKey(META_DATA_NEW_TASK)) {
|
||||
return mMetaData.getBoolean(META_DATA_NEW_TASK);
|
||||
|
||||
Reference in New Issue
Block a user