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

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
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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>
+11 −19
Original line number Diff line number Diff line
@@ -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,18 +322,16 @@ class CredentialAutofillService : AutofillService() {
                            .build())
            datasetAdded = true
            i++

            if (i == lastDropdownDatasetIndex) {
                addDropdownMoreOptionsPresentation(bottomSheetIntent, autofillId,
                        fillResponseBuilder)
            }
        }
        val pinnedSpec = getLastInlinePresentationSpec(inlinePresentationSpecs,
                inlinePresentationSpecsCount)
        if (datasetAdded && pinnedSpec != null) {
        if (datasetAdded) {
            addDropdownMoreOptionsPresentation(bottomSheetIntent, autofillId, fillResponseBuilder)
            if (pinnedSpec != null) {
                addPinnedInlineSuggestion(pinnedSpec, autofillId,
                        fillResponseBuilder, bottomSheetIntent)
            }
        }
        return datasetAdded
    }