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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/PlatformContextMenuUi.java

Issue 2775373002: Add a Share Icon to Tabular Context Menu (Closed)
Patch Set: Fixed more tests! Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.contextmenu; 5 package org.chromium.chrome.browser.contextmenu;
6 6
7 import android.app.Activity;
7 import android.content.Context; 8 import android.content.Context;
8 import android.text.TextUtils; 9 import android.text.TextUtils;
9 import android.util.Pair; 10 import android.util.Pair;
10 import android.view.ContextMenu; 11 import android.view.ContextMenu;
11 import android.view.MenuItem; 12 import android.view.MenuItem;
12 13
13 import org.chromium.base.Callback; 14 import org.chromium.base.Callback;
14 15
15 import java.util.List; 16 import java.util.List;
16 17
17 /** 18 /**
18 * A context menu that displays the Android Standard Context Menu. Comes the Ite m Groups into one 19 * A context menu that displays the Android Standard Context Menu. Comes the Ite m Groups into one
19 * list displayed in the order received. 20 * list displayed in the order received.
20 */ 21 */
21 public class PlatformContextMenuUi implements ContextMenuUi { 22 public class PlatformContextMenuUi implements ContextMenuUi {
22 private ContextMenu mMenu; 23 private ContextMenu mMenu;
23 24
24 PlatformContextMenuUi(ContextMenu menu) { 25 PlatformContextMenuUi(ContextMenu menu) {
25 mMenu = menu; 26 mMenu = menu;
26 } 27 }
27 28
28 @Override 29 @Override
29 public void displayMenu(Context context, ContextMenuParams params, 30 public void displayMenu(Activity activity, ContextMenuParams params,
30 List<Pair<Integer, List<ContextMenuItem>>> itemGroups, final Callbac k<Integer> listener, 31 List<Pair<Integer, List<ContextMenuItem>>> itemGroups, final Callbac k<Integer> listener,
31 Runnable onMenuShown, Runnable onMenuClosed) { 32 Runnable onMenuShown, Runnable onMenuClosed) {
32 String headerText = ChromeContextMenuPopulator.createHeaderText(params); 33 String headerText = ChromeContextMenuPopulator.createHeaderText(params);
33 if (!TextUtils.isEmpty(headerText)) { 34 if (!TextUtils.isEmpty(headerText)) {
34 setHeaderText(context, mMenu, headerText); 35 setHeaderText(activity, mMenu, headerText);
35 } 36 }
36 37
37 MenuItem.OnMenuItemClickListener menuListener = new MenuItem.OnMenuItemC lickListener() { 38 MenuItem.OnMenuItemClickListener menuListener = new MenuItem.OnMenuItemC lickListener() {
38 @Override 39 @Override
39 public boolean onMenuItemClick(MenuItem menuItem) { 40 public boolean onMenuItemClick(MenuItem menuItem) {
40 listener.onResult(menuItem.getItemId()); 41 listener.onResult(menuItem.getItemId());
41 return true; 42 return true;
42 } 43 }
43 }; 44 };
44 for (int groupIndex = 0; groupIndex < itemGroups.size(); groupIndex++) { 45 for (int groupIndex = 0; groupIndex < itemGroups.size(); groupIndex++) {
45 List<ContextMenuItem> group = itemGroups.get(groupIndex).second; 46 List<ContextMenuItem> group = itemGroups.get(groupIndex).second;
46 for (int itemIndex = 0; itemIndex < group.size(); itemIndex++) { 47 for (int itemIndex = 0; itemIndex < group.size(); itemIndex++) {
47 ContextMenuItem item = group.get(itemIndex); 48 ContextMenuItem item = group.get(itemIndex);
48 MenuItem menuItem = mMenu.add(0, item.menuId, 0, item.getString( context)); 49 MenuItem menuItem = mMenu.add(0, item.menuId, 0, item.getString( activity));
49 menuItem.setOnMenuItemClickListener(menuListener); 50 menuItem.setOnMenuItemClickListener(menuListener);
50 } 51 }
51 } 52 }
52 } 53 }
53 54
54 private void setHeaderText(Context context, ContextMenu menu, String text) { 55 private void setHeaderText(Context context, ContextMenu menu, String text) {
55 ContextMenuTitleView title = new ContextMenuTitleView(context, text); 56 ContextMenuTitleView title = new ContextMenuTitleView(context, text);
56 menu.setHeaderView(title); 57 menu.setHeaderView(title);
57 } 58 }
58 } 59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698