зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1358117 - Add pref to turn on/off leanplum. r=maliu,sebastian
MozReview-Commit-ID: 8LHvMPSxAdl --HG-- extra : rebase_source : fb968097e7722ebcfb1245c366f9224c5a57857f
This commit is contained in:
Родитель
6e2ac80093
Коммит
3558f2df91
|
@ -414,6 +414,15 @@ pref("ui.bookmark.mobilefolder.enabled", true);
|
|||
pref("ui.bookmark.mobilefolder.enabled", false);
|
||||
#endif
|
||||
|
||||
#if MOZ_UPDATE_CHANNEL == nightly
|
||||
pref("mma.enabled", true);
|
||||
#elif MOZ_UPDATE_CHANNEL == beta
|
||||
pref("mma.enabled", true);
|
||||
#else
|
||||
pref("mma.enabled", true);
|
||||
#endif
|
||||
|
||||
|
||||
pref("ui.touch.radius.enabled", false);
|
||||
pref("ui.touch.radius.leftmm", 3);
|
||||
pref("ui.touch.radius.topmm", 5);
|
||||
|
|
|
@ -10,18 +10,40 @@ import android.app.Application;
|
|||
import android.content.Context;
|
||||
|
||||
import org.mozilla.gecko.MmaConstants;
|
||||
import org.mozilla.gecko.PrefsHelper;
|
||||
|
||||
|
||||
public class MmaDelegate {
|
||||
|
||||
private static final String ENABLE_PREF = "mma.enabled";
|
||||
|
||||
private static MmaInterface mmaHelper = MmaConstants.getMma();
|
||||
|
||||
private static final String[] prefs = { ENABLE_PREF };
|
||||
|
||||
|
||||
public static void init(Application application) {
|
||||
mmaHelper.init(application);
|
||||
setupPrefHandler(application);
|
||||
}
|
||||
|
||||
public void start(Context context) {
|
||||
mmaHelper.start(context);
|
||||
public static void stop() {
|
||||
mmaHelper.stop();
|
||||
}
|
||||
|
||||
private static void setupPrefHandler(final Application application) {
|
||||
PrefsHelper.PrefHandler handler = new PrefsHelper.PrefHandlerBase() {
|
||||
@Override
|
||||
public void prefValue(String pref, boolean value) {
|
||||
if (pref.equals(ENABLE_PREF)) {
|
||||
if (value) {
|
||||
mmaHelper.init(application);
|
||||
} else {
|
||||
mmaHelper.stop();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
PrefsHelper.addObserver(prefs, handler);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,4 +19,5 @@ public interface MmaInterface {
|
|||
|
||||
void track(String leanplumEvent, double value);
|
||||
|
||||
void stop();
|
||||
}
|
||||
|
|
|
@ -49,4 +49,9 @@ public class MmaLeanplumImp implements MmaInterface {
|
|||
Leanplum.track(leanplumEvent, value);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
Leanplum.stop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,4 +30,9 @@ public class MmaStubImp implements MmaInterface {
|
|||
public void track(String leanplumEvent, double value) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.mozilla.gecko.activitystream.ActivityStream;
|
|||
import org.mozilla.gecko.db.BrowserContract.SuggestedSites;
|
||||
import org.mozilla.gecko.feeds.FeedService;
|
||||
import org.mozilla.gecko.feeds.action.CheckForUpdatesAction;
|
||||
import org.mozilla.gecko.mma.MmaDelegate;
|
||||
import org.mozilla.gecko.permissions.Permissions;
|
||||
import org.mozilla.gecko.restrictions.Restrictable;
|
||||
import org.mozilla.gecko.restrictions.Restrictions;
|
||||
|
@ -1197,6 +1198,9 @@ public class GeckoPreferences
|
|||
} else if (PREFS_HEALTHREPORT_UPLOAD_ENABLED.equals(prefName)) {
|
||||
final Boolean newBooleanValue = (Boolean) newValue;
|
||||
AdjustConstants.getAdjustHelper().setEnabled(newBooleanValue);
|
||||
if (!newBooleanValue) {
|
||||
MmaDelegate.stop();
|
||||
}
|
||||
} else if (PREFS_GEO_REPORTING.equals(prefName)) {
|
||||
if ((Boolean) newValue) {
|
||||
enableStumbler((CheckBoxPreference) preference);
|
||||
|
|
|
@ -1021,7 +1021,7 @@ public class Leanplum {
|
|||
* Call this to explicitly end the session. This should not be used in most cases, so we won't
|
||||
* make it public for now.
|
||||
*/
|
||||
static void stop() {
|
||||
public static void stop() {
|
||||
if (Constants.isNoop()) {
|
||||
return;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче