OLD | NEW |
1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- | 1 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- |
2 * This Source Code Form is subject to the terms of the Mozilla Public | 2 * This Source Code Form is subject to the terms of the Mozilla Public |
3 * License, v. 2.0. If a copy of the MPL was not distributed with this | 3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | 5 |
6 package org.mozilla.gecko.activitystream.homepanel; | 6 package org.mozilla.gecko.activitystream.homepanel; |
7 | 7 |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.SharedPreferences; | 9 import android.content.SharedPreferences; |
10 import android.database.Cursor; | 10 import android.database.Cursor; |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 public void onBindViewHolder(StreamViewHolder holder, int position) { | 193 public void onBindViewHolder(StreamViewHolder holder, int position) { |
194 int type = getItemViewType(position); | 194 int type = getItemViewType(position); |
195 if (type == RowItemType.HIGHLIGHT_ITEM.getViewType()) { | 195 if (type == RowItemType.HIGHLIGHT_ITEM.getViewType()) { |
196 final Highlight highlight = (Highlight) recyclerViewModel.get(positi
on); | 196 final Highlight highlight = (Highlight) recyclerViewModel.get(positi
on); |
197 ((WebpageItemRow) holder).bind(highlight, position, tilesSize); | 197 ((WebpageItemRow) holder).bind(highlight, position, tilesSize); |
198 } else if (type == RowItemType.TOP_PANEL.getViewType()) { | 198 } else if (type == RowItemType.TOP_PANEL.getViewType()) { |
199 ((TopPanelRow) holder).bind(topSitesCursor, tilesSize); | 199 ((TopPanelRow) holder).bind(topSitesCursor, tilesSize); |
200 } else if (type == RowItemType.TOP_STORIES_ITEM.getViewType()) { | 200 } else if (type == RowItemType.TOP_STORIES_ITEM.getViewType()) { |
201 final TopStory story = (TopStory) recyclerViewModel.get(position); | 201 final TopStory story = (TopStory) recyclerViewModel.get(position); |
202 ((WebpageItemRow) holder).bind(story, position, tilesSize); | 202 ((WebpageItemRow) holder).bind(story, position, tilesSize); |
| 203 // We always hide top stories by Pocket |
| 204 // See https://issues.adblockplus.org/ticket/7199 |
| 205 setViewVisible(false, holder.itemView); |
203 } else if (type == RowItemType.HIGHLIGHTS_TITLE.getViewType() | 206 } else if (type == RowItemType.HIGHLIGHTS_TITLE.getViewType() |
204 || type == RowItemType.HIGHLIGHTS_EMPTY_STATE.getViewType()) { | 207 || type == RowItemType.HIGHLIGHTS_EMPTY_STATE.getViewType()) { |
205 final Context context = holder.itemView.getContext(); | 208 final Context context = holder.itemView.getContext(); |
206 final SharedPreferences sharedPreferences = GeckoSharedPrefs.forProf
ile(context); | 209 final SharedPreferences sharedPreferences = GeckoSharedPrefs.forProf
ile(context); |
207 final boolean bookmarksEnabled = sharedPreferences.getBoolean(Activi
tyStreamPanel.PREF_BOOKMARKS_ENABLED, | 210 final boolean bookmarksEnabled = sharedPreferences.getBoolean(Activi
tyStreamPanel.PREF_BOOKMARKS_ENABLED, |
208 context.getResources().getBoolean(R.bool.pref_activitystream
_recentbookmarks_enabled_default)); | 211 context.getResources().getBoolean(R.bool.pref_activitystream
_recentbookmarks_enabled_default)); |
209 final boolean visitedEnabled = sharedPreferences.getBoolean(Activity
StreamPanel.PREF_VISITED_ENABLED, | 212 final boolean visitedEnabled = sharedPreferences.getBoolean(Activity
StreamPanel.PREF_VISITED_ENABLED, |
210 context.getResources().getBoolean(R.bool.pref_activitystream
_visited_enabled_default)); | 213 context.getResources().getBoolean(R.bool.pref_activitystream
_visited_enabled_default)); |
211 setViewVisible(bookmarksEnabled || visitedEnabled, holder.itemView); | 214 setViewVisible(bookmarksEnabled || visitedEnabled, holder.itemView); |
212 } else if (type == RowItemType.TOP_STORIES_TITLE.getViewType()) { | 215 } else if (type == RowItemType.TOP_STORIES_TITLE.getViewType()) { |
213 final Context context = holder.itemView.getContext(); | 216 final Context context = holder.itemView.getContext(); |
214 final boolean pocketEnabled = ActivityStreamConfiguration.isPocketEn
abledByLocale(context) && | 217 final boolean pocketEnabled = ActivityStreamConfiguration.isPocketEn
abledByLocale(context) && |
215 GeckoSharedPrefs.forProfile(context).getBoolean(ActivityStre
amPanel.PREF_POCKET_ENABLED, | 218 GeckoSharedPrefs.forProfile(context).getBoolean(ActivityStre
amPanel.PREF_POCKET_ENABLED, |
216 context.getResources().getBoolean(R.bool.pref_activitystream
_pocket_enabled_default)); | 219 context.getResources().getBoolean(R.bool.pref_activitystream
_pocket_enabled_default)); |
217 setViewVisible(pocketEnabled, holder.itemView); | 220 // We always hide top stories by Pocket |
| 221 // See https://issues.adblockplus.org/ticket/7199 |
| 222 setViewVisible(false, holder.itemView); |
218 } | 223 } |
219 } | 224 } |
220 | 225 |
221 /** | 226 /** |
222 * This sets a child view of the adapter visible or hidden. | 227 * This sets a child view of the adapter visible or hidden. |
223 * | 228 * |
224 * This only applies to children whose height and width are WRAP_CONTENT and
MATCH_PARENT | 229 * This only applies to children whose height and width are WRAP_CONTENT and
MATCH_PARENT |
225 * respectively. | 230 * respectively. |
226 * | 231 * |
227 * NB: This is a hack for the views that are included in the RecyclerView ad
apter even if | 232 * NB: This is a hack for the views that are included in the RecyclerView ad
apter even if |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 || viewType == RowItemType.TOP_STORIES_ITEM.getViewType()) { | 492 || viewType == RowItemType.TOP_STORIES_ITEM.getViewType()) { |
488 // Highlights are always picked from recent history - So using the h
istory id should | 493 // Highlights are always picked from recent history - So using the h
istory id should |
489 // give us a unique (positive) id. | 494 // give us a unique (positive) id. |
490 final WebpageRowModel model = (WebpageRowModel) recyclerViewModel.ge
t(position); | 495 final WebpageRowModel model = (WebpageRowModel) recyclerViewModel.ge
t(position); |
491 return model.getUniqueId(); | 496 return model.getUniqueId(); |
492 } else { | 497 } else { |
493 return recyclerViewModel.get(position).getRowItemType().stableId; | 498 return recyclerViewModel.get(position).getRowItemType().stableId; |
494 } | 499 } |
495 } | 500 } |
496 } | 501 } |
OLD | NEW |