-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add accessibility tags #288
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.ivanovsky.passnotes.presentation.core.compose | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.semantics.contentDescription | ||
import androidx.compose.ui.semantics.semantics | ||
|
||
@Composable | ||
fun contentDescription(description: String): Modifier { | ||
return remember { | ||
Modifier.semantics { | ||
contentDescription = description | ||
} | ||
} | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ | |
android:layout_marginStart="@dimen/element_margin" | ||
android:layout_marginTop="@dimen/group_margin" | ||
android:layout_marginEnd="@dimen/element_margin" | ||
app:description="@string/password" | ||
app:hint="@string/password" | ||
app:isEyeButtonEnabled="true" | ||
app:layout_constraintBottom_toTopOf="@id/newPassword" | ||
|
@@ -52,6 +53,7 @@ | |
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/element_margin" | ||
app:description="@string/new_password" | ||
app:hint="@string/new_password" | ||
app:isEyeButtonEnabled="true" | ||
app:layout_constraintBottom_toTopOf="@id/confirmation" | ||
|
@@ -68,6 +70,7 @@ | |
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/element_margin" | ||
app:description="@string/confirm_password" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Enhance password confirmation accessibility and error announcements The confirmation field needs clear distinction and proper error state handling for accessibility.
-app:description="@string/confirm_password"
+app:description="@string/confirm_password_input_description"
+android:importantForAccessibility="yes"
+android:accessibilityLiveRegion="polite"
<string name="confirm_password_input_description">Re-enter your new password for confirmation</string>
+android:accessibilityLiveRegion="assertive"
+app:errorAccessibilityAnnouncement="@{viewModel.confirmationError}" This will ensure that any password mismatch errors are properly announced to screen reader users. |
||
app:hint="@string/confirm_password" | ||
app:isEyeButtonEnabled="true" | ||
app:layout_constraintBottom_toTopOf="@id/applyButton" | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -16,9 +16,9 @@ | |||||||||
|
||||||||||
<com.google.android.material.textfield.TextInputEditText | ||||||||||
android:id="@+id/textInput" | ||||||||||
android:saveEnabled="false" | ||||||||||
android:layout_width="match_parent" | ||||||||||
android:layout_height="wrap_content" | ||||||||||
android:saveEnabled="false" | ||||||||||
android:textColor="?attr/kpPrimaryTextColor" | ||||||||||
android:textSize="@dimen/material_edit_text_primary_text_size" /> | ||||||||||
|
||||||||||
|
@@ -30,6 +30,7 @@ | |||||||||
android:layout_width="wrap_content" | ||||||||||
android:layout_height="wrap_content" | ||||||||||
android:layout_marginTop="@dimen/small_margin" | ||||||||||
android:contentDescription="@string/eye_icon" | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider dynamic content description for visibility toggle The static content description "@string/eye_icon" might not be descriptive enough. Consider making it dynamic based on the visibility state (e.g., "Show password" / "Hide password"). This should be handled in the corresponding Kotlin code rather than the layout XML. |
||||||||||
android:focusable="false" | ||||||||||
android:focusableInTouchMode="false" | ||||||||||
Comment on lines
34
to
35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Review focusability settings for accessibility Setting Consider removing these attributes to ensure the button is accessible via screen readers and keyboard navigation. - android:focusable="false"
- android:focusableInTouchMode="false"
+ android:focusable="true"
+ android:importantForAccessibility="yes" 📝 Committable suggestion
Suggested change
|
||||||||||
android:visibility="gone" | ||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Add content descriptions to interactive UI elements
Several Compose UI components lack proper content descriptions for accessibility:
ImageButton
inButtons.kt
explicitly setscontentDescription = null
Image
components inHistoryHeaderCell.kt
andInfoCell.kt
have null content descriptionsTextField.kt
have null content descriptionsThe newly added
contentDescription()
modifier function is not being utilized yet. These missing descriptions could impact accessibility for users relying on screen readers.🔗 Analysis chain
Verify usage patterns across the codebase
Let's ensure this new accessibility function is being used consistently across the codebase.
Let me search more specifically for UI components that might need accessibility descriptions and check if the new contentDescription function is being used.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 68267
Script:
Length of output: 5458