Bug 1390356: StreamPageIconLayout -> StreamOverridablePageIconLayout. r=liuche draft
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 15 Aug 2017 13:33:09 -0700
changeset 646946 8e5d6fe665f315da80c11a53fe5a63b85fa45c98
parent 646916 9461f49e0d1fbe3a948e7023063bc6f3976f41dd
child 646947 a0ce0cb638a985a7c41ecac89014e9b4e22c70a4
push id74256
push usermichael.l.comella@gmail.com
push dateTue, 15 Aug 2017 21:22:04 +0000
reviewersliuche
bugs1390356
milestone57.0a1
Bug 1390356: StreamPageIconLayout -> StreamOverridablePageIconLayout. r=liuche Now it doesn't imply it's used everywhere for page icons in activity stream. MozReview-Commit-ID: F7Z2HrhHsss
mobile/android/app/src/main/res/layout/activity_stream_card_history_item.xml
mobile/android/app/src/main/res/layout/activity_stream_overridable_page_icon_layout.xml
mobile/android/app/src/main/res/layout/activity_stream_page_icon_layout.xml
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/HighlightItem.java
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/StreamOverridablePageIconLayout.java
mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/StreamPageIconLayout.java
mobile/android/base/moz.build
--- a/mobile/android/app/src/main/res/layout/activity_stream_card_history_item.xml
+++ b/mobile/android/app/src/main/res/layout/activity_stream_card_history_item.xml
@@ -12,17 +12,17 @@
 
     <!-- On some devices, marginBottom is ignored for Views within a RelativeLayout.
          Wrapping in a FrameLayout appears to be a sufficient workaround for this issue -->
     <FrameLayout
         android:id="@+id/icon_wrapper"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content">
 
-        <org.mozilla.gecko.activitystream.homepanel.stream.StreamPageIconLayout
+        <org.mozilla.gecko.activitystream.homepanel.stream.StreamOverridablePageIconLayout
                 android:id="@+id/icon"
                 android:layout_width="@dimen/favicon_bg"
                 android:layout_height="@dimen/favicon_bg"
                 android:layout_marginStart="@dimen/activity_stream_base_margin"
                 android:layout_marginLeft="@dimen/activity_stream_base_margin"
                 android:layout_marginTop="@dimen/activity_stream_base_margin"
                 android:layout_marginBottom="@dimen/activity_stream_base_margin"
                 android:layout_gravity="center"
rename from mobile/android/app/src/main/res/layout/activity_stream_page_icon_layout.xml
rename to mobile/android/app/src/main/res/layout/activity_stream_overridable_page_icon_layout.xml
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/HighlightItem.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/HighlightItem.java
@@ -20,49 +20,48 @@ import org.mozilla.gecko.activitystream.
 import org.mozilla.gecko.activitystream.Utils;
 import org.mozilla.gecko.activitystream.homepanel.menu.ActivityStreamContextMenu;
 import org.mozilla.gecko.activitystream.homepanel.model.Highlight;
 import org.mozilla.gecko.home.HomePager;
 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 org.mozilla.gecko.widget.FaviconView;
 
 import java.lang.ref.WeakReference;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.UUID;
 
 public class HighlightItem extends StreamItem {
     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 Highlight highlight;
     private int position;
 
-    private final StreamPageIconLayout pageIconLayout;
+    private final StreamOverridablePageIconLayout pageIconLayout;
     private final TextView pageTitleView;
     private final TextView pageSourceView;
     private final TextView pageDomainView;
     private final ImageView pageSourceIconView;
 
     private int tilesMargin;
 
     public HighlightItem(final View itemView,
                          final HomePager.OnUrlOpenListener onUrlOpenListener,
                          final HomePager.OnUrlOpenInBackgroundListener onUrlOpenInBackgroundListener) {
         super(itemView);
 
         tilesMargin = itemView.getResources().getDimensionPixelSize(R.dimen.activity_stream_base_margin);
 
         pageTitleView = (TextView) itemView.findViewById(R.id.card_history_label);
-        pageIconLayout = (StreamPageIconLayout) itemView.findViewById(R.id.icon);
+        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);
 
         final ImageView menuButton = (ImageView) itemView.findViewById(R.id.menu);
 
         menuButton.setImageDrawable(
                 DrawableUtil.tintDrawable(menuButton.getContext(), R.drawable.menu, Color.LTGRAY));
rename from mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/StreamPageIconLayout.java
rename to mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/StreamOverridablePageIconLayout.java
--- a/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/StreamPageIconLayout.java
+++ b/mobile/android/base/java/org/mozilla/gecko/activitystream/homepanel/stream/StreamOverridablePageIconLayout.java
@@ -19,40 +19,40 @@ import org.mozilla.gecko.R;
 import org.mozilla.gecko.icons.IconCallback;
 import org.mozilla.gecko.icons.IconResponse;
 import org.mozilla.gecko.icons.Icons;
 import org.mozilla.gecko.widget.FaviconView;
 
 import java.util.concurrent.Future;
 
 /**
- * A layout that represents page icons in Activity Stream.
+ * A layout that represents page icons in Activity Stream, which can be overridden with a custom URL.
  *
  * Under the hood, it switches between multiple icon views because favicons (in FaviconView)
  * are handled differently from other types of page images.
  *
  * An alternative implementation would create a flag to override FaviconView to handle non-favicon images but I
  * found it to be more complicated: all code added to FaviconView has to be aware of which state it's in. This
  * composable switcher layout abstracts the switching state from the FaviconView and keeps it simple, but will
  * use slightly more resources.
  */
-public class StreamPageIconLayout extends FrameLayout implements IconCallback {
+public class StreamOverridablePageIconLayout extends FrameLayout implements IconCallback {
 
     private enum UIMode {
         FAVICON_IMAGE, NONFAVICON_IMAGE
     }
 
     private FaviconView faviconView;
     private ImageView imageView;
 
     private @Nullable Future<IconResponse> ongoingFaviconLoad;
 
-    public StreamPageIconLayout(final Context context, final AttributeSet attrs) {
+    public StreamOverridablePageIconLayout(final Context context, final AttributeSet attrs) {
         super(context, attrs);
-        LayoutInflater.from(context).inflate(R.layout.activity_stream_page_icon_layout, this, true);
+        LayoutInflater.from(context).inflate(R.layout.activity_stream_overridable_page_icon_layout, this, true);
         initViews();
     }
 
     /**
      * Updates the icon for the view. If a non-null overrideImageURL is provided, this image will be shown.
      * Otherwise, a favicon will be retrieved for the given pageURL.
      */
     public void updateIcon(@NonNull final String pageURL, @Nullable final String overrideImageURL) {
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -514,17 +514,17 @@ gbjar.sources += ['java/org/mozilla/geck
     'activitystream/homepanel/menu/PopupContextMenu.java',
     'activitystream/homepanel/model/Highlight.java',
     'activitystream/homepanel/model/Item.java',
     'activitystream/homepanel/model/Metadata.java',
     'activitystream/homepanel/model/TopSite.java',
     'activitystream/homepanel/stream/HighlightItem.java',
     'activitystream/homepanel/stream/HighlightsTitle.java',
     'activitystream/homepanel/stream/StreamItem.java',
-    'activitystream/homepanel/stream/StreamPageIconLayout.java',
+    'activitystream/homepanel/stream/StreamOverridablePageIconLayout.java',
     'activitystream/homepanel/stream/TopPanel.java',
     'activitystream/homepanel/stream/WelcomePanel.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',