Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java |
| index b7c134d46e2a60ac6ac9210c0d1b47f271e78aef..33c58b52b8b2409b743ab21260694d518911d036 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java |
| @@ -15,6 +15,8 @@ import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
| import org.chromium.content.browser.ContentViewCore; |
| import java.net.URL; |
| +import java.text.SimpleDateFormat; |
| +import java.util.Date; |
| import java.util.regex.Pattern; |
| import javax.annotation.Nullable; |
| @@ -269,6 +271,30 @@ class ContextualSearchPolicy { |
| return !isUserUndecided(); |
| } |
| + /** |
| + * The search provider icon is animated every time on long press if the user has never opened |
| + * the panel before and once a day on tap. |
| + * |
| + * @param selectionType The type of selection made by the user. |
| + * @return Whether the search provider icon should be animated. |
| + */ |
| + boolean shouldAnimateSearchProviderIcon(SelectionType selectionType) { |
| + if (selectionType == SelectionType.TAP) { |
| + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-d"); |
|
newt (away)
2015/09/11 23:01:15
Using System.currentTimeMillis() is much more effi
Theresa
2015/09/14 19:48:24
Done.
|
| + String date = dateFormat.format(new Date()); |
| + if (mPreferenceManager.getContextualSearchLastTapDate().equals(date)) { |
| + return false; |
| + } else { |
| + mPreferenceManager.setContextualSearchLastTapDate(date); |
| + return true; |
| + } |
| + } else if (selectionType == SelectionType.LONG_PRESS) { |
| + return DisableablePromoTapCounter.getInstance(mPreferenceManager).isEnabled(); |
| + } |
| + |
| + return false; |
| + } |
| + |
| // -------------------------------------------------------------------------------------------- |
| // Testing support. |
| // -------------------------------------------------------------------------------------------- |