Bug 1154980 - Localize first run pager titles. r=ally, a=sledru
authorChenxia Liu <liuche@mozilla.com>
Wed, 15 Apr 2015 16:08:33 -0700
changeset 258538 65cf03fc2bc9
parent 258537 18af6cfb3b86
child 258539 9117f9af554e
push id4691
push userryanvm@gmail.com
push date2015-04-20 17:16 +0000
treeherdermozilla-beta@72f1b4086067 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersally, sledru
bugs1154980
milestone38.0
Bug 1154980 - Localize first run pager titles. r=ally, a=sledru
mobile/android/base/firstrun/FirstrunPager.java
mobile/android/base/firstrun/FirstrunPagerConfig.java
mobile/android/base/firstrun/FirstrunPanel.java
mobile/android/base/firstrun/WelcomePanel.java
--- a/mobile/android/base/firstrun/FirstrunPager.java
+++ b/mobile/android/base/firstrun/FirstrunPager.java
@@ -67,24 +67,24 @@ public class FirstrunPager extends ViewP
 
         public ViewPagerAdapter(FragmentManager fm, List<FirstrunPagerConfig.FirstrunPanel> panels) {
             super(fm);
             this.panels = panels;
         }
 
         @Override
         public Fragment getItem(int i) {
-            final Fragment fragment = Fragment.instantiate(context, panels.get(i).getResource());
+            final Fragment fragment = Fragment.instantiate(context, panels.get(i).getClassname());
             ((FirstrunPanel) fragment).setOnFinishListener(listener);
             return fragment;
         }
 
         @Override
         public int getCount() {
             return panels.size();
         }
 
         @Override
         public CharSequence getPageTitle(int i) {
-            return panels.get(i).getTitle().toUpperCase();
+            return context.getString(panels.get(i).getTitleRes()).toUpperCase();
         }
     }
 }
--- a/mobile/android/base/firstrun/FirstrunPagerConfig.java
+++ b/mobile/android/base/firstrun/FirstrunPagerConfig.java
@@ -6,31 +6,31 @@
 package org.mozilla.gecko.firstrun;
 
 import java.util.LinkedList;
 import java.util.List;
 
 public class FirstrunPagerConfig {
     public static List<FirstrunPanel> getDefault() {
         final List<FirstrunPanel> panels = new LinkedList<>();
-        panels.add(new FirstrunPanel(WelcomePanel.class.getName(), "Welcome"));
+        panels.add(new FirstrunPanel(WelcomePanel.class.getName(), WelcomePanel.TITLE_RES));
         return panels;
     }
 
     public static class FirstrunPanel {
-        private String resource;
-        private String title;
+        private String classname;
+        private int titleRes;
 
-        public FirstrunPanel(String resource, String title) {
-            this.resource = resource;
-            this.title = title;
+        public FirstrunPanel(String resource, int titleRes) {
+            this.classname= resource;
+            this.titleRes = titleRes;
         }
 
-        public String getResource() {
-            return this.resource;
+        public String getClassname() {
+            return this.classname;
         }
 
-        public String getTitle() {
-            return this.title;
+        public int getTitleRes() {
+            return this.titleRes;
         }
 
     }
 }
--- a/mobile/android/base/firstrun/FirstrunPanel.java
+++ b/mobile/android/base/firstrun/FirstrunPanel.java
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.firstrun;
 
 import android.support.v4.app.Fragment;
 
 public class FirstrunPanel extends Fragment {
 
+    public static final int TITLE_RES = -1;
     protected FirstrunPane.OnFinishListener onFinishListener;
 
     public void setOnFinishListener(FirstrunPane.OnFinishListener listener) {
         this.onFinishListener = listener;
     }
 
     protected void close() {
         if (onFinishListener != null) {
--- a/mobile/android/base/firstrun/WelcomePanel.java
+++ b/mobile/android/base/firstrun/WelcomePanel.java
@@ -11,16 +11,18 @@ import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.fxa.activities.FxAccountGetStartedActivity;
 
 public class WelcomePanel extends FirstrunPanel {
+    public static final int TITLE_RES = R.string.firstrun_welcome_message;
+
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) {
         final ViewGroup root = (ViewGroup) inflater.inflate(R.layout.firstrun_welcome_fragment, container, false);
         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");