summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2016-04-21 14:30:18 -0700
committerSunny Goyal <sunnygoyal@google.com>2016-05-11 15:21:42 -0700
commiteb4b79935e9f75dda72e4953f45e616e252d7b03 (patch)
tree5d99db4651efdbf698cda8a59016b8db5335ac9e /src/com/android/launcher3
parent4dcd8ffecc5bbdc5c7496cea4eb6808f4026bf9e (diff)
downloadandroid_packages_apps_Trebuchet-eb4b79935e9f75dda72e4953f45e616e252d7b03.tar.gz
android_packages_apps_Trebuchet-eb4b79935e9f75dda72e4953f45e616e252d7b03.tar.bz2
android_packages_apps_Trebuchet-eb4b79935e9f75dda72e4953f45e616e252d7b03.zip
Removing icon_type column
Icon type is not used consistently. It is used initially during the loader. Afterwards, we save both the icon and resource to the db. Instead of changing the logic to always read the shortcut-resource first, and fallback to the bitmap if the resource is not available, always write the bitmap to DB whenever the shortcut is edited. Change-Id: I0ea5e88f8904bd3250ca669220b3e5d6aeef1bfd
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r--src/com/android/launcher3/AutoInstallsLayout.java1
-rw-r--r--src/com/android/launcher3/CommonAppTypeParser.java1
-rw-r--r--src/com/android/launcher3/LauncherBackupHelper.java50
-rw-r--r--src/com/android/launcher3/LauncherModel.java1
-rw-r--r--src/com/android/launcher3/LauncherProvider.java4
-rw-r--r--src/com/android/launcher3/LauncherSettings.java23
-rw-r--r--src/com/android/launcher3/ShortcutInfo.java32
-rw-r--r--src/com/android/launcher3/util/CursorIconInfo.java31
8 files changed, 40 insertions, 103 deletions
diff --git a/src/com/android/launcher3/AutoInstallsLayout.java b/src/com/android/launcher3/AutoInstallsLayout.java
index a04c5570a..f3a2bdc98 100644
--- a/src/com/android/launcher3/AutoInstallsLayout.java
+++ b/src/com/android/launcher3/AutoInstallsLayout.java
@@ -436,7 +436,6 @@ public class AutoInstallsLayout {
}
ItemInfo.writeBitmap(mValues, Utilities.createIconBitmap(icon, mContext));
- mValues.put(Favorites.ICON_TYPE, Favorites.ICON_TYPE_RESOURCE);
mValues.put(Favorites.ICON_PACKAGE, mIconRes.getResourcePackageName(iconId));
mValues.put(Favorites.ICON_RESOURCE, mIconRes.getResourceName(iconId));
diff --git a/src/com/android/launcher3/CommonAppTypeParser.java b/src/com/android/launcher3/CommonAppTypeParser.java
index 001e044f9..a4a92b6bf 100644
--- a/src/com/android/launcher3/CommonAppTypeParser.java
+++ b/src/com/android/launcher3/CommonAppTypeParser.java
@@ -68,7 +68,6 @@ public class CommonAppTypeParser implements LayoutParserCallback {
parsedValues = values;
// Remove unwanted values
- values.put(Favorites.ICON_TYPE, (Integer) null);
values.put(Favorites.ICON_PACKAGE, (String) null);
values.put(Favorites.ICON_RESOURCE, (String) null);
values.put(Favorites.ICON, (byte[]) null);
diff --git a/src/com/android/launcher3/LauncherBackupHelper.java b/src/com/android/launcher3/LauncherBackupHelper.java
index cad0f2c25..7238f7098 100644
--- a/src/com/android/launcher3/LauncherBackupHelper.java
+++ b/src/com/android/launcher3/LauncherBackupHelper.java
@@ -103,14 +103,13 @@ public class LauncherBackupHelper implements BackupHelper {
Favorites.ICON, // 8
Favorites.ICON_PACKAGE, // 9
Favorites.ICON_RESOURCE, // 10
- Favorites.ICON_TYPE, // 11
- Favorites.ITEM_TYPE, // 12
- Favorites.SCREEN, // 13
- Favorites.SPANX, // 14
- Favorites.SPANY, // 15
- Favorites.TITLE, // 16
- Favorites.PROFILE_ID, // 17
- Favorites.RANK, // 18
+ Favorites.ITEM_TYPE, // 11
+ Favorites.SCREEN, // 12
+ Favorites.SPANX, // 13
+ Favorites.SPANY, // 14
+ Favorites.TITLE, // 15
+ Favorites.PROFILE_ID, // 16
+ Favorites.RANK, // 17
};
private static final int ID_INDEX = 0;
@@ -124,13 +123,12 @@ public class LauncherBackupHelper implements BackupHelper {
private static final int ICON_INDEX = 8;
private static final int ICON_PACKAGE_INDEX = 9;
private static final int ICON_RESOURCE_INDEX = 10;
- private static final int ICON_TYPE_INDEX = 11;
- private static final int ITEM_TYPE_INDEX = 12;
- private static final int SCREEN_INDEX = 13;
- private static final int SPANX_INDEX = 14;
- private static final int SPANY_INDEX = 15;
- private static final int TITLE_INDEX = 16;
- private static final int RANK_INDEX = 18;
+ private static final int ITEM_TYPE_INDEX = 11;
+ private static final int SCREEN_INDEX = 12;
+ private static final int SPANX_INDEX = 13;
+ private static final int SPANY_INDEX = 14;
+ private static final int TITLE_INDEX = 15;
+ private static final int RANK_INDEX = 17;
private static final String[] SCREEN_PROJECTION = {
WorkspaceScreens._ID, // 0
@@ -814,7 +812,6 @@ public class LauncherBackupHelper implements BackupHelper {
favorite.cellY = c.getInt(CELLY_INDEX);
favorite.spanX = c.getInt(SPANX_INDEX);
favorite.spanY = c.getInt(SPANY_INDEX);
- favorite.iconType = c.getInt(ICON_TYPE_INDEX);
favorite.rank = c.getInt(RANK_INDEX);
String title = c.getString(TITLE_INDEX);
@@ -840,15 +837,11 @@ public class LauncherBackupHelper implements BackupHelper {
favorite.appWidgetProvider = appWidgetProvider;
}
} else if (favorite.itemType == Favorites.ITEM_TYPE_SHORTCUT) {
- if (favorite.iconType == Favorites.ICON_TYPE_RESOURCE) {
- String iconPackage = c.getString(ICON_PACKAGE_INDEX);
- if (!TextUtils.isEmpty(iconPackage)) {
- favorite.iconPackage = iconPackage;
- }
- String iconResource = c.getString(ICON_RESOURCE_INDEX);
- if (!TextUtils.isEmpty(iconResource)) {
- favorite.iconResource = iconResource;
- }
+ String iconPackage = c.getString(ICON_PACKAGE_INDEX);
+ String iconResource = c.getString(ICON_RESOURCE_INDEX);
+ if (!TextUtils.isEmpty(iconPackage) && !TextUtils.isEmpty(iconResource)) {
+ favorite.iconResource = iconResource;
+ favorite.iconPackage = iconPackage;
}
byte[] blob = c.getBlob(ICON_INDEX);
@@ -906,11 +899,8 @@ public class LauncherBackupHelper implements BackupHelper {
values.put(Favorites.RANK, favorite.rank);
if (favorite.itemType == Favorites.ITEM_TYPE_SHORTCUT) {
- values.put(Favorites.ICON_TYPE, favorite.iconType);
- if (favorite.iconType == Favorites.ICON_TYPE_RESOURCE) {
- values.put(Favorites.ICON_PACKAGE, favorite.iconPackage);
- values.put(Favorites.ICON_RESOURCE, favorite.iconResource);
- }
+ values.put(Favorites.ICON_PACKAGE, favorite.iconPackage);
+ values.put(Favorites.ICON_RESOURCE, favorite.iconResource);
values.put(Favorites.ICON, favorite.icon);
}
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 2fd12fd57..eaeb1acae 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -3473,7 +3473,6 @@ public class LauncherModel extends BroadcastReceiver
info.title = Utilities.trim(name);
info.contentDescription = mUserManager.getBadgedLabelForUser(info.title, info.user);
info.intent = intent;
- info.customIcon = customIcon;
info.iconResource = iconResource;
return info;
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index f10099e0c..5cc5aa6ec 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -1077,8 +1077,6 @@ public class LauncherProvider extends ContentProvider {
= c.getColumnIndexOrThrow(LauncherSettings.Favorites.INTENT);
final int titleIndex
= c.getColumnIndexOrThrow(LauncherSettings.Favorites.TITLE);
- final int iconTypeIndex
- = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ICON_TYPE);
final int iconIndex
= c.getColumnIndexOrThrow(LauncherSettings.Favorites.ICON);
final int iconPackageIndex
@@ -1195,8 +1193,6 @@ public class LauncherProvider extends ContentProvider {
values.put(LauncherSettings.Favorites._ID, c.getInt(idIndex));
values.put(LauncherSettings.Favorites.INTENT, intentStr);
values.put(LauncherSettings.Favorites.TITLE, c.getString(titleIndex));
- values.put(LauncherSettings.Favorites.ICON_TYPE,
- c.getInt(iconTypeIndex));
values.put(LauncherSettings.Favorites.ICON, c.getBlob(iconIndex));
values.put(LauncherSettings.Favorites.ICON_PACKAGE,
c.getString(iconPackageIndex));
diff --git a/src/com/android/launcher3/LauncherSettings.java b/src/com/android/launcher3/LauncherSettings.java
index 13e45476a..095670dc9 100644
--- a/src/com/android/launcher3/LauncherSettings.java
+++ b/src/com/android/launcher3/LauncherSettings.java
@@ -70,35 +70,19 @@ public class LauncherSettings {
public static final int ITEM_TYPE_SHORTCUT = 1;
/**
- * The icon type.
- * <P>Type: INTEGER</P>
- */
- public static final String ICON_TYPE = "iconType";
-
- /**
- * The icon is a resource identified by a package name and an integer id.
- */
- public static final int ICON_TYPE_RESOURCE = 0;
-
- /**
- * The icon is a bitmap.
- */
- public static final int ICON_TYPE_BITMAP = 1;
-
- /**
- * The icon package name, if icon type is ICON_TYPE_RESOURCE.
+ * The icon package name in Intent.ShortcutIconResource
* <P>Type: TEXT</P>
*/
public static final String ICON_PACKAGE = "iconPackage";
/**
- * The icon resource id, if icon type is ICON_TYPE_RESOURCE.
+ * The icon resource name in Intent.ShortcutIconResource
* <P>Type: TEXT</P>
*/
public static final String ICON_RESOURCE = "iconResource";
/**
- * The custom icon bitmap, if icon type is ICON_TYPE_BITMAP.
+ * The custom icon bitmap.
* <P>Type: BLOB</P>
*/
public static final String ICON = "icon";
@@ -272,7 +256,6 @@ public class LauncherSettings {
"spanY INTEGER," +
"itemType INTEGER," +
"appWidgetId INTEGER NOT NULL DEFAULT -1," +
- "iconType INTEGER," +
"iconPackage TEXT," +
"iconResource TEXT," +
"icon BLOB," +
diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java
index 128d695eb..2cc9bb0ab 100644
--- a/src/com/android/launcher3/ShortcutInfo.java
+++ b/src/com/android/launcher3/ShortcutInfo.java
@@ -74,13 +74,6 @@ public class ShortcutInfo extends ItemInfo {
public Intent intent;
/**
- * Indicates whether the icon comes from an application's resource (if false)
- * or from a custom Bitmap (if true.)
- * TODO: remove this flag
- */
- public boolean customIcon;
-
- /**
* Indicates whether we're using the default fallback icon instead of something from the
* app.
*/
@@ -175,7 +168,6 @@ public class ShortcutInfo extends ItemInfo {
iconResource.resourceName = info.iconResource.resourceName;
}
mIcon = info.mIcon; // TODO: should make a copy here. maybe we don't need this ctor at all
- customIcon = info.customIcon;
flags = info.flags;
user = info.user;
status = info.status;
@@ -186,7 +178,6 @@ public class ShortcutInfo extends ItemInfo {
super(info);
title = Utilities.trim(info.title);
intent = new Intent(info.intent);
- customIcon = false;
flags = info.flags;
isDisabled = info.isDisabled;
}
@@ -225,22 +216,14 @@ public class ShortcutInfo extends ItemInfo {
values.put(LauncherSettings.BaseLauncherColumns.INTENT, uri);
values.put(LauncherSettings.Favorites.RESTORED, status);
- if (customIcon) {
- values.put(LauncherSettings.BaseLauncherColumns.ICON_TYPE,
- LauncherSettings.BaseLauncherColumns.ICON_TYPE_BITMAP);
+ if (!usingFallbackIcon && !usingLowResIcon) {
writeBitmap(values, mIcon);
- } else {
- if (!usingFallbackIcon) {
- writeBitmap(values, mIcon);
- }
- if (iconResource != null) {
- values.put(LauncherSettings.BaseLauncherColumns.ICON_TYPE,
- LauncherSettings.BaseLauncherColumns.ICON_TYPE_RESOURCE);
- values.put(LauncherSettings.BaseLauncherColumns.ICON_PACKAGE,
- iconResource.packageName);
- values.put(LauncherSettings.BaseLauncherColumns.ICON_RESOURCE,
- iconResource.resourceName);
- }
+ }
+ if (iconResource != null) {
+ values.put(LauncherSettings.BaseLauncherColumns.ICON_PACKAGE,
+ iconResource.packageName);
+ values.put(LauncherSettings.BaseLauncherColumns.ICON_RESOURCE,
+ iconResource.resourceName);
}
}
@@ -284,7 +267,6 @@ public class ShortcutInfo extends ItemInfo {
shortcut.title = Utilities.trim(info.getLabel());
shortcut.contentDescription = UserManagerCompat.getInstance(context)
.getBadgedLabelForUser(info.getLabel(), info.getUser());
- shortcut.customIcon = false;
shortcut.intent = AppInfo.makeLaunchIntent(context, info, info.getUser());
shortcut.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
shortcut.flags = AppInfo.initFlags(info);
diff --git a/src/com/android/launcher3/util/CursorIconInfo.java b/src/com/android/launcher3/util/CursorIconInfo.java
index cdf9e3c60..120eacd0a 100644
--- a/src/com/android/launcher3/util/CursorIconInfo.java
+++ b/src/com/android/launcher3/util/CursorIconInfo.java
@@ -30,13 +30,11 @@ import com.android.launcher3.Utilities;
* Utility class to load icon from a cursor.
*/
public class CursorIconInfo {
- public final int iconTypeIndex;
public final int iconPackageIndex;
public final int iconResourceIndex;
public final int iconIndex;
public CursorIconInfo(Cursor c) {
- iconTypeIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ICON_TYPE);
iconIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ICON);
iconPackageIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ICON_PACKAGE);
iconResourceIndex = c.getColumnIndexOrThrow(LauncherSettings.Favorites.ICON_RESOURCE);
@@ -44,26 +42,17 @@ public class CursorIconInfo {
public Bitmap loadIcon(Cursor c, ShortcutInfo info, Context context) {
Bitmap icon = null;
- int iconType = c.getInt(iconTypeIndex);
- switch (iconType) {
- case LauncherSettings.Favorites.ICON_TYPE_RESOURCE:
- String packageName = c.getString(iconPackageIndex);
- String resourceName = c.getString(iconResourceIndex);
- if (!TextUtils.isEmpty(packageName) || !TextUtils.isEmpty(resourceName)) {
- info.iconResource = new ShortcutIconResource();
- info.iconResource.packageName = packageName;
- info.iconResource.resourceName = resourceName;
- icon = Utilities.createIconBitmap(packageName, resourceName, context);
- }
- if (icon == null) {
- // Failed to load from resource, try loading from DB.
- icon = Utilities.createIconBitmap(c, iconIndex, context);
- }
- break;
- case LauncherSettings.Favorites.ICON_TYPE_BITMAP:
+ String packageName = c.getString(iconPackageIndex);
+ String resourceName = c.getString(iconResourceIndex);
+ if (!TextUtils.isEmpty(packageName) || !TextUtils.isEmpty(resourceName)) {
+ info.iconResource = new ShortcutIconResource();
+ info.iconResource.packageName = packageName;
+ info.iconResource.resourceName = resourceName;
+ icon = Utilities.createIconBitmap(packageName, resourceName, context);
+ }
+ if (icon == null) {
+ // Failed to load from resource, try loading from DB.
icon = Utilities.createIconBitmap(c, iconIndex, context);
- info.customIcon = icon != null;
- break;
}
return icon;
}