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

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: Created 5 years, 3 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 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.
// --------------------------------------------------------------------------------------------

Powered by Google App Engine
This is Rietveld 408576698