OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.contextualsearch; | 5 package org.chromium.chrome.browser.contextualsearch; |
6 | 6 |
7 /** | 7 /** |
8 * Implements the policy that a Tap relatively far away from an existing Context
ual Search | 8 * Implements the policy that a Tap relatively far away from an existing Context
ual Search |
9 * selection should just dismiss our UX. When a Tap is close by, we assume the
user must have | 9 * selection should just dismiss our UX. When a Tap is close by, we assume the
user must have |
10 * missed the original intended target so we reselect based on the new Tap locat
ion. | 10 * missed the original intended target so we reselect based on the new Tap locat
ion. |
(...skipping 13 matching lines...) Expand all Loading... |
24 * @param y The y coordinate of the tap gesture. | 24 * @param y The y coordinate of the tap gesture. |
25 */ | 25 */ |
26 TapFarFromPreviousSuppression(ContextualSearchSelectionController controller
, | 26 TapFarFromPreviousSuppression(ContextualSearchSelectionController controller
, |
27 ContextualSearchTapState previousTapState, int x, int y) { | 27 ContextualSearchTapState previousTapState, int x, int y) { |
28 mPxToDp = controller.getPxToDp(); | 28 mPxToDp = controller.getPxToDp(); |
29 mPreviousTapState = previousTapState; | 29 mPreviousTapState = previousTapState; |
30 mShouldHandleTap = shouldHandleTap(x, y); | 30 mShouldHandleTap = shouldHandleTap(x, y); |
31 } | 31 } |
32 | 32 |
33 @Override | 33 @Override |
34 protected boolean isConditionSatisfied() { | 34 protected boolean isConditionSatisfiedAndEnabled() { |
35 return !mShouldHandleTap; | 35 return !mShouldHandleTap; |
36 } | 36 } |
37 | 37 |
38 @Override | 38 @Override |
39 protected boolean shouldAggregateLogForTapSuppression() { | 39 protected boolean shouldAggregateLogForTapSuppression() { |
40 return false; | 40 return false; |
41 } | 41 } |
42 | 42 |
43 @Override | 43 @Override |
44 protected boolean isConditionSatisfiedForAggregateLogging() { | 44 protected boolean isConditionSatisfiedForAggregateLogging() { |
(...skipping 13 matching lines...) Expand all Loading... |
58 * Determines whether a tap at the given coordinates is considered "close" t
o the previous | 58 * Determines whether a tap at the given coordinates is considered "close" t
o the previous |
59 * tap. | 59 * tap. |
60 */ | 60 */ |
61 private boolean wasTapCloseToPreviousTap(int x, int y) { | 61 private boolean wasTapCloseToPreviousTap(int x, int y) { |
62 float deltaXDp = (mPreviousTapState.getX() - x) * mPxToDp; | 62 float deltaXDp = (mPreviousTapState.getX() - x) * mPxToDp; |
63 float deltaYDp = (mPreviousTapState.getY() - y) * mPxToDp; | 63 float deltaYDp = (mPreviousTapState.getY() - y) * mPxToDp; |
64 float distanceSquaredDp = deltaXDp * deltaXDp + deltaYDp * deltaYDp; | 64 float distanceSquaredDp = deltaXDp * deltaXDp + deltaYDp * deltaYDp; |
65 return distanceSquaredDp <= RETAP_DISTANCE_SQUARED_DP; | 65 return distanceSquaredDp <= RETAP_DISTANCE_SQUARED_DP; |
66 } | 66 } |
67 } | 67 } |
OLD | NEW |