Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eb4b7993 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

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
parent 4dcd8ffe
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ message Favorite {
  optional string appWidgetProvider = 12;
  optional string intent = 13;
  optional string uri = 14;
  optional int32 iconType = 15;
  optional int32 iconType = 15 [deprecated = true];
  optional string iconPackage = 16;
  optional string iconResource = 17;
  optional bytes icon = 18;
+0 −1
Original line number Diff line number Diff line
@@ -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));

+0 −1
Original line number Diff line number Diff line
@@ -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);
+20 −30
Original line number Diff line number Diff line
@@ -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)) {
            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, favorite.icon);
        }

+0 −1
Original line number Diff line number Diff line
@@ -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;
Loading