Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db8d19c9 authored by Ben Murdoch's avatar Ben Murdoch
Browse files

Display the AutoFill preview string in the drop down box.

Native code now provides us with a preview string as well as
an autofill query id. Display the preview string in the
drop down box.

Requires a change in external/webkit:
https://android-git.corp.google.com/g/#change,77132

Change-Id: Ia5e26b98546cda1090142f1720f6a7836be6595c
parent 202a2c97
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -741,7 +741,7 @@ public class WebView extends AbsoluteLayout
    // for event log
    private long mLastTouchUpTime = 0;

    private int mAutoFillQueryId = WebTextView.FORM_NOT_AUTOFILLABLE;
    private WebViewCore.AutoFillData mAutoFillData;

    /**
     * URI scheme for telephone number
@@ -3911,7 +3911,7 @@ public class WebView extends AbsoluteLayout
        // At this point, we know we have found an input field, so go ahead
        // and create the WebTextView if necessary.
        if (mWebTextView == null) {
            mWebTextView = new WebTextView(mContext, WebView.this, mAutoFillQueryId);
            mWebTextView = new WebTextView(mContext, WebView.this, mAutoFillData.getQueryId());
            // Initialize our generation number.
            mTextGeneration = 0;
        }
@@ -4042,7 +4042,10 @@ public class WebView extends AbsoluteLayout
                // on the AutoFill item being at the top of the drop down list. If you change
                // the order, make sure to do it there too!
                pastEntries.add(getResources().getText(
                        com.android.internal.R.string.autofill_this_form).toString());
                        com.android.internal.R.string.autofill_this_form).toString() +
                        " " +
                        mAutoFillData.getPreviewString());
                }
            }

            pastEntries.addAll(mDatabase.getFormData(mUrl, mName));
@@ -6843,9 +6846,9 @@ public class WebView extends AbsoluteLayout
                    break;

                case SET_AUTOFILLABLE:
                    mAutoFillQueryId = msg.arg1;
                    mAutoFillData = (WebViewCore.AutoFillData) msg.obj;
                    if (mWebTextView != null) {
                        mWebTextView.setAutoFillable(mAutoFillQueryId);
                        mWebTextView.setAutoFillable(mAutoFillData.getQueryId());
                        rebuildWebTextView();
                    }
                    break;
+27 −3
Original line number Diff line number Diff line
@@ -732,6 +732,29 @@ final class WebViewCore {
        int mSlop;
    }

    static class AutoFillData {
        public AutoFillData() {
            mQueryId = WebTextView.FORM_NOT_AUTOFILLABLE;
            mPreview = "";
        }

        public AutoFillData(int queryId, String preview) {
            mQueryId = queryId;
            mPreview = preview;
        }

        public int getQueryId() {
            return mQueryId;
        }

        public String getPreviewString() {
            return mPreview;
        }

        private int mQueryId;
        private String mPreview;
    }

    // mAction of TouchEventData can be MotionEvent.getAction() which uses the
    // last two bytes or one of the following values
    static final int ACTION_LONGPRESS = 0x100;
@@ -2431,10 +2454,11 @@ final class WebViewCore {
        }
    }

    private void setWebTextViewAutoFillable(int queryId) {
    private void setWebTextViewAutoFillable(int queryId, String preview) {
        if (mWebView != null) {
            Message.obtain(mWebView.mPrivateHandler, WebView.SET_AUTOFILLABLE, queryId,
                    /* unused */0).sendToTarget();
            Message.obtain(mWebView.mPrivateHandler, WebView.SET_AUTOFILLABLE,
                    new AutoFillData(queryId, preview))
                    .sendToTarget();
        }
    }