Skip to content
This repository was archived by the owner on Dec 14, 2021. It is now read-only.

autofill search ui#487

Merged
sashei merged 6 commits intomasterfrom
467-search-ui
Mar 8, 2019
Merged

autofill search ui#487
sashei merged 6 commits intomasterfrom
467-search-ui

Conversation

@sashei
Copy link
Copy Markdown
Contributor

@sashei sashei commented Mar 5, 2019

Fixes #467

Testing and Review Notes

I couldn't find the designs for "No entries found" in Zeplin so I just took a shot in the dark at what the expected text qualities are.

I also made a design compromise in putting together the list view; when there are more than ~2 entries found, the dialog will touch to the top of the keyboard rather than "floating" as it does in the designs. Hopefully that's acceptable!!

To Do

  • double check the original issue to confirm it is fully satisfied
  • add testing notes and screenshots in PR description to help guide reviewers
  • add unit tests
  • request the "UX" team perform a design review (if/when applicable)
  • make sure CI builds are passing (e.g.: fix lint and other errors)

@ghost ghost assigned sashei Mar 5, 2019
@ghost ghost added the in progress label Mar 5, 2019
@sashei sashei force-pushed the 467-search-ui branch 2 times, most recently from 2fe47a6 to d156d0f Compare March 6, 2019 15:40
@sashei sashei marked this pull request as ready for review March 6, 2019 23:04
@sashei sashei requested a review from a team as a code owner March 6, 2019 23:04
@sashei sashei requested a review from a team March 6, 2019 23:05
Copy link
Copy Markdown
Contributor

@jhugman jhugman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nits, but looking good!

(type as? ItemListAdapterType.AutofillFilter)?.let {
if (count == 0 && !it.textEntered)
return 0
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be clearer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


if (type is ItemListAdapterType.AutofillFilter) {
view.disclosureIndicator.visibility = GONE
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:hmm:

.addTo(compositeDisposable)
}

private fun Observable<Pair<CharSequence, List<ItemViewModel>>>.filterItemsForText(): Observable<Pair<CharSequence, List<ItemViewModel>>> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:headsplode: I didn't know you could monkey patch from within a class.

fun updateItems(newItems: List<ItemViewModel>, isFiltering: Boolean = false) {
this.isFiltering = isFiltering
fun updateItems(newItems: List<ItemViewModel>, type: ItemListAdapterType = ItemListAdapterType.ItemList) {
this.type = type
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How often does this.type change. I think I would prefer this as an instance variable passed in to the adapter's constructor.

)
val displayNoEntries = it.second.isEmpty() || !it.first.isEmpty()
val itemList = if (it.first.isEmpty()) emptyList() else it.second
Pair(itemList, displayNoEntries)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

itemList to displayNoEntries

Pair(pair.first, pair.second.filter {
it.title.contains(pair.first, true) ||
it.subtitle.contains(pair.first, true)
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Pair(pair.pair, pair.filter { it.contains pair }

This feels like it could be clearer.

return this.map { (text, list) -> 
    val filtered = list.filter { it.title.contains(text, true) || it.subtitle.contains(text, true) }
    text to filtered
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: I'm not sure why this needs its own extension method.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: consider adding a contains method to ItemViewModel.

val cancelButtonClicks: Observable<Unit>
val cancelButtonVisibility: Consumer<in Boolean>
val itemSelection: Observable<ItemViewModel>
fun updateItems(items: List<ItemViewModel>, displayNoEntries: Boolean)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not wild about this method call. Either call updateItems or displayNoEntries. Currently the method is doing double duty here.

return@map AutofillAction.Complete(serverPassword)
}

AutofillAction.Cancel
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit

it.value?.let { serverPassword ->
    AutofillAction.Complete(serverPassword) 
} ?: AutofillAction.Cancel

@sashei sashei requested a review from jhugman March 7, 2019 19:23
Copy link
Copy Markdown
Contributor

@jhugman jhugman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good.

I think we should file an issue to rationalize the FilterPresenter and AutofillFilterPresenter, but I'm really liking how this has shaped up.

filteredItems
.map { !it.first.isEmpty() || it.second.isEmpty() }
.subscribe(view::displayNoEntries)
.addTo(compositeDisposable)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, interesting.

Pair(pair.first, pair.second.filter {
it.title.contains(pair.first, true) ||
it.subtitle.contains(pair.first, true)
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: make an ItemViewModel.contains(string: CharSequence) method.

            .map { (text, list) ->
                text to list.filter { it.contains(text) }
            }

(just noticed that this is also in FilterPresenter)


class ItemListAdapter(
val type: ItemListAdapterType
) : RecyclerView.Adapter<ItemListCell>() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😍

(type as? ItemListAdapterType.AutofillFilter)?.let {
if (count == 0 && !it.textEntered)
return 0
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@sashei sashei merged commit c34a3ba into master Mar 8, 2019
@ghost ghost removed the in progress label Mar 8, 2019
@sashei sashei deleted the 467-search-ui branch March 8, 2019 15:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement autofill search UI

2 participants