Bug 1312467 - Add context menu support to topsites r=sebastian
authorAndrzej Hunt <ahunt@mozilla.com>
Tue, 25 Oct 2016 11:38:52 -0700
changeset 320290 9f65ac29fa2447c4a590dd025753ff133279b404
parent 320289 aa12d5ecd8b6cb4c7293302fb9c67bf273620aec
child 320291 a9f1a369aa956e40bca3f7fe5fcbd2138dd6f044
push id30895
push userphilringnalda@gmail.com
push dateTue, 01 Nov 2016 01:31:50 +0000
treeherdermozilla-central@62c5218b7325 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1312467
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1312467 - Add context menu support to topsites r=sebastian MozReview-Commit-ID: TQ4gTgRqGq
mobile/android/base/java/org/mozilla/gecko/home/activitystream/topsites/TopSitesCard.java
--- a/mobile/android/base/java/org/mozilla/gecko/home/activitystream/topsites/TopSitesCard.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/activitystream/topsites/TopSitesCard.java
@@ -14,16 +14,17 @@ import android.widget.TextView;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.activitystream.ActivityStream;
 import org.mozilla.gecko.home.HomePager;
 import org.mozilla.gecko.home.activitystream.menu.ActivityStreamContextMenu;
 import org.mozilla.gecko.icons.IconCallback;
 import org.mozilla.gecko.icons.IconResponse;
 import org.mozilla.gecko.icons.Icons;
 import org.mozilla.gecko.util.DrawableUtil;
+import org.mozilla.gecko.util.TouchTargetUtil;
 import org.mozilla.gecko.widget.FaviconView;
 
 import java.util.EnumSet;
 import java.util.concurrent.Future;
 
 class TopSitesCard extends RecyclerView.ViewHolder
         implements IconCallback, View.OnClickListener {
     private final FaviconView faviconView;
@@ -44,16 +45,19 @@ class TopSitesCard extends RecyclerView.
 
         title = (TextView) card.findViewById(R.id.title);
         menuButton = (ImageView) card.findViewById(R.id.menu);
 
         this.onUrlOpenListener = onUrlOpenListener;
         this.onUrlOpenInBackgroundListener = onUrlOpenInBackgroundListener;
 
         card.setOnClickListener(this);
+
+        TouchTargetUtil.ensureTargetHitArea(menuButton, card);
+        menuButton.setOnClickListener(this);
     }
 
     void bind(final TopSitesPageAdapter.TopSite topSite) {
         final String label = ActivityStream.extractLabel(topSite.url, true);
         title.setText(label);
 
         this.url = topSite.url;
 
@@ -77,11 +81,15 @@ class TopSitesCard extends RecyclerView.
         menuButton.setImageDrawable(
                 DrawableUtil.tintDrawable(menuButton.getContext(), R.drawable.menu, tintColor));
     }
 
     @Override
     public void onClick(View clickedView) {
         if (clickedView == itemView) {
             onUrlOpenListener.onUrlOpen(url, EnumSet.noneOf(HomePager.OnUrlOpenListener.Flags.class));
+        } else if (clickedView == menuButton) {
+            ActivityStreamContextMenu.show(clickedView.getContext(), title.getText().toString(), url,
+                    onUrlOpenListener, onUrlOpenInBackgroundListener,
+                    faviconView.getWidth(), faviconView.getHeight());
         }
     }
 }