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

Commit d56a4978 authored by Felipe Leme's avatar Felipe Leme
Browse files

Add pseudo-filtering on authenticated views.

When the autofill UI is shown for an authenticated FillResponse or Dataset and
the user types something, it should be filtered as if the matched failed.

Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases

Fixes: 65415443

Change-Id: I6a6b5af369e4e5a9cea49ae124dc517dbe5c70be
parent 40f9beb5
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -229,6 +229,13 @@ final class FillUi {
    public void setFilterText(@Nullable String filterText) {
        throwIfDestroyed();
        if (mAdapter == null) {
            // ViewState doesn't not support filtering - typically when it's for an authenticated
            // FillResponse.
            if (TextUtils.isEmpty(filterText)) {
                mCallback.requestShowFillUi(mContentWidth, mContentHeight, mWindowPresenter);
            } else {
                mCallback.requestHideFillUi();
            }
            return;
        }

@@ -510,8 +517,9 @@ final class FillUi {
                        final ViewItem item = mAllItems.get(i);
                        final String value = item.getValue();
                        // No value, i.e. null, matches any filter
                        if (value == null
                                || value.toLowerCase().startsWith(constraintLowerCase)) {
                        if ((value == null && item.mDataset.getAuthentication() == null)
                                || (value != null
                                        && value.toLowerCase().startsWith(constraintLowerCase))) {
                            filteredItems.add(item);
                        }
                    }
@@ -525,9 +533,11 @@ final class FillUi {
                    final boolean resultCountChanged;
                    final int oldItemCount = mFilteredItems.size();
                    mFilteredItems.clear();
                    if (results.count > 0) {
                        @SuppressWarnings("unchecked")
                        final List<ViewItem> items = (List<ViewItem>) results.values;
                        mFilteredItems.addAll(items);
                    }
                    resultCountChanged = (oldItemCount != mFilteredItems.size());
                    if (resultCountChanged) {
                        announceSearchResultIfNeeded();