Commit f237b069 authored by Donn Denman's avatar Donn Denman Committed by Commit Bot

[TTS] Fix touch-highlight in the new layout in RTL

Touch highlight had some bugs in the new layout when not drawing
full width and in RTL.

This CL reworks the highlight calculations to fix the problems
and make the code easier to understand.

BUG=1016976

Change-Id: I911991b991a16296edce7b5d0c5061034497a304
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1906341Reviewed-by: default avatarJinsuk Kim <jinsukkim@chromium.org>
Commit-Queue: Donn Denman <donnd@chromium.org>
Auto-Submit: Donn Denman <donnd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714355}
parent 29a8695d
...@@ -569,32 +569,34 @@ public class ContextualSearchBarControl { ...@@ -569,32 +569,34 @@ public class ContextualSearchBarControl {
assert ChromeFeatureList.isEnabled(ChromeFeatureList.OVERLAY_NEW_LAYOUT); assert ChromeFeatureList.isEnabled(ChromeFeatureList.OVERLAY_NEW_LAYOUT);
// There are 3 cases: // There are 3 cases:
// 1) The whole Bar minus icon (when the icon is present) // 1) The whole Bar (without any icons)
// 2) The icon // 2) The Bar minus icon (when the icon is present)
// 3) The whole Bar (without any icons) // 3) The icon
boolean wereIconsVisibleOnTouch = !mContextualSearchPanel.isPeeking();
int panelWidth = mContextualSearchPanel.getContentViewWidthPx(); int panelWidth = mContextualSearchPanel.getContentViewWidthPx();
if (wereIconsVisibleOnTouch) { if (mContextualSearchPanel.isPeeking()) {
float iconOffsetPx = (mContextualSearchPanel.getOpenTabIconX() // Case 1 - whole Bar.
- mContextualSearchPanel.getButtonPaddingDps()) mTouchHighlightXOffsetPx = 0;
mTouchHighlightWidthPx = panelWidth;
} else {
// The open-tab-icon is on the right (on the left in RTL).
boolean isRtl = LocalizationUtils.isLayoutRtl();
float paddedIconWithMarginWidth =
(mContextualSearchPanel.getBarMarginSide()
+ mContextualSearchPanel.getOpenTabIconDimension()
+ mContextualSearchPanel.getButtonPaddingDps())
* mDpToPx; * mDpToPx;
if (xPx < iconOffsetPx) { float contentWidth = panelWidth - paddedIconWithMarginWidth;
// Case 1 - whole Bar minus icon. // Adjust the touch point to panel coordinates.
mTouchHighlightXOffsetPx = 0; xPx -= mContextualSearchPanel.getOffsetX() * mDpToPx;
mTouchHighlightWidthPx = iconOffsetPx; if (isRtl && xPx > paddedIconWithMarginWidth || !isRtl && xPx < contentWidth) {
// Case 2 - Bar minus icon.
mTouchHighlightXOffsetPx = isRtl ? paddedIconWithMarginWidth : 0;
mTouchHighlightWidthPx = contentWidth;
} else { } else {
// Case 2 - the icon. // Case 3 - the icon.
mTouchHighlightXOffsetPx = iconOffsetPx; mTouchHighlightXOffsetPx = isRtl ? 0 : contentWidth;
mTouchHighlightWidthPx = panelWidth - iconOffsetPx; mTouchHighlightWidthPx = paddedIconWithMarginWidth;
} }
} else {
// Case 3 - whole Bar.
mTouchHighlightXOffsetPx = 0;
mTouchHighlightWidthPx = panelWidth;
}
// If RTL then width is correct, just move offset to the other side of the panel.
if (LocalizationUtils.isLayoutRtl()) {
mTouchHighlightXOffsetPx = panelWidth - mTouchHighlightXOffsetPx;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment