summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/AppWidgetResizeFrame.java
diff options
context:
space:
mode:
authorJon Miranda <jonmiranda@google.com>2016-12-28 10:49:55 -0800
committerJon Miranda <jonmiranda@google.com>2016-12-29 17:09:10 -0800
commit097a725bb8d5a4c7322b3ddfb1861e52a1ba457c (patch)
tree6ea13a4d9adbbd3d0efaa8162ffa94bf83e3404a /src/com/android/launcher3/AppWidgetResizeFrame.java
parentbf8a265deb093e147a5289e0958cc9b1bc50a6e3 (diff)
downloadandroid_packages_apps_Trebuchet-097a725bb8d5a4c7322b3ddfb1861e52a1ba457c.tar.gz
android_packages_apps_Trebuchet-097a725bb8d5a4c7322b3ddfb1861e52a1ba457c.tar.bz2
android_packages_apps_Trebuchet-097a725bb8d5a4c7322b3ddfb1861e52a1ba457c.zip
Fixed mw bug where resize frame is off when resizing.
When a widget resizes in multi-window mode (ie. user is dragging the resize frame), the frame is misaligned until the user lets go. This is because the translation value to center fit the resized widget is not taken into consideration. Bug: 32176631 Change-Id: I6f9ee7be12d3266f021796576c771f86f6120246
Diffstat (limited to 'src/com/android/launcher3/AppWidgetResizeFrame.java')
-rw-r--r--src/com/android/launcher3/AppWidgetResizeFrame.java54
1 files changed, 44 insertions, 10 deletions
diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java
index 90dcc80de..9b9d6e6d4 100644
--- a/src/com/android/launcher3/AppWidgetResizeFrame.java
+++ b/src/com/android/launcher3/AppWidgetResizeFrame.java
@@ -212,6 +212,23 @@ public class AppWidgetResizeFrame extends FrameLayout
lp.height = mTempRange1.size();
resizeWidgetIfNeeded(false);
+
+ // When the widget resizes in multi-window mode, the translation value changes to maintain
+ // a center fit. These overrides ensure the resize frame always aligns with the widget view.
+ getSnappedRectRelativeToDragLayer(sTmpRect);
+ if (mLeftBorderActive) {
+ lp.width = sTmpRect.width() + sTmpRect.left - lp.x;
+ }
+ if (mTopBorderActive) {
+ lp.height = sTmpRect.height() + sTmpRect.top - lp.y;
+ }
+ if (mRightBorderActive) {
+ lp.x = sTmpRect.left;
+ }
+ if (mBottomBorderActive) {
+ lp.y = sTmpRect.top;
+ }
+
requestLayout();
}
@@ -340,8 +357,8 @@ public class AppWidgetResizeFrame extends FrameLayout
int xThreshold = mCellLayout.getCellWidth();
int yThreshold = mCellLayout.getCellHeight();
- mDeltaXAddOn = mRunningHInc * xThreshold;
- mDeltaYAddOn = mRunningVInc * yThreshold;
+ mDeltaXAddOn = mRunningHInc * xThreshold;
+ mDeltaYAddOn = mRunningVInc * yThreshold;
mDeltaX = 0;
mDeltaY = 0;
@@ -353,18 +370,35 @@ public class AppWidgetResizeFrame extends FrameLayout
});
}
- public void snapToWidget(boolean animate) {
+ /**
+ * Returns the rect of this view when the frame is snapped around the widget, with the bounds
+ * relative to the {@link DragLayer}.
+ */
+ private void getSnappedRectRelativeToDragLayer(Rect out) {
float scale = mWidgetView.getScaleToFit();
- mDragLayer.getViewRectRelativeToSelf(mWidgetView, sTmpRect);
+ mDragLayer.getViewRectRelativeToSelf(mWidgetView, out);
+
+ int width = 2 * mBackgroundPadding
+ + (int) (scale * (out.width() - mWidgetPadding.left - mWidgetPadding.right));
+ int height = 2 * mBackgroundPadding
+ + (int) (scale * (out.height() - mWidgetPadding.top - mWidgetPadding.bottom));
- int newWidth = 2 * mBackgroundPadding
- + (int) (scale * (sTmpRect.width() - mWidgetPadding.left - mWidgetPadding.right));
- int newHeight = 2 * mBackgroundPadding
- + (int) (scale * (sTmpRect.height() - mWidgetPadding.top - mWidgetPadding.bottom));
+ int x = (int) (out.left - mBackgroundPadding + scale * mWidgetPadding.left);
+ int y = (int) (out.top - mBackgroundPadding + scale * mWidgetPadding.top);
- int newX = (int) (sTmpRect.left - mBackgroundPadding + scale * mWidgetPadding.left);
- int newY = (int) (sTmpRect.top - mBackgroundPadding + scale * mWidgetPadding.top);
+ out.left = x;
+ out.top = y;
+ out.right = out.left + width;
+ out.bottom = out.top + height;
+ }
+
+ public void snapToWidget(boolean animate) {
+ getSnappedRectRelativeToDragLayer(sTmpRect);
+ int newWidth = sTmpRect.width();
+ int newHeight = sTmpRect.height();
+ int newX = sTmpRect.left;
+ int newY = sTmpRect.top;
// We need to make sure the frame's touchable regions lie fully within the bounds of the
// DragLayer. We allow the actual handles to be clipped, but we shift the touch regions