Bug 1445799 - User Attribute for Leanplum for Android Users that have Opted Out of Pocket in their Top Sites; r?mcomella
Added a new user attribute in LP: "Top Sites by Pocket" to indicate if the user has the feature enabled or not, which will stored in LP along with the other attributes when the app first starts.
MozReview-Commit-ID: IWieAorkB1P
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/ActivityStreamPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/ActivityStreamPanel.java
@@ -134,16 +134,22 @@ public class ActivityStreamPanel extends
// Destroy loaders so they don't restart loading when returning.
lm.destroyLoader(LOADER_ID_HIGHLIGHTS);
lm.destroyLoader(LOADER_ID_POCKET);
load(lm);
}
+ public static boolean isPocketRecommendingTopSites(final Context context) {
+ return ActivityStreamConfiguration.isPocketEnabledByLocale(context) &&
+ GeckoSharedPrefs.forProfile(context).getBoolean(ActivityStreamPanel.PREF_POCKET_ENABLED,
+ context.getResources().getBoolean(R.bool.pref_activitystream_pocket_enabled_default));
+ }
+
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
// This code does two things:
// * Calculate the size of the tiles we want to display (using a desired width as anchor point)
// * Add padding to the left/right side if there's too much space that we do not need
--- a/mobile/android/base/java/org/mozilla/gecko/mma/MmaDelegate.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaDelegate.java
@@ -18,16 +18,17 @@ import android.support.annotation.NonNul
import android.text.TextUtils;
import org.mozilla.gecko.Experiments;
import org.mozilla.gecko.MmaConstants;
import org.mozilla.gecko.PrefsHelper;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Tab;
import org.mozilla.gecko.Tabs;
+import org.mozilla.gecko.activitystream.homepanel.ActivityStreamPanel;
import org.mozilla.gecko.fxa.FirefoxAccounts;
import org.mozilla.gecko.preferences.GeckoPreferences;
import org.mozilla.gecko.switchboard.SwitchBoard;
import org.mozilla.gecko.util.ContextUtils;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
@@ -50,16 +51,17 @@ public class MmaDelegate {
public static final String DISMISS_ONBOARDING = "E_Dismiss_Onboarding";
public static final String USER_ATT_FOCUS_INSTALLED = "Focus Installed";
public static final String USER_ATT_KLAR_INSTALLED = "Klar Installed";
public static final String USER_ATT_POCKET_INSTALLED = "Pocket Installed";
public static final String USER_ATT_DEFAULT_BROWSER = "Default Browser";
public static final String USER_ATT_SIGNED_IN = "Signed In Sync";
+ public static final String USER_ATT_TOP_SITES_POCKET = "Top Sites by Pocket";
public static final String PACKAGE_NAME_KLAR = "org.mozilla.klar";
public static final String PACKAGE_NAME_FOCUS = "org.mozilla.focus";
public static final String PACKAGE_NAME_POCKET = "com.ideashower.readitlater.pro";
private static final String TAG = "MmaDelegate";
public static final String KEY_ANDROID_PREF_STRING_LEANPLUM_DEVICE_ID = "android.not_a_preference.leanplum.device_id";
@@ -97,16 +99,17 @@ public class MmaDelegate {
final Map<String, Object> attributes = new HashMap<>();
attributes.put(USER_ATT_FOCUS_INSTALLED, ContextUtils.isPackageInstalled(context, PACKAGE_NAME_FOCUS));
attributes.put(USER_ATT_KLAR_INSTALLED, ContextUtils.isPackageInstalled(context, PACKAGE_NAME_KLAR));
attributes.put(USER_ATT_POCKET_INSTALLED, ContextUtils.isPackageInstalled(context, PACKAGE_NAME_POCKET));
attributes.put(USER_ATT_DEFAULT_BROWSER, isDefaultBrowser(context));
attributes.put(USER_ATT_SIGNED_IN, FirefoxAccounts.firefoxAccountsExist(context));
+ attributes.put(USER_ATT_TOP_SITES_POCKET, ActivityStreamPanel.isPocketRecommendingTopSites(context));
return attributes;
}
public static void track(String event) {
if (applicationContext != null && isMmaEnabled(applicationContext.get())) {
mmaHelper.event(event);
}