| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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.ui.autofill; | 5 package org.chromium.ui.autofill; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.view.View; | 9 import android.view.View; |
| 10 import android.widget.AdapterView; | 10 import android.widget.AdapterView; |
| 11 import android.widget.PopupWindow; | 11 import android.widget.PopupWindow; |
| 12 | 12 |
| 13 import org.chromium.ui.DropdownAdapter; | 13 import org.chromium.ui.DropdownAdapter; |
| 14 import org.chromium.ui.DropdownItem; | 14 import org.chromium.ui.DropdownItem; |
| 15 import org.chromium.ui.DropdownPopupWindow; | 15 import org.chromium.ui.DropdownPopupWindow; |
| 16 import org.chromium.ui.R; | 16 import org.chromium.ui.R; |
| 17 import org.chromium.ui.base.ViewAndroidDelegate; | |
| 18 | 17 |
| 19 import java.util.ArrayList; | 18 import java.util.ArrayList; |
| 20 import java.util.Arrays; | 19 import java.util.Arrays; |
| 21 import java.util.HashSet; | 20 import java.util.HashSet; |
| 22 import java.util.List; | 21 import java.util.List; |
| 23 | 22 |
| 24 /** | 23 /** |
| 25 * The Autofill suggestion popup that lists relevant suggestions. | 24 * The Autofill suggestion popup that lists relevant suggestions. |
| 26 */ | 25 */ |
| 27 public class AutofillPopup extends DropdownPopupWindow implements AdapterView.On
ItemClickListener, | 26 public class AutofillPopup extends DropdownPopupWindow implements AdapterView.On
ItemClickListener, |
| 28 AdapterView.OnItemLongClickListener, PopupWindow.OnDismissListener { | 27 AdapterView.OnItemLongClickListener, PopupWindow.OnDismissListener { |
| 29 | 28 |
| 30 /** | 29 /** |
| 31 * The constant used to specify a separator in a list of Autofill suggestion
s. | 30 * The constant used to specify a separator in a list of Autofill suggestion
s. |
| 32 * Has to be kept in sync with enum in WebAutofillClient.h | 31 * Has to be kept in sync with enum in WebAutofillClient.h |
| 33 */ | 32 */ |
| 34 private static final int ITEM_ID_SEPARATOR_ENTRY = -3; | 33 private static final int ITEM_ID_SEPARATOR_ENTRY = -3; |
| 35 | 34 |
| 36 private final Context mContext; | 35 private final Context mContext; |
| 37 private final AutofillDelegate mAutofillDelegate; | 36 private final AutofillDelegate mAutofillDelegate; |
| 38 private List<AutofillSuggestion> mSuggestions; | 37 private List<AutofillSuggestion> mSuggestions; |
| 39 | 38 |
| 40 /** | 39 /** |
| 41 * Creates an AutofillWindow with specified parameters. | 40 * Creates an AutofillWindow with specified parameters. |
| 42 * @param context Application context. | 41 * @param context Application context. |
| 43 * @param viewAndroidDelegate View delegate used to add and remove views. | 42 * @param anchorView View anchored for popup. |
| 43 * @param anchorWidth Width of the anchor view. |
| 44 * @param autofillDelegate An object that handles the calls to the native Au
tofillPopupView. | 44 * @param autofillDelegate An object that handles the calls to the native Au
tofillPopupView. |
| 45 */ | 45 */ |
| 46 public AutofillPopup(Context context, ViewAndroidDelegate viewAndroidDelegat
e, | 46 public AutofillPopup(Context context, View anchorView, float anchorWidth, |
| 47 AutofillDelegate autofillDelegate) { | 47 AutofillDelegate autofillDelegate) { |
| 48 super(context, viewAndroidDelegate); | 48 super(context, anchorView, anchorWidth); |
| 49 mContext = context; | 49 mContext = context; |
| 50 mAutofillDelegate = autofillDelegate; | 50 mAutofillDelegate = autofillDelegate; |
| 51 | 51 |
| 52 setOnItemClickListener(this); | 52 setOnItemClickListener(this); |
| 53 setOnDismissListener(this); | 53 setOnDismissListener(this); |
| 54 disableHideOnOutsideTap(); | 54 disableHideOnOutsideTap(); |
| 55 setContentDescriptionForAccessibility( | 55 setContentDescriptionForAccessibility( |
| 56 mContext.getString(R.string.autofill_popup_content_description))
; | 56 mContext.getString(R.string.autofill_popup_content_description))
; |
| 57 } | 57 } |
| 58 | 58 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 assert listIndex > -1; | 99 assert listIndex > -1; |
| 100 mAutofillDelegate.deleteSuggestion(listIndex); | 100 mAutofillDelegate.deleteSuggestion(listIndex); |
| 101 return true; | 101 return true; |
| 102 } | 102 } |
| 103 | 103 |
| 104 @Override | 104 @Override |
| 105 public void onDismiss() { | 105 public void onDismiss() { |
| 106 mAutofillDelegate.dismissed(); | 106 mAutofillDelegate.dismissed(); |
| 107 } | 107 } |
| 108 } | 108 } |
| OLD | NEW |