summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/DeleteDropTarget.java
diff options
context:
space:
mode:
authorKenny Guy <kennyguy@google.com>2014-04-30 03:02:21 +0100
committerKenny Guy <kennyguy@google.com>2014-04-30 23:43:00 +0100
commited13187a745866483139e2878037e1f8427ce567 (patch)
treea60e4ab78d5365095fe90026df4dfa4e98e80d46 /src/com/android/launcher3/DeleteDropTarget.java
parent70c3d1da65fcdaf32b860a5582b211c1f0ae8718 (diff)
downloadandroid_packages_apps_Trebuchet-ed13187a745866483139e2878037e1f8427ce567.tar.gz
android_packages_apps_Trebuchet-ed13187a745866483139e2878037e1f8427ce567.tar.bz2
android_packages_apps_Trebuchet-ed13187a745866483139e2878037e1f8427ce567.zip
Launcher3 multi-profile support
Use LauncherApps API and badging APIs instead of PackageManager. With compatability layer that uses PackageManager pre L. Adds support to show apps from current user and any managed profiles. Background: Managed profiles are user sandboxes that are visible from the primary user and can be launched as if they are a part of this user. A launcher should now be capable of listing apps from this user as well as related profiles of this user. Launching of activities is now via the LauncherApps interface, to allow for cross-profile app launching. Only activities with category LAUNCHER can be added as a shortcut on the workspace for a managed profile. Widgets and non-application shortcuts are only supported for the current profile. Widgets from the managed profile are not available. Change-Id: I5f396b1bf7f91ad91a5710ea4a0fd14573972eb9
Diffstat (limited to 'src/com/android/launcher3/DeleteDropTarget.java')
-rw-r--r--src/com/android/launcher3/DeleteDropTarget.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java
index 75d906bc2..20546b8d8 100644
--- a/src/com/android/launcher3/DeleteDropTarget.java
+++ b/src/com/android/launcher3/DeleteDropTarget.java
@@ -38,6 +38,9 @@ import android.view.animation.AnimationUtils;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.LinearInterpolator;
+import com.android.launcher3.compat.LauncherAppsCompat;
+import com.android.launcher3.compat.UserHandleCompat;
+
import java.util.List;
import java.util.Set;
@@ -184,6 +187,11 @@ 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);
@@ -279,25 +287,27 @@ public class DeleteDropTarget extends ButtonDropTarget {
if (isAllAppsApplication(d.dragSource, item)) {
// Uninstall the application if it is being dragged from AppsCustomize
AppInfo appInfo = (AppInfo) item;
- mLauncher.startApplicationUninstallActivity(appInfo.componentName, appInfo.flags);
+ // We don't support uninstalling apps from other profiles.
+ if (item.user.equals(UserHandleCompat.myUserHandle())) {
+ mLauncher.startApplicationUninstallActivity(appInfo.componentName, appInfo.flags);
+ }
} else if (isUninstallFromWorkspace(d)) {
ShortcutInfo shortcut = (ShortcutInfo) item;
- if (shortcut.intent != null && shortcut.intent.getComponent() != null) {
+ // We don't support uninstalling apps from other profiles.
+ if (shortcut.intent != null && shortcut.intent.getComponent() != null &&
+ shortcut.user.equals(UserHandleCompat.myUserHandle())) {
final ComponentName componentName = shortcut.intent.getComponent();
final DragSource dragSource = d.dragSource;
- int flags = AppInfo.initFlags(
- ShortcutInfo.getPackageInfo(getContext(), componentName.getPackageName()));
mWaitingForUninstall =
- mLauncher.startApplicationUninstallActivity(componentName, flags);
+ mLauncher.startApplicationUninstallActivity(componentName, shortcut.flags);
if (mWaitingForUninstall) {
final Runnable checkIfUninstallWasSuccess = new Runnable() {
@Override
public void run() {
mWaitingForUninstall = false;
String packageName = componentName.getPackageName();
- List<ResolveInfo> activities =
- AllAppsList.findActivitiesForPackage(getContext(), packageName);
- boolean uninstallSuccessful = activities.size() == 0;
+ boolean uninstallSuccessful = !AllAppsList.packageHasActivities(
+ getContext(), packageName, UserHandleCompat.myUserHandle());
if (dragSource instanceof Folder) {
((Folder) dragSource).
onUninstallActivityReturned(uninstallSuccessful);