Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1026)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java

Issue 1337703002: [Contextual Search] Add support for crushed sprites and animate the search provider icon (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Very small changes from last pedrosimonneti@ review Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 a7ce11542692e550a7e39646fc6a46167418ee7a..c406f66eb6c98e770bedd47f7709a869c3daab1c 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
@@ -26,6 +26,7 @@ import javax.annotation.Nullable;
class ContextualSearchPolicy {
private static final Pattern CONTAINS_WHITESPACE_PATTERN = Pattern.compile("\\s");
private static final int REMAINING_NOT_APPLICABLE = -1;
+ private static final int ONE_DAY_IN_MILLIS = 24 * 60 * 60 * 1000;
private static ContextualSearchPolicy sInstance;
@@ -304,6 +305,39 @@ 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.
+ * @param isShowing Whether the panel is showing.
+ * @return Whether the search provider icon should be animated.
+ */
+ boolean shouldAnimateSearchProviderIcon(SelectionType selectionType, boolean isShowing) {
+ if (isShowing) {
+ return false;
+ }
+
+ if (selectionType == SelectionType.TAP) {
+ long currentTimeMillis = System.currentTimeMillis();
+ long lastAnimatedTimeMillis =
+ mPreferenceManager.getContextualSearchLastAnimationTime();
+ if (Math.abs(currentTimeMillis - lastAnimatedTimeMillis) > ONE_DAY_IN_MILLIS) {
+ mPreferenceManager.setContextualSearchLastAnimationTime(currentTimeMillis);
+ return true;
+ } else {
+ return false;
+ }
+ } else if (selectionType == SelectionType.LONG_PRESS) {
+ // If the panel has never been opened before, getPromoOpenCount() will be 0.
+ // Once the panel has been opened, regardless of whether or not the user has opted-in or
+ // opted-out, the promo open count will be greater than zero.
+ return getPromoOpenCount() == 0;
+ }
+
+ return false;
+ }
+
// --------------------------------------------------------------------------------------------
// Testing support.
// --------------------------------------------------------------------------------------------

Powered by Google App Engine
This is Rietveld 408576698