diff --git a/vector/src/main/java/im/vector/app/features/popup/PopupAlertManager.kt b/vector/src/main/java/im/vector/app/features/popup/PopupAlertManager.kt index d3c6e83589..29aa623c9b 100644 --- a/vector/src/main/java/im/vector/app/features/popup/PopupAlertManager.kt +++ b/vector/src/main/java/im/vector/app/features/popup/PopupAlertManager.kt @@ -21,9 +21,11 @@ import android.os.Handler import android.os.Looper import android.view.View import android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS +import androidx.core.view.ViewCompat import com.tapadoo.alerter.Alerter import im.vector.app.R import im.vector.app.core.platform.VectorBaseActivity +import im.vector.app.core.resources.StringProvider import im.vector.app.core.utils.isAnimationEnabled import im.vector.app.features.MainActivity import im.vector.app.features.analytics.ui.consent.AnalyticsOptInActivity @@ -46,6 +48,7 @@ import javax.inject.Singleton @Singleton class PopupAlertManager @Inject constructor( private val clock: Clock, + private val stringProvider: StringProvider, ) { companion object { @@ -282,6 +285,9 @@ class PopupAlertManager @Inject constructor( } currentIsDismissed() } + .setOnShowListener { + handleAccessibility(activity) + } .enableSwipeToDismiss() .enableInfiniteDuration(true) .apply { @@ -297,6 +303,24 @@ class PopupAlertManager @Inject constructor( .show() } + /* a11y */ + private fun handleAccessibility(activity: Activity) { + activity.window.decorView.findViewById(R.id.llAlertBackground)?.let { alertView -> + alertView.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_YES + + // Add close action for a11y (same action than swipe). User can select the action by swiping on the screen vertically, + // and double tap to perform the action + ViewCompat.addAccessibilityAction( + alertView, + stringProvider.getString(R.string.action_close) + ) { _, _ -> + currentIsDismissed() + Alerter.hide() + true + } + } + } + private fun currentIsDismissed() { // current alert has been hidden if (currentAlerter?.isLight == false) {