summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2011-07-20 15:45:11 -0700
committerAdam Cohen <adamcohen@google.com>2011-07-20 17:59:04 -0700
commitfc53cd22c9a78708c78c85946443f23ec8c59502 (patch)
treea61a0f1ffd4729401c65a1a9d36f20593100fe8a /src/com
parentd8ff0e68e8a5184b59876e987dc5e65b2f82baf5 (diff)
downloadandroid_packages_apps_Trebuchet-fc53cd22c9a78708c78c85946443f23ec8c59502.tar.gz
android_packages_apps_Trebuchet-fc53cd22c9a78708c78c85946443f23ec8c59502.tar.bz2
android_packages_apps_Trebuchet-fc53cd22c9a78708c78c85946443f23ec8c59502.zip
Fixing a couple bugs, allapps clicks and weird crash
-> issue 5021897 (when this was fixed, exposed more bugginess that is now fixed) -> issue 5038392 Change-Id: I49a4e9fca154f75ea22ad2c462641747536102ce
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java9
-rw-r--r--src/com/android/launcher2/CellLayout.java16
-rw-r--r--src/com/android/launcher2/DragController.java9
-rw-r--r--src/com/android/launcher2/DragLayer.java4
-rw-r--r--src/com/android/launcher2/DragSource.java6
-rw-r--r--src/com/android/launcher2/DragView.java25
-rw-r--r--src/com/android/launcher2/Folder.java14
-rw-r--r--src/com/android/launcher2/Launcher.java4
-rw-r--r--src/com/android/launcher2/PagedViewWithDraggableItems.java11
-rw-r--r--src/com/android/launcher2/Workspace.java25
10 files changed, 45 insertions, 78 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index c127ecd82..ca11c1e2a 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -350,6 +350,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
@Override
public void onClick(View v) {
+ // When we have exited all apps or are in transition, disregard clicks
+ if (!mLauncher.isAllAppsCustomizeOpen() ||
+ mLauncher.getWorkspace().isSwitchingState()) return;
+
if (v instanceof PagedViewIcon) {
// Animate some feedback to the click
final ApplicationInfo appInfo = (ApplicationInfo) v.getTag();
@@ -459,11 +463,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
- /*
- * DragSource implementation
- */
- @Override
- public void onDragViewVisible() {}
@Override
public void onDropCompleted(View target, DragObject d, boolean success) {
endDragging(target, success);
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index bd2a94942..de9c1887c 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -1454,23 +1454,12 @@ public class CellLayout extends ViewGroup {
void onDropChild(View child) {
if (child != null) {
LayoutParams lp = (LayoutParams) child.getLayoutParams();
- lp.isDragging = false;
lp.dropped = true;
child.requestLayout();
}
}
/**
- * Start dragging the specified child
- *
- * @param child The child that is being dragged
- */
- void onDragChild(View child) {
- LayoutParams lp = (LayoutParams) child.getLayoutParams();
- lp.isDragging = true;
- }
-
- /**
* Computes a bounding rectangle for a range of cells
*
* @param cellX X coordinate of upper left corner expressed as a cell position
@@ -1755,11 +1744,6 @@ out: for (int i = x; i < x + spanX - 1 && x < xCount; i++) {
*/
public boolean isLockedToGrid = true;
- /**
- * Is this item currently being dragged
- */
- public boolean isDragging;
-
// X coordinate of the view in the layout.
@ViewDebug.ExportedProperty
int x;
diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java
index 5aecede0e..eb0db69eb 100644
--- a/src/com/android/launcher2/DragController.java
+++ b/src/com/android/launcher2/DragController.java
@@ -23,13 +23,11 @@ import android.graphics.RectF;
import android.os.Handler;
import android.os.IBinder;
import android.os.Vibrator;
-import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
-import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import com.android.launcher.R;
@@ -288,13 +286,6 @@ public class DragController {
final DragView dragView = mDragObject.dragView = new DragView(mLauncher, b, registrationX,
registrationY, 0, 0, b.getWidth(), b.getHeight());
- final DragSource dragSource = source;
- dragView.setOnDrawRunnable(new Runnable() {
- public void run() {
- dragSource.onDragViewVisible();
- };
- });
-
if (dragRegion != null) {
dragView.setDragRegion(new Rect(dragRegion));
}
diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java
index 8563be9f2..809a65138 100644
--- a/src/com/android/launcher2/DragLayer.java
+++ b/src/com/android/launcher2/DragLayer.java
@@ -215,8 +215,8 @@ public class DragLayer extends FrameLayout {
pt[1] += view.getTop() - view.getScrollY();
viewParent = view.getParent();
}
- coord[0] = (int) pt[0];
- coord[1] = (int) pt[1];
+ coord[0] = (int) Math.round(pt[0]);
+ coord[1] = (int) Math.round(pt[1]);
return scale;
}
diff --git a/src/com/android/launcher2/DragSource.java b/src/com/android/launcher2/DragSource.java
index 2a8f263a5..06f5ee1e6 100644
--- a/src/com/android/launcher2/DragSource.java
+++ b/src/com/android/launcher2/DragSource.java
@@ -25,11 +25,5 @@ import com.android.launcher2.DropTarget.DragObject;
*
*/
public interface DragSource {
- /**
- * Callback from the DragController when it begins drawing the drag view.
- * This allows the DragSource to dim or hide the original view.
- */
- void onDragViewVisible();
-
void onDropCompleted(View target, DragObject d, boolean success);
}
diff --git a/src/com/android/launcher2/DragView.java b/src/com/android/launcher2/DragView.java
index 1c75e470f..386cb55d3 100644
--- a/src/com/android/launcher2/DragView.java
+++ b/src/com/android/launcher2/DragView.java
@@ -41,6 +41,7 @@ public class DragView extends View {
private Rect mDragRegion = null;
private DragLayer mDragLayer = null;
+ private boolean mHasDrawn = false;
ValueAnimator mAnim;
private float mOffsetX = 0.0f;
@@ -49,13 +50,6 @@ public class DragView extends View {
private DragLayer.LayoutParams mLayoutParams;
/**
- * A callback to be called the first time this view is drawn.
- * This allows the originator of the drag to dim or hide the original view as soon
- * as the DragView is drawn.
- */
- private Runnable mOnDrawRunnable = null;
-
- /**
* Construct the drag view.
* <p>
* The registration point is the point inside our view that the touch events should
@@ -125,10 +119,6 @@ public class DragView extends View {
return mOffsetY;
}
- public void setOnDrawRunnable(Runnable r) {
- mOnDrawRunnable = r;
- }
-
public int getDragRegionLeft() {
return mDragRegion.left;
}
@@ -168,14 +158,7 @@ public class DragView extends View {
canvas.drawRect(0, 0, getWidth(), getHeight(), p);
}
- // Call the callback if we haven't already been detached
- if (getParent() != null) {
- if (mOnDrawRunnable != null) {
- mOnDrawRunnable.run();
- mOnDrawRunnable = null;
- }
- }
-
+ mHasDrawn = true;
canvas.drawBitmap(mBitmap, 0.0f, 0.0f, mPaint);
}
@@ -184,6 +167,10 @@ public class DragView extends View {
invalidate();
}
+ public boolean hasDrawn() {
+ return mHasDrawn;
+ }
+
@Override
public void setAlpha(float alpha) {
super.setAlpha(alpha);
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java
index 96cd22b56..d3b5d4171 100644
--- a/src/com/android/launcher2/Folder.java
+++ b/src/com/android/launcher2/Folder.java
@@ -214,15 +214,13 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
mEmptyCell[0] = item.cellX;
mEmptyCell[1] = item.cellY;
mCurrentDragView = v;
+
+ mContent.removeView(mCurrentDragView);
+ mInfo.remove(mCurrentDragInfo);
}
return true;
}
- public void onDragViewVisible() {
- mContent.removeView(mCurrentDragView);
- mInfo.remove(mCurrentDragInfo);
- }
-
public boolean isEditingName() {
return mIsEditingName;
}
@@ -890,7 +888,11 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
si.cellX = lp.cellX = mEmptyCell[0];
si.cellX = lp.cellY = mEmptyCell[1];
mContent.addViewToCellLayout(mCurrentDragView, -1, (int)item.id, lp, true);
- mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, mCurrentDragView);
+ if (d.dragView.hasDrawn()) {
+ mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, mCurrentDragView);
+ } else {
+ mCurrentDragView.setVisibility(VISIBLE);
+ }
mItemsInvalidated = true;
setupContentDimension(getItemCount());
mSuppressOnAdd = true;
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 90bd151eb..0abdec090 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2418,6 +2418,10 @@ public final class Launcher extends Activity
// Otherwise, we are not in spring loaded mode, so don't do anything.
}
+ public boolean isAllAppsCustomizeOpen() {
+ return mState == State.APPS_CUSTOMIZE;
+ }
+
/**
* Shows the hotseat area.
*/
diff --git a/src/com/android/launcher2/PagedViewWithDraggableItems.java b/src/com/android/launcher2/PagedViewWithDraggableItems.java
index 5fa7be798..287a06565 100644
--- a/src/com/android/launcher2/PagedViewWithDraggableItems.java
+++ b/src/com/android/launcher2/PagedViewWithDraggableItems.java
@@ -37,17 +37,19 @@ public abstract class PagedViewWithDraggableItems extends PagedView
private boolean mIsDragging;
private boolean mIsDragEnabled;
private float mDragSlopeThreshold;
+ private Launcher mLauncher;
public PagedViewWithDraggableItems(Context context) {
- super(context, null);
+ this(context, null);
}
public PagedViewWithDraggableItems(Context context, AttributeSet attrs) {
- super(context, attrs, 0);
+ this(context, attrs, 0);
}
public PagedViewWithDraggableItems(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+ mLauncher = (Launcher) context;
}
protected boolean beginDragging(View v) {
@@ -102,10 +104,13 @@ public abstract class PagedViewWithDraggableItems extends PagedView
if (!v.isInTouchMode()) return false;
// Return early if we are still animating the pages
if (mNextPage != INVALID_PAGE) return false;
+ // When we have exited all apps or are in transition, disregard long clicks
+ if (!mLauncher.isAllAppsCustomizeOpen() ||
+ mLauncher.getWorkspace().isSwitchingState()) return false;
+
return beginDragging(v);
}
-
/*
* Determines if we should change the touch state to start scrolling after the
* user moves their touch point too far.
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index d40d77fdf..5309423b7 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -539,6 +539,10 @@ public class Workspace extends SmoothPagedView
return (isSmall() || mIsSwitchingState);
}
+ public boolean isSwitchingState() {
+ return mIsSwitchingState;
+ }
+
protected void onWindowVisibilityChanged (int visibility) {
mLauncher.onWindowVisibilityChanged(visibility);
}
@@ -1972,9 +1976,7 @@ public class Workspace extends SmoothPagedView
}
mDragInfo = cellInfo;
-
- CellLayout current = getParentCellLayoutForView(cellInfo.cell);
- current.onDragChild(child);
+ child.setVisibility(GONE);
child.clearFocus();
child.setPressed(false);
@@ -2001,8 +2003,7 @@ public class Workspace extends SmoothPagedView
mLauncher.getDragLayer().getLocationInDragLayer(child, mTempXY);
final int dragLayerX = (int) mTempXY[0] + (child.getWidth() - bmpWidth) / 2;
- int dragLayerY = (int) mTempXY[1] + (child.getHeight() - bmpHeight) / 2;
- dragLayerY -= (child.getHeight() - b.getHeight()) / 2;
+ int dragLayerY = mTempXY[1] - bitmapPadding / 2;
Rect dragRect = null;
if (child instanceof BubbleTextView) {
@@ -2011,6 +2012,7 @@ public class Workspace extends SmoothPagedView
int left = (bmpWidth - iconSize) / 2;
int right = left + iconSize;
int bottom = top + iconSize;
+ dragLayerY += top;
dragRect = new Rect(left, top, right, bottom);
} else if (child instanceof FolderIcon) {
int previewSize = getResources().getDimensionPixelSize(R.dimen.folder_preview_size);
@@ -2310,8 +2312,12 @@ public class Workspace extends SmoothPagedView
}
};
mAnimatingViewIntoPlace = true;
- mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell,
- disableHardwareLayersRunnable);
+ if (d.dragView.hasDrawn()) {
+ mLauncher.getDragLayer().animateViewIntoPosition(d.dragView, cell,
+ disableHardwareLayersRunnable);
+ } else {
+ cell.setVisibility(VISIBLE);
+ }
parent.onDropChild(cell);
}
}
@@ -3092,11 +3098,6 @@ public class Workspace extends SmoothPagedView
mDragInfo = null;
}
- @Override
- public void onDragViewVisible() {
- ((View) mDragInfo.cell).setVisibility(View.GONE);
- }
-
public boolean isDropEnabled() {
return true;
}