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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionPromoUtils.java

Issue 2367403005: Snackbar for promoting Data Saver to existing users (Closed)
Patch Set: Add space for TalkBack Created 4 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/preferences/datareduction/DataReductionPromoUtils.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionPromoUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionPromoUtils.java
index 9866be882a9f1184963f5c2582fb6c23685b9c5f..4bde1a11895af01c4704f5d98b62bca7fe4fb186 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionPromoUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/datareduction/DataReductionPromoUtils.java
@@ -15,25 +15,49 @@ import org.chromium.chrome.browser.preferences.PrefServiceBridge.AboutVersionStr
*/
public class DataReductionPromoUtils {
/**
- * Keys used to save whether the first run experience or second run promo screen has been shown,
- * the time in milliseconds since epoch it was shown, the Chrome version it was shown in, and
- * whether the user opted out of the data reduction proxy in the FRE promo.
+ * Key used to save whether the first run experience or second run promo screen has been shown.
*/
private static final String SHARED_PREF_DISPLAYED_FRE_OR_SECOND_RUN_PROMO =
"displayed_data_reduction_promo";
+ /**
+ * Key used to save the time in milliseconds since epoch that the first run experience or second
+ * run promo was shown.
+ */
private static final String SHARED_PREF_DISPLAYED_FRE_OR_SECOND_PROMO_TIME_MS =
"displayed_data_reduction_promo_time_ms";
+ /**
+ * Key used to save the Chrome version the first run experience or second run promo was shown
+ * in.
+ */
private static final String SHARED_PREF_DISPLAYED_FRE_OR_SECOND_PROMO_VERSION =
"displayed_data_reduction_promo_version";
+ /**
+ * Key used to save whether the user opted out of the data reduction proxy in the FRE promo.
+ */
private static final String SHARED_PREF_FRE_PROMO_OPT_OUT = "fre_promo_opt_out";
-
/**
- * Keys used to save whether the infobar promo is shown and the Chrome version it was shown in.
+ * Key used to save whether the infobar promo has been shown.
*/
private static final String SHARED_PREF_DISPLAYED_INFOBAR_PROMO =
"displayed_data_reduction_infobar_promo";
+ /**
+ * Key used to save the Chrome version the infobar promo was shown in.
+ */
private static final String SHARED_PREF_DISPLAYED_INFOBAR_PROMO_VERSION =
"displayed_data_reduction_infobar_promo_version";
+ /**
+ * Key used to save the content length when the snackbar promo was last shown.
+ */
+ private static final String SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_CONTENT_LENGTH =
+ "displayed_data_reduction_snackbar_promo_content_length";
+ /**
+ * Key used to save if the user has initialized the content length for the snackbar promo on the
+ * first upgrade to the version that shows the snackbar. This is for existing users. If they're
+ * already past a promo data saving content length when upgrading, they will skip seeing that
+ * promo.
+ */
+ private static final String SHARED_PREF_SNACKBAR_PROMO_INIT_WITH_STARTING_CONTENT_LENGTH =
+ "data_reduction_snackbar_promo_init_with_starting_content_length";
/**
* Returns whether any of the data reduction proxy promotions can be displayed. Checks if the
@@ -139,4 +163,46 @@ public class DataReductionPromoUtils {
return ContextUtils.getAppSharedPreferences().getBoolean(
SHARED_PREF_DISPLAYED_INFOBAR_PROMO, false);
}
+
+ /** See {@link #SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_CONTENT_LENGTH}. */
+ public static void saveSnackbarPromoDisplayed(long contentLength) {
+ ContextUtils.getAppSharedPreferences()
+ .edit()
+ .putLong(SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_CONTENT_LENGTH, contentLength)
+ .apply();
+ }
+
+ /**
+ * Returns the content length from when the promo snackbar was last displayed.
+ *
+ * @return The content length, or -1 if the promo has not been displayed before.
+ */
+ public static long getDisplayedSnackbarPromoContentLength() {
+ return ContextUtils.getAppSharedPreferences().getLong(
+ SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_CONTENT_LENGTH, -1);
+ }
+
+ /**
+ * Saves a shared pref indicating the content length on the first upgrade to the version that
+ * shows the snackbar. Also, saves a boolean indicating that the content length has been
+ * initialized.
+ */
+ public static void saveSnackbarPromoInitWithStartingContentLength(long contentLength) {
tbansal1 2016/10/25 23:15:13 Is the argument content length or saved bytes?
megjablon 2016/10/25 23:49:57 Done.
+ ContextUtils.getAppSharedPreferences()
+ .edit()
+ .putBoolean(SHARED_PREF_SNACKBAR_PROMO_INIT_WITH_STARTING_CONTENT_LENGTH, true)
+ .putLong(SHARED_PREF_DISPLAYED_SNACKBAR_PROMO_CONTENT_LENGTH, contentLength)
+ .apply();
+ }
+
+ /**
+ * Returns a boolean indicating that the content length on the first upgrade or install to the
+ * version that shows the snackbar has been initialized.
+ *
+ * @return Whether that the starting content length has been initialized.
+ */
+ public static boolean hasSnackbarPromoBeenInitWithStartingContentLength() {
+ return ContextUtils.getAppSharedPreferences().getBoolean(
+ SHARED_PREF_SNACKBAR_PROMO_INIT_WITH_STARTING_CONTENT_LENGTH, false);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698