| Index: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/BarOverlapTapSuppression.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/BarOverlapTapSuppression.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/BarOverlapTapSuppression.java
|
| index ba7becad7082773d5535bd569ad959b09face2f2..a3b201b5f8cac2dbf1b0c0185300376f0a3b906c 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/BarOverlapTapSuppression.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/BarOverlapTapSuppression.java
|
| @@ -14,36 +14,34 @@ import org.chromium.chrome.browser.tab.Tab;
|
| */
|
| public class BarOverlapTapSuppression extends ContextualSearchHeuristic {
|
| private final ChromeActivity mActivity;
|
| - private final boolean mDoesBarOverlap;
|
| private final boolean mIsConditionSatisfied;
|
| + private final boolean mIsEnabled;
|
| private final float mPxToDp;
|
|
|
| /**
|
| * Constructs a Tap suppression heuristic that handles a Tap near where the Bar shows.
|
| * @param selectionController The {@link ContextualSearchSelectionController}.
|
| - * @param x The x position of the Tap.
|
| * @param y The y position of the Tap.
|
| */
|
| BarOverlapTapSuppression(
|
| - ContextualSearchSelectionController selectionController, int x, int y) {
|
| + ContextualSearchSelectionController selectionController, int y) {
|
| // TODO(donnd): rather than getting the Activity, find a way to access the panel
|
| // and ask it to determine overlap. E.g. isCoordinateInsidePeekingBarArea(x, y) modeled
|
| // after isCoordinateInsideBar(x, y).
|
| mPxToDp = selectionController.getPxToDp();
|
| mActivity = selectionController.getActivity();
|
| - mDoesBarOverlap = doesBarOverlap(x, y);
|
| - mIsConditionSatisfied =
|
| - mDoesBarOverlap && ContextualSearchFieldTrial.isBarOverlapSuppressionEnabled();
|
| + mIsEnabled = ContextualSearchFieldTrial.isBarOverlapSuppressionEnabled();
|
| + mIsConditionSatisfied = doesBarOverlap(y);
|
| }
|
|
|
| @Override
|
| protected boolean isConditionSatisfied() {
|
| - return mIsConditionSatisfied;
|
| + return mIsEnabled && mIsConditionSatisfied;
|
| }
|
|
|
| @Override
|
| protected void logConditionState() {
|
| - if (ContextualSearchFieldTrial.isBarOverlapSuppressionEnabled()) {
|
| + if (mIsEnabled) {
|
| ContextualSearchUma.logBarOverlapSuppression(mIsConditionSatisfied);
|
| }
|
| }
|
| @@ -52,13 +50,13 @@ public class BarOverlapTapSuppression extends ContextualSearchHeuristic {
|
| protected void logResultsSeen(boolean wasSearchContentViewSeen, boolean wasActivatedByTap) {
|
| if (ContextualSearchFieldTrial.isBarOverlapCollectionEnabled()) {
|
| ContextualSearchUma.logBarOverlapResultsSeen(
|
| - wasSearchContentViewSeen, wasActivatedByTap, mDoesBarOverlap);
|
| + wasSearchContentViewSeen, wasActivatedByTap, mIsConditionSatisfied);
|
| }
|
| }
|
|
|
| @Override
|
| protected boolean isConditionSatisfiedForAggregateLogging() {
|
| - return mDoesBarOverlap;
|
| + return !mIsEnabled && mIsConditionSatisfied;
|
| }
|
|
|
| /**
|
| @@ -77,10 +75,10 @@ public class BarOverlapTapSuppression extends ContextualSearchHeuristic {
|
| }
|
|
|
| /**
|
| - * @return Whether the Bar would overlap the given x,y coordinate when in its normal
|
| + * @return Whether the Bar would overlap the given y coordinate when in its normal
|
| * peeking state.
|
| */
|
| - private boolean doesBarOverlap(int x, int y) {
|
| + private boolean doesBarOverlap(int y) {
|
| float contentHeightPx = getContentHeightPx();
|
| if (contentHeightPx == 0) return false;
|
|
|
| @@ -89,12 +87,7 @@ public class BarOverlapTapSuppression extends ContextualSearchHeuristic {
|
| float barHeightDp = 56; // DPs
|
| float yDp = y * mPxToDp;
|
| float contentHeightDp = contentHeightPx * mPxToDp;
|
| - if (yDp < contentHeightDp - barHeightDp) return false;
|
|
|
| - // Is there also a horizontal overlap?
|
| - float overlayPanelWidth = 600;
|
| - Tab currentTab = mActivity.getActivityTab();
|
| - float overlayPanelX = (currentTab.getWidth() - overlayPanelWidth) / 2;
|
| - return x > overlayPanelX && x < overlayPanelX + overlayPanelWidth;
|
| + return yDp >= (contentHeightDp - barHeightDp);
|
| }
|
| }
|
|
|