Don't show uninstall icon when user restricted
When the user can't uninstall apps from settings, also don't show
the icon to let them do it from here.
Change-Id: I3b203711630a4ff0ba4a5928667c9f09f9479aeb
diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java
index 4c3388e..22c1093 100644
--- a/src/com/android/launcher3/DeleteDropTarget.java
+++ b/src/com/android/launcher3/DeleteDropTarget.java
@@ -30,6 +30,7 @@
import android.graphics.Rect;
import android.graphics.drawable.TransitionDrawable;
import android.os.AsyncTask;
+import android.os.UserManager;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewConfiguration;
@@ -187,6 +188,14 @@
if (!willAcceptDrop(info) || isAllAppsWidget(source, info)) {
isVisible = false;
}
+ if (useUninstallLabel) {
+ UserManager userManager = (UserManager)
+ getContext().getSystemService(Context.USER_SERVICE);
+ if (userManager.hasUserRestriction(UserManager.DISALLOW_APPS_CONTROL)
+ || userManager.hasUserRestriction(UserManager.DISALLOW_UNINSTALL_APPS)) {
+ isVisible = false;
+ }
+ }
if (useUninstallLabel) {
setCompoundDrawablesRelativeWithIntrinsicBounds(mUninstallDrawable, null, null, null);