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

Commit 7f15208c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Rollback dropdown or inline suggestions when cancel fill dialog" into...

Merge "Rollback dropdown or inline suggestions when cancel fill dialog" into tm-dev am: d2c53f65 am: 59402af6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17937857



Change-Id: Ia3ccf206bc5fd71213f4b39a6eec3f9d2a37d55e
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 6ba1c53c 59402af6
Loading
Loading
Loading
Loading
+24 −16
Original line number Diff line number Diff line
@@ -1559,9 +1559,18 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                Slog.e(TAG, "Error sending input show up notification", e);
            }
        }
    }

    // AutoFillUiCallback
    @Override
    public void requestFallbackFromFillDialog() {
        setFillDialogDisabled();
        synchronized (mLock) {
            // stop to show fill dialog
            mSessionFlags.mFillDialogDisabled = true;
            if (mCurrentViewId == null) {
                return;
            }
            final ViewState currentView = mViewStates.get(mCurrentViewId);
            currentView.maybeCallOnFillReady(mFlags);
        }
    }

@@ -3208,6 +3217,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            return;
        }

        final AutofillId[] ids = response.getFillDialogTriggerIds();
        if (ids != null && ArrayUtils.contains(ids, filledId)) {
            if (requestShowFillDialog(response, filledId, filterText, flags)) {
                synchronized (mLock) {
                    final ViewState currentView = mViewStates.get(mCurrentViewId);
@@ -3215,9 +3226,10 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
                    mService.logDatasetShown(id, mClientState, UI_TYPE_DIALOG);
                }
                return;
        }

            } else {
                setFillDialogDisabled();
            }
        }

        if (response.supportsInlineSuggestions()) {
            synchronized (mLock) {
@@ -3324,15 +3336,11 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
            return false;
        }

        final AutofillId[] ids = response.getFillDialogTriggerIds();
        if (ids == null || !ArrayUtils.contains(ids, filledId)) {
            return false;
        }

        final Drawable serviceIcon = getServiceIcon();

        getUiForShowing().showFillDialog(filledId, response, filterText,
                mService.getServicePackageName(), mComponentName, serviceIcon, this);
                mService.getServicePackageName(), mComponentName, serviceIcon, this,
                id, mCompatMode);
        return true;
    }

+25 −2
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ public final class AutoFillUI {
        void dispatchUnhandledKey(AutofillId id, KeyEvent keyEvent);
        void cancelSession();
        void requestShowSoftInput(AutofillId id);
        void requestFallbackFromFillDialog();
    }

    public AutoFillUI(@NonNull Context context) {
@@ -388,13 +389,19 @@ public final class AutoFillUI {
    public void showFillDialog(@NonNull AutofillId focusedId, @NonNull FillResponse response,
            @Nullable String filterText, @Nullable String servicePackageName,
            @NonNull ComponentName componentName, @Nullable Drawable serviceIcon,
            @NonNull AutoFillUiCallback callback) {
            @NonNull AutoFillUiCallback callback, int sessionId, boolean compatMode) {
        if (sVerbose) {
            Slog.v(TAG, "showFillDialog for "
                    + componentName.toShortString() + ": " + response);
        }

        // TODO: enable LogMaker
        final LogMaker log = Helper
                .newLogMaker(MetricsEvent.AUTOFILL_FILL_UI, componentName, servicePackageName,
                        sessionId, compatMode)
                .addTaggedData(MetricsEvent.FIELD_AUTOFILL_FILTERTEXT_LEN,
                        filterText == null ? 0 : filterText.length())
                .addTaggedData(MetricsEvent.FIELD_AUTOFILL_NUM_DATASETS,
                        response.getDatasets() == null ? 0 : response.getDatasets().size());

        mHandler.post(() -> {
            if (callback != mCallback) {
@@ -406,6 +413,7 @@ public final class AutoFillUI {
                    mUiModeMgr.isNightMode(), new DialogFillUi.UiCallback() {
                        @Override
                        public void onResponsePicked(FillResponse response) {
                            log(MetricsEvent.TYPE_DETAIL);
                            hideFillDialogUiThread(callback);
                            if (mCallback != null) {
                                mCallback.authenticate(response.getRequestId(),
@@ -417,6 +425,7 @@ public final class AutoFillUI {

                        @Override
                        public void onDatasetPicked(Dataset dataset) {
                            log(MetricsEvent.TYPE_ACTION);
                            hideFillDialogUiThread(callback);
                            if (mCallback != null) {
                                final int datasetIndex = response.getDatasets().indexOf(dataset);
@@ -425,16 +434,30 @@ public final class AutoFillUI {
                            }
                        }

                        @Override
                        public void onDismissed() {
                            log(MetricsEvent.TYPE_DISMISS);
                            hideFillDialogUiThread(callback);
                            callback.requestShowSoftInput(focusedId);
                        }

                        @Override
                        public void onCanceled() {
                            log(MetricsEvent.TYPE_CLOSE);
                            hideFillDialogUiThread(callback);
                            callback.requestShowSoftInput(focusedId);
                            callback.requestFallbackFromFillDialog();
                        }

                        @Override
                        public void startIntentSender(IntentSender intentSender) {
                            mCallback.startIntentSenderAndFinishSession(intentSender);
                        }

                        private void log(int type) {
                            log.setType(type);
                            mMetricsLogger.write(log);
                        }
                    });
        });
    }
+3 −1
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ final class DialogFillUi {
    interface UiCallback {
        void onResponsePicked(@NonNull FillResponse response);
        void onDatasetPicked(@NonNull Dataset dataset);
        void onDismissed();
        void onCanceled();
        void startIntentSender(IntentSender intentSender);
    }
@@ -144,6 +145,7 @@ final class DialogFillUi {
        mDialog = new Dialog(mContext, mThemeId);
        mDialog.setContentView(decor);
        setDialogParamsAsBottomSheet();
        mDialog.setOnCancelListener((d) -> mCallback.onCanceled());

        show();
    }
@@ -220,7 +222,7 @@ final class DialogFillUi {
        final TextView noButton = decor.findViewById(R.id.autofill_dialog_no);
        // set "No thinks" by default
        noButton.setText(R.string.autofill_save_no);
        noButton.setOnClickListener((v) -> mCallback.onCanceled());
        noButton.setOnClickListener((v) -> mCallback.onDismissed());
    }

    private void setContinueButton(View decor, View.OnClickListener listener) {