[a11y] Make more items focusable (#4605)

* Fix settings entry point not available when there is no avatar on the account. Fixes #4599.

* Use Ktx extension `String.toUri()`

* Allow screen reader to focus on the user avatar to allow editing it.

* Fix import order
This commit is contained in:
Benoit Marty 2025-04-22 08:50:50 +02:00 committed by GitHub
parent cb926ee9c5
commit bacfa09916
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 48 additions and 24 deletions

View file

@ -9,12 +9,12 @@ package io.element.android.libraries.androidutils.browser
import android.app.Activity
import android.content.ActivityNotFoundException
import android.net.Uri
import android.os.Bundle
import android.provider.Browser
import androidx.browser.customtabs.CustomTabColorSchemeParams
import androidx.browser.customtabs.CustomTabsIntent
import androidx.browser.customtabs.CustomTabsSession
import androidx.core.net.toUri
import io.element.android.libraries.androidutils.system.openUrlInExternalApp
import java.util.Locale
@ -58,7 +58,7 @@ fun Activity.openUrlInChromeCustomTab(
putString("Accept-Language", Locale.getDefault().toLanguageTag())
})
}
.launchUrl(this, Uri.parse(url))
.launchUrl(this, url.toUri())
} catch (activityNotFoundException: ActivityNotFoundException) {
openUrlInExternalApp(url)
}

View file

@ -19,6 +19,7 @@ import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher
import androidx.annotation.RequiresApi
import androidx.core.content.pm.PackageInfoCompat
import androidx.core.net.toUri
import io.element.android.libraries.androidutils.R
import io.element.android.libraries.androidutils.compat.getApplicationInfoCompat
import io.element.android.libraries.core.mimetype.MimeTypes
@ -121,7 +122,7 @@ fun Context.startInstallFromSourceIntent(
noActivityFoundMessage: String = getString(R.string.error_no_compatible_app_found),
) {
val intent = Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES)
.setData(Uri.parse("package:$packageName"))
.setData("package:$packageName".toUri())
try {
activityResultLauncher.launch(intent)
} catch (activityNotFoundException: ActivityNotFoundException) {
@ -165,7 +166,7 @@ fun Context.openUrlInExternalApp(
url: String,
errorMessage: String = getString(R.string.error_no_compatible_app_found),
) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
val intent = Intent(Intent.ACTION_VIEW, url.toUri())
if (this !is Activity) {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}

View file

@ -8,7 +8,8 @@
package io.element.android.libraries.androidutils.uri
import android.net.Uri
import androidx.core.net.toUri
const val IGNORED_SCHEMA = "ignored"
fun createIgnoredUri(path: String): Uri = Uri.parse("$IGNORED_SCHEMA://$path")
fun createIgnoredUri(path: String): Uri = "$IGNORED_SCHEMA://$path".toUri()