Bug 1393672 - first run per focus
MozReview-Commit-ID: MXuSCwu7Ey
new file mode 100644
--- /dev/null
+++ b/mobile/android/app/src/photon/res/layout/pwa_firstrun_page.xml
@@ -0,0 +1,97 @@
+<?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/. -->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:cardview="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <!-- The actual size of FirstrunCardView is determined in onMeasure() -->
+ <org.mozilla.gecko.toolbar.FirstrunCardView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:layout_marginTop="4dp"
+ android:layout_marginBottom="4dp"
+ android:elevation="4dp"
+ cardview:cardCornerRadius="6dp"
+ cardview:cardBackgroundColor="#FFF9F9FA">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical">
+
+ <ScrollView
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:fadingEdgeLength="12sp"
+ android:fillViewport="true"
+ android:requiresFadingEdge="vertical">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="top"
+ android:orientation="vertical">
+
+ <ImageView
+ android:id="@+id/image"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:layout_marginBottom="24dp"
+ tools:src="@drawable/onboarding_img1" />
+
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="24dp"
+ android:layout_marginRight="24dp"
+ android:gravity="center"
+ android:lineSpacingMultiplier="1.25"
+ android:textColor="#ff212121"
+ android:textSize="18sp"
+ tools:text="@string/firstrun_tracking_title" />
+
+ <TextView
+ android:id="@+id/text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="24dp"
+ android:layout_marginRight="24dp"
+ android:layout_marginTop="16dp"
+ android:gravity="center"
+ android:lineSpacingMultiplier="1.25"
+ android:textColor="#ff737373"
+ android:textSize="14sp"
+ tools:text="@string/firstrun_tracking_text" />
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1" />
+
+ </LinearLayout>
+
+ </ScrollView>
+
+ <Button
+ android:id="@+id/button"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
+ android:background="?android:attr/selectableItemBackground"
+ android:textColor="#ff9400FF"
+ android:textSize="16sp"
+ tools:text="@string/firstrun_next_button" />
+
+ </LinearLayout>
+
+ </org.mozilla.gecko.toolbar.FirstrunCardView>
+
+</FrameLayout>
\ No newline at end of file
--- a/mobile/android/app/src/photon/res/values/dimens.xml
+++ b/mobile/android/app/src/photon/res/values/dimens.xml
@@ -42,17 +42,16 @@
<!-- If you update one of these values, update the others. -->
<dimen name="tablet_nav_button_width">48dp</dimen>
<dimen name="tablet_nav_button_width_half">21dp</dimen>
<dimen name="tablet_nav_button_width_plus_half">36dp</dimen>
<dimen name="tablet_fwd_button_padding_start">4dp</dimen>
<dimen name="tablet_fwd_button_padding_end">4dp</dimen>
- <dimen name="tablet_tab_strip_height_pwa">0dp</dimen>
<dimen name="tablet_tab_strip_height">48dp</dimen>
<dimen name="tablet_tab_strip_item_width">178dp</dimen>
<dimen name="tablet_tab_strip_item_height">40dp</dimen>
<dimen name="tablet_tab_strip_fading_edge_size">15dp</dimen>
<dimen name="tablet_tab_strip_item_margin">0dp</dimen>
<dimen name="tablet_tab_strip_divider_width">1dp</dimen>
<dimen name="tablet_tab_strip_divider_height">30dp</dimen>
<dimen name="tablet_tab_strip_divider_padding_bottom">4dp</dimen>
@@ -256,9 +255,15 @@
<dimen name="bookmark_folder_first_child_padding">40dp</dimen>
<dimen name="bookmark_folder_child_padding">16dp</dimen>
<!-- Dialogs -->
<dimen name="dialog_switchpreferenceview_padding">24dp</dimen>
<!-- Preferences -->
<dimen name="preference_panel_text_size">15dp</dimen>
+
+ <!-- PWA -->
+ <dimen name="tablet_tab_strip_height_pwa">0dp</dimen>
+ <dimen name="firstrun_card_width">300dp</dimen>
+ <dimen name="firstrun_card_height">460dp</dimen>
+
</resources>
new file mode 100644
--- /dev/null
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/PwaFirstrunCardView.java
@@ -0,0 +1,59 @@
+/* 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.toolbar;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.support.v7.widget.CardView;
+import android.util.AttributeSet;
+
+import org.mozilla.gecko.R;
+
+
+public class PwaFirstrunCardView extends CardView {
+ private int maxWidth;
+ private int maxHeight;
+
+ public PwaFirstrunCardView(Context context) {
+ super(context);
+ init();
+ }
+
+ public PwaFirstrunCardView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init();
+ }
+
+ public PwaFirstrunCardView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init();
+ }
+
+ private void init() {
+ final Resources resources = getResources();
+
+ maxWidth = resources.getDimensionPixelSize(R.dimen.firstrun_card_width);
+ maxHeight = resources.getDimensionPixelSize(R.dimen.firstrun_card_height);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ // The view is set to match_parent in the layout file. So width and height should be the
+ // value needed to fill the whole parent view.
+ final int availableWidth = MeasureSpec.getSize(widthMeasureSpec);
+ final int availableHeight = MeasureSpec.getSize(heightMeasureSpec);
+
+ // Now let's use those sizes to measure - but let's not exceed our defined max sizes (We do
+ // not want to have gigantic cards on large devices like tablets.)
+ final int measuredWidth = Math.min(availableWidth, maxWidth);
+ final int measuredHeight = Math.min(availableHeight, maxHeight);
+
+ // Let's use the measured values to hand them to the super class to measure the child views etc.
+ widthMeasureSpec = MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY);
+ heightMeasureSpec = MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY);
+
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+}
--- a/mobile/android/base/java/org/mozilla/gecko/toolbar/PwaOnboarding.java
+++ b/mobile/android/base/java/org/mozilla/gecko/toolbar/PwaOnboarding.java
@@ -20,17 +20,17 @@ import org.mozilla.gecko.Tabs;
public class PwaOnboarding extends RelativeLayout {
static final String LINK_PWA_SUMO = "http://pwa.rocks";
public static void show(Context context) {
if (context instanceof Activity) {
final ViewGroup contetView = (ViewGroup) ((Activity) context).findViewById(android.R.id.content);
- LayoutInflater.from(context).inflate(R.layout.pwa_onboarding, contetView);
+ LayoutInflater.from(context).inflate(R.layout.pwa_firstrun_page, contetView);
}
}
public PwaOnboarding(Context context) {
super(context);
}
public PwaOnboarding(Context context, @Nullable AttributeSet attrs) {