Skip to content
Snippets Groups Projects
Commit d49294cb authored by Joy Babafemi's avatar Joy Babafemi
Browse files

CredMan - Make inline suggestions limit uniform with bottom sheet and dropdown

Previously, we showed as many credentials (deduped per username) as available in the suggestion strip. This CL limits to 4 as specified for the other selectors.

Bug: 326264258
Change-Id: I7df3c3e00afebbd7d3ef358224e4415ab16b7cc1
parent a9a83eed
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@
<dimen name="autofill_dropdown_textview_min_width">112dp</dimen>
<dimen name="autofill_dropdown_textview_max_width">230dp</dimen>
<dimen name="dropdown_layout_horizontal_margin">24dp</dimen>
<integer name="autofill_max_visible_datasets">5</integer>
<integer name="autofill_max_visible_datasets">4</integer>
<dimen name="dropdown_touch_target_min_height">48dp</dimen>
<dimen name="horizontal_chip_padding">8dp</dimen>
<dimen name="vertical_chip_padding">6dp</dimen>
......
......@@ -240,17 +240,11 @@ class CredentialAutofillService : AutofillService() {
val providerDisplayInfo: ProviderDisplayInfo = toProviderDisplayInfo(providerList)
var totalEntryCount = providerDisplayInfo.sortedUserNameToCredentialEntryList.size
val inlineSuggestionsRequest = filLRequest.inlineSuggestionsRequest
val inlineMaxSuggestedCount = inlineSuggestionsRequest?.maxSuggestionCount ?: 0
val inlinePresentationSpecs = inlineSuggestionsRequest?.inlinePresentationSpecs
val inlinePresentationSpecsCount = inlinePresentationSpecs?.size ?: 0
val maxDropdownDisplayLimit = this.resources.getInteger(
val maxDatasetDisplayLimit = this.resources.getInteger(
com.android.credentialmanager.R.integer.autofill_max_visible_datasets)
var maxInlineItemCount = totalEntryCount
maxInlineItemCount = maxInlineItemCount.coerceAtMost(inlineMaxSuggestedCount)
val lastDropdownDatasetIndex = Settings.Global.getInt(this.contentResolver,
Settings.Global.AUTOFILL_MAX_VISIBLE_DATASETS,
(maxDropdownDisplayLimit - 1)).coerceAtMost(totalEntryCount)
.coerceAtMost(totalEntryCount)
var i = 0
var datasetAdded = false
......@@ -275,7 +269,7 @@ class CredentialAutofillService : AutofillService() {
Log.e(TAG, "PendingIntent was missing from the entry.")
return@usernameLoop
}
if (i >= maxInlineItemCount && i >= lastDropdownDatasetIndex) {
if (i >= maxDatasetDisplayLimit) {
return@usernameLoop
}
val icon: Icon = if (primaryEntry.icon == null) {
......@@ -288,7 +282,7 @@ class CredentialAutofillService : AutofillService() {
}
// Create inline presentation
var inlinePresentation: InlinePresentation? = null
if (inlinePresentationSpecs != null && i < maxInlineItemCount) {
if (inlinePresentationSpecs != null && i < maxDatasetDisplayLimit) {
val spec: InlinePresentationSpec? = if (i < inlinePresentationSpecsCount) {
inlinePresentationSpecs[i]
} else {
......@@ -302,7 +296,7 @@ class CredentialAutofillService : AutofillService() {
}
}
var dropdownPresentation: RemoteViews? = null
if (i < lastDropdownDatasetIndex) {
if (i < maxDatasetDisplayLimit) {
dropdownPresentation = RemoteViewsFactory
.createDropdownPresentation(this, icon, primaryEntry)
}
......@@ -328,17 +322,15 @@ class CredentialAutofillService : AutofillService() {
.build())
datasetAdded = true
i++
if (i == lastDropdownDatasetIndex) {
addDropdownMoreOptionsPresentation(bottomSheetIntent, autofillId,
fillResponseBuilder)
}
}
val pinnedSpec = getLastInlinePresentationSpec(inlinePresentationSpecs,
inlinePresentationSpecsCount)
if (datasetAdded && pinnedSpec != null) {
addPinnedInlineSuggestion(pinnedSpec, autofillId,
fillResponseBuilder, bottomSheetIntent)
if (datasetAdded) {
addDropdownMoreOptionsPresentation(bottomSheetIntent, autofillId, fillResponseBuilder)
if (pinnedSpec != null) {
addPinnedInlineSuggestion(pinnedSpec, autofillId,
fillResponseBuilder, bottomSheetIntent)
}
}
return datasetAdded
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment