Merge "Fix predictiveApps Bug: 67010327" into ub-launcher3-dorval-polish2
diff --git a/res/layout/search_container_all_apps.xml b/res/layout/search_container_all_apps.xml
index c430521..fc07002 100644
--- a/res/layout/search_container_all_apps.xml
+++ b/res/layout/search_container_all_apps.xml
@@ -19,11 +19,11 @@
android:layout_width="match_parent"
android:layout_height="@dimen/all_apps_search_bar_height"
android:layout_gravity="center|top"
+ android:layout_marginBottom="-8dp"
android:gravity="center|bottom"
- android:saveEnabled="false"
android:paddingLeft="@dimen/dynamic_grid_edge_margin"
android:paddingRight="@dimen/dynamic_grid_edge_margin"
- android:layout_marginBottom="-8dp" >
+ android:saveEnabled="false" >
<!--
Note: The following relation should always be true so that the shadows are aligned properly
@@ -45,6 +45,7 @@
android:imeOptions="actionSearch|flagNoExtractUi"
android:inputType="text|textNoSuggestions|textCapWords"
android:maxLines="1"
+ android:saveEnabled="false"
android:scrollHorizontally="true"
android:singleLine="true"
android:textColor="?android:attr/textColorSecondary"
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 68b628f..5aee715 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -123,6 +123,7 @@
<attr name="iconTextSize" format="float" />
<attr name="defaultLayoutId" format="reference" />
+ <attr name="demoModeLayoutId" format="reference" />
</declare-styleable>
<declare-styleable name="CellLayout">
diff --git a/src/com/android/launcher3/AppInfo.java b/src/com/android/launcher3/AppInfo.java
index 3da1996..7d2f753 100644
--- a/src/com/android/launcher3/AppInfo.java
+++ b/src/com/android/launcher3/AppInfo.java
@@ -19,6 +19,7 @@
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo;
import android.os.UserHandle;
@@ -31,6 +32,10 @@
*/
public class AppInfo extends ItemInfoWithIcon {
+ public static final int FLAG_SYSTEM_UNKNOWN = 0;
+ public static final int FLAG_SYSTEM_YES = 1 << 0;
+ public static final int FLAG_SYSTEM_NO = 1 << 1;
+
/**
* The intent used to start the application.
*/
@@ -43,6 +48,11 @@
*/
public int isDisabled = ShortcutInfo.DEFAULT;
+ /**
+ * Stores if the app is a system app or not.
+ */
+ public int isSystemApp;
+
public AppInfo() {
itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
}
@@ -71,6 +81,10 @@
}
intent = makeLaunchIntent(info);
+
+ isSystemApp = (info.getApplicationInfo().flags & ApplicationInfo.FLAG_SYSTEM) == 0
+ ? FLAG_SYSTEM_NO : FLAG_SYSTEM_YES;
+
}
public AppInfo(AppInfo info) {
@@ -79,6 +93,7 @@
title = Utilities.trim(info.title);
intent = new Intent(info.intent);
isDisabled = info.isDisabled;
+ isSystemApp = info.isSystemApp;
}
@Override
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index d7bebd1..7a43198 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -85,7 +85,9 @@
* Number of icons inside the hotseat area.
*/
public int numHotseatIcons;
+
int defaultLayoutId;
+ int demoModeLayoutId;
public DeviceProfile landscapeProfile;
public DeviceProfile portraitProfile;
@@ -99,11 +101,11 @@
this(p.name, p.minWidthDps, p.minHeightDps, p.numRows, p.numColumns,
p.numFolderRows, p.numFolderColumns, p.minAllAppsPredictionColumns,
p.iconSize, p.landscapeIconSize, p.iconTextSize, p.numHotseatIcons,
- p.defaultLayoutId);
+ p.defaultLayoutId, p.demoModeLayoutId);
}
InvariantDeviceProfile(String n, float w, float h, int r, int c, int fr, int fc, int maapc,
- float is, float lis, float its, int hs, int dlId) {
+ float is, float lis, float its, int hs, int dlId, int dmlId) {
name = n;
minWidthDps = w;
minHeightDps = h;
@@ -117,6 +119,7 @@
iconTextSize = its;
numHotseatIcons = hs;
defaultLayoutId = dlId;
+ demoModeLayoutId = dmlId;
}
@TargetApi(23)
@@ -144,6 +147,7 @@
numColumns = closestProfile.numColumns;
numHotseatIcons = closestProfile.numHotseatIcons;
defaultLayoutId = closestProfile.defaultLayoutId;
+ demoModeLayoutId = closestProfile.demoModeLayoutId;
numFolderRows = closestProfile.numFolderRows;
numFolderColumns = closestProfile.numFolderColumns;
minAllAppsPredictionColumns = closestProfile.minAllAppsPredictionColumns;
@@ -208,7 +212,8 @@
a.getFloat(R.styleable.InvariantDeviceProfile_landscapeIconSize, iconSize),
a.getFloat(R.styleable.InvariantDeviceProfile_iconTextSize, 0),
a.getInt(R.styleable.InvariantDeviceProfile_numHotseatIcons, numColumns),
- a.getResourceId(R.styleable.InvariantDeviceProfile_defaultLayoutId, 0)));
+ a.getResourceId(R.styleable.InvariantDeviceProfile_defaultLayoutId, 0),
+ a.getResourceId(R.styleable.InvariantDeviceProfile_demoModeLayoutId, 0)));
a.recycle();
}
}
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index dc83f36..b31df98 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -552,7 +552,14 @@
}
private DefaultLayoutParser getDefaultLayoutParser(AppWidgetHost widgetHost) {
- int defaultLayout = LauncherAppState.getIDP(getContext()).defaultLayoutId;
+ InvariantDeviceProfile idp = LauncherAppState.getIDP(getContext());
+ int defaultLayout = idp.defaultLayoutId;
+
+ UserManagerCompat um = UserManagerCompat.getInstance(getContext());
+ if (um.isDemoUser() && idp.demoModeLayoutId != 0) {
+ defaultLayout = idp.demoModeLayoutId;
+ }
+
return new DefaultLayoutParser(getContext(), widgetHost,
mOpenHelper, getContext().getResources(), defaultLayout);
}
diff --git a/src/com/android/launcher3/UninstallDropTarget.java b/src/com/android/launcher3/UninstallDropTarget.java
index 84d6a9b..902fd34 100644
--- a/src/com/android/launcher3/UninstallDropTarget.java
+++ b/src/com/android/launcher3/UninstallDropTarget.java
@@ -21,6 +21,7 @@
public class UninstallDropTarget extends ButtonDropTarget {
private static final String TAG = "UninstallDropTarget";
+ private static Boolean sUninstallDisabled;
public UninstallDropTarget(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@@ -48,13 +49,22 @@
}
public static boolean supportsDrop(Context context, ItemInfo info) {
- UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
- Bundle restrictions = userManager.getUserRestrictions();
- if (restrictions.getBoolean(UserManager.DISALLOW_APPS_CONTROL, false)
- || restrictions.getBoolean(UserManager.DISALLOW_UNINSTALL_APPS, false)) {
+ if (sUninstallDisabled == null) {
+ UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
+ Bundle restrictions = userManager.getUserRestrictions();
+ sUninstallDisabled = restrictions.getBoolean(UserManager.DISALLOW_APPS_CONTROL, false)
+ || restrictions.getBoolean(UserManager.DISALLOW_UNINSTALL_APPS, false);
+ }
+ if (sUninstallDisabled) {
return false;
}
+ if (info instanceof AppInfo) {
+ AppInfo appInfo = (AppInfo) info;
+ if (appInfo.isSystemApp != AppInfo.FLAG_SYSTEM_UNKNOWN) {
+ return (appInfo.isSystemApp & AppInfo.FLAG_SYSTEM_NO) != 0;
+ }
+ }
return getUninstallTarget(context, info) != null;
}