summaryrefslogtreecommitdiffstats
path: root/src/com/cyanogenmod/trebuchet/Workspace.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/Workspace.java
parentda04260b2994b38ebe58d794dae300470c14621f (diff)
downloadandroid_packages_apps_Trebuchet-25350504863f87d88d3e86c58714275c963b8469.tar.gz
android_packages_apps_Trebuchet-25350504863f87d88d3e86c58714275c963b8469.tar.bz2
android_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/Workspace.java')
-rw-r--r--src/com/cyanogenmod/trebuchet/Workspace.java53
1 files changed, 34 insertions, 19 deletions
diff --git a/src/com/cyanogenmod/trebuchet/Workspace.java b/src/com/cyanogenmod/trebuchet/Workspace.java
index 7e330eb3b..c6da8a984 100644
--- a/src/com/cyanogenmod/trebuchet/Workspace.java
+++ b/src/com/cyanogenmod/trebuchet/Workspace.java
@@ -2794,10 +2794,12 @@ public class Workspace extends PagedView
if (v == null || hasntMoved || !mCreateUserFolderOnDrop) return false;
mCreateUserFolderOnDrop = false;
- final int screen = (targetCell == null) ? mDragInfo.screen :
- (mLauncher.isHotseatLayout(target) ?
- mLauncher.getHotseat().indexOfChild(target) :
- indexOfChild(target));
+ final int screen =
+ (targetCell == null) ?
+ mDragInfo.screen :
+ (mLauncher.isHotseatLayout(target) ?
+ mLauncher.getHotseat().getScreenFromOrder(mLauncher.getHotseat().indexOfChild(target)) :
+ indexOfChild(target));
boolean aboveShortcut = (v.getTag() instanceof ShortcutInfo);
boolean willBecomeShortcut = (newView.getTag() instanceof ShortcutInfo);
@@ -2890,10 +2892,12 @@ public class Workspace extends PagedView
long container = hasMovedIntoHotseat ?
LauncherSettings.Favorites.CONTAINER_HOTSEAT :
LauncherSettings.Favorites.CONTAINER_DESKTOP;
- int screen = (mTargetCell[0] < 0) ?
- mDragInfo.screen : (hasMovedIntoHotseat ?
- mLauncher.getHotseat().indexOfChild(dropTargetLayout) :
- indexOfChild(dropTargetLayout));
+ int screen =
+ (mTargetCell[0] < 0) ?
+ mDragInfo.screen :
+ (hasMovedIntoHotseat ?
+ mLauncher.getHotseat().getScreenFromOrder(mLauncher.getHotseat().indexOfChild(dropTargetLayout)) :
+ indexOfChild(dropTargetLayout));
int spanX = mDragInfo != null ? mDragInfo.spanX : 1;
int spanY = mDragInfo != null ? mDragInfo.spanY : 1;
// First we find the cell nearest to point at which the item is
@@ -2947,7 +2951,8 @@ public class Workspace extends PagedView
if (mCurrentPage != screen && !hasMovedIntoHotseat) {
snapScreen = screen;
snapToPage(screen);
- } else if (mLauncher.getHotseat().getCurrentPage() != screen && hasMovedIntoHotseat) {
+ } else if (hasMovedIntoHotseat &&
+ mLauncher.getHotseat().getScreenFromOrder(mLauncher.getHotseat().getCurrentPage()) != screen) {
mLauncher.getHotseat().snapToPage(screen);
}
@@ -3295,10 +3300,17 @@ public class Workspace extends PagedView
xy[1] -= (getScrollY() - v.getTop());
}
- static float squaredDistance(float[] point1, float[] point2) {
- float distanceX = point1[0] - point2[0];
- float distanceY = point2[1] - point2[1];
- return distanceX * distanceX + distanceY * distanceY;
+ static float squaredDistance(float[] point1, float[] point2, boolean spatial) {
+ // Horizontal
+ if (!spatial) {
+ float distanceX = point1[0] - point2[0];
+ float distanceY = point2[1] - point2[1];
+ return distanceX * distanceX + distanceY * distanceY;
+ }
+ // Spatial xy
+ double distanceX = Math.pow(point2[0] - point2[1], 2);
+ double distanceY = Math.pow(point2[1] - point2[0], 2);
+ return (float)Math.sqrt(distanceX + distanceY);
}
/**
@@ -3341,7 +3353,7 @@ public class Workspace extends PagedView
// Calculate the distance between the center of the CellLayout
// and the touch point
- float dist = squaredDistance(touchXy, cellLayoutCenter);
+ float dist = squaredDistance(touchXy, cellLayoutCenter, false);
if (dist < smallestDistSoFar) {
smallestDistSoFar = dist;
@@ -3666,13 +3678,15 @@ public class Workspace extends PagedView
final long container = mLauncher.isHotseatLayout(cellLayout) ?
LauncherSettings.Favorites.CONTAINER_HOTSEAT :
LauncherSettings.Favorites.CONTAINER_DESKTOP;
- final int screen = mLauncher.isHotseatLayout(cellLayout) ?
- mLauncher.getHotseat().indexOfChild(cellLayout) :
+ final int screen =
+ mLauncher.isHotseatLayout(cellLayout) ?
+ mLauncher.getHotseat().getScreenFromOrder(mLauncher.getHotseat().indexOfChild(cellLayout)) :
indexOfChild(cellLayout);
if (mState != State.SPRING_LOADED) {
if (!mLauncher.isHotseatLayout(cellLayout) && screen != mCurrentPage) {
snapToPage(screen);
- } else if (mLauncher.isHotseatLayout(cellLayout) && screen != mLauncher.getHotseat().getCurrentPage()) {
+ } else if (mLauncher.isHotseatLayout(cellLayout) && screen !=
+ mLauncher.getHotseat().getScreenFromOrder(mLauncher.getHotseat().getCurrentPage())) {
mLauncher.getHotseat().snapToPage(screen);
}
}
@@ -3810,9 +3824,10 @@ public class Workspace extends PagedView
info.spanY, insertAtFirst);
cellLayout.onDropChild(view);
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) view.getLayoutParams();
+ lp.cellX = mTargetCell[0];
+ lp.cellY = mTargetCell[1];
cellLayout.getShortcutsAndWidgets().measureChild(view);
-
LauncherModel.addOrMoveItemInDatabase(mLauncher, info, container, screen,
lp.cellX, lp.cellY);
@@ -4045,7 +4060,7 @@ public class Workspace extends PagedView
int container = Favorites.CONTAINER_DESKTOP;
if (mLauncher.isHotseatLayout(cl)) {
- screen = mLauncher.getHotseat().indexOfChild(cl);
+ screen = mLauncher.getHotseat().getScreenFromOrder(mLauncher.getHotseat().indexOfChild(cl));
container = Favorites.CONTAINER_HOTSEAT;
}