Fix Accessbility bugs for PS.

This Cl contains:
1. Alt text for Lock/Unlock button as per state.
2. Alt text for Header when Locked.
3. Removing Header from accessibility target when unlocked.

Bug: 328024119
Test: Manual
Flag: NA
Change-Id: I791176afdae4fc6eb9387080aa036c1aed2a03a9
This commit is contained in:
Himanshu Gupta
2024-04-24 14:46:47 +01:00
parent 6fc5e7a010
commit 42e3196011
3 changed files with 23 additions and 5 deletions

View File

@@ -25,7 +25,9 @@
android:clipToOutline="true"
android:gravity="center_vertical"
android:textDirection="locale"
android:orientation="horizontal">
android:orientation="horizontal"
android:contentDescription="@string/ps_container_lock_button_content_description"
android:importantForAccessibility="yes">
<LinearLayout
android:id="@+id/settingsAndLockGroup"
@@ -49,7 +51,7 @@
android:background="@drawable/ps_lock_background"
android:gravity="center_vertical"
android:layout_marginEnd="@dimen/ps_lock_button_margin_end"
android:contentDescription="@string/ps_container_lock_unlock_button">
android:contentDescription="@string/ps_container_lock_button_content_description">
<ImageView
android:id="@+id/lock_icon"
android:layout_width="@dimen/ps_lock_icon_size"
@@ -95,6 +97,7 @@
android:gravity="center_vertical"
android:layout_marginStart="@dimen/ps_header_layout_margin"
android:text="@string/ps_container_title"
android:theme="@style/PrivateSpaceHeaderTextStyle"/>
android:theme="@style/PrivateSpaceHeaderTextStyle"
android:importantForAccessibility="no"/>
</RelativeLayout>

View File

@@ -487,8 +487,10 @@
<string name="ps_container_title">Private</string>
<!-- Description for Private Space Settings button -->
<string name="ps_container_settings">Private Space Settings</string>
<!-- Description for Private Space Lock/Unlock button -->
<string name="ps_container_lock_unlock_button">Lock/Unlock Private Space</string>
<!-- Description for Private Space Unlock button -->
<string name="ps_container_unlock_button_content_description">Private, unlocked.</string>
<!-- Description for Private Space Lock button -->
<string name="ps_container_lock_button_content_description">Private, locked.</string>
<string name="ps_container_lock_title">Lock</string>
<!-- Description for Private Space Transition button -->
<string name="ps_container_transition">Private Space Transitioning</string>

View File

@@ -112,6 +112,8 @@ public class PrivateProfileManager extends UserProfileManager {
private Runnable mOnPSHeaderAdded;
@Nullable
private RelativeLayout mPSHeader;
private final String mLockedStateContentDesc;
private final String mUnLockedStateContentDesc;
public PrivateProfileManager(UserManager userManager,
ActivityAllAppsContainerView<?> allApps,
@@ -125,6 +127,10 @@ public class PrivateProfileManager extends UserProfileManager {
UI_HELPER_EXECUTOR.post(() -> initializeInBackgroundThread(appContext));
mPsHeaderHeight = mAllApps.getContext().getResources().getDimensionPixelSize(
R.dimen.ps_header_height);
mLockedStateContentDesc = mAllApps.getContext()
.getString(R.string.ps_container_lock_button_content_description);
mUnLockedStateContentDesc = mAllApps.getContext()
.getString(R.string.ps_container_unlock_button_content_description);
}
/** Adds Private Space Header to the layout. */
@@ -398,11 +404,13 @@ public class PrivateProfileManager extends UserProfileManager {
lockText.setVisibility(VISIBLE);
lockButton.setVisibility(VISIBLE);
lockButton.setOnClickListener(view -> lockingAction(/* lock */ true));
lockButton.setContentDescription(mUnLockedStateContentDesc);
}
case STATE_DISABLED -> {
lockText.setVisibility(GONE);
lockButton.setVisibility(VISIBLE);
lockButton.setOnClickListener(view -> lockingAction(/* lock */ false));
lockButton.setContentDescription(mLockedStateContentDesc);
}
default -> lockButton.setVisibility(GONE);
}
@@ -412,9 +420,14 @@ public class PrivateProfileManager extends UserProfileManager {
if (getCurrentState() == STATE_DISABLED) {
header.setOnClickListener(view -> lockingAction(/* lock */ false));
header.setClickable(true);
// Add header as accessibility target when disabled.
header.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
header.setContentDescription(mLockedStateContentDesc);
} else {
header.setOnClickListener(null);
header.setClickable(false);
// Remove header from accessibility target when enabled.
header.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
}
}