Skip to content
Snippets Groups Projects
Commit 8454fc6b authored by Joy Babafemi's avatar Joy Babafemi Committed by Android (Google) Code Review
Browse files

Merge "CredMan - Make inline suggestions limit uniform with bottom sheet and dropdown" into main

parents 9b2e54f2 d49294cb
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<dimen name="autofill_dropdown_textview_min_width">112dp</dimen> <dimen name="autofill_dropdown_textview_min_width">112dp</dimen>
<dimen name="autofill_dropdown_textview_max_width">230dp</dimen> <dimen name="autofill_dropdown_textview_max_width">230dp</dimen>
<dimen name="dropdown_layout_horizontal_margin">24dp</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="dropdown_touch_target_min_height">48dp</dimen>
<dimen name="horizontal_chip_padding">8dp</dimen> <dimen name="horizontal_chip_padding">8dp</dimen>
<dimen name="vertical_chip_padding">6dp</dimen> <dimen name="vertical_chip_padding">6dp</dimen>
......
...@@ -240,17 +240,11 @@ class CredentialAutofillService : AutofillService() { ...@@ -240,17 +240,11 @@ class CredentialAutofillService : AutofillService() {
val providerDisplayInfo: ProviderDisplayInfo = toProviderDisplayInfo(providerList) val providerDisplayInfo: ProviderDisplayInfo = toProviderDisplayInfo(providerList)
var totalEntryCount = providerDisplayInfo.sortedUserNameToCredentialEntryList.size var totalEntryCount = providerDisplayInfo.sortedUserNameToCredentialEntryList.size
val inlineSuggestionsRequest = filLRequest.inlineSuggestionsRequest val inlineSuggestionsRequest = filLRequest.inlineSuggestionsRequest
val inlineMaxSuggestedCount = inlineSuggestionsRequest?.maxSuggestionCount ?: 0
val inlinePresentationSpecs = inlineSuggestionsRequest?.inlinePresentationSpecs val inlinePresentationSpecs = inlineSuggestionsRequest?.inlinePresentationSpecs
val inlinePresentationSpecsCount = inlinePresentationSpecs?.size ?: 0 val inlinePresentationSpecsCount = inlinePresentationSpecs?.size ?: 0
val maxDropdownDisplayLimit = this.resources.getInteger( val maxDatasetDisplayLimit = this.resources.getInteger(
com.android.credentialmanager.R.integer.autofill_max_visible_datasets) com.android.credentialmanager.R.integer.autofill_max_visible_datasets)
var maxInlineItemCount = totalEntryCount .coerceAtMost(totalEntryCount)
maxInlineItemCount = maxInlineItemCount.coerceAtMost(inlineMaxSuggestedCount)
val lastDropdownDatasetIndex = Settings.Global.getInt(this.contentResolver,
Settings.Global.AUTOFILL_MAX_VISIBLE_DATASETS,
(maxDropdownDisplayLimit - 1)).coerceAtMost(totalEntryCount)
var i = 0 var i = 0
var datasetAdded = false var datasetAdded = false
...@@ -275,7 +269,7 @@ class CredentialAutofillService : AutofillService() { ...@@ -275,7 +269,7 @@ class CredentialAutofillService : AutofillService() {
Log.e(TAG, "PendingIntent was missing from the entry.") Log.e(TAG, "PendingIntent was missing from the entry.")
return@usernameLoop return@usernameLoop
} }
if (i >= maxInlineItemCount && i >= lastDropdownDatasetIndex) { if (i >= maxDatasetDisplayLimit) {
return@usernameLoop return@usernameLoop
} }
val icon: Icon = if (primaryEntry.icon == null) { val icon: Icon = if (primaryEntry.icon == null) {
...@@ -288,7 +282,7 @@ class CredentialAutofillService : AutofillService() { ...@@ -288,7 +282,7 @@ class CredentialAutofillService : AutofillService() {
} }
// Create inline presentation // Create inline presentation
var inlinePresentation: InlinePresentation? = null var inlinePresentation: InlinePresentation? = null
if (inlinePresentationSpecs != null && i < maxInlineItemCount) { if (inlinePresentationSpecs != null && i < maxDatasetDisplayLimit) {
val spec: InlinePresentationSpec? = if (i < inlinePresentationSpecsCount) { val spec: InlinePresentationSpec? = if (i < inlinePresentationSpecsCount) {
inlinePresentationSpecs[i] inlinePresentationSpecs[i]
} else { } else {
...@@ -302,7 +296,7 @@ class CredentialAutofillService : AutofillService() { ...@@ -302,7 +296,7 @@ class CredentialAutofillService : AutofillService() {
} }
} }
var dropdownPresentation: RemoteViews? = null var dropdownPresentation: RemoteViews? = null
if (i < lastDropdownDatasetIndex) { if (i < maxDatasetDisplayLimit) {
dropdownPresentation = RemoteViewsFactory dropdownPresentation = RemoteViewsFactory
.createDropdownPresentation(this, icon, primaryEntry) .createDropdownPresentation(this, icon, primaryEntry)
} }
...@@ -328,17 +322,15 @@ class CredentialAutofillService : AutofillService() { ...@@ -328,17 +322,15 @@ class CredentialAutofillService : AutofillService() {
.build()) .build())
datasetAdded = true datasetAdded = true
i++ i++
if (i == lastDropdownDatasetIndex) {
addDropdownMoreOptionsPresentation(bottomSheetIntent, autofillId,
fillResponseBuilder)
}
} }
val pinnedSpec = getLastInlinePresentationSpec(inlinePresentationSpecs, val pinnedSpec = getLastInlinePresentationSpec(inlinePresentationSpecs,
inlinePresentationSpecsCount) inlinePresentationSpecsCount)
if (datasetAdded && pinnedSpec != null) { if (datasetAdded) {
addPinnedInlineSuggestion(pinnedSpec, autofillId, addDropdownMoreOptionsPresentation(bottomSheetIntent, autofillId, fillResponseBuilder)
fillResponseBuilder, bottomSheetIntent) if (pinnedSpec != null) {
addPinnedInlineSuggestion(pinnedSpec, autofillId,
fillResponseBuilder, bottomSheetIntent)
}
} }
return datasetAdded 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