summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/drawable-hdpi/widget_resize_frame_holo.9.pngbin0 -> 3411 bytes
-rw-r--r--res/drawable-hdpi/widget_resize_handle_bottom.pngbin0 -> 769 bytes
-rw-r--r--res/drawable-hdpi/widget_resize_handle_left.pngbin0 -> 753 bytes
-rw-r--r--res/drawable-hdpi/widget_resize_handle_right.pngbin0 -> 756 bytes
-rw-r--r--res/drawable-hdpi/widget_resize_handle_top.pngbin0 -> 769 bytes
-rw-r--r--res/drawable-mdpi/widget_resize_frame_holo.9.pngbin0 -> 1848 bytes
-rw-r--r--res/drawable-mdpi/widget_resize_handle_bottom.pngbin0 -> 582 bytes
-rw-r--r--res/drawable-mdpi/widget_resize_handle_left.pngbin0 -> 593 bytes
-rw-r--r--res/drawable-mdpi/widget_resize_handle_right.pngbin0 -> 592 bytes
-rw-r--r--res/drawable-mdpi/widget_resize_handle_top.pngbin0 -> 582 bytes
-rw-r--r--res/drawable-xlarge-hdpi/widget_resize_frame_holo.9.pngbin0 -> 3433 bytes
-rw-r--r--res/drawable-xlarge-hdpi/widget_resize_handle_bottom.pngbin0 -> 783 bytes
-rw-r--r--res/drawable-xlarge-hdpi/widget_resize_handle_left.pngbin0 -> 796 bytes
-rw-r--r--res/drawable-xlarge-hdpi/widget_resize_handle_right.pngbin0 -> 798 bytes
-rw-r--r--res/drawable-xlarge-hdpi/widget_resize_handle_top.pngbin0 -> 783 bytes
-rw-r--r--res/drawable-xlarge-mdpi/widget_resize_frame_holo.9.pngbin0 -> 1834 bytes
-rw-r--r--res/drawable-xlarge-mdpi/widget_resize_handle_bottom.pngbin0 -> 602 bytes
-rw-r--r--res/drawable-xlarge-mdpi/widget_resize_handle_left.pngbin0 -> 608 bytes
-rw-r--r--res/drawable-xlarge-mdpi/widget_resize_handle_right.pngbin0 -> 610 bytes
-rw-r--r--res/drawable-xlarge-mdpi/widget_resize_handle_top.pngbin0 -> 602 bytes
-rw-r--r--src/com/android/launcher2/AppWidgetResizeFrame.java80
21 files changed, 44 insertions, 36 deletions
diff --git a/res/drawable-hdpi/widget_resize_frame_holo.9.png b/res/drawable-hdpi/widget_resize_frame_holo.9.png
new file mode 100644
index 000000000..8da665b7a
--- /dev/null
+++ b/res/drawable-hdpi/widget_resize_frame_holo.9.png
Binary files differ
diff --git a/res/drawable-hdpi/widget_resize_handle_bottom.png b/res/drawable-hdpi/widget_resize_handle_bottom.png
new file mode 100644
index 000000000..495476b7c
--- /dev/null
+++ b/res/drawable-hdpi/widget_resize_handle_bottom.png
Binary files differ
diff --git a/res/drawable-hdpi/widget_resize_handle_left.png b/res/drawable-hdpi/widget_resize_handle_left.png
new file mode 100644
index 000000000..c73cf0e2a
--- /dev/null
+++ b/res/drawable-hdpi/widget_resize_handle_left.png
Binary files differ
diff --git a/res/drawable-hdpi/widget_resize_handle_right.png b/res/drawable-hdpi/widget_resize_handle_right.png
new file mode 100644
index 000000000..953230276
--- /dev/null
+++ b/res/drawable-hdpi/widget_resize_handle_right.png
Binary files differ
diff --git a/res/drawable-hdpi/widget_resize_handle_top.png b/res/drawable-hdpi/widget_resize_handle_top.png
new file mode 100644
index 000000000..a3d2f7c77
--- /dev/null
+++ b/res/drawable-hdpi/widget_resize_handle_top.png
Binary files differ
diff --git a/res/drawable-mdpi/widget_resize_frame_holo.9.png b/res/drawable-mdpi/widget_resize_frame_holo.9.png
new file mode 100644
index 000000000..0572f8999
--- /dev/null
+++ b/res/drawable-mdpi/widget_resize_frame_holo.9.png
Binary files differ
diff --git a/res/drawable-mdpi/widget_resize_handle_bottom.png b/res/drawable-mdpi/widget_resize_handle_bottom.png
new file mode 100644
index 000000000..6c9397322
--- /dev/null
+++ b/res/drawable-mdpi/widget_resize_handle_bottom.png
Binary files differ
diff --git a/res/drawable-mdpi/widget_resize_handle_left.png b/res/drawable-mdpi/widget_resize_handle_left.png
new file mode 100644
index 000000000..71394155b
--- /dev/null
+++ b/res/drawable-mdpi/widget_resize_handle_left.png
Binary files differ
diff --git a/res/drawable-mdpi/widget_resize_handle_right.png b/res/drawable-mdpi/widget_resize_handle_right.png
new file mode 100644
index 000000000..442224b51
--- /dev/null
+++ b/res/drawable-mdpi/widget_resize_handle_right.png
Binary files differ
diff --git a/res/drawable-mdpi/widget_resize_handle_top.png b/res/drawable-mdpi/widget_resize_handle_top.png
new file mode 100644
index 000000000..24358849b
--- /dev/null
+++ b/res/drawable-mdpi/widget_resize_handle_top.png
Binary files differ
diff --git a/res/drawable-xlarge-hdpi/widget_resize_frame_holo.9.png b/res/drawable-xlarge-hdpi/widget_resize_frame_holo.9.png
new file mode 100644
index 000000000..7d16d7dea
--- /dev/null
+++ b/res/drawable-xlarge-hdpi/widget_resize_frame_holo.9.png
Binary files differ
diff --git a/res/drawable-xlarge-hdpi/widget_resize_handle_bottom.png b/res/drawable-xlarge-hdpi/widget_resize_handle_bottom.png
new file mode 100644
index 000000000..045c15e2c
--- /dev/null
+++ b/res/drawable-xlarge-hdpi/widget_resize_handle_bottom.png
Binary files differ
diff --git a/res/drawable-xlarge-hdpi/widget_resize_handle_left.png b/res/drawable-xlarge-hdpi/widget_resize_handle_left.png
new file mode 100644
index 000000000..f0fc4d65d
--- /dev/null
+++ b/res/drawable-xlarge-hdpi/widget_resize_handle_left.png
Binary files differ
diff --git a/res/drawable-xlarge-hdpi/widget_resize_handle_right.png b/res/drawable-xlarge-hdpi/widget_resize_handle_right.png
new file mode 100644
index 000000000..9c1f36602
--- /dev/null
+++ b/res/drawable-xlarge-hdpi/widget_resize_handle_right.png
Binary files differ
diff --git a/res/drawable-xlarge-hdpi/widget_resize_handle_top.png b/res/drawable-xlarge-hdpi/widget_resize_handle_top.png
new file mode 100644
index 000000000..f7839ed9a
--- /dev/null
+++ b/res/drawable-xlarge-hdpi/widget_resize_handle_top.png
Binary files differ
diff --git a/res/drawable-xlarge-mdpi/widget_resize_frame_holo.9.png b/res/drawable-xlarge-mdpi/widget_resize_frame_holo.9.png
new file mode 100644
index 000000000..e2e1396a1
--- /dev/null
+++ b/res/drawable-xlarge-mdpi/widget_resize_frame_holo.9.png
Binary files differ
diff --git a/res/drawable-xlarge-mdpi/widget_resize_handle_bottom.png b/res/drawable-xlarge-mdpi/widget_resize_handle_bottom.png
new file mode 100644
index 000000000..99ac1b209
--- /dev/null
+++ b/res/drawable-xlarge-mdpi/widget_resize_handle_bottom.png
Binary files differ
diff --git a/res/drawable-xlarge-mdpi/widget_resize_handle_left.png b/res/drawable-xlarge-mdpi/widget_resize_handle_left.png
new file mode 100644
index 000000000..d031ddda1
--- /dev/null
+++ b/res/drawable-xlarge-mdpi/widget_resize_handle_left.png
Binary files differ
diff --git a/res/drawable-xlarge-mdpi/widget_resize_handle_right.png b/res/drawable-xlarge-mdpi/widget_resize_handle_right.png
new file mode 100644
index 000000000..f1b689ca4
--- /dev/null
+++ b/res/drawable-xlarge-mdpi/widget_resize_handle_right.png
Binary files differ
diff --git a/res/drawable-xlarge-mdpi/widget_resize_handle_top.png b/res/drawable-xlarge-mdpi/widget_resize_handle_top.png
new file mode 100644
index 000000000..40bef020c
--- /dev/null
+++ b/res/drawable-xlarge-mdpi/widget_resize_handle_top.png
Binary files differ
diff --git a/src/com/android/launcher2/AppWidgetResizeFrame.java b/src/com/android/launcher2/AppWidgetResizeFrame.java
index d17bc5abd..40347adc2 100644
--- a/src/com/android/launcher2/AppWidgetResizeFrame.java
+++ b/src/com/android/launcher2/AppWidgetResizeFrame.java
@@ -33,19 +33,21 @@ public class AppWidgetResizeFrame extends FrameLayout {
private int mBaselineX;
private int mBaselineY;
private int mResizeMode;
-
+
private int mRunningHInc;
private int mRunningVInc;
private int mMinHSpan;
private int mMinVSpan;
private int mDeltaX;
private int mDeltaY;
+ private int mBackgroundPadding;
+ private int mTouchTargetWidth;
private int mExpandability[] = new int[4];
- final int BORDER_WIDTH = 50;
- final int FRAME_MARGIN = 15;
final int SNAP_DURATION = 150;
+ final int BACKGROUND_PADDING = 24;
+ final float DIMMED_HANDLE_ALPHA = 0.3f;
public AppWidgetResizeFrame(Context context, ItemInfo itemInfo,
LauncherAppWidgetHostView widgetView, CellLayout cellLayout) {
@@ -56,36 +58,36 @@ public class AppWidgetResizeFrame extends FrameLayout {
mCellLayout = cellLayout;
mWidgetView = widgetView;
mResizeMode = widgetView.getAppWidgetInfo().resizeMode;
-
+
final AppWidgetProviderInfo info = widgetView.getAppWidgetInfo();
int[] result = mCellLayout.rectToCell(info.minWidth, info.minHeight, null);
mMinHSpan = result[0];
mMinVSpan = result[1];
- setBackgroundResource(R.drawable.resize_frame);
+ setBackgroundResource(R.drawable.widget_resize_frame_holo);
setPadding(0, 0, 0, 0);
LayoutParams lp;
mLeftHandle = new ImageView(context);
- mLeftHandle.setImageResource(R.drawable.h_handle);
+ mLeftHandle.setImageResource(R.drawable.widget_resize_handle_left);
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
Gravity.LEFT | Gravity.CENTER_VERTICAL);
addView(mLeftHandle, lp);
mRightHandle = new ImageView(context);
- mRightHandle.setImageResource(R.drawable.h_handle);
+ mRightHandle.setImageResource(R.drawable.widget_resize_handle_right);
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
Gravity.RIGHT | Gravity.CENTER_VERTICAL);
addView(mRightHandle, lp);
mTopHandle = new ImageView(context);
- mTopHandle.setImageResource(R.drawable.v_handle);
+ mTopHandle.setImageResource(R.drawable.widget_resize_handle_top);
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
Gravity.CENTER_HORIZONTAL | Gravity.TOP);
addView(mTopHandle, lp);
mBottomHandle = new ImageView(context);
- mBottomHandle.setImageResource(R.drawable.v_handle);
+ mBottomHandle.setImageResource(R.drawable.widget_resize_handle_bottom);
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
addView(mBottomHandle, lp);
@@ -96,16 +98,20 @@ public class AppWidgetResizeFrame extends FrameLayout {
} else if (mResizeMode == AppWidgetProviderInfo.RESIZE_VERTICAL) {
mLeftHandle.setVisibility(GONE);
mRightHandle.setVisibility(GONE);
- }
+ }
+
+ final float density = mContext.getResources().getDisplayMetrics().density;
+ mBackgroundPadding = (int) Math.ceil(density * BACKGROUND_PADDING);
+ mTouchTargetWidth = 2 * mBackgroundPadding;
}
public boolean beginResizeIfPointInRegion(int x, int y) {
boolean horizontalActive = (mResizeMode & AppWidgetProviderInfo.RESIZE_HORIZONTAL) != 0;
boolean verticalActive = (mResizeMode & AppWidgetProviderInfo.RESIZE_VERTICAL) != 0;
- mLeftBorderActive = (x < BORDER_WIDTH) && horizontalActive;
- mRightBorderActive = (x > getWidth() - BORDER_WIDTH) && horizontalActive;
- mTopBorderActive = (y < BORDER_WIDTH) && verticalActive;
- mBottomBorderActive = (y > getHeight() - BORDER_WIDTH) && verticalActive;
+ mLeftBorderActive = (x < mTouchTargetWidth) && horizontalActive;
+ mRightBorderActive = (x > getWidth() - mTouchTargetWidth) && horizontalActive;
+ mTopBorderActive = (y < mTouchTargetWidth) && verticalActive;
+ mBottomBorderActive = (y > getHeight() - mTouchTargetWidth) && verticalActive;
boolean anyBordersActive = mLeftBorderActive || mRightBorderActive
|| mTopBorderActive || mBottomBorderActive;
@@ -118,30 +124,31 @@ public class AppWidgetResizeFrame extends FrameLayout {
mRunningVInc = 0;
if (anyBordersActive) {
- mLeftHandle.setAlpha(mLeftBorderActive ? 1.0f : 0.5f);
- mRightHandle.setAlpha(mRightBorderActive ? 1.0f : 0.5f);
- mTopHandle.setAlpha(mTopBorderActive ? 1.0f : 0.5f);
- mBottomHandle.setAlpha(mBottomBorderActive ? 1.0f : 0.5f);
+ mLeftHandle.setAlpha(mLeftBorderActive ? 1.0f : DIMMED_HANDLE_ALPHA);
+ mRightHandle.setAlpha(mRightBorderActive ? 1.0f :DIMMED_HANDLE_ALPHA);
+ mTopHandle.setAlpha(mTopBorderActive ? 1.0f : DIMMED_HANDLE_ALPHA);
+ mBottomHandle.setAlpha(mBottomBorderActive ? 1.0f : DIMMED_HANDLE_ALPHA);
}
mCellLayout.getExpandabilityArrayForView(mWidgetView, mExpandability);
+
return anyBordersActive;
}
public void updateDeltas(int deltaX, int deltaY) {
if (mLeftBorderActive) {
mDeltaX = Math.max(-mBaselineX, deltaX);
- mDeltaX = Math.min(mBaselineWidth - 2*BORDER_WIDTH, mDeltaX);
+ mDeltaX = Math.min(mBaselineWidth - 2 * mTouchTargetWidth, mDeltaX);
} else if (mRightBorderActive) {
mDeltaX = Math.min(mCellLayout.getWidth() - (mBaselineX + mBaselineWidth), deltaX);
- mDeltaX = Math.max(-mBaselineWidth + 2*BORDER_WIDTH, mDeltaX);
+ mDeltaX = Math.max(-mBaselineWidth + 2 * mTouchTargetWidth, mDeltaX);
}
if (mTopBorderActive) {
mDeltaY = Math.max(-mBaselineY, deltaY);
- mDeltaY = Math.min(mBaselineHeight - 2*BORDER_WIDTH, mDeltaY);
+ mDeltaY = Math.min(mBaselineHeight - 2 * mTouchTargetWidth, mDeltaY);
} else if (mBottomBorderActive) {
mDeltaY = Math.min(mCellLayout.getHeight() - (mBaselineY + mBaselineHeight), deltaY);
- mDeltaY = Math.max(-mBaselineHeight + 2*BORDER_WIDTH, mDeltaY);
+ mDeltaY = Math.max(-mBaselineHeight + 2 * mTouchTargetWidth, mDeltaY);
}
}
@@ -167,11 +174,6 @@ public class AppWidgetResizeFrame extends FrameLayout {
}
private void resizeWidgetIfNeeded() {
- // TODO: these computations probably aren't quite right... think about them
-
- //System.out.println("runningIncX before: " + mRunningHInc);
- //System.out.println("runningIncY before: " + mRunningVInc);
-
int xThreshold = mCellLayout.getCellWidth() + mCellLayout.getWidthGap();
int yThreshold = mCellLayout.getCellHeight() + mCellLayout.getHeightGap();
@@ -224,11 +226,7 @@ public class AppWidgetResizeFrame extends FrameLayout {
lp.cellY += cellYInc;
}
- try {
- mCellLayout.getExpandabilityArrayForView(mWidgetView, mExpandability);
- } catch (Exception e) {
- System.out.println("Problem!");
- }
+ mCellLayout.getExpandabilityArrayForView(mWidgetView, mExpandability);
// Update the cells occupied by this widget
mCellLayout.markCellsAsOccupiedForView(mWidgetView);
@@ -253,10 +251,20 @@ public class AppWidgetResizeFrame extends FrameLayout {
public void snapToWidget(boolean animate) {
final CellLayout.LayoutParams lp = (CellLayout.LayoutParams) getLayoutParams();
- final int newWidth = mWidgetView.getWidth() + 2 * FRAME_MARGIN;
- final int newHeight = mWidgetView.getHeight() + 2 * FRAME_MARGIN;
- final int newX = mWidgetView.getLeft() - FRAME_MARGIN;
- final int newY = mWidgetView.getTop() - FRAME_MARGIN;
+ int newWidth = mWidgetView.getWidth() + 2 * mBackgroundPadding;
+ int newHeight = mWidgetView.getHeight() + 2 * mBackgroundPadding;
+ int newX = mWidgetView.getLeft() - mBackgroundPadding;
+ int newY = mWidgetView.getTop() - mBackgroundPadding;
+
+ // We need to make sure the frame stays within the bounds of the CellLayout
+ if (newY < 0) {
+ newHeight -= -newY;
+ newY = 0;
+ }
+ if (newY + newHeight > mCellLayout.getHeight()) {
+ newHeight -= newY + newHeight - mCellLayout.getHeight();
+ }
+
if (!animate) {
lp.width = newWidth;
lp.height = newHeight;