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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillKeyboardAccessoryBridge.java

Issue 1082183002: Android - Introduce "keyboard accessory" for Autofill suggestions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 5 years, 8 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: chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillKeyboardAccessoryBridge.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopupBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillKeyboardAccessoryBridge.java
similarity index 52%
copy from chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopupBridge.java
copy to chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillKeyboardAccessoryBridge.java
index 773632c8f9175f2550fe1f78ebc09b86e98e29c4..60afbd7f139be7ca5a5185c18de4683d6ded20ff 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillPopupBridge.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill/AutofillKeyboardAccessoryBridge.java
@@ -4,33 +4,32 @@
package org.chromium.chrome.browser.autofill;
-import android.app.Activity;
import android.os.Handler;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.chrome.browser.ResourceId;
import org.chromium.ui.DropdownItem;
-import org.chromium.ui.autofill.AutofillPopup;
-import org.chromium.ui.autofill.AutofillPopup.AutofillPopupDelegate;
+import org.chromium.ui.autofill.AutofillKeyboardAccessory;
+import org.chromium.ui.autofill.AutofillKeyboardAccessory.AutofillKeyboardAccessoryDelegate;
import org.chromium.ui.autofill.AutofillSuggestion;
-import org.chromium.ui.base.ViewAndroidDelegate;
import org.chromium.ui.base.WindowAndroid;
/**
* JNI call glue for AutofillExternalDelagate C++ and Java objects.
+* This provides an alternative UI for Autofill suggestions, and replaces AutofillPopupBridge when
+* --enable-autofill-keyboard-accessory-view is passed on the command line.
*/
@JNINamespace("autofill")
-public class AutofillPopupBridge implements AutofillPopupDelegate{
- private final long mNativeAutofillPopup;
- private final AutofillPopup mAutofillPopup;
+public class AutofillKeyboardAccessoryBridge implements AutofillKeyboardAccessoryDelegate {
+ private final long mNativeAutofillKeyboardAccessory;
+ private final AutofillKeyboardAccessory mAccessoryView;
- public AutofillPopupBridge(long nativeAutofillPopupViewAndroid, WindowAndroid windowAndroid,
- ViewAndroidDelegate containerViewDelegate) {
- mNativeAutofillPopup = nativeAutofillPopupViewAndroid;
- Activity activity = windowAndroid.getActivity().get();
- if (activity == null) {
- mAutofillPopup = null;
+ public AutofillKeyboardAccessoryBridge(
+ long nativeAutofillKeyboardAccessory, WindowAndroid windowAndroid) {
+ mNativeAutofillKeyboardAccessory = nativeAutofillKeyboardAccessory;
+ if (windowAndroid.getActivity().get() == null) {
+ mAccessoryView = null;
David Trainor- moved to gerrit 2015/04/20 23:29:43 Do you need this line?
Evan Stade 2015/04/21 00:48:51 code removed
// Clean up the native counterpart. This is posted to allow the native counterpart
// to fully finish the construction of this glue object before we attempt to delete it.
new Handler().post(new Runnable() {
@@ -40,57 +39,47 @@ public class AutofillPopupBridge implements AutofillPopupDelegate{
}
});
} else {
- mAutofillPopup = new AutofillPopup(activity, containerViewDelegate, this);
+ mAccessoryView = new AutofillKeyboardAccessory(windowAndroid, this);
}
}
@CalledByNative
- private static AutofillPopupBridge create(long nativeAutofillPopupViewAndroid,
- WindowAndroid windowAndroid, ViewAndroidDelegate viewAndroidDelegate) {
- return new AutofillPopupBridge(
- nativeAutofillPopupViewAndroid, windowAndroid, viewAndroidDelegate);
+ private static AutofillKeyboardAccessoryBridge create(
+ long nativeAutofillKeyboardAccessoryView, WindowAndroid windowAndroid) {
+ return new AutofillKeyboardAccessoryBridge(
+ nativeAutofillKeyboardAccessoryView, windowAndroid);
}
@Override
public void dismissed() {
- nativePopupDismissed(mNativeAutofillPopup);
+ nativeViewDismissed(mNativeAutofillKeyboardAccessory);
}
@Override
public void suggestionSelected(int listIndex) {
- nativeSuggestionSelected(mNativeAutofillPopup, listIndex);
+ nativeSuggestionSelected(mNativeAutofillKeyboardAccessory, listIndex);
}
/**
- * Hides the Autofill Popup and removes its anchor from the ContainerView.
+ * Hides the Autofill view.
*/
@CalledByNative
private void dismiss() {
- if (mAutofillPopup != null) mAutofillPopup.dismiss();
+ if (mAccessoryView != null) mAccessoryView.dismiss();
}
/**
- * Shows an Autofill popup with specified suggestions.
+ * Shows an Autofill view with specified suggestions.
* @param suggestions Autofill suggestions to be displayed.
*/
@CalledByNative
private void show(AutofillSuggestion[] suggestions, boolean isRtl) {
- if (mAutofillPopup != null) mAutofillPopup.filterAndShow(suggestions, isRtl);
+ if (mAccessoryView != null) mAccessoryView.filterAndShow(suggestions, isRtl);
}
- /**
- * Sets the location and size of the Autofill popup anchor (input field).
- * @param x X coordinate.
- * @param y Y coordinate.
- * @param width The width of the anchor.
- * @param height The height of the anchor.
- */
- @CalledByNative
- private void setAnchorRect(float x, float y, float width, float height) {
- if (mAutofillPopup != null) mAutofillPopup.setAnchorRect(x, y, width, height);
- }
-
- // Helper methods for AutofillSuggestion
+ // Helper methods for AutofillSuggestion. These are copied from AutofillPopupBridge (which
+ // should
+ // eventually disappear).
@CalledByNative
private static AutofillSuggestion[] createAutofillSuggestionArray(int size) {
@@ -112,7 +101,7 @@ public class AutofillPopupBridge implements AutofillPopupDelegate{
array[index] = new AutofillSuggestion(label, sublabel, drawableId, suggestionId);
}
- private native void nativePopupDismissed(long nativeAutofillPopupViewAndroid);
- private native void nativeSuggestionSelected(long nativeAutofillPopupViewAndroid,
- int listIndex);
+ private native void nativeViewDismissed(long nativeAutofillKeyboardAccessoryView);
+ private native void nativeSuggestionSelected(
+ long nativeAutofillKeyboardAccessoryView, int listIndex);
}

Powered by Google App Engine
This is Rietveld 408576698