Loading src/com/android/launcher3/DeleteDropTarget.java +7 −15 Original line number Diff line number Diff line Loading @@ -187,11 +187,6 @@ public class DeleteDropTarget extends ButtonDropTarget { if (!willAcceptDrop(info) || isAllAppsWidget(source, info)) { isVisible = false; } if (useUninstallLabel && !(((ItemInfo) info).user.equals(UserHandleCompat.myUserHandle()))) { // Don't support uninstall for apps from other profiles. isVisible = false; } if (useUninstallLabel) { setCompoundDrawablesRelativeWithIntrinsicBounds(mUninstallDrawable, null, null, null); Loading Loading @@ -287,19 +282,16 @@ public class DeleteDropTarget extends ButtonDropTarget { if (isAllAppsApplication(d.dragSource, item)) { // Uninstall the application if it is being dragged from AppsCustomize AppInfo appInfo = (AppInfo) item; // We don't support uninstalling apps from other profiles. if (item.user.equals(UserHandleCompat.myUserHandle())) { mLauncher.startApplicationUninstallActivity(appInfo.componentName, appInfo.flags); } mLauncher.startApplicationUninstallActivity(appInfo.componentName, appInfo.flags, appInfo.user); } else if (isUninstallFromWorkspace(d)) { ShortcutInfo shortcut = (ShortcutInfo) item; // We don't support uninstalling apps from other profiles. if (shortcut.intent != null && shortcut.intent.getComponent() != null && shortcut.user.equals(UserHandleCompat.myUserHandle())) { if (shortcut.intent != null && shortcut.intent.getComponent() != null) { final ComponentName componentName = shortcut.intent.getComponent(); final DragSource dragSource = d.dragSource; mWaitingForUninstall = mLauncher.startApplicationUninstallActivity(componentName, shortcut.flags); final UserHandleCompat user = shortcut.user; mWaitingForUninstall = mLauncher.startApplicationUninstallActivity( componentName, shortcut.flags, user); if (mWaitingForUninstall) { final Runnable checkIfUninstallWasSuccess = new Runnable() { @Override Loading @@ -307,7 +299,7 @@ public class DeleteDropTarget extends ButtonDropTarget { mWaitingForUninstall = false; String packageName = componentName.getPackageName(); boolean uninstallSuccessful = !AllAppsList.packageHasActivities( getContext(), packageName, UserHandleCompat.myUserHandle()); getContext(), packageName, user); if (dragSource instanceof Folder) { ((Folder) dragSource). onUninstallActivityReturned(uninstallSuccessful); Loading src/com/android/launcher3/Launcher.java +5 −1 Original line number Diff line number Diff line Loading @@ -2721,7 +2721,8 @@ public class Launcher extends Activity } // returns true if the activity was started boolean startApplicationUninstallActivity(ComponentName componentName, int flags) { boolean startApplicationUninstallActivity(ComponentName componentName, int flags, UserHandleCompat user) { if ((flags & AppInfo.DOWNLOADED_FLAG) == 0) { // System applications cannot be installed. For now, show a toast explaining that. // We may give them the option of disabling apps this way. Loading @@ -2735,6 +2736,9 @@ public class Launcher extends Activity Intent.ACTION_DELETE, Uri.fromParts("package", packageName, className)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); if (user != null) { user.addToIntent(intent, Intent.EXTRA_USER); } startActivity(intent); return true; } Loading src/com/android/launcher3/compat/UserHandleCompat.java +13 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.launcher3.compat; import android.content.Intent; import android.os.Build; import android.os.UserHandle; Loading Loading @@ -78,4 +79,16 @@ public class UserHandleCompat { return 0; } } /** * Adds {@link UserHandle} to the intent in for L or above. * Pre-L the launcher doesn't support showing apps for multiple * profiles so this is a no-op. */ public void addToIntent(Intent intent, String name) { // TODO change this to use api version once L gets an API number. if ("L".equals(Build.VERSION.CODENAME) && mUser != null) { intent.putExtra(name, mUser); } } } No newline at end of file Loading
src/com/android/launcher3/DeleteDropTarget.java +7 −15 Original line number Diff line number Diff line Loading @@ -187,11 +187,6 @@ public class DeleteDropTarget extends ButtonDropTarget { if (!willAcceptDrop(info) || isAllAppsWidget(source, info)) { isVisible = false; } if (useUninstallLabel && !(((ItemInfo) info).user.equals(UserHandleCompat.myUserHandle()))) { // Don't support uninstall for apps from other profiles. isVisible = false; } if (useUninstallLabel) { setCompoundDrawablesRelativeWithIntrinsicBounds(mUninstallDrawable, null, null, null); Loading Loading @@ -287,19 +282,16 @@ public class DeleteDropTarget extends ButtonDropTarget { if (isAllAppsApplication(d.dragSource, item)) { // Uninstall the application if it is being dragged from AppsCustomize AppInfo appInfo = (AppInfo) item; // We don't support uninstalling apps from other profiles. if (item.user.equals(UserHandleCompat.myUserHandle())) { mLauncher.startApplicationUninstallActivity(appInfo.componentName, appInfo.flags); } mLauncher.startApplicationUninstallActivity(appInfo.componentName, appInfo.flags, appInfo.user); } else if (isUninstallFromWorkspace(d)) { ShortcutInfo shortcut = (ShortcutInfo) item; // We don't support uninstalling apps from other profiles. if (shortcut.intent != null && shortcut.intent.getComponent() != null && shortcut.user.equals(UserHandleCompat.myUserHandle())) { if (shortcut.intent != null && shortcut.intent.getComponent() != null) { final ComponentName componentName = shortcut.intent.getComponent(); final DragSource dragSource = d.dragSource; mWaitingForUninstall = mLauncher.startApplicationUninstallActivity(componentName, shortcut.flags); final UserHandleCompat user = shortcut.user; mWaitingForUninstall = mLauncher.startApplicationUninstallActivity( componentName, shortcut.flags, user); if (mWaitingForUninstall) { final Runnable checkIfUninstallWasSuccess = new Runnable() { @Override Loading @@ -307,7 +299,7 @@ public class DeleteDropTarget extends ButtonDropTarget { mWaitingForUninstall = false; String packageName = componentName.getPackageName(); boolean uninstallSuccessful = !AllAppsList.packageHasActivities( getContext(), packageName, UserHandleCompat.myUserHandle()); getContext(), packageName, user); if (dragSource instanceof Folder) { ((Folder) dragSource). onUninstallActivityReturned(uninstallSuccessful); Loading
src/com/android/launcher3/Launcher.java +5 −1 Original line number Diff line number Diff line Loading @@ -2721,7 +2721,8 @@ public class Launcher extends Activity } // returns true if the activity was started boolean startApplicationUninstallActivity(ComponentName componentName, int flags) { boolean startApplicationUninstallActivity(ComponentName componentName, int flags, UserHandleCompat user) { if ((flags & AppInfo.DOWNLOADED_FLAG) == 0) { // System applications cannot be installed. For now, show a toast explaining that. // We may give them the option of disabling apps this way. Loading @@ -2735,6 +2736,9 @@ public class Launcher extends Activity Intent.ACTION_DELETE, Uri.fromParts("package", packageName, className)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); if (user != null) { user.addToIntent(intent, Intent.EXTRA_USER); } startActivity(intent); return true; } Loading
src/com/android/launcher3/compat/UserHandleCompat.java +13 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.launcher3.compat; import android.content.Intent; import android.os.Build; import android.os.UserHandle; Loading Loading @@ -78,4 +79,16 @@ public class UserHandleCompat { return 0; } } /** * Adds {@link UserHandle} to the intent in for L or above. * Pre-L the launcher doesn't support showing apps for multiple * profiles so this is a no-op. */ public void addToIntent(Intent intent, String name) { // TODO change this to use api version once L gets an API number. if ("L".equals(Build.VERSION.CODENAME) && mUser != null) { intent.putExtra(name, mUser); } } } No newline at end of file