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

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

Issue 2382913004: Move autofill from ui/ to components/ (Closed)
Patch Set: move dimens cleanly Created 4 years, 2 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
deleted file mode 100644
index 865cff26857e712aa9d946d2f47fddb6f98cdc13..0000000000000000000000000000000000000000
--- a/ui/android/java/src/org/chromium/ui/autofill/AutofillPopup.java
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.ui.autofill;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.PopupWindow;
-
-import org.chromium.ui.DropdownAdapter;
-import org.chromium.ui.DropdownItem;
-import org.chromium.ui.DropdownPopupWindow;
-import org.chromium.ui.R;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-
-/**
- * The Autofill suggestion popup that lists relevant suggestions.
- */
-public class AutofillPopup extends DropdownPopupWindow implements AdapterView.OnItemClickListener,
- AdapterView.OnItemLongClickListener, PopupWindow.OnDismissListener {
-
- /**
- * The constant used to specify a separator in a list of Autofill suggestions.
- * Has to be kept in sync with enum in WebAutofillClient.h
- */
- private static final int ITEM_ID_SEPARATOR_ENTRY = -3;
-
- private final Context mContext;
- private final AutofillDelegate mAutofillDelegate;
- private List<AutofillSuggestion> mSuggestions;
-
- /**
- * Creates an AutofillWindow with specified parameters.
- * @param context Application context.
- * @param anchorView View anchored for popup.
- * @param autofillDelegate An object that handles the calls to the native AutofillPopupView.
- */
- public AutofillPopup(Context context, View anchorView, AutofillDelegate autofillDelegate) {
- super(context, anchorView);
- mContext = context;
- mAutofillDelegate = autofillDelegate;
-
- setOnItemClickListener(this);
- setOnDismissListener(this);
- disableHideOnOutsideTap();
- setContentDescriptionForAccessibility(
- mContext.getString(R.string.autofill_popup_content_description));
- }
-
- /**
- * Filters the Autofill suggestions to the ones that we support and shows the popup.
- * @param suggestions Autofill suggestion data.
- */
- @SuppressLint("InlinedApi")
- public void filterAndShow(AutofillSuggestion[] suggestions, boolean isRtl) {
- mSuggestions = new ArrayList<AutofillSuggestion>(Arrays.asList(suggestions));
- // Remove the AutofillSuggestions with IDs that are not supported by Android
- ArrayList<DropdownItem> cleanedData = new ArrayList<DropdownItem>();
- HashSet<Integer> separators = new HashSet<Integer>();
- for (int i = 0; i < suggestions.length; i++) {
- int itemId = suggestions[i].getSuggestionId();
- if (itemId == ITEM_ID_SEPARATOR_ENTRY) {
- separators.add(cleanedData.size());
- } else {
- cleanedData.add(suggestions[i]);
- }
- }
-
- setAdapter(new DropdownAdapter(mContext, cleanedData, separators));
- setRtl(isRtl);
- show();
- getListView().setOnItemLongClickListener(this);
- }
-
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- DropdownAdapter adapter = (DropdownAdapter) parent.getAdapter();
- int listIndex = mSuggestions.indexOf(adapter.getItem(position));
- assert listIndex > -1;
- mAutofillDelegate.suggestionSelected(listIndex);
- }
-
- @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;
- mAutofillDelegate.deleteSuggestion(listIndex);
- return true;
- }
-
- @Override
- public void onDismiss() {
- mAutofillDelegate.dismissed();
- }
-}

Powered by Google App Engine
This is Rietveld 408576698