Commit 6fa3908a authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

[Home] Remove time restriction from Chrome Home info promo

This change removes the 60 second time restriction from the info-promo
and adds a shared preference to determine whether it was shown. As to
not conflict with the opt-in/out promo, when that experiment is
disabled, the info preference is set so that promo will not be
presented to the user.

BUG=789685

Change-Id: Iabe72822dd6e51b35427719454b48e1fb7818bd3
Reviewed-on: https://chromium-review.googlesource.com/809344
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523155}
parent 7452640f
...@@ -68,6 +68,8 @@ public class ChromePreferenceManager { ...@@ -68,6 +68,8 @@ public class ChromePreferenceManager {
public static final String CHROME_HOME_SHARED_PREFERENCES_KEY = "chrome_home_enabled_date"; public static final String CHROME_HOME_SHARED_PREFERENCES_KEY = "chrome_home_enabled_date";
public static final String CHROME_HOME_INFO_PROMO_SHOWN_KEY = "chrome_home_info_promo_shown";
private static class LazyHolder { private static class LazyHolder {
static final ChromePreferenceManager INSTANCE = new ChromePreferenceManager(); static final ChromePreferenceManager INSTANCE = new ChromePreferenceManager();
} }
...@@ -431,6 +433,20 @@ public class ChromePreferenceManager { ...@@ -431,6 +433,20 @@ public class ChromePreferenceManager {
mSharedPreferences.edit().remove(CHROME_HOME_USER_ENABLED_KEY).apply(); mSharedPreferences.edit().remove(CHROME_HOME_USER_ENABLED_KEY).apply();
} }
/**
* Set that the Chrome Home info-promo has been shown.
*/
public void setChromeHomeInfoPromoShown() {
writeBoolean(CHROME_HOME_INFO_PROMO_SHOWN_KEY, true);
}
/**
* @return Whether the info-only version of the Chrome Home promo has been shown.
*/
public boolean hasChromeHomeInfoPromoShown() {
return mSharedPreferences.getBoolean(CHROME_HOME_INFO_PROMO_SHOWN_KEY, false);
}
/** /**
* Mark that the Chrome Home opt-out snackbar has been shown. * Mark that the Chrome Home opt-out snackbar has been shown.
*/ */
......
...@@ -8,7 +8,6 @@ import android.annotation.SuppressLint; ...@@ -8,7 +8,6 @@ import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.os.Build; import android.os.Build;
...@@ -55,8 +54,6 @@ public class FeatureUtilities { ...@@ -55,8 +54,6 @@ public class FeatureUtilities {
private static final String ENABLED_EXPERIMENT_GROUP = "Enabled"; private static final String ENABLED_EXPERIMENT_GROUP = "Enabled";
private static final String DISABLED_EXPERIMENT_GROUP = "Disabled"; private static final String DISABLED_EXPERIMENT_GROUP = "Disabled";
private static final long CHROME_HOME_MAX_ENABLED_TIME_MS = 60000; // 60 seconds.
private static Boolean sHasGoogleAccountAuthenticator; private static Boolean sHasGoogleAccountAuthenticator;
private static Boolean sHasRecognitionIntentHandler; private static Boolean sHasRecognitionIntentHandler;
private static Boolean sChromeHomeEnabled; private static Boolean sChromeHomeEnabled;
...@@ -288,6 +285,9 @@ public class FeatureUtilities { ...@@ -288,6 +285,9 @@ public class FeatureUtilities {
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO) if (!ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO)
&& manager.isChromeHomeUserPreferenceSet()) { && manager.isChromeHomeUserPreferenceSet()) {
// If we showed the user the old promo, set the info promo preference so that it is not
// presented when the opt-in/out promo is turned off.
manager.setChromeHomeInfoPromoShown();
manager.clearChromeHomeUserPreference(); manager.clearChromeHomeUserPreference();
} }
...@@ -387,27 +387,25 @@ public class FeatureUtilities { ...@@ -387,27 +387,25 @@ public class FeatureUtilities {
public static boolean shouldShowChromeHomePromoForStartup() { public static boolean shouldShowChromeHomePromoForStartup() {
if (DeviceFormFactor.isTablet()) return false; if (DeviceFormFactor.isTablet()) return false;
ChromePreferenceManager prefManager = ChromePreferenceManager.getInstance();
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO_INFO_ONLY)
&& isChromeHomeEnabled()) {
prefManager.setChromeHomeInfoPromoShown();
}
// The preference will be set if the promo has been seen before. If that is the case, do not // The preference will be set if the promo has been seen before. If that is the case, do not
// show it again. // show it again.
ChromePreferenceManager prefManager = ChromePreferenceManager.getInstance();
boolean isChromeHomePrefSet = prefManager.isChromeHomeUserPreferenceSet(); boolean isChromeHomePrefSet = prefManager.isChromeHomeUserPreferenceSet();
if (isChromeHomePrefSet) return false; if (isChromeHomePrefSet) return false;
if (isChromeHomeEnabled() if (isChromeHomeEnabled()
&& ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO_INFO_ONLY)) { && ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO_INFO_ONLY)) {
long chromeHomeEnabledDate = System.currentTimeMillis(); boolean promoShown;
try (StrictModeContext unused = StrictModeContext.allowDiskReads()) { try (StrictModeContext unused = StrictModeContext.allowDiskReads()) {
SharedPreferences sharedPreferences = ContextUtils.getAppSharedPreferences(); promoShown = ChromePreferenceManager.getInstance().hasChromeHomeInfoPromoShown();
chromeHomeEnabledDate = sharedPreferences.getLong(
ChromePreferenceManager.CHROME_HOME_SHARED_PREFERENCES_KEY,
chromeHomeEnabledDate);
} }
return !promoShown;
long timeDeadlineForPromo = chromeHomeEnabledDate + CHROME_HOME_MAX_ENABLED_TIME_MS;
// If Chrome Home has been enabled for < 60 seconds, show the info dialog.
return System.currentTimeMillis() < timeDeadlineForPromo;
} else if (!isChromeHomeEnabled() } else if (!isChromeHomeEnabled()
&& ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO) && ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO)
&& ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO_ON_STARTUP)) { && ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO_ON_STARTUP)) {
......
mdjones@chromium.org
twellington@chromium.org
...@@ -95,6 +95,9 @@ public class ChromeHomePromoDialog extends PromoDialog { ...@@ -95,6 +95,9 @@ public class ChromeHomePromoDialog extends PromoDialog {
if (DeviceFormFactor.isTablet()) { if (DeviceFormFactor.isTablet()) {
throw new RuntimeException("Promo should not be shown for tablet devices!"); throw new RuntimeException("Promo should not be shown for tablet devices!");
} }
if (ChromeFeatureList.isEnabled(ChromeFeatureList.CHROME_HOME_PROMO_INFO_ONLY)) {
ChromePreferenceManager.getInstance().setChromeHomeInfoPromoShown();
}
super.show(); super.show();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment