Bug 1547924 - Ensure Leanplum Onboarding falls back to the new Onboarding UX; r=VladBaicu a=pascalc
authorPetru Lingurar <petru.lingurar@softvision.ro>
Tue, 30 Apr 2019 16:43:46 +0300
changeset 536514 54457d76cd8cc055a48a4955822e937511e1b460
parent 536513 0a91cbfe3b3fa04f0af0adcaff33c8dc3b4a345d
child 536515 d674f0f91eb487be6b23ea00f607da8843d079b4
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersVladBaicu, pascalc
bugs1547924
milestone68.0
Bug 1547924 - Ensure Leanplum Onboarding falls back to the new Onboarding UX; r=VladBaicu a=pascalc Summary: - Added the `LAST_PRIVACY` case for when the user is already signed into Firefox; - Use the new default onboarding strings and images. If they are localized. Differential Revision: https://phabricator.services.mozilla.com/D29347
mobile/android/base/java/org/mozilla/gecko/mma/LeanplumVariables.java
mobile/android/base/java/org/mozilla/gecko/mma/MmaLeanplumImp.java
--- a/mobile/android/base/java/org/mozilla/gecko/mma/LeanplumVariables.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/LeanplumVariables.java
@@ -8,16 +8,18 @@ package org.mozilla.gecko.mma;
 import android.content.Context;
 import android.content.res.Resources;
 import android.support.annotation.DrawableRes;
 import android.support.annotation.NonNull;
 
 import com.leanplum.annotations.Variable;
 
 import org.mozilla.gecko.R;
+import org.mozilla.gecko.firstrun.FirstrunPanel;
+import org.mozilla.gecko.util.OnboardingStringUtil;
 
 import java.lang.reflect.Field;
 
 /**
  * Unified repo for all LeanPlum variables.<br>
  * <ul>To make them appear in the LP dashboard and get new values from the server
  *      <li>they must be annotated with {@link com.leanplum.annotations.Variable}.</li>
  *      <li>they need to be parsed with {@link com.leanplum.annotations.Parser} after {@link com.leanplum.Leanplum#setApplicationContext(Context)}</li>
@@ -72,35 +74,53 @@ public class LeanplumVariables {
     }
 
     /**
      * Allows setting default values for instance variables.
      * @param context used to access application resources
      */
     private LeanplumVariables(@NonNull Context context) {
         appResources = context.getResources();
+
+        // Same titles for the screens of the old / new onboarding UX.
         welcomePanelTitle = appResources.getString(R.string.firstrun_panel_title_welcome);
-        welcomePanelMessage = appResources.getString(R.string.firstrun_urlbar_message);
-        welcomePanelSubtext = appResources.getString(R.string.firstrun_urlbar_subtext);
-        welcomeDrawableId = R.drawable.firstrun_welcome;
+        privacyPanelTitle = appResources.getString(R.string.firstrun_panel_title_privacy);
+        customizePanelTitle = appResources.getString(R.string.firstrun_panel_title_customize);
+        syncPanelTitle = appResources.getString(R.string.firstrun_sync_title);
 
-        privacyPanelTitle = appResources.getString(R.string.firstrun_panel_title_privacy);
-        privacyPanelMessage = appResources.getString(R.string.firstrun_privacy_message);
-        privacyPanelSubtext = appResources.getString(R.string.firstrun_privacy_subtext);
-        privacyDrawableId = R.drawable.firstrun_private;
+        // The new Onboarding UX uses different messages and images. Only if they are localized.
+        if (OnboardingStringUtil.getInstance(context).areStringsLocalized()) {
+            welcomePanelMessage = appResources.getString(R.string.newfirstrun_urlbar_message);
+            welcomePanelSubtext = appResources.getString(R.string.newfirstrun_privacy_subtext);
+            welcomeDrawableId = R.drawable.firstrun_welcome2;
+
+            privacyPanelMessage = FirstrunPanel.NO_MESSAGE;
+            privacyPanelSubtext = appResources.getString(R.string.newfirstrun_privacy_subtext);
+            privacyDrawableId = R.drawable.firstrun_private2;
 
-        customizePanelTitle = appResources.getString(R.string.firstrun_panel_title_customize);
-        customizePanelMessage = appResources.getString(R.string.firstrun_customize_message);
-        customizePanelSubtext = appResources.getString(R.string.firstrun_customize_subtext);
-        customizingDrawableId = R.drawable.firstrun_data;
+            syncPanelMessage = FirstrunPanel.NO_MESSAGE;
+            syncPanelSubtext = appResources.getString(R.string.newfirstrun_sync_subtext);
+            syncDrawableId = R.drawable.firstrun_sync2;
+        } else {
+            welcomePanelMessage = appResources.getString(R.string.firstrun_urlbar_message);
+            welcomePanelSubtext = appResources.getString(R.string.firstrun_urlbar_subtext);
+            welcomeDrawableId = R.drawable.firstrun_welcome;
 
-        syncPanelTitle = appResources.getString(R.string.firstrun_sync_title);
-        syncPanelMessage = appResources.getString(R.string.firstrun_sync_message);
-        syncPanelSubtext = appResources.getString(R.string.firstrun_sync_subtext);
-        syncDrawableId = R.drawable.firstrun_sync;
+            privacyPanelMessage = appResources.getString(R.string.firstrun_privacy_message);
+            privacyPanelSubtext = appResources.getString(R.string.firstrun_privacy_subtext);
+            privacyDrawableId = R.drawable.firstrun_private;
+
+            customizePanelMessage = appResources.getString(R.string.firstrun_customize_message);
+            customizePanelSubtext = appResources.getString(R.string.firstrun_customize_subtext);
+            customizingDrawableId = R.drawable.firstrun_data;
+
+            syncPanelMessage = appResources.getString(R.string.firstrun_sync_message);
+            syncPanelSubtext = appResources.getString(R.string.firstrun_sync_subtext);
+            syncDrawableId = R.drawable.firstrun_sync;
+        }
     }
 
     public static int getWelcomeImage() {
         return welcomeDrawableId;
     }
 
     public static int getPrivacyImage() {
         return privacyDrawableId;
--- a/mobile/android/base/java/org/mozilla/gecko/mma/MmaLeanplumImp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/mma/MmaLeanplumImp.java
@@ -165,16 +165,17 @@ public class MmaLeanplumImp implements M
             throw new UnsupportedOperationException("Cannot build remote panel config with local values");
         }
 
         switch (type) {
             case WELCOME:
                 return new PanelConfig(type, useLocalValues, LeanplumVariables.welcomePanelTitle, LeanplumVariables.welcomePanelMessage,
                         LeanplumVariables.welcomePanelSubtext, LeanplumVariables.getWelcomeImage());
             case PRIVACY:
+            case LAST_PRIVACY:
                 return new PanelConfig(type, useLocalValues, LeanplumVariables.privacyPanelTitle, LeanplumVariables.privacyPanelMessage,
                         LeanplumVariables.privacyPanelSubtext, LeanplumVariables.getPrivacyImage());
             case CUSTOMIZE:
             case LAST_CUSTOMIZE:
                 return new PanelConfig(type, useLocalValues, LeanplumVariables.customizePanelTitle, LeanplumVariables.customizePanelMessage,
                         LeanplumVariables.customizePanelSubtext, LeanplumVariables.getCustomizingImage());
             case SYNC:
                 return new PanelConfig(type, useLocalValues, LeanplumVariables.syncPanelTitle, LeanplumVariables.syncPanelMessage,