Bug 1384021 - Enable Activity Stream for all users and remove experiment/setting. r=mcomella

MozReview-Commit-ID: NDTBevZfX1

--HG--
extra : rebase_source : 9f8ccdf804fa7d501e8bb570e6e0113d32cdf343
This commit is contained in:
Sebastian Kaspari 2017-08-02 18:58:31 +02:00
parent f333782a51
commit 51c4b1edea
8 changed files with 6 additions and 196 deletions

View File

@ -78,12 +78,6 @@
android:key="android.not_a_preference.category_experimental"
android:title="@string/pref_category_experimental">
<org.mozilla.gecko.activitystream.ActivityStreamPreference
android:key="android.not_a_preference.experiments.activitystream"
android:title="@string/pref_activity_stream"
android:summary="@string/pref_activity_stream_summary" />
<SwitchPreference android:key="android.not_a_preference.customtabs"
android:title="@string/pref_custom_tabs"
android:summary="@string/pref_custom_tabs_summary"

View File

@ -56,15 +56,6 @@ public class Experiments {
// Play HLS videos in a VideoView (Bug 1313391)
public static final String HLS_VIDEO_PLAYBACK = "hls-video-playback";
// Make new activity stream panel available (to replace top sites) (Bug 1313316)
public static final String ACTIVITY_STREAM = "activity-stream";
// Show a setting in "experimental features" for enabling/disabling activity stream.
public static final String ACTIVITY_STREAM_SETTING = "activity-stream-setting";
// Enable Activity stream by default for users in the "opt out" group.
public static final String ACTIVITY_STREAM_OPT_OUT = "activity-stream-opt-out";
// Show AddOns menu-item in top level menu
public static final String TOP_ADDONS_MENU = "top-addons-menu";

View File

@ -50,96 +50,13 @@ public class ActivityStream {
);
/**
* Returns true if the user has made an active decision: Enabling or disabling Activity Stream.
*/
public static boolean hasUserEnabledOrDisabled(Context context) {
final SharedPreferences preferences = GeckoSharedPrefs.forApp(context);
return preferences.contains(GeckoPreferences.PREFS_ACTIVITY_STREAM);
}
/**
* Set the user's decision: Enable or disable Activity Stream.
*/
public static void setUserEnabled(Context context, boolean value) {
GeckoSharedPrefs.forApp(context).edit()
.putBoolean(GeckoPreferences.PREFS_ACTIVITY_STREAM, value)
.apply();
}
/**
* Returns true if Activity Stream has been enabled by the user. Before calling this method
* hasUserEnabledOrDisabled() should be used to determine whether the user actually has made
* a decision.
*/
public static boolean isEnabledByUser(Context context) {
final SharedPreferences preferences = GeckoSharedPrefs.forApp(context);
if (!preferences.contains(GeckoPreferences.PREFS_ACTIVITY_STREAM)) {
throw new IllegalStateException("User hasn't made a decision. Call hasUserEnabledOrDisabled() before calling this method");
}
return preferences.getBoolean(GeckoPreferences.PREFS_ACTIVITY_STREAM, /* should not be used */ false);
}
/**
* Is Activity Stream enabled by an A/B experiment?
*/
public static boolean isEnabledByExperiment(Context context) {
// For users in the "opt out" group Activity Stream is enabled by default.
return SwitchBoard.isInExperiment(context, Experiments.ACTIVITY_STREAM_OPT_OUT);
}
/**
* Is Activity Stream enabled? Either actively by the user or by an experiment?
* Is Activity Stream enabled?
*/
public static boolean isEnabled(Context context) {
// (1) Can Activity Steam be enabled on this device?
if (!canBeEnabled(context)) {
return false;
}
// (2) Has Activity Stream be enabled/disabled by the user?
if (hasUserEnabledOrDisabled(context)) {
return isEnabledByUser(context);
}
// (3) Is Activity Stream enabled by an experiment?
return isEnabledByExperiment(context);
}
/**
* Can the user enable/disable Activity Stream (Returns true) or is this completely controlled by us?
*/
public static boolean isUserSwitchable(Context context) {
// (1) Can Activity Steam be enabled on this device?
if (!canBeEnabled(context)) {
return false;
}
// (2) Is the user part of the experiment for showing the settings UI?
return SwitchBoard.isInExperiment(context, Experiments.ACTIVITY_STREAM_SETTING);
}
/**
* This method returns true if Activity Stream can be enabled - by the user or an experiment.
* Whether a setting shows up or whether the user is in an experiment group is evaluated
* separately from this method. However if this methods returns false then Activity Stream
* should never be visible/enabled - no matter what build or what experiments are active.
*/
public static boolean canBeEnabled(Context context) {
if (!AppConstants.NIGHTLY_BUILD) {
// If this is not a Nightly build then hide Activity Stream completely. We can control
// this via the Switchboard experiment too but I want to make really sure that this
// isn't riding the trains accidentally.
return false;
}
if (!SwitchBoard.isInExperiment(context, Experiments.ACTIVITY_STREAM)) {
// This is our kill switch. If the user is not part of this experiment then show no
// Activity Stream UI.
return false;
}
// Activity stream can be enabled. Whether it is depends on other experiments and settings.
// Fennec 57+ here we come!
// The only reason this method still exists is so that the old home panel code isn't
// suddenly unused and triggers all kinds of lint errors. However we should clean
// this up soon (Bug 1386725).
return true;
}

View File

@ -1,77 +0,0 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.activitystream;
import android.content.Context;
import android.content.Intent;
import android.preference.SwitchPreference;
import android.util.AttributeSet;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.GeckoApplication;
import org.mozilla.gecko.util.ThreadUtils;
/**
* A custom switch preference that is used while we allow users to opt-out from using Activity Stream.
*/
public class ActivityStreamPreference extends SwitchPreference {
@SuppressWarnings("unused") // Used from XML
public ActivityStreamPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context);
}
@SuppressWarnings("unused") // Used from XML
public ActivityStreamPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
@SuppressWarnings("unused") // Used from XML
public ActivityStreamPreference(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
@SuppressWarnings("unused") // Used from XML
public ActivityStreamPreference(Context context) {
super(context);
init(context);
}
private void init(Context context) {
// The SwitchPreference shouldn't do any persistence itself. We want to avoid that a value
// is written that is not set by the user but set from an experiment.
setPersistent(false);
setChecked(ActivityStream.isEnabled(context));
}
@Override
public boolean isPersistent() {
// Just be absolutely sure that no one re-sets this value since calling init().
return false;
}
@Override
protected void onClick() {
super.onClick();
ActivityStream.setUserEnabled(getContext(), isChecked());
// We require a restart for this change to take effect. This is not nice, but this setting
// is not something we want to ship outside of Nightly anyways.
ThreadUtils.postDelayedToUiThread(new Runnable() {
@Override
public void run() {
final Intent restartIntent = new Intent(Intent.ACTION_MAIN);
restartIntent.setClassName(getContext().getApplicationContext(),
AppConstants.MOZ_ANDROID_BROWSER_INTENT_CLASS);
GeckoApplication.shutdown(restartIntent);
}
}, 1000);
}
}

View File

@ -163,7 +163,6 @@ public class GeckoPreferences
public static final String PREFS_READ_PARTNER_BOOKMARKS_PROVIDER = NON_PREF_PREFIX + "distribution.read_partner_bookmarks_provider";
public static final String PREFS_CUSTOM_TABS = NON_PREF_PREFIX + "customtabs";
public static final String PREFS_PWA = NON_PREF_PREFIX + "pwa";
public static final String PREFS_ACTIVITY_STREAM = NON_PREF_PREFIX + "experiments.activitystream";
public static final String PREFS_CATEGORY_EXPERIMENTAL_FEATURES = NON_PREF_PREFIX + "category_experimental";
public static final String PREFS_COMPACT_TABS = NON_PREF_PREFIX + "compact_tabs";
public static final String PREFS_SHOW_QUIT_MENU = NON_PREF_PREFIX + "distribution.show_quit_menu";
@ -677,8 +676,7 @@ public class GeckoPreferences
continue;
} else if (PREFS_CATEGORY_EXPERIMENTAL_FEATURES.equals(key)
&& !AppConstants.MOZ_ANDROID_PWA
&& !AppConstants.MOZ_ANDROID_CUSTOM_TABS
&& !ActivityStream.isUserSwitchable(this)) {
&& !AppConstants.MOZ_ANDROID_CUSTOM_TABS) {
preferences.removePreference(pref);
i--;
continue;
@ -876,11 +874,6 @@ public class GeckoPreferences
preferences.removePreference(pref);
i--;
continue;
} else if (PREFS_ACTIVITY_STREAM.equals(key)
&& !ActivityStream.isUserSwitchable(this)) {
preferences.removePreference(pref);
i--;
continue;
} else if (PREFS_COMPACT_TABS.equals(key)) {
if (HardwareUtils.isTablet()) {
preferences.removePreference(pref);

View File

@ -298,10 +298,6 @@
<!ENTITY pref_pwa "Progressive Web Apps">
<!ENTITY pref_pwa_summary "Allow web apps to be added to home screen">
<!-- Localization note (pref_activity_stream): Experimental feature, see https://testpilot.firefox.com/experiments/activity-stream -->
<!ENTITY pref_activity_stream "Activity Stream">
<!ENTITY pref_activity_stream_summary "A rich visual history feed and a reimagined home page make it easier than ever to find exactly what you\'re looking for in &brandShortName;.">
<!ENTITY tracking_protection_prompt_title "Now with Tracking Protection">
<!ENTITY tracking_protection_prompt_text "Actively block tracking elements so you don\'t have to worry.">
<!ENTITY tracking_protection_prompt_tip_text "Visit Privacy settings to learn more">

View File

@ -499,7 +499,6 @@ gbjar.sources += ['java/org/mozilla/gecko/' + x for x in [
'ActionModeCompatView.java',
'ActivityHandlerHelper.java',
'activitystream/ActivityStream.java',
'activitystream/ActivityStreamPreference.java',
'activitystream/ActivityStreamTelemetry.java',
'activitystream/homepanel/ActivityStreamHomeFragment.java',
'activitystream/homepanel/ActivityStreamHomeScreen.java',

View File

@ -250,9 +250,6 @@
<string name="pref_pwa">&pref_pwa;</string>
<string name="pref_pwa_summary">&pref_pwa_summary;</string>
<string name="pref_activity_stream">&pref_activity_stream;</string>
<string name="pref_activity_stream_summary">&pref_activity_stream_summary;</string>
<string name="pref_char_encoding">&pref_char_encoding;</string>
<string name="pref_char_encoding_on">&pref_char_encoding_on;</string>
<string name="pref_char_encoding_off">&pref_char_encoding_off;</string>