Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1545805 - Update Fennec Onboarding process; r=VladBaicu
Browse files Browse the repository at this point in the history
The new Onboarding process will have updated imagery and strings.
It will also not show the "Customize" screen anymore.

It will only be shown if the new Strings are localized;

Differential Revision: https://phabricator.services.mozilla.com/D28863
  • Loading branch information
Petru Lingurar committed Apr 25, 2019
1 parent 431dce2 commit 3f255eb
Show file tree
Hide file tree
Showing 11 changed files with 167 additions and 32 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import android.os.Bundle;
import android.support.annotation.NonNull;

import org.mozilla.gecko.util.OnboardingStringUtil;

import java.util.LinkedList;
import java.util.List;

Expand All @@ -23,7 +25,9 @@ static List<FirstrunPanelConfig> getDefault(Context context, final boolean useLo
final List<FirstrunPanelConfig> panels = new LinkedList<>();
panels.add(FirstrunPanelConfig.getConfiguredPanel(context, PanelConfig.TYPE.WELCOME, useLocalValues));
panels.add(FirstrunPanelConfig.getConfiguredPanel(context, PanelConfig.TYPE.PRIVACY, useLocalValues));
panels.add(FirstrunPanelConfig.getConfiguredPanel(context, PanelConfig.TYPE.CUSTOMIZE, useLocalValues));
if (!OnboardingStringUtil.getInstance(context).areStringsLocalized()) {
panels.add(FirstrunPanelConfig.getConfiguredPanel(context, PanelConfig.TYPE.CUSTOMIZE, useLocalValues));
}
panels.add(FirstrunPanelConfig.getConfiguredPanel(context, PanelConfig.TYPE.SYNC, useLocalValues));

return panels;
Expand All @@ -32,8 +36,12 @@ static List<FirstrunPanelConfig> getDefault(Context context, final boolean useLo
static List<FirstrunPanelConfig> forFxAUser(Context context, final boolean useLocalValues) {
final List<FirstrunPanelConfig> panels = new LinkedList<>();
panels.add(FirstrunPanelConfig.getConfiguredPanel(context, PanelConfig.TYPE.WELCOME, useLocalValues));
panels.add(FirstrunPanelConfig.getConfiguredPanel(context, PanelConfig.TYPE.PRIVACY, useLocalValues));
panels.add(FirstrunPanelConfig.getConfiguredPanel(context, PanelConfig.TYPE.LAST_CUSTOMIZE, useLocalValues));
if (OnboardingStringUtil.getInstance(context).areStringsLocalized()) {
panels.add(FirstrunPanelConfig.getConfiguredPanel(context, PanelConfig.TYPE.LAST_PRIVACY, useLocalValues));
} else {
panels.add(FirstrunPanelConfig.getConfiguredPanel(context, PanelConfig.TYPE.PRIVACY, useLocalValues));
panels.add(FirstrunPanelConfig.getConfiguredPanel(context, PanelConfig.TYPE.LAST_CUSTOMIZE, useLocalValues));
}

return panels;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
public class FirstrunPanel extends Fragment {

protected boolean showBrowserHint = true;
public static final String NO_MESSAGE = "";

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstance) {
Expand All @@ -39,6 +40,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
((ImageView) root.findViewById(R.id.firstrun_image)).setImageDrawable(getResources().getDrawable(image));
((TextView) root.findViewById(R.id.firstrun_text)).setText(message);
((TextView) root.findViewById(R.id.firstrun_subtext)).setText(subtext);

final TextView messageView = root.findViewById(R.id.firstrun_text);
if (NO_MESSAGE.equals(message)) {
messageView.setVisibility(View.GONE);
} else {
messageView.setText(message);
}
}

root.findViewById(R.id.firstrun_link).setOnClickListener(new View.OnClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
final String subtext = args.getString(FirstrunPagerConfig.KEY_SUBTEXT);

((ImageView) root.findViewById(R.id.firstrun_image)).setImageDrawable(getResources().getDrawable(image));
((TextView) root.findViewById(R.id.firstrun_text)).setText(message);
((TextView) root.findViewById(R.id.firstrun_subtext)).setText(subtext);
((TextView) root.findViewById(R.id.firstrun_link)).setText(R.string.firstrun_welcome_button_browser);

final TextView messageView = root.findViewById(R.id.firstrun_text);
if (NO_MESSAGE.equals(message)) {
messageView.setVisibility(View.GONE);
} else {
messageView.setText(message);
}
}

root.findViewById(R.id.firstrun_link).setOnClickListener(new View.OnClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,72 @@
import android.support.annotation.NonNull;

import org.mozilla.gecko.R;
import org.mozilla.gecko.util.OnboardingStringUtil;

public class LocalFirstRunPanelProvider implements FirstRunPanelConfigProviderStrategy {
public PanelConfig getPanelConfig(@NonNull Context context, PanelConfig.TYPE type, final boolean useLocalValues) {
final Resources resources = context.getResources();
switch (type) {
case WELCOME:
return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_panel_title_welcome),
resources.getString(R.string.firstrun_urlbar_message),
resources.getString(R.string.firstrun_urlbar_subtext),
R.drawable.firstrun_welcome);
case PRIVACY:
return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_panel_title_privacy),
resources.getString(R.string.firstrun_privacy_message),
resources.getString(R.string.firstrun_privacy_subtext),
R.drawable.firstrun_private);
case CUSTOMIZE:
case LAST_CUSTOMIZE:
return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_panel_title_customize),
resources.getString(R.string.firstrun_customize_message),
resources.getString(R.string.firstrun_customize_subtext),
R.drawable.firstrun_data);
case SYNC:
return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_sync_title),
resources.getString(R.string.firstrun_sync_message),
resources.getString(R.string.firstrun_sync_subtext),
R.drawable.firstrun_sync);
default: // This will also be the case for "WELCOME"
return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_panel_title_welcome),
resources.getString(R.string.firstrun_urlbar_message),
resources.getString(R.string.firstrun_urlbar_subtext),
R.drawable.firstrun_welcome);
final OnboardingStringUtil onboardingStrings = OnboardingStringUtil.getInstance(context);

if (onboardingStrings.areStringsLocalized()) {
switch (type) {
case WELCOME:
return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_panel_title_welcome),
resources.getString(R.string.newfirstrun_urlbar_message),
resources.getString(R.string.newfirstrun_urlbar_subtext),
R.drawable.firstrun_welcome2);
case PRIVACY:
case LAST_PRIVACY:
return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_panel_title_privacy),
FirstrunPanel.NO_MESSAGE,
resources.getString(R.string.newfirstrun_privacy_subtext),
R.drawable.firstrun_private2);
case CUSTOMIZE:
case LAST_CUSTOMIZE:
throw new IllegalArgumentException("Onboarding will not show the addons screen anymore");
case SYNC:
return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_sync_title),
FirstrunPanel.NO_MESSAGE,
resources.getString(R.string.newfirstrun_sync_subtext),
R.drawable.firstrun_sync2);
default: // This will also be the case for "WELCOME"
return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_panel_title_welcome),
resources.getString(R.string.newfirstrun_urlbar_message),
resources.getString(R.string.newfirstrun_urlbar_subtext),
R.drawable.firstrun_welcome2);
}

// Show the previous Onboarding experience. Same old screens, imagery and strings.
} else {
switch (type) {
case WELCOME:
return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_panel_title_welcome),
resources.getString(R.string.firstrun_urlbar_message),
resources.getString(R.string.firstrun_urlbar_subtext),
R.drawable.firstrun_welcome);
case PRIVACY:
case LAST_PRIVACY:
return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_panel_title_privacy),
resources.getString(R.string.firstrun_privacy_message),
resources.getString(R.string.firstrun_privacy_subtext),
R.drawable.firstrun_private);
case CUSTOMIZE:
case LAST_CUSTOMIZE:
return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_panel_title_customize),
resources.getString(R.string.firstrun_customize_message),
resources.getString(R.string.firstrun_customize_subtext),
R.drawable.firstrun_data);
case SYNC:
return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_sync_title),
resources.getString(R.string.firstrun_sync_message),
resources.getString(R.string.firstrun_sync_subtext),
R.drawable.firstrun_sync);
default: // This will also be the case for "WELCOME"
return new PanelConfig(type, useLocalValues, resources.getString(R.string.firstrun_panel_title_welcome),
resources.getString(R.string.firstrun_urlbar_message),
resources.getString(R.string.firstrun_urlbar_subtext),
R.drawable.firstrun_welcome);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
public class PanelConfig {
public enum TYPE {
WELCOME, PRIVACY, CUSTOMIZE, LAST_CUSTOMIZE, SYNC
WELCOME, PRIVACY, LAST_PRIVACY, CUSTOMIZE, LAST_CUSTOMIZE, SYNC
}

private final TYPE type;
Expand All @@ -35,6 +35,7 @@ public String getClassName() {
case PRIVACY:
case CUSTOMIZE:
return FirstrunPanel.class.getName();
case LAST_PRIVACY:
case LAST_CUSTOMIZE:
return LastPanel.class.getName();
case SYNC:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
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;
import org.mozilla.gecko.util.OnboardingStringUtil;

public class SyncPanel extends FirstrunPanel {
@Override
Expand All @@ -32,6 +34,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
((ImageView) root.findViewById(R.id.firstrun_image)).setImageDrawable(getResources().getDrawable(image));
((TextView) root.findViewById(R.id.firstrun_text)).setText(message);
((TextView) root.findViewById(R.id.firstrun_subtext)).setText(subtext);

if (OnboardingStringUtil.getInstance(getContext()).areStringsLocalized()) {
((Button) root.findViewById(R.id.welcome_account)).setText(R.string.newfirstrun_signin_button);
}
}

root.findViewById(R.id.welcome_account).setOnClickListener(new View.OnClickListener() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* -*- 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.util;

import android.content.Context;
import android.content.res.Resources;

import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.R;

import java.util.Locale;

public class OnboardingStringUtil {
private static OnboardingStringUtil INSTANCE;

private static String initialWelcomeMessage;
private static String updatedWelcomeMessage;
private static String initialWelcomeSubtext =
"A modern mobile browser from Mozilla, the non-profit committed to a free and open web.";
private static String updatedWelcomeSubtext;

private static String initialPrivacySubtext = "Private Browsing with Tracking Protection blocks " +
"trackers while you browse and won’t remember your history when you finish browsing.";
private static String updatedPrivacySubtext;

private static String initialSyncSubtext = "Use Sync to find the bookmarks, passwords, and other " +
"things you save to &brandShortName; on all your devices.";
private static String updatedSyncSubtext;

private static boolean areStringsLocalized = false;

private OnboardingStringUtil(final Context context) {

final Locale locale = context.getResources().getConfiguration().locale;
if ("en".equals(locale.getLanguage())) {
areStringsLocalized = true;
return;
}

final Resources resources = context.getResources();
initialWelcomeMessage = "Thanks for choosing " + AppConstants.MOZ_APP_BASENAME;
updatedWelcomeMessage = resources.getString(R.string.firstrun_urlbar_message);
updatedWelcomeSubtext = resources.getString(R.string.firstrun_urlbar_subtext);
updatedPrivacySubtext = resources.getString(R.string.firstrun_privacy_subtext);
updatedSyncSubtext = resources.getString(R.string.firstrun_sync_subtext);

final boolean areWelcomeStringsLocalized =
!initialWelcomeMessage.equals(updatedWelcomeMessage) &&
!initialWelcomeSubtext.equals(updatedWelcomeSubtext);
final boolean arePrivacyStringsLocalized =
!initialPrivacySubtext.equals(updatedPrivacySubtext);
final boolean areSyncStringsLocalized =
!initialSyncSubtext.equals(updatedSyncSubtext);

areStringsLocalized = areWelcomeStringsLocalized && arePrivacyStringsLocalized && areSyncStringsLocalized;
}

public static OnboardingStringUtil getInstance(final Context context) {
if (INSTANCE == null) {
INSTANCE = new OnboardingStringUtil(context);
}
return INSTANCE;
}

public boolean areStringsLocalized() {
return areStringsLocalized;
}
}

0 comments on commit 3f255eb

Please sign in to comment.