Bug 1268647 - Add new sync slide. r=sebastian draft
authorChenxia Liu <liuche@mozilla.com>
Tue, 10 May 2016 19:52:30 -0700
changeset 366174 73173f7c1e55eaf127c84f65175ab998c92de850
parent 366173 937d421ed530c9ecb781985d61cfdfea4eb7a153
child 366175 b85ab019bb1559d09df4fb0a55a303a663a2eef9
push id17914
push usercliu@mozilla.com
push dateThu, 12 May 2016 04:08:30 +0000
reviewerssebastian
bugs1268647
milestone49.0a1
Bug 1268647 - Add new sync slide. r=sebastian MozReview-Commit-ID: 69YpFgmIN80
mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPagerConfig.java
mobile/android/base/java/org/mozilla/gecko/firstrun/SyncPanel.java
mobile/android/base/resources/layout/firstrun_sync_fragment.xml
--- a/mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPagerConfig.java
+++ b/mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPagerConfig.java
@@ -21,31 +21,31 @@ public class FirstrunPagerConfig {
     public static final String LOGTAG = "FirstrunPagerConfig";
 
     public static final String KEY_IMAGE = "imageRes";
     public static final String KEY_TEXT = "textRes";
     public static final String KEY_SUBTEXT = "subtextRes";
 
    public static List<FirstrunPanelConfig> getDefault(Context context) {
         final List<FirstrunPanelConfig> panels = new LinkedList<>();
-
         if (Experiments.isInExperimentLocal(context, Experiments.ONBOARDING3_A)) {
             Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, Experiments.ONBOARDING3_A);
             GeckoSharedPrefs.forProfile(context).edit().putString(Experiments.PREF_ONBOARDING_VERSION, Experiments.ONBOARDING3_A).apply();
         } else if (Experiments.isInExperimentLocal(context, Experiments.ONBOARDING3_B)) {
             panels.add(SimplePanelConfigs.urlbarPanelConfig);
             panels.add(SimplePanelConfigs.bookmarksPanelConfig);
             panels.add(SimplePanelConfigs.dataPanelConfig);
             panels.add(SimplePanelConfigs.syncPanelConfig);
-            panels.add(new FirstrunPanelConfig(SyncPanel.class.getName(), SyncPanel.TITLE_RES));
+            panels.add(SimplePanelConfigs.signInPanelConfig);
             Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, Experiments.ONBOARDING3_B);
             GeckoSharedPrefs.forProfile(context).edit().putString(Experiments.PREF_ONBOARDING_VERSION, Experiments.ONBOARDING3_B).apply();
         } else if (Experiments.isInExperimentLocal(context, Experiments.ONBOARDING3_C)) {
             panels.add(SimplePanelConfigs.notificationsPanelConfig);
             panels.add(SimplePanelConfigs.readerviewPanelConfig);
+            panels.add(SimplePanelConfigs.accountPanelConfig);
             Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, Experiments.ONBOARDING3_C);
             GeckoSharedPrefs.forProfile(context).edit().putString(Experiments.PREF_ONBOARDING_VERSION, Experiments.ONBOARDING3_C).apply();
         } else {
             Log.d(LOGTAG, "Not in an experiment!");
         }
         return panels;
     }
 
@@ -92,15 +92,17 @@ public class FirstrunPagerConfig {
         public Bundle getArgs() {
             return args;
         }
     }
 
     protected static class SimplePanelConfigs {
         public static final FirstrunPanelConfig urlbarPanelConfig = new FirstrunPanelConfig(FirstrunPanel.class.getName(), R.string.firstrun_panel_title_welcome, R.drawable.firstrun_urlbar, R.string.firstrun_urlbar_message, R.string.firstrun_urlbar_subtext);
         public static final FirstrunPanelConfig bookmarksPanelConfig = new FirstrunPanelConfig(FirstrunPanel.class.getName(), R.string.firstrun_bookmarks_title, R.drawable.firstrun_bookmarks, R.string.firstrun_bookmarks_message, R.string.firstrun_bookmarks_subtext);
+        public static final FirstrunPanelConfig dataPanelConfig = new FirstrunPanelConfig(DataPanel.class.getName(), R.string.firstrun_data_title, R.drawable.firstrun_data_off, R.string.firstrun_data_message, R.string.firstrun_data_subtext);
         public static final FirstrunPanelConfig syncPanelConfig = new FirstrunPanelConfig(FirstrunPanel.class.getName(), R.string.firstrun_sync_title, R.drawable.firstrun_sync, R.string.firstrun_sync_message, R.string.firstrun_sync_subtext);
-        public static final FirstrunPanelConfig dataPanelConfig = new FirstrunPanelConfig(DataPanel.class.getName(), R.string.firstrun_data_title, R.drawable.firstrun_data_off, R.string.firstrun_data_message, R.string.firstrun_data_subtext);
+        public static final FirstrunPanelConfig signInPanelConfig = new FirstrunPanelConfig(SyncPanel.class.getName(), R.string.pref_sync, R.drawable.firstrun_signin, R.string.firstrun_signin_message, R.string.firstrun_welcome_button_browser);
 
         public static final FirstrunPanelConfig notificationsPanelConfig = new FirstrunPanelConfig(FirstrunPanel.class.getName(), R.string.firstrun_notifications_title, R.drawable.firstrun_notifications, R.string.firstrun_notifications_message, R.string.firstrun_notifications_subtext);
         public static final FirstrunPanelConfig readerviewPanelConfig = new FirstrunPanelConfig(FirstrunPanel.class.getName(), R.string.firstrun_readerview_title, R.drawable.firstrun_readerview, R.string.firstrun_readerview_message, R.string.firstrun_readerview_subtext);
+        public static final FirstrunPanelConfig accountPanelConfig = new FirstrunPanelConfig(SyncPanel.class.getName(), R.string.firstrun_account_title, R.drawable.firstrun_account, R.string.firstrun_account_message, R.string.firstrun_button_notnow);
     }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/firstrun/SyncPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/firstrun/SyncPanel.java
@@ -5,30 +5,39 @@
 
 package org.mozilla.gecko.firstrun;
 
 import android.content.Intent;
 import android.os.Bundle;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.fxa.FxAccountConstants;
 import org.mozilla.gecko.fxa.activities.FxAccountWebFlowActivity;
 
 public class SyncPanel extends FirstrunPanel {
-    // XXX: To simplify localization, this uses the pref_sync string. If this is used in the final product, add a new string to Nightly.
-    public static final int TITLE_RES = R.string.pref_sync;
-
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) {
         final ViewGroup root = (ViewGroup) inflater.inflate(R.layout.firstrun_sync_fragment, container, false);
-        // TODO: Update id names.
+        final Bundle args = getArguments();
+        if (args != null) {
+            final int imageRes = args.getInt(FirstrunPagerConfig.KEY_IMAGE);
+            final int textRes = args.getInt(FirstrunPagerConfig.KEY_TEXT);
+            final int subtextRes = args.getInt(FirstrunPagerConfig.KEY_SUBTEXT);
+
+            ((ImageView) root.findViewById(R.id.firstrun_image)).setImageResource(imageRes);
+            ((TextView) root.findViewById(R.id.firstrun_text)).setText(textRes);
+            ((TextView) root.findViewById(R.id.welcome_browse)).setText(subtextRes);
+        }
+
         root.findViewById(R.id.welcome_account).setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, "firstrun-sync");
                 showBrowserHint = false;
 
                 final Intent intent = new Intent(FxAccountConstants.ACTION_FXA_GET_STARTED);
                 intent.putExtra(FxAccountWebFlowActivity.EXTRA_ENDPOINT, FxAccountConstants.ENDPOINT_FIRSTRUN);
--- a/mobile/android/base/resources/layout/firstrun_sync_fragment.xml
+++ b/mobile/android/base/resources/layout/firstrun_sync_fragment.xml
@@ -13,43 +13,42 @@
     <LinearLayout android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:minHeight="@dimen/firstrun_min_height"
                   android:background="@color/about_page_header_grey"
                   android:gravity="center_horizontal"
                   android:orientation="vertical">
 
 
-        <ImageView android:layout_width="wrap_content"
+        <ImageView android:id="@+id/firstrun_image"
+                   android:layout_width="wrap_content"
                    android:layout_height="@dimen/firstrun_background_height"
                    android:layout_marginTop="40dp"
                    android:layout_marginBottom="40dp"
                    android:scaleType="fitCenter"
                    android:layout_gravity="center"
-                   android:adjustViewBounds="true"
-                   android:src="@drawable/firstrun_signin"/>
+                   android:adjustViewBounds="true"/>
 
-        <TextView android:layout_width="@dimen/firstrun_content_width"
+        <TextView android:id="@+id/firstrun_text"
+                  android:layout_width="@dimen/firstrun_content_width"
                   android:layout_height="wrap_content"
                   android:gravity="center"
                   android:paddingBottom="40dp"
-                  android:textAppearance="@style/TextAppearance.FirstrunLight.Main"
-                  android:text="@string/firstrun_signin_message"/>
+                  android:textAppearance="@style/TextAppearance.FirstrunLight.Main"/>
 
         <Button android:id="@+id/welcome_account"
                 style="@style/Widget.Firstrun.Button"
                 android:background="@drawable/button_background_action_orange_round"
                 android:layout_gravity="center"
                 android:text="@string/firstrun_signin_button"/>
 
         <View android:layout_weight="1"
               android:layout_height="0dp"
               android:layout_width="match_parent"/>
 
         <TextView android:id="@+id/welcome_browse"
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                   android:padding="30dp"
                   android:gravity="center"
-                  android:textAppearance="@style/TextAppearance.FirstrunRegular.Link"
-                  android:text="@string/firstrun_welcome_button_browser"/>
+                  android:textAppearance="@style/TextAppearance.FirstrunRegular.Link"/>
     </LinearLayout>
 </ScrollView>