Backed out changeset 512562477a1e, c5b310c419c4 (bug 1388377) for Android build bustage

--HG--
extra : histedit_source : 45a7c9ad2418f3fbf1f6b3d544806e43e337749e%2C73fe36a02238f02dcac1d1010504fb42a2008701
This commit is contained in:
Gregory Szorc 2017-09-01 17:07:21 -07:00
parent 1538ddc813
commit 54ce1a0575
12 changed files with 162 additions and 49 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,12 +0,0 @@
<?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/. -->
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_stream_base_margin"
android:text="@string/activity_stream_highlights_empty"
android:textColor="@color/activity_stream_subtitle"
/>

View File

@ -0,0 +1,16 @@
<?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>

View File

@ -0,0 +1,67 @@
<?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>

View File

@ -17,8 +17,8 @@ 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.
private static final int START_DRAWING_AT_POSITION = 1;
// 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;
private static final int[] ATTRS = new int[]{
android.R.attr.listDivider

View File

@ -22,7 +22,6 @@ import org.mozilla.gecko.activitystream.ActivityStreamTelemetry;
import org.mozilla.gecko.activitystream.homepanel.menu.ActivityStreamContextMenu;
import org.mozilla.gecko.activitystream.homepanel.model.RowModel;
import org.mozilla.gecko.activitystream.homepanel.model.WebpageRowModel;
import org.mozilla.gecko.activitystream.homepanel.stream.HighlightsEmptyStateRow;
import org.mozilla.gecko.activitystream.homepanel.stream.TopPanelRow;
import org.mozilla.gecko.activitystream.homepanel.model.TopStory;
import org.mozilla.gecko.activitystream.homepanel.topstories.PocketStoriesLoader;
@ -31,6 +30,7 @@ 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;
@ -54,7 +54,7 @@ public class StreamRecyclerAdapter extends RecyclerView.Adapter<StreamViewHolder
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.TOP_STORIES_TITLE, RowItemType.HIGHLIGHTS_TITLE };
private final RowItemType[] ACTIVITY_STREAM_SECTIONS = { RowItemType.TOP_PANEL, RowItemType.WELCOME, RowItemType.TOP_STORIES_TITLE, RowItemType.HIGHLIGHTS_TITLE };
private final int MAX_TOP_STORIES = 3;
private HomePager.OnUrlOpenListener onUrlOpenListener;
@ -65,10 +65,10 @@ public class StreamRecyclerAdapter extends RecyclerView.Adapter<StreamViewHolder
public enum RowItemType {
TOP_PANEL (-2), // RecyclerView.NO_ID is -1, so start hard-coded stableIds at -2.
TOP_STORIES_TITLE(-3),
WELCOME (-3),
TOP_STORIES_TITLE(-4),
TOP_STORIES_ITEM(-1), // There can be multiple Top Stories items so caller should handle as a special case.
HIGHLIGHTS_TITLE (-4),
HIGHLIGHTS_EMPTY_STATE(-5),
HIGHLIGHTS_TITLE (-5),
HIGHLIGHT_ITEM (-1); // There can be multiple Highlight Items so caller should handle as a special case.
public final int stableId;
@ -131,6 +131,8 @@ public class StreamRecyclerAdapter extends RecyclerView.Adapter<StreamViewHolder
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()) {
@ -138,8 +140,6 @@ public class StreamRecyclerAdapter extends RecyclerView.Adapter<StreamViewHolder
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 if (type == RowItemType.HIGHLIGHTS_EMPTY_STATE.getViewType()) {
return new HighlightsEmptyStateRow(inflater.inflate(HighlightsEmptyStateRow.LAYOUT_ID, parent, false));
} else {
throw new IllegalStateException("Missing inflation for ViewType " + type);
}
@ -312,11 +312,7 @@ public class StreamRecyclerAdapter extends RecyclerView.Adapter<StreamViewHolder
public void swapHighlights(List<Highlight> highlights) {
recyclerViewModel = recyclerViewModel.subList(0, ACTIVITY_STREAM_SECTIONS.length + getNumOfTypeShown(RowItemType.TOP_STORIES_ITEM));
if (!highlights.isEmpty()) {
recyclerViewModel.addAll(highlights);
} else {
recyclerViewModel.add(makeRowModelFromType(RowItemType.HIGHLIGHTS_EMPTY_STATE));
}
recyclerViewModel.addAll(highlights);
notifyDataSetChanged();
}

View File

@ -1,20 +0,0 @@
/* 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.support.annotation.LayoutRes;
import android.view.View;
import org.mozilla.gecko.R;
/** A row to be displayed when there are no highlights. */
public class HighlightsEmptyStateRow extends StreamViewHolder {
@LayoutRes
public static final int LAYOUT_ID = R.layout.activity_stream_highlights_empty_state;
public HighlightsEmptyStateRow(final View itemView) {
super(itemView);
}
}

View File

@ -0,0 +1,62 @@
/* -*- 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());
}
}

View File

@ -849,8 +849,6 @@ Stream list for highlights sourced from th user's bookmarks. -->
<!ENTITY activity_stream_highlight_label_visited "Visited">
<!-- LOCALIZATION NOTE (activity_stream_highlight_label_trending): This label is shown in the Activity Stream list for highlights sourced from a recommendations engine. -->
<!ENTITY activity_stream_highlight_label_trending "Trending">
<!-- LOCALIZATION NOTE (activity_stream_highlights_empty): This text is shown when we could not find highlights for this user. This is also shown on first run. -->
<!ENTITY activity_stream_highlights_empty "Start browsing, and we\'ll show some of the great articles, videos, and other pages you\'ve recently visited or bookmarked here.">
<!-- 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
@ -858,6 +856,10 @@ 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.">

View File

@ -634,7 +634,9 @@
<string name="activity_stream_remove">&activity_stream_remove;</string>
<string name="activity_stream_delete_history">&activity_stream_delete_history;</string>
<string name="activity_stream_highlights_empty">&activity_stream_highlights_empty;</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>