Merge "Enable unpausing apps from the workspace." into sc-dev

This commit is contained in:
TreeHugger Robot authored and Android (Google) Code Review committed 2021-05-26 22:24:40 +00:00
commit a07c2efdf6
2 files changed
+8 -7

No files matched your search

@@ -271,9 +271,7 @@ public class TaskbarActivityContext extends ContextThemeWrapper implements Activ
}); });
} else if (tag instanceof WorkspaceItemInfo) { } else if (tag instanceof WorkspaceItemInfo) {
WorkspaceItemInfo info = (WorkspaceItemInfo) tag; WorkspaceItemInfo info = (WorkspaceItemInfo) tag;
if (info.isDisabled()) { if (!(info.isDisabled() && ItemClickHandler.handleDisabledItemClicked(info, this))) {
ItemClickHandler.handleDisabledItemClicked(info, this);
} else {
Intent intent = new Intent(info.getIntent()) Intent intent = new Intent(info.getIntent())
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try { try {
@@ -196,8 +196,10 @@ public class ItemClickHandler {
/** /**
* Handles clicking on a disabled shortcut * Handles clicking on a disabled shortcut
*
* @return true iff the disabled item click has been handled.
*/ */
public static void handleDisabledItemClicked(WorkspaceItemInfo shortcut, Context context) { public static boolean handleDisabledItemClicked(WorkspaceItemInfo shortcut, Context context) {
final int disabledFlags = shortcut.runtimeStatusFlags final int disabledFlags = shortcut.runtimeStatusFlags
& WorkspaceItemInfo.FLAG_DISABLED_MASK; & WorkspaceItemInfo.FLAG_DISABLED_MASK;
if ((disabledFlags if ((disabledFlags
@@ -205,11 +207,12 @@ public class ItemClickHandler {
& ~FLAG_DISABLED_QUIET_USER) == 0) { & ~FLAG_DISABLED_QUIET_USER) == 0) {
// If the app is only disabled because of the above flags, launch activity anyway. // If the app is only disabled because of the above flags, launch activity anyway.
// Framework will tell the user why the app is suspended. // Framework will tell the user why the app is suspended.
return false;
} else { } else {
if (!TextUtils.isEmpty(shortcut.disabledMessage)) { if (!TextUtils.isEmpty(shortcut.disabledMessage)) {
// Use a message specific to this shortcut, if it has one. // Use a message specific to this shortcut, if it has one.
Toast.makeText(context, shortcut.disabledMessage, Toast.LENGTH_SHORT).show(); Toast.makeText(context, shortcut.disabledMessage, Toast.LENGTH_SHORT).show();
return; return true;
} }
// Otherwise just use a generic error message. // Otherwise just use a generic error message.
int error = R.string.activity_not_available; int error = R.string.activity_not_available;
@@ -220,6 +223,7 @@ public class ItemClickHandler {
error = R.string.shortcut_not_available; error = R.string.shortcut_not_available;
} }
Toast.makeText(context, error, Toast.LENGTH_SHORT).show(); Toast.makeText(context, error, Toast.LENGTH_SHORT).show();
return true;
} }
} }
@@ -229,8 +233,7 @@ public class ItemClickHandler {
* @param v The view that was clicked. Must be a tagged with a {@link WorkspaceItemInfo}. * @param v The view that was clicked. Must be a tagged with a {@link WorkspaceItemInfo}.
*/ */
public static void onClickAppShortcut(View v, WorkspaceItemInfo shortcut, Launcher launcher) { public static void onClickAppShortcut(View v, WorkspaceItemInfo shortcut, Launcher launcher) {
if (shortcut.isDisabled()) { if (shortcut.isDisabled() && handleDisabledItemClicked(shortcut, launcher)) {
handleDisabledItemClicked(shortcut, launcher);
return; return;
} }