Skip to content

Conversation

@star-studio975
Copy link
Contributor

English:
Description
This PR fixes an accessibility issue in the "Share Server" dialog. Previously, the QR code image (iv_qcode) lacked a contentDescription. Depending on the screen reader or system version, this caused two issues:

  • The element was announced as an "unlabeled image."
  • The element was completely skipped (no focus), making the QR code "invisible" to visually impaired users during linear navigation.
    Changes
  • Modified MainRecyclerAdapter.kt: In the showQRCode method, dynamically set the contentDescription for the QR code ImageView.
  • Optimization: Reused the existing localized string from R.array.share_method[0] (which contains "QRcode" / "二维码"). This ensures proper localization support without adding redundant string resources to strings.xml.
    Impact
  • Accessibility: Ensures the QR code is always focusable and correctly announced as "QRcode" (or the localized equivalent) by screen readers.
  • Visual: No changes to the UI layout or visual appearance.
    中文:
    描述
    此 PR 修复了“分享配置文件”弹窗中的一个无障碍问题。此前,二维码图片 (iv_qcode) 缺少 contentDescription 属性。根据屏幕阅读器或系统版本的不同,这会导致以下两种问题:
  • 元素被朗读为“未加标签的图片”。
  • 元素被完全跳过(无法获取焦点),导致视障用户在通过触摸或滑动浏览时完全无法感知到二维码的存在。
    更改
  • 修改了 MainRecyclerAdapter.kt:在 showQRCode 方法中,为二维码 ImageView 动态设置了无障碍描述。
  • 优化:直接复用了 R.array.share_method 数组中的第一个现成字符串(即“二维码” / "QRcode")。这样做既解决了无障碍问题,又无需在 strings.xml 中新增冗余的字符串资源,且自动支持多语言。
    影响
  • 无障碍性:确保二维码图片始终可以被屏幕阅读器聚焦,并正确朗读为“二维码”(或对应的系统语言文本)。
  • 视觉:对界面布局和视觉效果无任何影响。

private fun showQRCode(guid: String) {
val ivBinding = ItemQrcodeBinding.inflate(LayoutInflater.from(mActivity))
ivBinding.ivQcode.setImageBitmap(AngConfigManager.share2QRCode(guid))
val shareOptions = mActivity.resources.getStringArray(R.array.share_method)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接使用目前是没有问题,但是却存在不确定性。
因为后面有可能会调整此项目

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an accessibility issue where the QR code image in the "Share Server" dialog lacked a content description, causing it to be either announced as "unlabeled image" or skipped entirely by screen readers.

Key Changes:

  • Added content description to the QR code ImageView in the showQRCode method
  • Reused localized strings from R.array.share_method to ensure proper internationalization

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 204 to 209
val shareOptions = mActivity.resources.getStringArray(R.array.share_method)
if (shareOptions.isNotEmpty()) {
ivBinding.ivQcode.contentDescription = shareOptions[0]
} else {
ivBinding.ivQcode.contentDescription = "QR Code"
}
Copy link

Copilot AI Dec 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation of the newly added lines is inconsistent with the rest of the method. The lines setting contentDescription should be indented with 8 spaces (or 2 levels) to match the indentation of the line above (line 203) and below (line 210).

Suggested change
val shareOptions = mActivity.resources.getStringArray(R.array.share_method)
if (shareOptions.isNotEmpty()) {
ivBinding.ivQcode.contentDescription = shareOptions[0]
} else {
ivBinding.ivQcode.contentDescription = "QR Code"
}
val shareOptions = mActivity.resources.getStringArray(R.array.share_method)
if (shareOptions.isNotEmpty()) {
ivBinding.ivQcode.contentDescription = shareOptions[0]
} else {
ivBinding.ivQcode.contentDescription = "QR Code"
}

Copilot uses AI. Check for mistakes.
@2dust 2dust merged commit 0b76ff0 into 2dust:master Dec 25, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants