diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2015-07-21 01:50:37 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-07-21 01:50:38 +0000 |
commit | 7e0a403759c401d3b94f4576bca3aa8fb94fe542 (patch) | |
tree | c0c5e8f0b8884498fc5618f248fce229d5f11819 | |
parent | 3ba922aa62b70bc0a3307e43980c4ff189486694 (diff) | |
parent | c115e647ad79face0b57240fe3a7e7be2ce85145 (diff) | |
download | android_packages_apps_Trebuchet-7e0a403759c401d3b94f4576bca3aa8fb94fe542.tar.gz android_packages_apps_Trebuchet-7e0a403759c401d3b94f4576bca3aa8fb94fe542.tar.bz2 android_packages_apps_Trebuchet-7e0a403759c401d3b94f4576bca3aa8fb94fe542.zip |
Merge "Shifting hotseat icons to aling with all-apps icon, if the hotseat size is different from the source device" into ub-launcher3-burnaby
-rw-r--r-- | src/com/android/launcher3/LauncherBackupHelper.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/com/android/launcher3/LauncherBackupHelper.java b/src/com/android/launcher3/LauncherBackupHelper.java index 744f73bda..38a4bdeb4 100644 --- a/src/com/android/launcher3/LauncherBackupHelper.java +++ b/src/com/android/launcher3/LauncherBackupHelper.java @@ -153,6 +153,10 @@ public class LauncherBackupHelper implements BackupHelper { boolean restoreSuccessful; int restoredBackupVersion = 1; + // When migrating from a device which different hotseat configuration, the icons are shifted + // to center along the new all-apps icon. + private int mHotseatShift = 0; + public LauncherBackupHelper(Context context) { mContext = context; mExistingKeys = new HashSet<String>(); @@ -285,10 +289,15 @@ public class LauncherBackupHelper implements BackupHelper { boolean isHotsetCompatible = false; if (currentProfile.allappsRank >= oldProfile.hotseatCount) { isHotsetCompatible = true; + mHotseatShift = 0; } - if ((currentProfile.hotseatCount >= oldProfile.hotseatCount) && - (currentProfile.allappsRank == oldProfile.allappsRank)) { + + if ((currentProfile.allappsRank >= oldProfile.allappsRank) + && ((currentProfile.hotseatCount - currentProfile.allappsRank) >= + (oldProfile.hotseatCount - oldProfile.allappsRank))) { + // There is enough space on both sides of the hotseat. isHotsetCompatible = true; + mHotseatShift = currentProfile.allappsRank - oldProfile.allappsRank; } return isHotsetCompatible && (currentProfile.desktopCols >= oldProfile.desktopCols) @@ -848,6 +857,11 @@ public class LauncherBackupHelper implements BackupHelper { throws IOException { Favorite favorite = unpackProto(new Favorite(), buffer, dataSize); + // If it is a hotseat item, move it accordingly. + if (favorite.container == Favorites.CONTAINER_HOTSEAT) { + favorite.screen += mHotseatShift; + } + ContentValues values = new ContentValues(); values.put(Favorites._ID, favorite.id); values.put(Favorites.SCREEN, favorite.screen); |