[Android] Fix NoSuchMethodError for content description setter on lower Android versions
Nicolas Pomepuy
git at videolan.org
Mon Jun 20 08:33:50 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Jun 20 07:20:08 2022 +0200| [c29d2c0666a46f58afbff0713f3641c83ad52eb1] | committer: Duncan McNamara
Fix NoSuchMethodError for content description setter on lower Android versions
> https://code.videolan.org/videolan/vlc-android/commit/c29d2c0666a46f58afbff0713f3641c83ad52eb1
---
application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
index 0cb13e445..8b0b53b58 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.kt
@@ -58,6 +58,7 @@ import androidx.core.content.pm.ShortcutManagerCompat
import androidx.core.graphics.drawable.IconCompat
import androidx.core.net.toUri
import androidx.core.os.bundleOf
+import androidx.core.view.MenuItemCompat
import androidx.databinding.BindingAdapter
import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.lifecycleScope
@@ -620,7 +621,7 @@ object UiTools {
private fun Menu.appendSortOrder(context: Context, @IdRes id:Int, @StringRes titleRes:Int, isCurrent:Boolean, desc:Boolean) = findItem(id)?.let { menuItem ->
val title = context.getString(titleRes)
menuItem.title = if (!isCurrent) title else "$title ${if (desc) "▼" else "▲"}"
- menuItem.contentDescription = if (!isCurrent) title else "$title. ${context.getString(if (desc) R.string.descending else R.string.ascending)}"
+ MenuItemCompat.setContentDescription(menuItem, if (!isCurrent) title else "$title. ${context.getString(if (desc) R.string.descending else R.string.ascending)}")
}
fun confirmExit(activity: Activity) {
More information about the Android
mailing list