Skip to content

Commit

Permalink
Bug 1366664 - If the user has alread signed-in, we show only three fi…
Browse files Browse the repository at this point in the history
…rst-run panel. r=walkingice

MozReview-Commit-ID: DcsbR7TEplk
  • Loading branch information
cnevinc committed Aug 7, 2017
1 parent 51919c4 commit 31c68e8
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

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;
Expand Down Expand Up @@ -67,6 +68,8 @@ public void load(Context appContext, FragmentManager fm, final FirstrunAnimation

if (Restrictions.isRestrictedProfile(context)) {
panels = FirstrunPagerConfig.getRestricted();
} else if (FirefoxAccounts.firefoxAccountsExist(context)) {
panels = FirstrunPagerConfig.forFxAUser(appContext);
} else {
panels = FirstrunPagerConfig.getDefault(appContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ public static List<FirstrunPanelConfig> getDefault(Context context) {
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));
Expand Down Expand Up @@ -83,6 +92,8 @@ 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);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class FirstrunPanel extends Fragment {
@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);
Expand Down
47 changes: 47 additions & 0 deletions mobile/android/base/java/org/mozilla/gecko/firstrun/LastPanel.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
1 change: 1 addition & 0 deletions mobile/android/base/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ gbjar.sources += ['java/org/mozilla/gecko/' + x for x in [
'firstrun/FirstrunPager.java',
'firstrun/FirstrunPagerConfig.java',
'firstrun/FirstrunPanel.java',
'firstrun/LastPanel.java',
'firstrun/RestrictedWelcomePanel.java',
'firstrun/SyncPanel.java',
'firstrun/TabQueuePanel.java',
Expand Down

0 comments on commit 31c68e8

Please sign in to comment.