Bug 1238780 - Remove old firstrun panels. r=sebastian draft
authorChenxia Liu <liuche@mozilla.com>
Tue, 19 Jan 2016 16:24:49 -0800
changeset 323339 9a0a294812a1f35a860324a5f88a8bd92eb11218
parent 323338 266fae559621e55d614f52c66e95c08228aef8ca
child 323340 2ffa2d0253131bf662b852ac2b5c21d18ee468af
child 323996 638edf8580304113f55e2d451a14b75f7522b224
push id9705
push usercliu@mozilla.com
push dateWed, 20 Jan 2016 03:03:11 +0000
reviewerssebastian
bugs1238780
milestone46.0a1
Bug 1238780 - Remove old firstrun panels. r=sebastian
mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPagerConfig.java
mobile/android/base/java/org/mozilla/gecko/firstrun/ImportPanel.java
mobile/android/base/locales/en-US/android_strings.dtd
mobile/android/base/moz.build
mobile/android/base/resources/layout/firstrun_import_fragment.xml
mobile/android/base/strings.xml.in
--- a/mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPagerConfig.java
+++ b/mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPagerConfig.java
@@ -14,48 +14,50 @@ import org.mozilla.gecko.TelemetryContra
 
 import java.util.LinkedList;
 import java.util.List;
 
 public class FirstrunPagerConfig {
     public static final String LOGTAG = "FirstrunPagerConfig";
     public static final String ONBOARDING_A = "onboarding-a";
     public static final String ONBOARDING_B = "onboarding-b";
+    public static final String ONBOARDING_C = "onboarding-c";
 
     public static List<FirstrunPanelConfig> getDefault(Context context) {
         final List<FirstrunPanelConfig> panels = new LinkedList<>();
 
-        // The "Import" feature is disabled on devices running Android M+ (Bug 1183559).
-        // Exclude these users from the experiment to add an "Import" panel.
-        if (isInExperimentLocal(context, ONBOARDING_A) && AppConstants.Versions.preM) {
+        if (isInExperimentLocal(context, ONBOARDING_A)) {
             panels.add(new FirstrunPanelConfig(WelcomePanel.class.getName(), WelcomePanel.TITLE_RES));
             Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, ONBOARDING_A);
-        } else if (isInExperimentLocal(context, ONBOARDING_B) && AppConstants.Versions.preM) {
-            // Strings used for first run, pulled from existing strings.
-            panels.add(new FirstrunPanelConfig(ImportPanel.class.getName(), ImportPanel.TITLE_RES));
-            panels.add(new FirstrunPanelConfig(SyncPanel.class.getName(), SyncPanel.TITLE_RES));
+        } else if (isInExperimentLocal(context, ONBOARDING_B)) {
+            // TODO: Add new static onboarding flow.
             Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, ONBOARDING_B);
+        } else if (isInExperimentLocal(context, ONBOARDING_C)) {
+            // TODO: Add new interactive onboarding flow.
+            Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, ONBOARDING_C);
         } else {
             Log.d(LOGTAG, "Not in an experiment!");
             panels.add(new FirstrunPanelConfig(WelcomePanel.class.getName(), WelcomePanel.TITLE_RES));
         }
 
         return panels;
     }
 
     /*
      * Wrapper method for using local bucketing rather than server-side.
      * This needs to match the server-side bucketing used on mozilla-switchboard.herokuapp.com.
      */
     private static boolean isInExperimentLocal(Context context, String name) {
         if (AppConstants.MOZ_SWITCHBOARD) {
-            if (SwitchBoard.isInBucket(context, 0, 50)) {
+            if (SwitchBoard.isInBucket(context, 0, 33)) {
                 return ONBOARDING_A.equals(name);
-            } else if (SwitchBoard.isInBucket(context, 50, 100)) {
+            } else if (SwitchBoard.isInBucket(context, 33, 66)) {
                 return ONBOARDING_B.equals(name);
+            } else if (SwitchBoard.isInBucket(context, 66, 100)) {
+                return ONBOARDING_C.equals(name);
             }
         }
         return false;
     }
 
     public static List<FirstrunPanelConfig> getRestricted() {
         final List<FirstrunPanelConfig> panels = new LinkedList<>();
         panels.add(new FirstrunPanelConfig(RestrictedWelcomePanel.class.getName(), RestrictedWelcomePanel.TITLE_RES));
deleted file mode 100644
--- a/mobile/android/base/java/org/mozilla/gecko/firstrun/ImportPanel.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-package org.mozilla.gecko.firstrun;
-
-import android.app.AlertDialog;
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.util.Log;
-import android.util.SparseBooleanArray;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.Button;
-import android.widget.CheckedTextView;
-import android.widget.ImageView;
-import android.widget.ListView;
-import org.mozilla.gecko.AppConstants;
-import org.mozilla.gecko.R;
-import org.mozilla.gecko.Telemetry;
-import org.mozilla.gecko.TelemetryContract;
-import org.mozilla.gecko.preferences.AndroidImport;
-import org.mozilla.gecko.util.ThreadUtils;
-
-import java.util.Arrays;
-
-public class ImportPanel extends FirstrunPanel {
-    public static final String LOGTAG = "GeckoImportPanel";
-    public static final int TITLE_RES = R.string.firstrun_import_title;
-    private static final int AUTOADVANCE_DELAY_MS = 1500;
-
-    // These match the item positions in R.array.pref_import_android_entries.
-    private static int BOOKMARKS_INDEX = 0;
-    private static int HISTORY_INDEX = 1;
-
-    private ImageView confirmImage;
-    private Button choiceButton;
-
-    @Override
-    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) {
-        final ViewGroup root = (ViewGroup) inflater.inflate(R.layout.firstrun_import_fragment, container, false);
-        choiceButton = (Button) root.findViewById(R.id.import_action_button);
-        confirmImage = (ImageView) root.findViewById(R.id.confirm_check);
-        choiceButton.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
-                final boolean[] checked = {true, true};
-                Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, "firstrun-import-action");
-
-                // We set ListView.OnItemClickListener later, which overrides OnMultiChoiceClickListener, so don't make one here.
-                builder.setTitle(R.string.firstrun_import_action)
-                       .setMultiChoiceItems(R.array.pref_import_android_entries, makeBooleanArray(R.array.pref_import_android_defaults), null)
-                       .setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
-                           @Override
-                           public void onClick(DialogInterface dialog, int i) {
-                               Telemetry.sendUIEvent(TelemetryContract.Event.CANCEL, TelemetryContract.Method.BUTTON, "firstrun-import-dialog");
-                               dialog.dismiss();
-                           }
-                       })
-                       .setPositiveButton(R.string.firstrun_import_dialog_button, new DialogInterface.OnClickListener() {
-                           @Override
-                           public void onClick(DialogInterface dialog, int i) {
-                               final boolean importBookmarks = checked[BOOKMARKS_INDEX];
-                               final boolean importHistory = checked[HISTORY_INDEX];
-
-                               runImport(importBookmarks, importHistory);
-
-                               // Telemetry for what options are confirmed.
-                               final int importState = (importBookmarks ? 1 : 0) + (importHistory ? 2 : 0);
-                               Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, "firstrun-import-dialog-" + importState);
-                               dialog.dismiss();
-                           }
-                       });
-
-                final AlertDialog dialog = builder.create();
-                dialog.show();
-
-                final Button importButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
-                final ListView listView = dialog.getListView();
-
-                // Setting this listView listener is equivalent to setting OnMultiChoiceClickListener.
-                listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
-                    @Override
-                    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
-                        // Keep track of checked state.
-                        final boolean isChecked = ((CheckedTextView) view).isChecked();
-                        checked[i] = isChecked;
-
-                        // Update importButton state.
-                        if (AppConstants.Versions.feature11Plus) {
-                            if (listView.getCheckedItemCount() == 0) {
-                                importButton.setEnabled(false);
-                            } else {
-                                importButton.setEnabled(true);
-                            }
-                        } else {
-                            final SparseBooleanArray checkedItems = listView.getCheckedItemPositions();
-                            for (int j = 0; j < checkedItems.size(); j++) {
-                               if (checkedItems.valueAt(j) == true) {
-                                   importButton.setEnabled(true);
-                                   return;
-                               }
-                            }
-                            importButton.setEnabled(false);
-                        }
-                    }
-                });
-
-            }
-        });
-
-        root.findViewById(R.id.import_link).setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, "firstrun-import-next");
-                pagerNavigation.next();
-            }
-        });
-
-        return root;
-    }
-
-    private boolean[] makeBooleanArray(int resId) {
-        final String[] defaults = getResources().getStringArray(resId);
-        final boolean[] booleanArray = new boolean[defaults.length];
-        for (int i = 0; i < defaults.length; i++) {
-            booleanArray[i] = defaults[i].equals("true");
-        }
-        return booleanArray;
-    }
-
-    protected void runImport(final boolean doBookmarks, final boolean doHistory) {
-        Log.d(LOGTAG, "Importing Android history/bookmarks");
-        if (!doBookmarks && !doHistory) {
-            return;
-        }
-
-        final Context context = getActivity();
-        final String dialogTitle = context.getString(R.string.firstrun_import_progress_title);
-
-        final ProgressDialog dialog =
-                ProgressDialog.show(context,
-                        dialogTitle,
-                        context.getString(R.string.bookmarkhistory_import_wait),
-                        true);
-
-        final Runnable stopCallback = new Runnable() {
-            @Override
-            public void run() {
-                ThreadUtils.postToUiThread(new Runnable() {
-                    @Override
-                    public void run() {
-                        confirmImage.setVisibility(View.VISIBLE);
-                        choiceButton.setVisibility(View.GONE);
-
-                        dialog.dismiss();
-
-                        ThreadUtils.postDelayedToUiThread(new Runnable() {
-                            @Override
-                            public void run() {
-                                next();
-                            }
-                        }, AUTOADVANCE_DELAY_MS);
-                    }
-                });
-            }
-        };
-
-        ThreadUtils.postToBackgroundThread(
-            // Constructing AndroidImport may need finding the profile,
-            // which hits disk, so it needs to go into a Runnable too.
-            new Runnable() {
-                @Override
-                public void run() {
-                    new AndroidImport(context, stopCallback, doBookmarks, doHistory).run();
-                }
-            }
-        );
-    }
-}
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -10,23 +10,16 @@
 <!ENTITY  onboard_start_message3 "Browse with &brandShortName;">
 <!ENTITY  onboard_start_subtext3 "Make your mobile Web browsing experience truly your own.">
 <!ENTITY  onboard_start_button_account "Sign in to &brandShortName;">
 <!ENTITY  onboard_start_button_browser "Start Browsing">
 <!ENTITY firstrun_button_next "Next">
 
 <!ENTITY  onboard_start_restricted1 "Stay safe and in control with this simplified version of &brandShortName;.">
 
-<!ENTITY firstrun_import_title "Import">
-<!ENTITY firstrun_import_message "Welcome to &brandShortName;">
-<!ENTITY firstrun_import_subtext "Import your bookmarks and history from another browser.">
-<!ENTITY firstrun_import_action "Transfer to &brandShortName;">
-<!ENTITY firstrun_import_dialog_button "Transfer">
-<!ENTITY firstrun_import_progress_title "Transferring">
-
 <!-- Localization note: These are used as the titles of different pages on the home screen.
      They are automatically converted to all caps by the Android platform. -->
 <!ENTITY  bookmarks_title "Bookmarks">
 <!ENTITY  history_title "History">
 <!ENTITY  reading_list_title "Reading List">
 <!ENTITY  recent_tabs_title "Recent Tabs">
 
 <!ENTITY  switch_to_tab "Switch to tab">
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -273,17 +273,16 @@ gbjar.sources += ['java/org/mozilla/geck
     'favicons/RemoteFavicon.java',
     'FilePicker.java',
     'FilePickerResultHandler.java',
     'FindInPageBar.java',
     'firstrun/FirstrunAnimationContainer.java',
     'firstrun/FirstrunPager.java',
     'firstrun/FirstrunPagerConfig.java',
     'firstrun/FirstrunPanel.java',
-    'firstrun/ImportPanel.java',
     'firstrun/RestrictedWelcomePanel.java',
     'firstrun/SyncPanel.java',
     'firstrun/WelcomePanel.java',
     'FormAssistPopup.java',
     'GeckoAccessibility.java',
     'GeckoActivity.java',
     'GeckoActivityStatus.java',
     'GeckoApp.java',
deleted file mode 100644
--- a/mobile/android/base/resources/layout/firstrun_import_fragment.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
-   - License, v. 2.0. If a copy of the MPL was not distributed with this
-   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
-
-
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
-            android:layout_height="wrap_content"
-            android:layout_width="match_parent"
-            android:orientation="vertical"
-            android:fillViewport="true">
-
-    <LinearLayout android:layout_width="match_parent"
-                  android:layout_height="match_parent"
-                  android:minHeight="@dimen/firstrun_min_height"
-                  android:background="@color/android:white"
-                  android:gravity="center_horizontal"
-                  android:orientation="vertical">
-
-        <FrameLayout android:layout_width="match_parent"
-                     android:layout_height="wrap_content"
-                     android:background="@color/link_blue">
-
-            <ImageView android:layout_width="wrap_content"
-                       android:layout_height="@dimen/firstrun_background_height"
-                       android:scaleType="fitCenter"
-                       android:layout_gravity="center"
-                       android:adjustViewBounds="true"
-                       android:src="@drawable/firstrun_background_coffee"/>
-
-            <ImageView android:layout_width="@dimen/firstrun_brand_size"
-                       android:layout_height="@dimen/firstrun_brand_size"
-                       android:src="@drawable/large_icon"
-                       android:layout_gravity="center"/>
-        </FrameLayout>
-
-
-        <TextView android:layout_width="@dimen/firstrun_content_width"
-                      android:layout_height="wrap_content"
-                      android:gravity="center"
-                      android:paddingTop="30dp"
-                      android:textAppearance="@style/TextAppearance.FirstrunLight.Main"
-                      android:text="@string/firstrun_import_message"/>
-
-            <TextView android:layout_width="@dimen/firstrun_content_width"
-                      android:layout_height="wrap_content"
-                      android:paddingTop="20dp"
-                      android:paddingBottom="30dp"
-                      android:gravity="center"
-                      android:textAppearance="@style/TextAppearance.FirstrunRegular.Body"
-                      android:text="@string/firstrun_import_subtext"/>
-
-            <Button android:id="@+id/import_action_button"
-                    style="@style/Widget.Firstrun.Button"
-                    android:background="@drawable/button_background_action_orange_round"
-                    android:layout_gravity="center"
-                    android:text="@string/firstrun_import_action"/>
-
-            <ImageView android:id="@+id/confirm_check"
-                       android:layout_width="wrap_content"
-                       android:layout_height="60dp"
-                       android:visibility="gone"
-                       android:src="@drawable/overlay_check"/>
-
-            <TextView android:id="@+id/import_link"
-                      android:layout_width="wrap_content"
-                      android:layout_height="wrap_content"
-                      android:padding="20dp"
-                      android:gravity="center"
-                      android:textAppearance="@style/TextAppearance.FirstrunRegular.Link"
-                      android:text="@string/firstrun_button_next"/>
-        </LinearLayout>
-</ScrollView>
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -43,23 +43,16 @@
   <string name="firstrun_welcome_subtext">&onboard_start_subtext3;</string>
   <string name="firstrun_welcome_button_account">&onboard_start_button_account;</string>
   <string name="firstrun_welcome_button_browser">&onboard_start_button_browser;</string>
   <string name="firstrun_button_next">&firstrun_button_next;</string>
   <string name="firstrun_empty_contentDescription"></string>
 
   <string name="firstrun_welcome_restricted">&onboard_start_restricted1;</string>
 
-  <string name="firstrun_import_title">&firstrun_import_title;</string>
-  <string name="firstrun_import_message">&firstrun_import_message;</string>
-  <string name="firstrun_import_subtext">&firstrun_import_subtext;</string>
-  <string name="firstrun_import_action">&firstrun_import_action;</string>
-  <string name="firstrun_import_dialog_button">&firstrun_import_dialog_button;</string>
-  <string name="firstrun_import_progress_title">&firstrun_import_progress_title;</string>
-
   <string name="bookmarks_title">&bookmarks_title;</string>
   <string name="history_title">&history_title;</string>
   <string name="reading_list_title">&reading_list_title;</string>
   <string name="recent_tabs_title">&recent_tabs_title;</string>
 
   <string name="switch_to_tab">&switch_to_tab;</string>
 
   <string name="crash_reporter_title">&crash_reporter_title;</string>