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

Unified Diff: ui/android/java/src/org/chromium/ui/autofill/AutofillKeyboardAccessory.java

Issue 1281323003: Remove items on long press in keyboard accessory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixups Created 5 years, 4 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: 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..93c4f702d9b878ccf84f1b3c104c6e6d1659e720 100644
--- a/ui/android/java/src/org/chromium/ui/autofill/AutofillKeyboardAccessory.java
+++ b/ui/android/java/src/org/chromium/ui/autofill/AutofillKeyboardAccessory.java
@@ -25,41 +25,26 @@ 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 mAutofillDelegate;
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.
+ * @param autofillDelegate A object that handles the calls to the native
+ * AutofillKeyboardAccessoryView.
*/
public AutofillKeyboardAccessory(
- WindowAndroid windowAndroid, AutofillKeyboardAccessoryDelegate autofillCallback) {
+ WindowAndroid windowAndroid, AutofillDelegate autofillDelegate) {
super(windowAndroid.getActivity().get());
- assert autofillCallback != null;
+ assert autofillDelegate != null;
assert windowAndroid.getActivity().get() != null;
mWindowAndroid = windowAndroid;
- mAutofillCallback = autofillCallback;
+ mAutofillDelegate = autofillDelegate;
int deviceWidthPx = DeviceDisplayInfo.create(getContext()).getDisplayWidth();
mMaximumLabelWidthPx = deviceWidthPx / 2;
@@ -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);
@@ -138,7 +126,7 @@ public class AutofillKeyboardAccessory extends LinearLayout
public void keyboardVisibilityChanged(boolean isShowing) {
if (!isShowing) {
dismiss();
- mAutofillCallback.dismissed();
+ mAutofillDelegate.dismissed();
}
}
@@ -147,11 +135,25 @@ public class AutofillKeyboardAccessory extends LinearLayout
int count = getChildCount();
for (int i = 0; i < count; i++) {
if (getChildAt(i) == v) {
- mAutofillCallback.suggestionSelected(i);
+ mAutofillDelegate.suggestionSelected(i);
return;
}
}
assert false;
}
+
+ @Override
+ public boolean onLongClick(View v) {
+ int count = getChildCount();
+ for (int i = 0; i < count; i++) {
+ if (getChildAt(i) == v) {
+ mAutofillDelegate.deleteSuggestion(i);
newt (away) 2015/08/11 21:31:32 Consider this scenario: AutofillKeyboardAccesso
+ return true;
+ }
+ }
+
+ assert false;
+ return false;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698