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..8f6ee85a5263091f261004525e849d59bd3a4b4b 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 an icon. |
*/ |
- TabularContextMenuListAdapter(List<ContextMenuItem> menuItems, Activity activity) { |
+ TabularContextMenuListAdapter(List<ContextMenuItem> menuItems, Activity activity, |
+ ContextMenuHelper contextMenuHelper) { |
mMenuItems = menuItems; |
mActivity = activity; |
+ mContextMenuHelper = contextMenuHelper; |
} |
@Override |
@@ -82,6 +87,26 @@ 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.setVisibility(View.GONE); |
+ } |
+ |
return convertView; |
} |