Bug 1366664 - If the user has alread signed-in, we show only three first-run panel. r?walkingice
MozReview-Commit-ID: DcsbR7TEplk
--- a/mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPager.java
+++ b/mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPager.java
@@ -15,16 +15,17 @@ import android.view.ViewGroup;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import com.booking.rtlviewpager.RtlViewPager;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
+import org.mozilla.gecko.fxa.FirefoxAccounts;
import org.mozilla.gecko.home.HomePager.Decor;
import org.mozilla.gecko.home.TabMenuStrip;
import org.mozilla.gecko.restrictions.Restrictions;
import java.util.List;
/**
* ViewPager containing for our first run pages.
@@ -62,16 +63,18 @@ public class FirstrunPager extends RtlVi
super.addView(child, index, params);
}
public void load(Context appContext, FragmentManager fm, final FirstrunAnimationContainer.OnFinishListener onFinishListener) {
final List<FirstrunPagerConfig.FirstrunPanelConfig> panels;
if (Restrictions.isRestrictedProfile(context)) {
panels = FirstrunPagerConfig.getRestricted();
+ } else if (FirefoxAccounts.firefoxAccountsExist(context)) {
+ panels = FirstrunPagerConfig.forFxAUser(appContext);
} else {
panels = FirstrunPagerConfig.getDefault(appContext);
}
setAdapter(new ViewPagerAdapter(fm, panels));
this.pagerNavigation = new FirstrunPanel.PagerNavigation() {
@Override
public void next() {
--- a/mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPagerConfig.java
+++ b/mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPagerConfig.java
@@ -29,16 +29,25 @@ public class FirstrunPagerConfig {
panels.add(SimplePanelConfigs.welcomePanelConfig);
panels.add(SimplePanelConfigs.privatePanelConfig);
panels.add(SimplePanelConfigs.customizePanelConfig);
panels.add(SimplePanelConfigs.syncPanelConfig);
return panels;
}
+ public static List<FirstrunPanelConfig> forFxAUser(Context context) {
+ final List<FirstrunPanelConfig> panels = new LinkedList<>();
+ panels.add(SimplePanelConfigs.welcomePanelConfig);
+ panels.add(SimplePanelConfigs.privatePanelConfig);
+ panels.add(SimplePanelConfigs.customizeLastPanelConfig);
+
+ return panels;
+ }
+
public static List<FirstrunPanelConfig> getRestricted() {
final List<FirstrunPanelConfig> panels = new LinkedList<>();
panels.add(new FirstrunPanelConfig(RestrictedWelcomePanel.class.getName(), RestrictedWelcomePanel.TITLE_RES));
return panels;
}
public static class FirstrunPanelConfig {
@@ -78,12 +87,14 @@ public class FirstrunPagerConfig {
return args;
}
}
private static class SimplePanelConfigs {
public static final FirstrunPanelConfig welcomePanelConfig = new FirstrunPanelConfig(FirstrunPanel.class.getName(), R.string.firstrun_panel_title_welcome, R.drawable.firstrun_welcome, R.string.firstrun_urlbar_message, R.string.firstrun_urlbar_subtext);
public static final FirstrunPanelConfig privatePanelConfig = new FirstrunPanelConfig(FirstrunPanel.class.getName(), R.string.firstrun_panel_title_privacy, R.drawable.firstrun_private, R.string.firstrun_privacy_message, R.string.firstrun_privacy_subtext);
public static final FirstrunPanelConfig customizePanelConfig = new FirstrunPanelConfig(FirstrunPanel.class.getName(), R.string.firstrun_panel_title_customize, R.drawable.firstrun_data, R.string.firstrun_customize_message, R.string.firstrun_customize_subtext);
+ public static final FirstrunPanelConfig customizeLastPanelConfig = new FirstrunPanelConfig(LastPanel.class.getName(), R.string.firstrun_panel_title_customize, R.drawable.firstrun_data, R.string.firstrun_customize_message, R.string.firstrun_customize_subtext);
+
public static final FirstrunPanelConfig syncPanelConfig = new FirstrunPanelConfig(SyncPanel.class.getName(), R.string.firstrun_sync_title, R.drawable.firstrun_sync, R.string.firstrun_sync_message, R.string.firstrun_sync_subtext);
}
}
--- a/mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/firstrun/FirstrunPanel.java
@@ -25,17 +25,17 @@ import org.mozilla.gecko.TelemetryContra
public class FirstrunPanel extends Fragment {
public static final int TITLE_RES = -1;
protected boolean showBrowserHint = true;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) {
final ViewGroup root = (ViewGroup) inflater.inflate(R.layout.firstrun_basepanel_checkable_fragment, container, false);
- Bundle args = getArguments();
+ 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.firstrun_subtext)).setText(subtextRes);
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/java/org/mozilla/gecko/firstrun/LastPanel.java
@@ -0,0 +1,47 @@
+/* -*- 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.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;
+
+public class LastPanel extends FirstrunPanel {
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) {
+ final ViewGroup root = (ViewGroup) inflater.inflate(R.layout.firstrun_basepanel_checkable_fragment, container, false);
+ 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.firstrun_subtext)).setText(subtextRes);
+ ((TextView) root.findViewById(R.id.firstrun_link)).setText(R.string.firstrun_welcome_button_browser);
+
+ }
+
+ root.findViewById(R.id.firstrun_link).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.BUTTON, "firstrun-next");
+ close();
+ }
+ });
+
+
+ return root;
+ }
+}
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -643,16 +643,17 @@ gbjar.sources += ['java/org/mozilla/geck
'FilePicker.java',
'FilePickerResultHandler.java',
'FindInPageBar.java',
'firstrun/DataPanel.java',
'firstrun/FirstrunAnimationContainer.java',
'firstrun/FirstrunPager.java',
'firstrun/FirstrunPagerConfig.java',
'firstrun/FirstrunPanel.java',
+ 'firstrun/LastPanel.java',
'firstrun/RestrictedWelcomePanel.java',
'firstrun/SyncPanel.java',
'firstrun/TabQueuePanel.java',
'FormAssistPopup.java',
'GeckoActivity.java',
'GeckoActivityMonitor.java',
'GeckoApp.java',
'GeckoApplication.java',