Bug 1388377: Rm WelcomePanelRow. r=liuche draft
authorMichael Comella <michael.l.comella@gmail.com>
Thu, 31 Aug 2017 14:39:40 -0700
changeset 657823 ed21103350ea13813062e214d3aec22805cfa7d7
parent 657805 77621126fd70e53253ba4da085cfbb03bea023dc
child 657824 b3beb1e9a2b21262a37654f64de918bbbeb921ea
child 657827 4c84e431baac1a64876bede36d05c0d3399b0f63
push id77630
push usermichael.l.comella@gmail.com
push dateSat, 02 Sep 2017 00:28:01 +0000
reviewersliuche
bugs1388377
milestone57.0a1
Bug 1388377: Rm WelcomePanelRow. r=liuche We show a message: 1) On first run 2) When there are no highlights However, these are actually the same case (there are no highlights) so I wanted to defer to that situation. I felt it was easier to rm the WelcomePanel and rewrite it than it was to try to morph it into an empty state for the highlights. MozReview-Commit-ID: CrRbzA0NoRx
mobile/android/app/src/main/res/drawable-hdpi/foxfinder.webp
mobile/android/app/src/main/res/drawable-xhdpi/foxfinder.webp
mobile/android/app/src/main/res/drawable-xxhdpi/foxfinder.webp
mobile/android/app/src/main/res/layout/activity_stream_main_welcomepanel.xml
mobile/android/app/src/main/res/layout/activity_stream_main_welcomepanel_content.xml
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/HighlightsDividerItemDecoration.java
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/WelcomePanelRow.java
mobile/android/base/locales/en-US/android_strings.dtd
mobile/android/base/moz.build
mobile/android/base/strings.xml.in
deleted file mode 100644
index ca6d920858b704e29617b77175cd68d336b073f0..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index b90f5a9cd8444cdc065c273314ac6ab86e7bb79e..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
index 49acdf4d808e12fb56c02ef3e22c5d5c72a592c1..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
deleted file mode 100644
--- a/mobile/android/app/src/main/res/layout/activity_stream_main_welcomepanel.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Viewstub requires a parent (since inflation involves removing the stub and replacing it with
-     the new layout, hence we need this empty framelayout (we don't attach the welcomepanel
-     to it's enclosing RecyclerView until after inflation - otherwise this issue wouldn't exist).
-     In this case, we need a FrameLayout for animations to work correctly, it would originally have lived
-     within welcomepanel_content, but this placing it here is just as good. -->
-<FrameLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content">
-
-    <ViewStub android:id="@+id/welcomepanel_stub"
-              android:layout="@layout/activity_stream_main_welcomepanel_content"
-              android:layout_width="match_parent"
-              android:layout_height="wrap_content"/>
-</FrameLayout>
\ No newline at end of file
deleted file mode 100644
--- a/mobile/android/app/src/main/res/layout/activity_stream_main_welcomepanel_content.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- We need an enclosing layout for the animation calculations to work correctly. This is provided
-     in the enclosing layout which wraps the ViewStub in a FrameLayout. -->
-<RelativeLayout
-    android:id="@+id/welcome_panel"
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content">
-
-    <View
-        android:id="@+id/divider0"
-        android:layout_width="match_parent"
-        android:layout_height="0.5dp"
-        android:background="#ffe0e0e0"
-        android:padding="4dp"/>
-
-    <ImageView
-        android:id="@+id/welcome_fox"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_alignParentRight="true"
-        android:layout_marginBottom="@dimen/activity_stream_base_margin"
-        android:layout_marginLeft="-30dp"
-        android:layout_marginTop="@dimen/activity_stream_base_margin"
-        android:adjustViewBounds="true"
-        android:scaleType="fitXY"
-        android:src="@drawable/foxfinder"/>
-
-    <TextView
-        android:id="@+id/title_welcome"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginBottom="@dimen/activity_stream_base_margin"
-        android:layout_marginEnd="@dimen/activity_stream_base_margin"
-        android:layout_marginLeft="@dimen/activity_stream_base_margin"
-        android:layout_marginRight="@dimen/activity_stream_base_margin"
-        android:layout_marginStart="@dimen/activity_stream_base_margin"
-        android:layout_marginTop="@dimen/activity_stream_base_margin"
-        android:text="@string/activity_stream_welcome_title"
-        android:textColor="#FF858585"
-        android:textSize="16sp"
-        android:textStyle="bold"/>
-
-    <TextView
-        android:id="@+id/welcome_text"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_alignLeft="@+id/title_welcome"
-        android:layout_alignStart="@+id/title_welcome"
-        android:layout_below="@+id/title_welcome"
-        android:layout_toLeftOf="@+id/welcome_fox"
-        android:layout_toStartOf="@+id/welcome_fox"
-        android:text="@string/activity_stream_welcome_content"
-        android:textColor="#FF858585"/>
-
-    <Button
-        android:id="@+id/dismiss_welcomepanel"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_alignBottom="@+id/welcome_fox"
-        android:layout_alignLeft="@+id/title_welcome"
-        android:layout_alignStart="@+id/title_welcome"
-        android:elevation="1dp"
-        android:text="@string/activity_stream_welcome_dismiss"
-        android:theme="@style/ActivityStreamButton"/>
-
-</RelativeLayout>
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/HighlightsDividerItemDecoration.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/HighlightsDividerItemDecoration.java
@@ -12,18 +12,18 @@ import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
 import android.support.v7.widget.RecyclerView;
 import android.view.View;
 
 /**
  * ItemDecoration implementation that draws horizontal divider line between highlight items.
  */
 /* package */ class HighlightsDividerItemDecoration extends RecyclerView.ItemDecoration {
-    // We do not want to draw a divider for the Top Sites panel and the Welcome panel.
-    private static final int START_DRAWING_AT_POSITION = 2;
+    // We do not want to draw a divider for the Top Sites panel.
+    private static final int START_DRAWING_AT_POSITION = 1;
 
     private static final int[] ATTRS = new int[]{
             android.R.attr.listDivider
     };
     private Drawable divider;
 
     /* package */ HighlightsDividerItemDecoration(Context context) {
         final TypedArray a = context.obtainStyledAttributes(ATTRS);
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
@@ -24,55 +24,55 @@ import org.mozilla.gecko.activitystream.
 import org.mozilla.gecko.activitystream.homepanel.model.WebpageRowModel;
 import org.mozilla.gecko.activitystream.homepanel.stream.TopPanelRow;
 import org.mozilla.gecko.activitystream.homepanel.model.TopStory;
 import org.mozilla.gecko.home.HomePager;
 import org.mozilla.gecko.activitystream.homepanel.model.Highlight;
 import org.mozilla.gecko.activitystream.homepanel.stream.WebpageItemRow;
 import org.mozilla.gecko.activitystream.homepanel.stream.StreamTitleRow;
 import org.mozilla.gecko.activitystream.homepanel.stream.StreamViewHolder;
-import org.mozilla.gecko.activitystream.homepanel.stream.WelcomePanelRow;
 import org.mozilla.gecko.util.StringUtils;
 import org.mozilla.gecko.widget.RecyclerViewClickSupport;
 
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.LinkedList;
 import java.util.List;
 
+import static android.R.attr.type;
+
 /**
  * The adapter for the Activity Stream panel.
  *
  * Every item is in a single adapter: Top Sites, Welcome panel, Highlights.
  */
 public class StreamRecyclerAdapter extends RecyclerView.Adapter<StreamViewHolder> implements RecyclerViewClickSupport.OnItemClickListener,
         RecyclerViewClickSupport.OnItemLongClickListener, StreamHighlightItemRowContextMenuListener {
 
     private static final String LOGTAG = StringUtils.safeSubstring("Gecko" + StreamRecyclerAdapter.class.getSimpleName(), 0, 23);
 
     private Cursor topSitesCursor;
     private List<RowModel> recyclerViewModel; // List of item types backing this RecyclerView.
     private List<TopStory> topStoriesQueue;
 
     // Content sections available on the Activity Stream page. These may be hidden if the sections are disabled.
-    private final RowItemType[] ACTIVITY_STREAM_SECTIONS = { RowItemType.TOP_PANEL, RowItemType.WELCOME, RowItemType.TOP_STORIES_TITLE, RowItemType.HIGHLIGHTS_TITLE };
+    private final RowItemType[] ACTIVITY_STREAM_SECTIONS = { RowItemType.TOP_PANEL, RowItemType.TOP_STORIES_TITLE, RowItemType.HIGHLIGHTS_TITLE };
     private final int MAX_TOP_STORIES = 3;
 
     private HomePager.OnUrlOpenListener onUrlOpenListener;
     private HomePager.OnUrlOpenInBackgroundListener onUrlOpenInBackgroundListener;
 
     private int tiles;
     private int tilesSize;
 
     public enum RowItemType {
         TOP_PANEL (-2), // RecyclerView.NO_ID is -1, so start hard-coded stableIds at -2.
-        WELCOME (-3),
-        TOP_STORIES_TITLE(-4),
+        TOP_STORIES_TITLE(-3),
         TOP_STORIES_ITEM(-1), // There can be multiple Top Stories items so caller should handle as a special case.
-        HIGHLIGHTS_TITLE (-5),
+        HIGHLIGHTS_TITLE (-4),
         HIGHLIGHT_ITEM (-1); // There can be multiple Highlight Items so caller should handle as a special case.
 
         public final int stableId;
 
         RowItemType(int stableId) {
             this.stableId = stableId;
         }
 
@@ -125,18 +125,16 @@ public class StreamRecyclerAdapter exten
 
         if (type == RowItemType.TOP_PANEL.getViewType()) {
             return new TopPanelRow(inflater.inflate(TopPanelRow.LAYOUT_ID, parent, false), onUrlOpenListener, onUrlOpenInBackgroundListener);
         } else if (type == RowItemType.TOP_STORIES_TITLE.getViewType()) {
             final boolean pocketEnabled = GeckoSharedPrefs.forProfile(parent.getContext()).getBoolean(ActivityStreamPanel.PREF_POCKET_ENABLED, true);
             return new StreamTitleRow(inflater.inflate(StreamTitleRow.LAYOUT_ID, parent, false), R.string.activity_stream_topstories, pocketEnabled);
         } else if (type == RowItemType.TOP_STORIES_ITEM.getViewType()) {
             return new WebpageItemRow(inflater.inflate(WebpageItemRow.LAYOUT_ID, parent, false), this);
-        } else if (type == RowItemType.WELCOME.getViewType()) {
-            return new WelcomePanelRow(inflater.inflate(WelcomePanelRow.LAYOUT_ID, parent, false), this);
         } else if (type == RowItemType.HIGHLIGHT_ITEM.getViewType()) {
             return new WebpageItemRow(inflater.inflate(WebpageItemRow.LAYOUT_ID, parent, false), this);
         } else if (type == RowItemType.HIGHLIGHTS_TITLE.getViewType()) {
             final SharedPreferences sharedPreferences = GeckoSharedPrefs.forProfile(parent.getContext());
             final boolean bookmarksEnabled = sharedPreferences.getBoolean(ActivityStreamPanel.PREF_BOOKMARKS_ENABLED, true);
             final boolean visitedEnabled = sharedPreferences.getBoolean(ActivityStreamPanel.PREF_VISITED_ENABLED, true);
             return new StreamTitleRow(inflater.inflate(StreamTitleRow.LAYOUT_ID, parent, false), R.string.activity_stream_highlights, bookmarksEnabled || visitedEnabled);
         } else {
deleted file mode 100644
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/WelcomePanelRow.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; 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.activitystream.homepanel.stream;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.support.v7.widget.RecyclerView;
-import android.view.View;
-import android.view.ViewStub;
-import android.widget.Button;
-
-import org.mozilla.gecko.GeckoSharedPrefs;
-import org.mozilla.gecko.R;
-
-public class WelcomePanelRow extends StreamViewHolder implements View.OnClickListener {
-    public static final int LAYOUT_ID = R.layout.activity_stream_main_welcomepanel;
-
-    public static final String PREF_WELCOME_DISMISSED = "activitystream.welcome_dismissed";
-
-    private final RecyclerView.Adapter<StreamViewHolder> adapter;
-    private final Context context;
-
-    public WelcomePanelRow(final View itemView, final RecyclerView.Adapter<StreamViewHolder> adapter) {
-        super(itemView);
-
-        this.adapter = adapter;
-        this.context = itemView.getContext();
-
-        final SharedPreferences sharedPrefs = GeckoSharedPrefs.forApp(itemView.getContext());
-
-        if (!sharedPrefs.getBoolean(PREF_WELCOME_DISMISSED, false)) {
-            final ViewStub welcomePanelStub = (ViewStub) itemView.findViewById(R.id.welcomepanel_stub);
-
-            welcomePanelStub.inflate();
-
-            final Button dismissButton = (Button) itemView.findViewById(R.id.dismiss_welcomepanel);
-
-            dismissButton.setOnClickListener(this);
-        }
-    }
-
-    @Override
-    public void onClick(View v) {
-        // To animate between item changes, RecyclerView keeps around the old version of the view,
-        // and creates a new equivalent item (which is bound using the new data) - followed by
-        // animating between those two versions. Hence we just need to make sure that
-        // any future calls to onCreateViewHolder create a version of the Header StreamViewHolder
-        // with the welcome panel hidden (i.e. we don't need to care about animations ourselves).
-        // We communicate this state change via the pref.
-
-        final SharedPreferences sharedPrefs = GeckoSharedPrefs.forApp(context);
-
-        sharedPrefs.edit()
-                .putBoolean(WelcomePanelRow.PREF_WELCOME_DISMISSED, true)
-                .apply();
-
-        adapter.notifyItemChanged(getAdapterPosition());
-    }
-}
\ No newline at end of file
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -851,18 +851,14 @@ Stream list for highlights sourced from 
 <!ENTITY activity_stream_highlight_label_trending "Trending">
 
 <!-- LOCALIZATION NOTE (activity_stream_remove): This label is shown in the Activity Stream context menu,
 and allows hiding a URL/page from highlights or topsites. The page remains in history/bookmarks, but
 is simply hidden from the Activity Stream panel. -->
 <!ENTITY activity_stream_remove "Remove">
 <!ENTITY activity_stream_delete_history "Delete from History">
 
-<!ENTITY activity_stream_welcome_title "Welcome to your Highlights">
-<!ENTITY activity_stream_welcome_content1 "&brandShortName; now creates highlights of things you\'ve discovered on the web so you can find your way back to great articles, videos, bookmarks, and other pages.">
-<!ENTITY activity_stream_welcome_dismiss "Dismiss">
-
 <!ENTITY private_tab_panel_title "Private Browsing + Tracking Protection">
 <!ENTITY private_tab_panel_description "&brandShortName; blocks parts of the pages that may track your browsing activity.">
 <!ENTITY private_tab_panel_description2 "We won\'t remember any history, but downloaded files and new bookmarks will still be saved to your device.">
 <!ENTITY private_tab_learn_more "Want to learn more?">
 
 <!ENTITY fullscreen_warning "Entered full screen">
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -519,17 +519,16 @@ gbjar.sources += ['java/org/mozilla/geck
     'activitystream/homepanel/model/TopStory.java',
     'activitystream/homepanel/model/WebpageModel.java',
     'activitystream/homepanel/model/WebpageRowModel.java',
     'activitystream/homepanel/stream/StreamOverridablePageIconLayout.java',
     'activitystream/homepanel/stream/StreamTitleRow.java',
     'activitystream/homepanel/stream/StreamViewHolder.java',
     'activitystream/homepanel/stream/TopPanelRow.java',
     'activitystream/homepanel/stream/WebpageItemRow.java',
-    'activitystream/homepanel/stream/WelcomePanelRow.java',
     'activitystream/homepanel/StreamHighlightItemRowContextMenuListener.java',
     'activitystream/homepanel/StreamItemAnimator.java',
     'activitystream/homepanel/StreamRecyclerAdapter.java',
     'activitystream/homepanel/topsites/TopSitesCard.java',
     'activitystream/homepanel/topsites/TopSitesPage.java',
     'activitystream/homepanel/topsites/TopSitesPageAdapter.java',
     'activitystream/homepanel/topsites/TopSitesPagerAdapter.java',
     'activitystream/homepanel/topstories/PocketStoriesLoader.java',
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -629,19 +629,15 @@
   <string name="activity_stream_topstories">&activity_stream_topstories;</string>
   <string name="activity_stream_highlights">&activity_stream_highlights;</string>
   <string name="activity_stream_highlight_label_bookmarked">&activity_stream_highlight_label_bookmarked;</string>
   <string name="activity_stream_highlight_label_visited">&activity_stream_highlight_label_visited;</string>
   <string name="activity_stream_highlight_label_trending">&activity_stream_highlight_label_trending;</string>
   <string name="activity_stream_remove">&activity_stream_remove;</string>
   <string name="activity_stream_delete_history">&activity_stream_delete_history;</string>
 
-  <string name="activity_stream_welcome_title">&activity_stream_welcome_title;</string>
-  <string name="activity_stream_welcome_content">&activity_stream_welcome_content1;</string>
-  <string name="activity_stream_welcome_dismiss">&activity_stream_welcome_dismiss;</string>
-
   <string name="private_tab_panel_title">&private_tab_panel_title;</string>
   <string name="private_tab_panel_description">&private_tab_panel_description;</string>
   <string name="private_tab_panel_description2">&private_tab_panel_description2;</string>
   <string name="private_tab_learn_more">&private_tab_learn_more;</string>
 
   <string name="fullscreen_warning">&fullscreen_warning;</string>
 </resources>