summaryrefslogtreecommitdiffstats
path: root/src/com/cyanogenmod/trebuchet/LauncherModel.java
diff options
context:
space:
mode:
authorJorge Ruesga <jorge@ruesga.com>2013-04-13 21:57:41 +0200
committerJorge Ruesga <jorge@ruesga.com>2013-04-17 01:47:56 +0200
commit25350504863f87d88d3e86c58714275c963b8469 (patch)
tree89d5148cad8926b619670844bd6e919e6c761fad /src/com/cyanogenmod/trebuchet/LauncherModel.java
parentda04260b2994b38ebe58d794dae300470c14621f (diff)
downloadpackages_apps_trebuchet-25350504863f87d88d3e86c58714275c963b8469.tar.gz
packages_apps_trebuchet-25350504863f87d88d3e86c58714275c963b8469.tar.bz2
packages_apps_trebuchet-25350504863f87d88d3e86c58714275c963b8469.zip
Trebuchet: Hotseat fixes
This change fixes some of the bugs of HotSeat on landscape mode: * Fixed distance algorithm for XY spatial (not only for X axis) * Fixed cellX and cellY database handling when items are added in landscape mode * Fixed cellX and cellY transtions when add new items * Restore the current hotseat page on rotation Patchset 2: Fixed create new folder in vertical hotseat Patchset 3: Fixed broken mTransposeLayoutWithOrientation != true (large screen devices) Fixed delete existing folder in vertical hotseat Patchset 4: Fixed destroy animation when a folder is destroyed in vertical hotseat Rebased Change-Id: I8b0faa5b6fde42d80e0d98226fca07eead04223c JIRA: CYAN-315 Issue: https://jira.cyanogenmod.org/browse/CYAN-315 Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'src/com/cyanogenmod/trebuchet/LauncherModel.java')
-rw-r--r--src/com/cyanogenmod/trebuchet/LauncherModel.java81
1 files changed, 57 insertions, 24 deletions
diff --git a/src/com/cyanogenmod/trebuchet/LauncherModel.java b/src/com/cyanogenmod/trebuchet/LauncherModel.java
index 501058e8..a3d198c7 100644
--- a/src/com/cyanogenmod/trebuchet/LauncherModel.java
+++ b/src/com/cyanogenmod/trebuchet/LauncherModel.java
@@ -368,16 +368,29 @@ public class LauncherModel extends BroadcastReceiver {
*/
static void moveItemInDatabase(Context context, final ItemInfo item, final long container,
final int screen, final int cellX, final int cellY) {
+
+ // We store hotseat items in canonical form which is this orientation invariant position
+ // in the hotseat
+ int screenEx = screen;
+ if (context instanceof Launcher && screen < 0 &&
+ container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
+ screenEx = ((Launcher) context).getHotseat().getOrderInHotseat(cellX, cellY);
+ }
+ int[] cells = {cellX, cellY};
+ if (context instanceof Launcher &&
+ container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
+ cells = ((Launcher)context).getHotseat().
+ getDatabaseCellsFromLayout(new int[]{cellX, cellY});
+ }
+
String transaction = "DbDebug Modify item (" + item.title + ") in db, id: " + item.id +
" (" + item.container + ", " + item.screen + ", " + item.cellX + ", " + item.cellY +
- ") --> " + "(" + container + ", " + screen + ", " + cellX + ", " + cellY + ")";
+ ") --> " + "(" + container + ", " + screenEx + ", " + cells[0] + ", " + cells[1] + ")";
Launcher.sDumpLogs.add(transaction);
- Log.d(TAG, transaction);
item.container = container;
- item.cellX = cellX;
- item.cellY = cellY;
-
- item.screen = screen;
+ item.cellX = cells[0];
+ item.cellY = cells[1];
+ item.screen = screenEx;
final ContentValues values = new ContentValues();
values.put(LauncherSettings.Favorites.CONTAINER, item.container);
@@ -393,25 +406,31 @@ public class LauncherModel extends BroadcastReceiver {
*/
static void modifyItemInDatabase(Context context, final ItemInfo item, final long container,
final int screen, final int cellX, final int cellY, final int spanX, final int spanY) {
- String transaction = "DbDebug Modify item (" + item.title + ") in db, id: " + item.id +
- " (" + item.container + ", " + item.screen + ", " + item.cellX + ", " + item.cellY +
- ") --> " + "(" + container + ", " + screen + ", " + cellX + ", " + cellY + ")";
- Launcher.sDumpLogs.add(transaction);
- Log.d(TAG, transaction);
- item.cellX = cellX;
- item.cellY = cellY;
- item.spanX = spanX;
- item.spanY = spanY;
// We store hotseat items in canonical form which is this orientation invariant position
// in the hotseat
+ int screenEx = screen;
if (context instanceof Launcher && screen < 0 &&
container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
- item.screen = ((Launcher) context).getHotseat().getOrderInHotseat(cellX, cellY);
- } else {
- item.screen = screen;
+ screenEx = ((Launcher) context).getHotseat().getOrderInHotseat(cellX, cellY);
+ }
+ int[] cells = {cellX, cellY};
+ if (context instanceof Launcher &&
+ container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
+ cells = ((Launcher)context).getHotseat().
+ getDatabaseCellsFromLayout(new int[]{cellX, cellY});
}
+ String transaction = "DbDebug Modify item (" + item.title + ") in db, id: " + item.id +
+ " (" + item.container + ", " + item.screen + ", " + item.cellX + ", " + item.cellY +
+ ") --> " + "(" + container + ", " + screenEx + ", " + cells[0] + ", " + cells[1] + ")";
+ Launcher.sDumpLogs.add(transaction);
+ item.cellX = cells[0];
+ item.cellY = cells[1];
+ item.spanX = spanX;
+ item.spanY = spanY;
+ item.screen = screenEx;
+
final ContentValues values = new ContentValues();
values.put(LauncherSettings.Favorites.CONTAINER, item.container);
values.put(LauncherSettings.Favorites.CELLX, item.cellX);
@@ -543,11 +562,25 @@ public class LauncherModel extends BroadcastReceiver {
*/
static void addItemToDatabase(Context context, final ItemInfo item, final long container,
final int screen, final int cellX, final int cellY, final boolean notify) {
- item.container = container;
- item.cellX = cellX;
- item.cellY = cellY;
- item.screen = screen;
+ // We store hotseat items in canonical form which is this orientation invariant position
+ // in the hotseat
+ int screenEx = screen;
+ if (context instanceof Launcher && screen < 0 &&
+ container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
+ screenEx = ((Launcher) context).getHotseat().getOrderInHotseat(cellX, cellY);
+ }
+ int[] cells = {cellX, cellY};
+ if (context instanceof Launcher &&
+ container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
+ cells = ((Launcher)context).getHotseat().
+ getDatabaseCellsFromLayout(new int[]{cellX, cellY});
+ }
+
+ item.container = container;
+ item.cellX = cells[0];
+ item.cellY = cells[1];
+ item.screen = screenEx;
final ContentValues values = new ContentValues();
final ContentResolver cr = context.getContentResolver();
@@ -561,8 +594,8 @@ public class LauncherModel extends BroadcastReceiver {
Runnable r = new Runnable() {
public void run() {
String transaction = "DbDebug Add item (" + item.title + ") to db, id: "
- + item.id + " (" + container + ", " + screen + ", " + cellX + ", "
- + cellY + ")";
+ + item.id + " (" + container + ", " + item.screen + ", " + item.cellX + ", "
+ + item.cellY + ")";
Launcher.sDumpLogs.add(transaction);
Log.d(TAG, transaction);