OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.content.ClipboardManager; | 7 import android.content.ClipboardManager; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.view.ActionMode; | 9 import android.view.ActionMode; |
10 import android.view.Menu; | 10 import android.view.Menu; |
11 import android.view.MenuItem; | 11 import android.view.MenuItem; |
| 12 import android.widget.Toast; |
12 | 13 |
13 import org.chromium.content.R; | 14 import org.chromium.content.R; |
14 | 15 |
15 /** | 16 /** |
16 * An ActionMode.Callback for in-page selection. This class handles both the edi
table and | 17 * An ActionMode.Callback for in-page selection. This class handles both the edi
table and |
17 * non-editable cases. | 18 * non-editable cases. |
18 */ | 19 */ |
19 public class SelectActionModeCallback implements ActionMode.Callback { | 20 public class SelectActionModeCallback implements ActionMode.Callback { |
20 /** | 21 /** |
21 * An interface to retrieve information about the current selection, and als
o to perform | 22 * An interface to retrieve information about the current selection, and als
o to perform |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 130 } |
130 } | 131 } |
131 | 132 |
132 @Override | 133 @Override |
133 public boolean onActionItemClicked(ActionMode mode, MenuItem item) { | 134 public boolean onActionItemClicked(ActionMode mode, MenuItem item) { |
134 int id = item.getItemId(); | 135 int id = item.getItemId(); |
135 | 136 |
136 if (id == R.id.select_action_menu_select_all) { | 137 if (id == R.id.select_action_menu_select_all) { |
137 mActionHandler.selectAll(); | 138 mActionHandler.selectAll(); |
138 } else if (id == R.id.select_action_menu_cut) { | 139 } else if (id == R.id.select_action_menu_cut) { |
| 140 //toast message for cut/copy |
| 141 Toast.makeText(mContext, R.string.copy_to_clipboard_success_message, |
| 142 Toast.LENGTH_SHORT).show(); |
139 mActionHandler.cut(); | 143 mActionHandler.cut(); |
140 } else if (id == R.id.select_action_menu_copy) { | 144 } else if (id == R.id.select_action_menu_copy) { |
| 145 //toast message for cut/copy |
| 146 Toast.makeText(mContext, R.string.copy_to_clipboard_success_message, |
| 147 Toast.LENGTH_SHORT).show(); |
141 mActionHandler.copy(); | 148 mActionHandler.copy(); |
142 mode.finish(); | 149 mode.finish(); |
143 } else if (id == R.id.select_action_menu_paste) { | 150 } else if (id == R.id.select_action_menu_paste) { |
144 mActionHandler.paste(); | 151 mActionHandler.paste(); |
145 } else if (id == R.id.select_action_menu_share) { | 152 } else if (id == R.id.select_action_menu_share) { |
146 mActionHandler.share(); | 153 mActionHandler.share(); |
147 mode.finish(); | 154 mode.finish(); |
148 } else if (id == R.id.select_action_menu_web_search) { | 155 } else if (id == R.id.select_action_menu_web_search) { |
149 mActionHandler.search(); | 156 mActionHandler.search(); |
150 mode.finish(); | 157 mode.finish(); |
151 } else { | 158 } else { |
152 return false; | 159 return false; |
153 } | 160 } |
154 return true; | 161 return true; |
155 } | 162 } |
156 | 163 |
157 @Override | 164 @Override |
158 public void onDestroyActionMode(ActionMode mode) { | 165 public void onDestroyActionMode(ActionMode mode) { |
159 mActionHandler.onDestroyActionMode(); | 166 mActionHandler.onDestroyActionMode(); |
160 } | 167 } |
161 | 168 |
162 private boolean canPaste() { | 169 private boolean canPaste() { |
163 ClipboardManager clipMgr = (ClipboardManager) | 170 ClipboardManager clipMgr = (ClipboardManager) |
164 getContext().getSystemService(Context.CLIPBOARD_SERVICE); | 171 getContext().getSystemService(Context.CLIPBOARD_SERVICE); |
165 return clipMgr.hasPrimaryClip(); | 172 return clipMgr.hasPrimaryClip(); |
166 } | 173 } |
167 } | 174 } |
OLD | NEW |