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

Commit b2c7a440 authored by Matt Pietal's avatar Matt Pietal
Browse files

Controls a11y - Various fixes

1. Long press on togglerange controls
2. Range status text now corrected displayed when using seek controls
3. Check for valid intent before opening
4. Fix the activity titles

Fixes: 153283023
Fixes: 152932546
Fixes: 152924457
Test: talkback
Change-Id: Ic90cd9de660426838ed2a63e6079224d65c8e6d2
parent bf8d4b44
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -692,6 +692,7 @@
        </activity>

        <activity android:name=".controls.management.ControlsFavoritingActivity"
                  android:label="@string/controls_favorite_default_title"
                  android:theme="@style/Theme.ControlsManagement"
                  android:excludeFromRecents="true"
                  android:showForAllUsers="true"
+4 −3
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ class ControlsFavoritingActivity @Inject constructor(
        val collator = Collator.getInstance(resources.configuration.locales[0])
        comparator = compareBy(collator) { it.structureName }
        appName = intent.getCharSequenceExtra(EXTRA_APP)
        structureExtra = intent.getCharSequenceExtra(EXTRA_STRUCTURE) ?: ""
        structureExtra = intent.getCharSequenceExtra(EXTRA_STRUCTURE)
        component = intent.getParcelableExtra<ComponentName>(Intent.EXTRA_COMPONENT_NAME)
        fromProviderSelector = intent.getBooleanExtra(EXTRA_FROM_PROVIDER_SELECTOR, false)

@@ -206,7 +206,9 @@ class ControlsFavoritingActivity @Inject constructor(
                override fun onPageSelected(position: Int) {
                    super.onPageSelected(position)
                    val name = listOfStructures[position].structureName
                    titleView.text = if (!TextUtils.isEmpty(name)) name else appName
                    val title = if (!TextUtils.isEmpty(name)) name else appName
                    titleView.text = title
                    setTitle(title)
                }

                override fun onPageScrolled(
@@ -261,7 +263,6 @@ class ControlsFavoritingActivity @Inject constructor(

        val title = structureExtra
            ?: (appName ?: resources.getText(R.string.controls_favorite_default_title))
        setTitle(title)
        titleView = requireViewById<TextView>(R.id.title).apply {
            text = title
        }
+23 −3
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.systemui.controls.ui
import android.app.Dialog
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
import android.os.Vibrator
import android.os.VibrationEffect
import android.service.controls.Control
@@ -26,10 +28,12 @@ import android.service.controls.actions.BooleanAction
import android.service.controls.actions.CommandAction
import android.util.Log
import android.view.HapticFeedbackConstants
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.globalactions.GlobalActionsComponent
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.concurrency.DelayableExecutor
import com.android.systemui.R

import javax.inject.Inject
import javax.inject.Singleton
@@ -38,6 +42,7 @@ import javax.inject.Singleton
class ControlActionCoordinatorImpl @Inject constructor(
    private val context: Context,
    private val bgExecutor: DelayableExecutor,
    @Main private val uiExecutor: DelayableExecutor,
    private val activityStarter: ActivityStarter,
    private val keyguardStateController: KeyguardStateController,
    private val globalActionsComponent: GlobalActionsComponent
@@ -110,9 +115,24 @@ class ControlActionCoordinatorImpl @Inject constructor(
    }

    private fun showDialog(cvh: ControlViewHolder, intent: Intent) {
        bgExecutor.execute {
            val activities: List<ResolveInfo> = cvh.context.packageManager.queryIntentActivities(
                intent,
                PackageManager.MATCH_DEFAULT_ONLY
            )

            uiExecutor.execute {
                // make sure the intent is valid before attempting to open the dialog
                if (activities.isNotEmpty()) {
                    dialog = DetailDialog(cvh, intent).also {
                        it.setOnDismissListener { _ -> dialog = null }
                        it.show()
                    }
                } else {
                    cvh.setTransientStatus(
                        cvh.context.resources.getString(R.string.controls_error_failed))
                }
            }
        }
    }
}
+8 −6
Original line number Diff line number Diff line
@@ -145,6 +145,10 @@ class ToggleRangeBehavior : Behavior {
                            template.isChecked())
                        true
                    }
                    AccessibilityNodeInfo.ACTION_LONG_CLICK -> {
                        cvh.controlActionCoordinator.longPress(cvh)
                        true
                    }
                    AccessibilityNodeInfo.AccessibilityAction.ACTION_SET_PROGRESS.getId() -> {
                        if (arguments == null || !arguments.containsKey(
                                AccessibilityNodeInfo.ACTION_ARGUMENT_PROGRESS_VALUE)) {
@@ -152,8 +156,8 @@ class ToggleRangeBehavior : Behavior {
                        } else {
                            val value = arguments.getFloat(
                                AccessibilityNodeInfo.ACTION_ARGUMENT_PROGRESS_VALUE)
                            val level = rangeToLevelValue(value - rangeTemplate.getCurrentValue())
                            updateRange(level, template.isChecked(), /* isDragging */ false)
                            val level = rangeToLevelValue(value)
                            updateRange(level, template.isChecked(), /* isDragging */ true)
                            endUpdateRange()
                            true
                        }
@@ -168,7 +172,7 @@ class ToggleRangeBehavior : Behavior {
                host: ViewGroup,
                child: View,
                event: AccessibilityEvent
            ): Boolean = false
            ): Boolean = true
        })
    }

@@ -180,14 +184,12 @@ class ToggleRangeBehavior : Behavior {
    fun updateRange(level: Int, checked: Boolean, isDragging: Boolean) {
        val newLevel = if (checked) Math.max(MIN_LEVEL, Math.min(MAX_LEVEL, level)) else MIN_LEVEL

        if (newLevel == clipLayer.level) return

        rangeAnimator?.cancel()
        if (isDragging) {
            clipLayer.level = newLevel
            val isEdge = newLevel == MIN_LEVEL || newLevel == MAX_LEVEL
            cvh.controlActionCoordinator.drag(isEdge)
        } else {
        } else if (newLevel != clipLayer.level) {
            rangeAnimator = ValueAnimator.ofInt(cvh.clipLayer.level, newLevel).apply {
                addUpdateListener {
                    cvh.clipLayer.level = it.animatedValue as Int