Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4706)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuListAdapter.java

Issue 2775373002: Add a Share Icon to Tabular Context Menu (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuListAdapter.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuListAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuListAdapter.java
index 80894d34dbc3785be33d3195becc982dcec2a481..585396a05bfdc1675b8e5bc821501c9be709a082 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuListAdapter.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuListAdapter.java
@@ -15,6 +15,7 @@ import android.widget.ImageView;
import android.widget.TextView;
import org.chromium.chrome.R;
+import org.chromium.chrome.browser.share.ShareHelper;
import java.util.List;
@@ -25,15 +26,19 @@ import java.util.List;
class TabularContextMenuListAdapter extends BaseAdapter {
private final List<ContextMenuItem> mMenuItems;
private final Activity mActivity;
+ private final ContextMenuHelper mContextMenuHelper;
/**
* Adapter for the tabular context menu UI
* @param menuItems The list of items to display in the view.
* @param activity Used to inflate the layout.
+ * @param contextMenuHelper Used to directly share an image through the icon.
Theresa 2017/03/27 21:17:43 nit: ... through an icon.
JJ 2017/03/27 23:23:09 Done.
*/
- TabularContextMenuListAdapter(List<ContextMenuItem> menuItems, Activity activity) {
+ TabularContextMenuListAdapter(List<ContextMenuItem> menuItems, Activity activity,
+ ContextMenuHelper contextMenuHelper) {
mMenuItems = menuItems;
mActivity = activity;
+ mContextMenuHelper = contextMenuHelper;
}
@Override
@@ -82,6 +87,29 @@ class TabularContextMenuListAdapter extends BaseAdapter {
viewHolder.mIcon.setContentDescription(null);
}
+ if (menuItem == ContextMenuItem.SHARE_IMAGE) {
+ final Pair<Drawable, CharSequence> shareInfo =
+ ShareHelper.getShareableIconAndName(mActivity);
+ if (shareInfo.first != null) {
+ viewHolder.mShareIcon.setImageDrawable(shareInfo.first);
+ viewHolder.mShareIcon.setVisibility(View.VISIBLE);
+ viewHolder.mShareIcon.setContentDescription(mActivity.getString(
+ R.string.accessibility_menu_share_via, iconPair.second));
+ viewHolder.mShareIcon.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ mContextMenuHelper.shareImageDirectly(
+ ShareHelper.getLastShareComponentName());
+ }
+ });
+ }
+ } else {
+ viewHolder.mShareIcon.setImageDrawable(null);
+ viewHolder.mShareIcon.setVisibility(View.GONE);
Theresa 2017/03/27 21:17:43 You should just be able to set visibility to GONE
JJ 2017/03/27 23:23:09 True. I'll change it so!
+ viewHolder.mShareIcon.setOnClickListener(null);
+ viewHolder.mShareIcon.setContentDescription(null);
+ }
+
return convertView;
}

Powered by Google App Engine
This is Rietveld 408576698