summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Dubroy <dubroy@google.com>2010-08-04 20:03:37 -0700
committerPatrick Dubroy <dubroy@google.com>2010-08-04 20:10:24 -0700
commit976ebec9e31643d3513f9f0de2b433d9aa186ce9 (patch)
treebd7daac4f2f3cbea96d5645f4aca09b568cad58e
parentec1b932159cd6ea5dd5e3aee2554131d175e03d9 (diff)
downloadandroid_packages_apps_Trebuchet-976ebec9e31643d3513f9f0de2b433d9aa186ce9.tar.gz
android_packages_apps_Trebuchet-976ebec9e31643d3513f9f0de2b433d9aa186ce9.tar.bz2
android_packages_apps_Trebuchet-976ebec9e31643d3513f9f0de2b433d9aa186ce9.zip
Fix incorrect offset in drag feedback, and other minor stuff.
- moved some dimens to -xlarge - enlarge AllApps so that it's not clipped
-rw-r--r--res/layout-xlarge/launcher.xml2
-rw-r--r--res/values-xlarge/dimens.xml7
-rw-r--r--res/values/dimens.xml7
-rw-r--r--src/com/android/launcher2/CellLayout.java4
-rw-r--r--src/com/android/launcher2/Workspace.java15
5 files changed, 24 insertions, 11 deletions
diff --git a/res/layout-xlarge/launcher.xml b/res/layout-xlarge/launcher.xml
index 0dd25d2ac..fa9c88137 100644
--- a/res/layout-xlarge/launcher.xml
+++ b/res/layout-xlarge/launcher.xml
@@ -26,7 +26,7 @@
layout="@layout/all_apps_tabbed"
android:id="@+id/all_apps_view"
android:layout_width="match_parent"
- android:layout_height="500dip"
+ android:layout_height="550dip"
android:layout_gravity="top"/>
<!-- The workspace contains 5 screens of cells -->
diff --git a/res/values-xlarge/dimens.xml b/res/values-xlarge/dimens.xml
index 827949274..9e98e4690 100644
--- a/res/values-xlarge/dimens.xml
+++ b/res/values-xlarge/dimens.xml
@@ -17,4 +17,11 @@
<resources>
<dimen name="workspace_cell_width">76dip</dimen>
<dimen name="workspace_cell_height">76dip</dimen>
+
+ <!-- horizontal spacing between mini screen thumbnails ie. in all
+ apps and in customization mode -->
+ <dimen name="smallScreenSpacing">10dip</dimen>
+
+ <!-- vertical spacing between edge of screen and mini screen thumbnails -->
+ <dimen name="smallScreenVerticalMargin">20dip</dimen>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 38936ce90..790f83599 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -37,11 +37,4 @@
<!-- delete_zone_size_full - button_bar_height_portrait -->
<dimen name="delete_zone_padding">14dip</dimen>
-
- <!-- horizontal spacing between mini screen thumbnails ie. in all
- apps and in customization mode -->
- <dimen name="smallScreenSpacing">10dip</dimen>
-
- <!-- vertical spacing between edge of screen and mini screen thumbnails -->
- <dimen name="smallScreenVerticalMargin">20dip</dimen>
</resources>
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 2a8c5732e..2488e6e32 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -764,7 +764,9 @@ public class CellLayout extends ViewGroup {
final int countX = mCountX;
final int countY = mCountY;
- pointToCellRounded(originX, originY, result);
+ // originX and originY give the top left of the cell, but pointToCellRounded
+ // compares center-to-center, so pass in the middle coordinates
+ pointToCellRounded(originX + (mCellWidth / 2), originY + (mCellHeight / 2), result);
// If the item isn't fully on this screen, snap to the edges
int rightOverhang = result[0] + spanX - countX;
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 818cedd86..2bb1b7f12 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -1369,8 +1369,8 @@ public class Workspace extends ViewGroup
public void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset,
DragView dragView, Object dragInfo) {
- ItemInfo item = (ItemInfo)dragInfo;
- CellLayout currentLayout = getCurrentDropLayout();
+ final ItemInfo item = (ItemInfo)dragInfo;
+ final CellLayout currentLayout = getCurrentDropLayout();
if (dragInfo instanceof LauncherAppWidgetInfo) {
LauncherAppWidgetInfo widgetInfo = (LauncherAppWidgetInfo)dragInfo;
@@ -1393,6 +1393,17 @@ public class Workspace extends ViewGroup
int originX = x - xOffset;
int originY = y - yOffset;
+ // If not dragging from the Workspace, the size of dragView might not match the cell size
+ if (!source.equals(this)) {
+ // Break the drag view up into evenly sized chunks based on its spans
+ int chunkWidth = dragView.getWidth() / item.spanX;
+ int chunkHeight = dragView.getHeight() / item.spanY;
+
+ // Adjust the origin for a cell centered at the top left chunk
+ originX += (chunkWidth - currentLayout.getCellWidth()) / 2;
+ originY += (chunkHeight - currentLayout.getCellHeight()) / 2;
+ }
+
final View child = (mDragInfo == null) ? null : mDragInfo.cell;
currentLayout.visualizeDropLocation(child, originX, originY, item.spanX, item.spanY);
}