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

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: Fixes based off twellington's comments 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..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;
}

Powered by Google App Engine
This is Rietveld 408576698