Chromium Code Reviews| Index: ui/android/java/src/org/chromium/ui/autofill/AutofillKeyboardAccessory.java |
| diff --git a/ui/android/java/src/org/chromium/ui/autofill/AutofillKeyboardAccessory.java b/ui/android/java/src/org/chromium/ui/autofill/AutofillKeyboardAccessory.java |
| index 1968592db34b41b689b18811daa6030f0c576b30..81b23f9567a21d51aabf082d6f84653a0f417f32 100644 |
| --- a/ui/android/java/src/org/chromium/ui/autofill/AutofillKeyboardAccessory.java |
| +++ b/ui/android/java/src/org/chromium/ui/autofill/AutofillKeyboardAccessory.java |
| @@ -25,36 +25,21 @@ import org.chromium.ui.gfx.DeviceDisplayInfo; |
| * below the content area. |
| */ |
| public class AutofillKeyboardAccessory extends LinearLayout |
| - implements WindowAndroid.KeyboardVisibilityListener, View.OnClickListener { |
| + implements WindowAndroid.KeyboardVisibilityListener, View.OnClickListener, |
| + View.OnLongClickListener { |
| private final WindowAndroid mWindowAndroid; |
| - private final AutofillKeyboardAccessoryDelegate mAutofillCallback; |
| + private final AutofillDelegate mAutofillCallback; |
| private final int mMaximumLabelWidthPx; |
| private final int mMaximumSublabelWidthPx; |
| /** |
| - * An interface to handle the touch interaction with an AutofillKeyboardAccessory object. |
| - */ |
| - public interface AutofillKeyboardAccessoryDelegate { |
| - /** |
| - * Informs the controller the AutofillKeyboardAccessory was hidden. |
| - */ |
| - public void dismissed(); |
| - |
| - /** |
| - * Handles the selection of an Autofill suggestion from an AutofillKeyboardAccessory. |
| - * @param listIndex The index of the selected Autofill suggestion. |
| - */ |
| - public void suggestionSelected(int listIndex); |
| - } |
| - |
| - /** |
| * Creates an AutofillKeyboardAccessory with specified parameters. |
| * @param windowAndroid The owning WindowAndroid. |
| * @param autofillCallback A object that handles the calls to the native |
| * AutofillKeyboardAccessoryView. |
| */ |
| public AutofillKeyboardAccessory( |
| - WindowAndroid windowAndroid, AutofillKeyboardAccessoryDelegate autofillCallback) { |
| + WindowAndroid windowAndroid, AutofillDelegate autofillCallback) { |
|
newt (away)
2015/08/10 20:39:37
s/callback/delegate. Same for the member variable
please use gerrit instead
2015/08/11 20:42:19
Done.
|
| super(windowAndroid.getActivity().get()); |
| assert autofillCallback != null; |
| assert windowAndroid.getActivity().get() != null; |
| @@ -85,6 +70,9 @@ public class AutofillKeyboardAccessory extends LinearLayout |
| View touchTarget = LayoutInflater.from(getContext()).inflate( |
| R.layout.autofill_keyboard_accessory_item, this, false); |
| touchTarget.setOnClickListener(this); |
| + if (suggestion.isDeletable()) { |
| + touchTarget.setOnLongClickListener(this); |
| + } |
| TextView label = (TextView) touchTarget.findViewById( |
| R.id.autofill_keyboard_accessory_item_label); |
| label.setMaxWidth(mMaximumLabelWidthPx); |
| @@ -154,4 +142,18 @@ public class AutofillKeyboardAccessory extends LinearLayout |
| assert false; |
| } |
| + |
| + @Override |
| + public boolean onLongClick(View v) { |
| + int count = getChildCount(); |
| + for (int i = 0; i < count; i++) { |
| + if (getChildAt(i) == v) { |
| + mAutofillCallback.deleteSuggestion(i); |
|
newt (away)
2015/08/10 20:39:37
If this LinearLayout ever contains child views oth
please use gerrit instead
2015/08/11 20:42:19
This is prevented by calling setOnLongClickListene
|
| + return true; |
| + } |
| + } |
| + |
| + assert false; |
| + return false; |
| + } |
| } |