Loading protos/backup.proto +8 −4 Original line number Diff line number Diff line Loading @@ -120,4 +120,8 @@ message Widget { optional bool configure = 3; optional Resource icon = 4; optional Resource preview = 5; // Assume that a widget is resizable upto 2x2 if no data is available optional int32 minSpanX = 6 [default = 2]; optional int32 minSpanY = 7 [default = 2]; } src/com/android/launcher3/CellLayout.java +6 −2 Original line number Diff line number Diff line Loading @@ -2690,8 +2690,12 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler { * @param result An array of length 2 in which to store the result (may be null). */ public static int[] rectToCell(Launcher launcher, int width, int height, int[] result) { DeviceProfile grid = launcher.getDeviceProfile(); Rect padding = grid.getWorkspacePadding(Utilities.isRtl(launcher.getResources())); return rectToCell(launcher.getDeviceProfile(), launcher, width, height, result); } public static int[] rectToCell(DeviceProfile grid, Context context, int width, int height, int[] result) { Rect padding = grid.getWorkspacePadding(Utilities.isRtl(context.getResources())); // Always assume we're working with the smallest span to make sure we // reserve enough space in both orientations. Loading src/com/android/launcher3/LauncherBackupAgentHelper.java +1 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ public class LauncherBackupAgentHelper extends BackupAgentHelper { LauncherClings.synchonouslyMarkFirstRunClingDismissed(this); // TODO: Update the backup set to include rank. if (mHelper.restoredBackupVersion <= 2) { if (mHelper.restoredBackupVersion <= 3) { LauncherAppState.getLauncherProvider().updateFolderItemsRank(); LauncherAppState.getLauncherProvider().convertShortcutsToLauncherActivities(); } Loading src/com/android/launcher3/LauncherBackupHelper.java +19 −7 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ public class LauncherBackupHelper implements BackupHelper { private static final boolean VERBOSE = LauncherBackupAgentHelper.VERBOSE; private static final boolean DEBUG = LauncherBackupAgentHelper.DEBUG; private static final int BACKUP_VERSION = 2; private static final int BACKUP_VERSION = 3; private static final int MAX_JOURNAL_SIZE = 1000000; // Journal key is such that it is always smaller than any dynamically generated Loading Loading @@ -148,6 +148,7 @@ public class LauncherBackupHelper implements BackupHelper { private IconCache mIconCache; private DeviceProfieData mDeviceProfileData; private InvariantDeviceProfile mIdp; boolean restoreSuccessful; int restoredBackupVersion = 1; Loading Loading @@ -178,6 +179,7 @@ public class LauncherBackupHelper implements BackupHelper { mExistingKeys.add(keyToBackupKey(key)); } } restoredBackupVersion = journal.backupVersion; } /** Loading Loading @@ -206,7 +208,8 @@ public class LauncherBackupHelper implements BackupHelper { if (mDeviceProfileData == null) { LauncherAppState app = LauncherAppState.getInstance(); mDeviceProfileData = initDeviceProfileData(app.getInvariantDeviceProfile()); mIdp = app.getInvariantDeviceProfile(); mDeviceProfileData = initDeviceProfileData(mIdp); mIconCache = app.getIconCache(); } Loading Loading @@ -308,9 +311,9 @@ public class LauncherBackupHelper implements BackupHelper { if (mDeviceProfileData == null) { // This call does not happen on a looper thread. So LauncherAppState // can't be created . Instead initialize required dependencies directly. InvariantDeviceProfile profile = new InvariantDeviceProfile(mContext); mDeviceProfileData = initDeviceProfileData(profile); mIconCache = new IconCache(mContext, profile); mIdp = new InvariantDeviceProfile(mContext); mDeviceProfileData = initDeviceProfileData(mIdp); mIconCache = new IconCache(mContext, mIdp); } int dataSize = data.size(); Loading @@ -335,7 +338,6 @@ public class LauncherBackupHelper implements BackupHelper { MessageNano.mergeFrom(journal, readCheckedBytes(mBuffer, dataSize)); applyJournal(journal); restoreSuccessful = isBackupCompatible(journal); restoredBackupVersion = journal.backupVersion; return; } Loading Loading @@ -636,7 +638,7 @@ public class LauncherBackupHelper implements BackupHelper { } else { Log.w(TAG, "empty intent on appwidget: " + id); } if (mExistingKeys.contains(backupKey)) { if (mExistingKeys.contains(backupKey) && restoredBackupVersion >= BACKUP_VERSION) { if (DEBUG) Log.d(TAG, "already saved widget " + backupKey); // remember that we already backed this up previously Loading Loading @@ -969,6 +971,16 @@ public class LauncherBackupHelper implements BackupHelper { widget.icon.data = Utilities.flattenBitmap(icon); widget.icon.dpi = dpi; } // Calculate the spans corresponding to any one of the orientations as it should not change // based on orientation. int[] minSpans = CellLayout.rectToCell( mIdp.portraitProfile, mContext, info.minResizeWidth, info.minResizeHeight, null); widget.minSpanX = (info.resizeMode & LauncherAppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0 ? minSpans[0] : -1; widget.minSpanY = (info.resizeMode & LauncherAppWidgetProviderInfo.RESIZE_VERTICAL) != 0 ? minSpans[1] : -1; return widget; } Loading Loading
protos/backup.proto +8 −4 Original line number Diff line number Diff line Loading @@ -120,4 +120,8 @@ message Widget { optional bool configure = 3; optional Resource icon = 4; optional Resource preview = 5; // Assume that a widget is resizable upto 2x2 if no data is available optional int32 minSpanX = 6 [default = 2]; optional int32 minSpanY = 7 [default = 2]; }
src/com/android/launcher3/CellLayout.java +6 −2 Original line number Diff line number Diff line Loading @@ -2690,8 +2690,12 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler { * @param result An array of length 2 in which to store the result (may be null). */ public static int[] rectToCell(Launcher launcher, int width, int height, int[] result) { DeviceProfile grid = launcher.getDeviceProfile(); Rect padding = grid.getWorkspacePadding(Utilities.isRtl(launcher.getResources())); return rectToCell(launcher.getDeviceProfile(), launcher, width, height, result); } public static int[] rectToCell(DeviceProfile grid, Context context, int width, int height, int[] result) { Rect padding = grid.getWorkspacePadding(Utilities.isRtl(context.getResources())); // Always assume we're working with the smallest span to make sure we // reserve enough space in both orientations. Loading
src/com/android/launcher3/LauncherBackupAgentHelper.java +1 −1 Original line number Diff line number Diff line Loading @@ -92,7 +92,7 @@ public class LauncherBackupAgentHelper extends BackupAgentHelper { LauncherClings.synchonouslyMarkFirstRunClingDismissed(this); // TODO: Update the backup set to include rank. if (mHelper.restoredBackupVersion <= 2) { if (mHelper.restoredBackupVersion <= 3) { LauncherAppState.getLauncherProvider().updateFolderItemsRank(); LauncherAppState.getLauncherProvider().convertShortcutsToLauncherActivities(); } Loading
src/com/android/launcher3/LauncherBackupHelper.java +19 −7 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ public class LauncherBackupHelper implements BackupHelper { private static final boolean VERBOSE = LauncherBackupAgentHelper.VERBOSE; private static final boolean DEBUG = LauncherBackupAgentHelper.DEBUG; private static final int BACKUP_VERSION = 2; private static final int BACKUP_VERSION = 3; private static final int MAX_JOURNAL_SIZE = 1000000; // Journal key is such that it is always smaller than any dynamically generated Loading Loading @@ -148,6 +148,7 @@ public class LauncherBackupHelper implements BackupHelper { private IconCache mIconCache; private DeviceProfieData mDeviceProfileData; private InvariantDeviceProfile mIdp; boolean restoreSuccessful; int restoredBackupVersion = 1; Loading Loading @@ -178,6 +179,7 @@ public class LauncherBackupHelper implements BackupHelper { mExistingKeys.add(keyToBackupKey(key)); } } restoredBackupVersion = journal.backupVersion; } /** Loading Loading @@ -206,7 +208,8 @@ public class LauncherBackupHelper implements BackupHelper { if (mDeviceProfileData == null) { LauncherAppState app = LauncherAppState.getInstance(); mDeviceProfileData = initDeviceProfileData(app.getInvariantDeviceProfile()); mIdp = app.getInvariantDeviceProfile(); mDeviceProfileData = initDeviceProfileData(mIdp); mIconCache = app.getIconCache(); } Loading Loading @@ -308,9 +311,9 @@ public class LauncherBackupHelper implements BackupHelper { if (mDeviceProfileData == null) { // This call does not happen on a looper thread. So LauncherAppState // can't be created . Instead initialize required dependencies directly. InvariantDeviceProfile profile = new InvariantDeviceProfile(mContext); mDeviceProfileData = initDeviceProfileData(profile); mIconCache = new IconCache(mContext, profile); mIdp = new InvariantDeviceProfile(mContext); mDeviceProfileData = initDeviceProfileData(mIdp); mIconCache = new IconCache(mContext, mIdp); } int dataSize = data.size(); Loading @@ -335,7 +338,6 @@ public class LauncherBackupHelper implements BackupHelper { MessageNano.mergeFrom(journal, readCheckedBytes(mBuffer, dataSize)); applyJournal(journal); restoreSuccessful = isBackupCompatible(journal); restoredBackupVersion = journal.backupVersion; return; } Loading Loading @@ -636,7 +638,7 @@ public class LauncherBackupHelper implements BackupHelper { } else { Log.w(TAG, "empty intent on appwidget: " + id); } if (mExistingKeys.contains(backupKey)) { if (mExistingKeys.contains(backupKey) && restoredBackupVersion >= BACKUP_VERSION) { if (DEBUG) Log.d(TAG, "already saved widget " + backupKey); // remember that we already backed this up previously Loading Loading @@ -969,6 +971,16 @@ public class LauncherBackupHelper implements BackupHelper { widget.icon.data = Utilities.flattenBitmap(icon); widget.icon.dpi = dpi; } // Calculate the spans corresponding to any one of the orientations as it should not change // based on orientation. int[] minSpans = CellLayout.rectToCell( mIdp.portraitProfile, mContext, info.minResizeWidth, info.minResizeHeight, null); widget.minSpanX = (info.resizeMode & LauncherAppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0 ? minSpans[0] : -1; widget.minSpanY = (info.resizeMode & LauncherAppWidgetProviderInfo.RESIZE_VERTICAL) != 0 ? minSpans[1] : -1; return widget; } Loading