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

Commit c7643d41 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10950137 from abb9b067 to 24Q1-release

Change-Id: I35223a64d19205c5dfe09c64a33eb9c78af4936c
parents 17ffbe32 abb9b067
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
        android:id="@+id/switcher"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:focusable="false"
        android:clickable="false"
        android:layout_gravity="center"
        style="@style/Switch.SettingsLib"
+24 −0
Original line number Diff line number Diff line
@@ -20,7 +20,11 @@ package com.android.customization.picker.quickaffordance.ui.binder
import android.app.Dialog
import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.view.accessibility.AccessibilityEvent
import android.widget.ImageView
import androidx.core.view.AccessibilityDelegateCompat
import androidx.core.view.ViewCompat
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
@@ -62,6 +66,26 @@ object KeyguardQuickAffordancePickerBinder {
        slotTabView.layoutManager =
            LinearLayoutManager(view.context, RecyclerView.HORIZONTAL, false)
        slotTabView.addItemDecoration(ItemSpacing(ItemSpacing.TAB_ITEM_SPACING_DP))

        // Setting a custom accessibility delegate so that the default content descriptions
        // for items in a list aren't announced (for left & right shortcuts). We populate
        // the content description for these shortcuts later on with the right (expected)
        // values.
        val slotTabViewDelegate: AccessibilityDelegateCompat =
            object : AccessibilityDelegateCompat() {
                override fun onRequestSendAccessibilityEvent(
                    host: ViewGroup,
                    child: View,
                    event: AccessibilityEvent
                ): Boolean {
                    if (event.eventType != AccessibilityEvent.TYPE_VIEW_FOCUSED) {
                        child.contentDescription = null
                    }
                    return super.onRequestSendAccessibilityEvent(host, child, event)
                }
            }

        ViewCompat.setAccessibilityDelegate(slotTabView, slotTabViewDelegate)
        val affordancesAdapter =
            OptionItemAdapter(
                layoutResourceId = R.layout.keyguard_quick_affordance,
+14 −1
Original line number Diff line number Diff line
@@ -158,7 +158,8 @@ private constructor(
                                        Icon.Loaded(
                                            drawable =
                                                getAffordanceIcon(affordanceModel.iconResourceId),
                                            contentDescription = null,
                                            contentDescription =
                                                Text.Loaded(getSlotContentDescription(slot.id)),
                                        ),
                                    text = Text.Loaded(affordanceModel.name),
                                    isSelected = MutableStateFlow(true) as StateFlow<Boolean>,
@@ -423,6 +424,18 @@ private constructor(
        )
    }

    private fun getSlotContentDescription(slotId: String): String {
        return applicationContext.getString(
            when (slotId) {
                KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_START ->
                    R.string.keyguard_slot_name_bottom_start
                KeyguardQuickAffordanceSlots.SLOT_ID_BOTTOM_END ->
                    R.string.keyguard_slot_name_bottom_end
                else -> error("No accessibility label for slot with ID \"$slotId\"!")
            }
        )
    }

    private suspend fun getAffordanceIcon(@DrawableRes iconResourceId: Int): Drawable {
        return quickAffordanceInteractor.getAffordanceIcon(iconResourceId)
    }