Bug 1380808 - HighlightItem -> HighlightItemRow. r?mcomella draft
authorChenxia Liu <liuche@mozilla.com>
Tue, 22 Aug 2017 14:39:54 -0700
changeset 652851 335a1f808b239db9c8cabdc8755afb2701a18335
parent 652850 b0339dce6f690471a5cacedf4fc8d530f422d159
child 652852 677d0a9b5b355cc8e23cb0fc79f18a5bad4b5cab
push id76170
push usercliu@mozilla.com
push dateFri, 25 Aug 2017 08:33:06 +0000
reviewersmcomella
bugs1380808
milestone57.0a1
Bug 1380808 - HighlightItem -> HighlightItemRow. r?mcomella MozReview-Commit-ID: GM2tWWPh3t1
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamHighlightItemContextMenuListener.java
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamHighlightItemRowContextMenuListener.java
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/HighlightItem.java
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/HighlightItemRow.java
mobile/android/base/moz.build
rename from mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamHighlightItemContextMenuListener.java
rename to mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamHighlightItemRowContextMenuListener.java
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamHighlightItemContextMenuListener.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamHighlightItemRowContextMenuListener.java
@@ -1,21 +1,18 @@
 /* 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;
 
 import android.support.annotation.NonNull;
-import org.mozilla.gecko.activitystream.homepanel.stream.HighlightItem;
+import org.mozilla.gecko.activitystream.homepanel.stream.HighlightItemRow;
 
 /**
  * Provides a method to open the context menu for a highlight item.
  *
  * I tried declaring this inside StreamRecyclerAdapter but I got cyclical inheritance warnings
  * (I don't understand why) so it's here instead.
  */
-public interface StreamHighlightItemContextMenuListener {
-    /**
-     * @param position position of item in RecyclerView
-     */
-    void openContextMenu(HighlightItem highlightItem, int position, @NonNull final String interactionExtra);
+public interface StreamHighlightItemRowContextMenuListener {
+    void openContextMenu(HighlightItemRow highlightItem, int position, @NonNull final String interactionExtra);
 }
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/StreamRecyclerAdapter.java
@@ -15,17 +15,17 @@ import android.view.ViewGroup;
 
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 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.home.HomePager;
 import org.mozilla.gecko.activitystream.homepanel.model.Highlight;
-import org.mozilla.gecko.activitystream.homepanel.stream.HighlightItem;
+import org.mozilla.gecko.activitystream.homepanel.stream.HighlightItemRow;
 import org.mozilla.gecko.activitystream.homepanel.stream.HighlightsTitle;
 import org.mozilla.gecko.activitystream.homepanel.stream.StreamViewHolder;
 import org.mozilla.gecko.activitystream.homepanel.stream.TopPanel;
 import org.mozilla.gecko.activitystream.homepanel.stream.WelcomePanel;
 import org.mozilla.gecko.util.StringUtils;
 import org.mozilla.gecko.widget.RecyclerViewClickSupport;
 
 import java.util.EnumSet;
@@ -33,17 +33,17 @@ import java.util.LinkedList;
 import java.util.List;
 
 /**
  * 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, StreamHighlightItemContextMenuListener {
+        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 final RowItemType[] FIXED_ROWS = {RowItemType.TOP_PANEL, RowItemType.WELCOME, RowItemType.HIGHLIGHTS_TITLE};
     private static final int HIGHLIGHTS_OFFSET = 3; // Topsites, Welcome, Highlights Title
@@ -112,34 +112,34 @@ public class StreamRecyclerAdapter exten
     public StreamViewHolder onCreateViewHolder(ViewGroup parent, final int type) {
         final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
 
         if (type == RowItemType.TOP_PANEL.getViewType()) {
             return new TopPanel(inflater.inflate(TopPanel.LAYOUT_ID, parent, false), onUrlOpenListener, onUrlOpenInBackgroundListener);
         } else if (type == RowItemType.WELCOME.getViewType()) {
             return new WelcomePanel(inflater.inflate(WelcomePanel.LAYOUT_ID, parent, false), this);
         } else if (type == RowItemType.HIGHLIGHT_ITEM.getViewType()) {
-            return new HighlightItem(inflater.inflate(HighlightItem.LAYOUT_ID, parent, false), this);
+            return new HighlightItemRow(inflater.inflate(HighlightItemRow.LAYOUT_ID, parent, false), this);
         } else if (type == RowItemType.HIGHLIGHTS_TITLE.getViewType()) {
             return new HighlightsTitle(inflater.inflate(HighlightsTitle.LAYOUT_ID, parent, false));
         } else {
             throw new IllegalStateException("Missing inflation for ViewType " + type);
         }
     }
 
     private int getHighlightsOffsetFromRVPosition(int position) {
         return position - HIGHLIGHTS_OFFSET;
     }
 
     @Override
     public void onBindViewHolder(StreamViewHolder holder, int position) {
         int type = getItemViewType(position);
         if (type == RowItemType.HIGHLIGHT_ITEM.getViewType()) {
             final Highlight highlight = (Highlight) recyclerViewModel.get(position);
-            ((HighlightItem) holder).bind(highlight, position, tilesSize);
+            ((HighlightItemRow) holder).bind(highlight, position, tilesSize);
         } else if (type == RowItemType.TOP_PANEL.getViewType()) {
             ((TopPanel) holder).bind(topSitesCursor, tiles, tilesSize);
         }
     }
 
     @Override
     public void onItemClicked(RecyclerView recyclerView, int position, View v) {
         if (!onItemClickIsValidHighlightItem(position)) {
@@ -167,17 +167,17 @@ public class StreamRecyclerAdapter exten
     }
 
     @Override
     public boolean onItemLongClicked(final RecyclerView recyclerView, final int position, final View v) {
         if (!onItemClickIsValidHighlightItem(position)) {
             return false;
         }
 
-        final HighlightItem highlightItem = (HighlightItem) recyclerView.getChildViewHolder(v);
+        final HighlightItemRow highlightItem = (HighlightItemRow) recyclerView.getChildViewHolder(v);
         openContextMenu(highlightItem, position, ActivityStreamTelemetry.Contract.INTERACTION_LONG_CLICK);
         return true;
     }
 
     private boolean onItemClickIsValidHighlightItem(final int position) {
         if (getItemViewType(position) != RowItemType.HIGHLIGHT_ITEM.getViewType()) {
             // Headers (containing topsites and/or the highlights title) do their own click handling as needed
             return false;
@@ -197,17 +197,17 @@ public class StreamRecyclerAdapter exten
             Log.w(LOGTAG, "onItemClicked: received NO_POSITION. Returning");
             return false;
         }
 
         return true;
     }
 
     @Override
-    public void openContextMenu(final HighlightItem highlightItem, final int position, @NonNull final String interactionExtra) {
+    public void openContextMenu(final HighlightItemRow highlightItem, final int position, @NonNull final String interactionExtra) {
         final Highlight highlight = (Highlight) recyclerViewModel.get(position);
 
         ActivityStreamTelemetry.Extras.Builder extras = ActivityStreamTelemetry.Extras.builder()
                 .set(ActivityStreamTelemetry.Contract.SOURCE_TYPE, ActivityStreamTelemetry.Contract.TYPE_HIGHLIGHTS)
                 .set(ActivityStreamTelemetry.Contract.ACTION_POSITION, position - HIGHLIGHTS_OFFSET)
                 .set(ActivityStreamTelemetry.Contract.INTERACTION, interactionExtra)
                 .forHighlightSource(highlight.getSource());
 
rename from mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/HighlightItem.java
rename to mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/HighlightItemRow.java
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/HighlightItem.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/HighlightItemRow.java
@@ -11,61 +11,61 @@ import android.support.annotation.UiThre
 import android.text.TextUtils;
 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.activitystream.ActivityStreamTelemetry;
 import org.mozilla.gecko.activitystream.Utils;
-import org.mozilla.gecko.activitystream.homepanel.StreamHighlightItemContextMenuListener;
+import org.mozilla.gecko.activitystream.homepanel.StreamHighlightItemRowContextMenuListener;
 import org.mozilla.gecko.activitystream.homepanel.model.Highlight;
 import org.mozilla.gecko.util.DrawableUtil;
 import org.mozilla.gecko.util.TouchTargetUtil;
 import org.mozilla.gecko.util.URIUtils;
 import org.mozilla.gecko.util.ViewUtil;
 
 import java.lang.ref.WeakReference;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.UUID;
 
-public class HighlightItem extends StreamViewHolder {
+public class HighlightItemRow extends StreamViewHolder {
     private static final String LOGTAG = "GeckoHighlightItem";
 
     public static final int LAYOUT_ID = R.layout.activity_stream_card_history_item;
     private static final double SIZE_RATIO = 0.75;
 
     private int position;
 
     private final StreamOverridablePageIconLayout pageIconLayout;
     private final TextView pageTitleView;
     private final TextView pageSourceView;
     private final TextView pageDomainView;
     private final ImageView pageSourceIconView;
     private final ImageView menuButton;
 
-    public HighlightItem(final View itemView, final StreamHighlightItemContextMenuListener contextMenuListener) {
+    public HighlightItemRow(final View itemView, final StreamHighlightItemRowContextMenuListener contextMenuListener) {
         super(itemView);
 
         pageTitleView = (TextView) itemView.findViewById(R.id.card_history_label);
         pageIconLayout = (StreamOverridablePageIconLayout) itemView.findViewById(R.id.icon);
         pageSourceView = (TextView) itemView.findViewById(R.id.card_history_source);
         pageDomainView = (TextView) itemView.findViewById(R.id.page);
         pageSourceIconView = (ImageView) itemView.findViewById(R.id.source_icon);
 
         menuButton = (ImageView) itemView.findViewById(R.id.menu);
         menuButton.setImageDrawable(
                 DrawableUtil.tintDrawable(menuButton.getContext(), R.drawable.menu, Color.LTGRAY));
         TouchTargetUtil.ensureTargetHitArea(menuButton, itemView);
         ViewUtil.enableTouchRipple(menuButton);
         menuButton.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                contextMenuListener.openContextMenu(HighlightItem.this, position,
+                contextMenuListener.openContextMenu(HighlightItemRow.this, position,
                         ActivityStreamTelemetry.Contract.INTERACTION_MENU_BUTTON);
             }
         });
     }
 
     public void bind(Highlight highlight, int position, int tilesWidth) {
         this.position = position;
 
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -512,23 +512,23 @@ gbjar.sources += ['java/org/mozilla/geck
     'activitystream/homepanel/menu/ActivityStreamContextMenu.java',
     'activitystream/homepanel/menu/BottomSheetContextMenu.java',
     'activitystream/homepanel/menu/PopupContextMenu.java',
     'activitystream/homepanel/model/Highlight.java',
     'activitystream/homepanel/model/Metadata.java',
     'activitystream/homepanel/model/RowModel.java',
     'activitystream/homepanel/model/TopSite.java',
     'activitystream/homepanel/model/WebpageModel.java',
-    'activitystream/homepanel/stream/HighlightItem.java',
+    'activitystream/homepanel/stream/HighlightItemRow.java',
     'activitystream/homepanel/stream/HighlightsTitle.java',
     'activitystream/homepanel/stream/StreamOverridablePageIconLayout.java',
     'activitystream/homepanel/stream/StreamViewHolder.java',
     'activitystream/homepanel/stream/TopPanel.java',
     'activitystream/homepanel/stream/WelcomePanel.java',
-    'activitystream/homepanel/StreamHighlightItemContextMenuListener.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',
     'activitystream/ranking/HighlightCandidate.java',