Chromium Code Reviews| 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; |
| } |