summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/popup/PopupContainerWithArrow.java
diff options
context:
space:
mode:
authorTony <twickham@google.com>2017-12-22 13:54:08 -0800
committerTony <twickham@google.com>2017-12-22 13:54:08 -0800
commitefacffa08a1a584371b2f42590c6b8d8d6eca2a8 (patch)
tree467aec8ca532e1240dc3b3e92219d55f76fd8fe4 /src/com/android/launcher3/popup/PopupContainerWithArrow.java
parent9558a884ddf52a38d471477abbc6b52c853471a9 (diff)
downloadandroid_packages_apps_Trebuchet-efacffa08a1a584371b2f42590c6b8d8d6eca2a8.tar.gz
android_packages_apps_Trebuchet-efacffa08a1a584371b2f42590c6b8d8d6eca2a8.tar.bz2
android_packages_apps_Trebuchet-efacffa08a1a584371b2f42590c6b8d8d6eca2a8.zip
Fix popup container alignment issues
- Arrow did not line up with the icon when right aligned - Popup was always centered horizontally in RTL instead of aligning with the icon Change-Id: I90e065d0b0c1c59166e5c2e5de5e6cff9126ee6f
Diffstat (limited to 'src/com/android/launcher3/popup/PopupContainerWithArrow.java')
-rw-r--r--src/com/android/launcher3/popup/PopupContainerWithArrow.java18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index a166dff0f..6481183e1 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -341,15 +341,17 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
updateDividers();
// Add the arrow.
- final int arrowHorizontalOffset = getResources().getDimensionPixelSize(isAlignedWithStart()
- ? R.dimen.popup_arrow_horizontal_offset_start
- : R.dimen.popup_arrow_horizontal_offset_end);
+ final Resources res = getResources();
+ final int arrowCenterOffset = res.getDimensionPixelSize(isAlignedWithStart()
+ ? R.dimen.popup_arrow_horizontal_center_start
+ : R.dimen.popup_arrow_horizontal_center_end);
+ final int halfArrowWidth = res.getDimensionPixelSize(R.dimen.popup_arrow_width) / 2;
mLauncher.getDragLayer().addView(mArrow);
DragLayer.LayoutParams arrowLp = (DragLayer.LayoutParams) mArrow.getLayoutParams();
if (mIsLeftAligned) {
- mArrow.setX(getX() + arrowHorizontalOffset);
+ mArrow.setX(getX() + arrowCenterOffset - halfArrowWidth);
} else {
- mArrow.setX(getX() + getMeasuredWidth() - arrowHorizontalOffset);
+ mArrow.setX(getX() + getMeasuredWidth() - arrowCenterOffset - halfArrowWidth);
}
if (Gravity.isVertical(mGravity)) {
@@ -435,9 +437,6 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
x = rightAlignedX;
}
mIsLeftAligned = x == leftAlignedX;
- if (mIsRtl) {
- x -= dragLayer.getWidth() - width;
- }
// Offset x so that the arrow and shortcut icons are center-aligned with the original icon.
int iconWidth = mOriginalIcon.getWidth()
@@ -529,8 +528,7 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
// enforce contained is within screen
DragLayer dragLayer = mLauncher.getDragLayer();
- if (getTranslationX() + l < 0 ||
- getTranslationX() + r > dragLayer.getWidth()) {
+ if (getTranslationX() + l < 0 || getTranslationX() + r > dragLayer.getWidth()) {
// If we are still off screen, center horizontally too.
mGravity |= Gravity.CENTER_HORIZONTAL;
}