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

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

Issue 1134793004: Autofill item deletion on android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test fix Created 5 years, 7 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/AutofillPopup.java
diff --git a/ui/android/java/src/org/chromium/ui/autofill/AutofillPopup.java b/ui/android/java/src/org/chromium/ui/autofill/AutofillPopup.java
index f41c3f464f3aa46ab6cad8df33584d17936838af..0019b4cd1d90c5474d0c712a7baff19406272afd 100644
--- a/ui/android/java/src/org/chromium/ui/autofill/AutofillPopup.java
+++ b/ui/android/java/src/org/chromium/ui/autofill/AutofillPopup.java
@@ -25,7 +25,7 @@ import java.util.List;
* The Autofill suggestion popup that lists relevant suggestions.
*/
public class AutofillPopup extends DropdownPopupWindow implements AdapterView.OnItemClickListener,
- PopupWindow.OnDismissListener {
+ AdapterView.OnItemLongClickListener, PopupWindow.OnDismissListener {
/**
* The constant used to specify a separator in a list of Autofill suggestions.
@@ -52,6 +52,12 @@ public class AutofillPopup extends DropdownPopupWindow implements AdapterView.On
* @param listIndex The index of the selected Autofill suggestion.
*/
public void suggestionSelected(int listIndex);
+
+ /**
+ * Initiates the deletion process for an item. (A confirm dialog should be shown.)
+ * @param listIndex The index of the suggestion to delete.
+ */
+ public void deleteSuggestion(int listIndex);
}
/**
@@ -95,6 +101,7 @@ public class AutofillPopup extends DropdownPopupWindow implements AdapterView.On
setAdapter(new DropdownAdapter(mContext, cleanedData, separators));
setRtl(isRtl);
show();
+ getListView().setOnItemLongClickListener(this);
}
@Override
@@ -106,6 +113,18 @@ public class AutofillPopup extends DropdownPopupWindow implements AdapterView.On
}
@Override
+ public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
+ DropdownAdapter adapter = (DropdownAdapter) parent.getAdapter();
+ AutofillSuggestion suggestion = (AutofillSuggestion) adapter.getItem(position);
+ if (!suggestion.isDeletable()) return false;
+
+ int listIndex = mSuggestions.indexOf(suggestion);
+ assert listIndex > -1;
+ mAutofillCallback.deleteSuggestion(listIndex);
+ return true;
+ }
+
+ @Override
public void onDismiss() {
mAutofillCallback.dismissed();
}

Powered by Google App Engine
This is Rietveld 408576698