Bug 1238780 - Add static slides. r=sebastian

--HG--
extra : commitid : JdmuM23vAZu
extra : rebase_source : 4170a6f2d5bccef26a8198ed7d3f4c686bdf208a
This commit is contained in:
Chenxia Liu 2016-01-12 16:05:38 -08:00
parent 7e8e2cc568
commit 40ac435891
16 changed files with 179 additions and 44 deletions

View File

@ -109,6 +109,9 @@ public class FirstrunPager extends ViewPager {
});
animateLoad();
// Record telemetry for first onboarding panel, for baseline.
Telemetry.sendUIEvent(TelemetryContract.Event.SHOW, TelemetryContract.Method.PANEL, "onboarding.0");
}
public void cleanup() {
@ -155,7 +158,8 @@ public class FirstrunPager extends ViewPager {
public Fragment getItem(int i) {
Fragment fragment = this.fragments[i];
if (fragment == null) {
fragment = Fragment.instantiate(context, panels.get(i).getClassname());
FirstrunPagerConfig.FirstrunPanelConfig panelConfig = panels.get(i);
fragment = Fragment.instantiate(context, panelConfig.getClassname(), panelConfig.getArgs());
((FirstrunPanel) fragment).setPagerNavigation(pagerNavigation);
fragments[i] = fragment;
}

View File

@ -6,9 +6,11 @@
package org.mozilla.gecko.firstrun;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import com.keepsafe.switchboard.SwitchBoard;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
@ -17,6 +19,11 @@ import java.util.List;
public class FirstrunPagerConfig {
public static final String LOGTAG = "FirstrunPagerConfig";
public static final String KEY_IMAGE = "imageRes";
public static final String KEY_TEXT = "textRes";
public static final String KEY_SUBTEXT = "subtextRes";
public static final String ONBOARDING_A = "onboarding-a";
public static final String ONBOARDING_B = "onboarding-b";
public static final String ONBOARDING_C = "onboarding-c";
@ -28,7 +35,10 @@ public class FirstrunPagerConfig {
panels.add(new FirstrunPanelConfig(WelcomePanel.class.getName(), WelcomePanel.TITLE_RES));
Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, ONBOARDING_A);
} else if (isInExperimentLocal(context, ONBOARDING_B)) {
// TODO: Add new static onboarding flow.
panels.add(SimplePanelConfigs.urlbarPanelConfig);
panels.add(SimplePanelConfigs.bookmarksPanelConfig);
panels.add(SimplePanelConfigs.syncPanelConfig);
panels.add(new FirstrunPanelConfig(SyncPanel.class.getName(), SyncPanel.TITLE_RES));
Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, ONBOARDING_B);
} else if (isInExperimentLocal(context, ONBOARDING_C)) {
// TODO: Add new interactive onboarding flow.
@ -65,12 +75,29 @@ public class FirstrunPagerConfig {
}
public static class FirstrunPanelConfig {
private String classname;
private int titleRes;
private Bundle args;
public FirstrunPanelConfig(String resource, int titleRes) {
this.classname= resource;
this(resource, titleRes, -1, -1, -1, true);
}
public FirstrunPanelConfig(String classname, int titleRes, int imageRes, int textRes, int subtextRes) {
this(classname, titleRes, imageRes, textRes, subtextRes, false);
}
private FirstrunPanelConfig(String classname, int titleRes, int imageRes, int textRes, int subtextRes, boolean isCustom) {
this.classname = classname;
this.titleRes = titleRes;
if (!isCustom) {
this.args = new Bundle();
this.args.putInt(KEY_IMAGE, imageRes);
this.args.putInt(KEY_TEXT, textRes);
this.args.putInt(KEY_SUBTEXT, subtextRes);
}
}
public String getClassname() {
@ -81,5 +108,14 @@ public class FirstrunPagerConfig {
return this.titleRes;
}
public Bundle getArgs() {
return args;
}
}
protected static class SimplePanelConfigs {
public static final FirstrunPanelConfig urlbarPanelConfig = new FirstrunPanelConfig(FirstrunPanel.class.getName(), R.string.firstrun_panel_title_welcome, R.drawable.firstrun_urlbar, R.string.firstrun_urlbar_message, R.string.firstrun_urlbar_subtext);
public static final FirstrunPanelConfig bookmarksPanelConfig = new FirstrunPanelConfig(FirstrunPanel.class.getName(), R.string.firstrun_bookmarks_title, R.drawable.firstrun_bookmarks, R.string.firstrun_bookmarks_message, R.string.firstrun_bookmarks_subtext);
public static final FirstrunPanelConfig syncPanelConfig = new FirstrunPanelConfig(FirstrunPanel.class.getName(), R.string.firstrun_sync_title, R.drawable.firstrun_sync, R.string.firstrun_sync_message, R.string.firstrun_sync_subtext);
}
}

View File

@ -5,7 +5,16 @@
package org.mozilla.gecko.firstrun;
import android.os.Bundle;
import android.support.v4.app.Fragment;
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;
/**
* Base class for our first run pages. We call these FirstrunPanel for consistency
@ -18,6 +27,31 @@ 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_fragment, container, false);
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);
}
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");
pagerNavigation.next();
}
});
return root;
}
public interface PagerNavigation {
void next();
void finish();

View File

@ -9,7 +9,17 @@
<!ENTITY firstrun_panel_title_welcome "Welcome">
<!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 firstrun_urlbar_message "Welcome to &brandShortName;">
<!ENTITY firstrun_urlbar_subtext "Find things faster with helpful search suggestion shortcuts.">
<!ENTITY firstrun_bookmarks_title "History">
<!ENTITY firstrun_bookmarks_message "Your faves, front and center">
<!ENTITY firstrun_bookmarks_subtext "Get results from your bookmarks and history when you search.">
<!ENTITY firstrun_sync_title "Sync">
<!ENTITY firstrun_sync_message "&brandShortName;, always by your side">
<!ENTITY firstrun_sync_subtext "Sync your tabs, passwords, and more everywhere you use it.">
<!ENTITY firstrun_signin_message "Get connected, get started">
<!ENTITY firstrun_signin_button "Sign in to Sync">
<!ENTITY onboard_start_button_browser "Start Browsing">
<!ENTITY firstrun_button_next "Next">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

View File

@ -14,17 +14,16 @@
android:id="@+id/firstrun_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/firstrun_pager_background">
android:background="@android:color/white">
<org.mozilla.gecko.home.TabMenuStrip android:layout_width="match_parent"
android:layout_height="@dimen/tabs_strip_height"
android:background="@color/firstrun_tabstrip"
android:background="@color/firstrun_pager_header"
android:visibility="visible"
android:layout_gravity="top"
gecko:strip="@drawable/home_tab_menu_strip"
gecko:titlebarFill="true"
gecko:activeTextColor="@android:color/white"
gecko:inactiveTextColor="@color/toolbar_divider_grey" />
gecko:activeTextColor="@color/placeholder_grey"
gecko:inactiveTextColor="@color/tab_text_color" />
</org.mozilla.gecko.firstrun.FirstrunPager>
</org.mozilla.gecko.firstrun.FirstrunAnimationContainer>

View File

@ -0,0 +1,55 @@
<?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/about_page_header_grey"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView android:id="@+id/firstrun_image"
android:layout_width="wrap_content"
android:layout_height="@dimen/firstrun_background_height"
android:layout_marginTop="40dp"
android:layout_marginBottom="40dp"
android:scaleType="fitCenter"
android:layout_gravity="center"
android:adjustViewBounds="true"/>
<TextView android:id="@+id/firstrun_text"
android:layout_width="@dimen/firstrun_content_width"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="@style/TextAppearance.FirstrunLight.Main"/>
<TextView android:id="@+id/firstrun_subtext"
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"/>
<View android:layout_weight="1"
android:layout_height="0dp"
android:layout_width="match_parent"/>
<TextView android:id="@+id/firstrun_link"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="30dp"
android:gravity="center"
android:textAppearance="@style/TextAppearance.FirstrunRegular.Link"
android:text="@string/firstrun_button_next"/>
</LinearLayout>
</ScrollView>

View File

@ -13,52 +13,41 @@
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="@dimen/firstrun_min_height"
android:background="@color/android:white"
android:background="@color/about_page_header_grey"
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_devices"/>
<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>
<ImageView android:layout_width="wrap_content"
android:layout_height="@dimen/firstrun_background_height"
android:layout_marginTop="40dp"
android:layout_marginBottom="40dp"
android:scaleType="fitCenter"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:src="@drawable/firstrun_signin"/>
<TextView android:layout_width="@dimen/firstrun_content_width"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="30dp"
android:paddingBottom="40dp"
android:textAppearance="@style/TextAppearance.FirstrunLight.Main"
android:text="@string/firstrun_welcome_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_welcome_subtext"/>
android:text="@string/firstrun_signin_message"/>
<Button android:id="@+id/welcome_account"
style="@style/Widget.Firstrun.Button"
android:background="@drawable/button_background_action_orange_round"
android:layout_gravity="center"
android:text="@string/firstrun_welcome_button_account"/>
android:text="@string/firstrun_signin_button"/>
<View android:layout_weight="1"
android:layout_height="0dp"
android:layout_width="match_parent"/>
<TextView android:id="@+id/welcome_browse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dp"
android:padding="30dp"
android:gravity="center"
android:textAppearance="@style/TextAppearance.FirstrunRegular.Link"
android:text="@string/firstrun_welcome_button_browser"/>

View File

@ -53,7 +53,7 @@
style="@style/Widget.Firstrun.Button"
android:background="@drawable/button_background_action_orange_round"
android:layout_gravity="center"
android:text="@string/firstrun_welcome_button_account"/>
android:text="@string/firstrun_signin_button"/>
<TextView android:id="@+id/welcome_browse"
android:layout_width="wrap_content"

View File

@ -66,9 +66,8 @@
<color name="dark_transparent_overlay">#99000000</color>
<!-- Firstrun tour-->
<color name="firstrun_tabstrip">#1193CB</color>
<color name="firstrun_pager_background">#16A3DF</color>
<!-- Firstrun tour -->
<color name="firstrun_pager_header">#E8E8E8</color>
<!-- Tab Queue -->
<color name="tab_queue_dismiss_button_foreground">#16A3DF</color>

View File

@ -61,7 +61,7 @@
<dimen name="firstrun_content_width">300dp</dimen>
<dimen name="firstrun_min_height">180dp</dimen>
<dimen name="firstrun_brand_size">48dp</dimen>
<dimen name="firstrun_background_height">200dp</dimen>
<dimen name="firstrun_background_height">180dp</dimen>
<dimen name="overlay_prompt_content_width">260dp</dimen>
<dimen name="overlay_prompt_button_width">148dp</dimen>

View File

@ -37,11 +37,20 @@
<string name="no_space_to_start_error">&no_space_to_start_error;</string>
<string name="error_loading_file">&error_loading_file;</string>
<string name="firstrun_panel_title_welcome">&firstrun_panel_title_welcome;</string>
<string name="firstrun_welcome_message">&onboard_start_message3;</string>
<string name="firstrun_welcome_subtext">&onboard_start_subtext3;</string>
<string name="firstrun_welcome_button_account">&onboard_start_button_account;</string>
<string name="firstrun_urlbar_message">&firstrun_urlbar_message;</string>
<string name="firstrun_urlbar_subtext">&firstrun_urlbar_subtext;</string>
<string name="firstrun_bookmarks_title">&firstrun_bookmarks_title;</string>
<string name="firstrun_bookmarks_message">&firstrun_bookmarks_message;</string>
<string name="firstrun_bookmarks_subtext">&firstrun_bookmarks_subtext;</string>
<string name="firstrun_sync_title">&firstrun_sync_title;</string>
<string name="firstrun_sync_message">&firstrun_sync_message;</string>
<string name="firstrun_sync_subtext">&firstrun_sync_subtext;</string>
<string name="firstrun_signin_message">&firstrun_signin_message;</string>
<string name="firstrun_signin_button">&firstrun_signin_button;</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>