From 42e3196011e0c5250acecbc6a77e2c72eb2dba0b Mon Sep 17 00:00:00 2001 From: Himanshu Gupta Date: Wed, 24 Apr 2024 14:46:47 +0100 Subject: [PATCH] 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 --- res/layout/private_space_header.xml | 9 ++++++--- res/values/strings.xml | 6 ++++-- .../launcher3/allapps/PrivateProfileManager.java | 13 +++++++++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/res/layout/private_space_header.xml b/res/layout/private_space_header.xml index 84554e48e6..cefe39430b 100644 --- a/res/layout/private_space_header.xml +++ b/res/layout/private_space_header.xml @@ -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"> + android:contentDescription="@string/ps_container_lock_button_content_description"> + android:theme="@style/PrivateSpaceHeaderTextStyle" + android:importantForAccessibility="no"/> \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index e1c7d64323..da5b70962f 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -487,8 +487,10 @@ Private Private Space Settings - - Lock/Unlock Private Space + + Private, unlocked. + + Private, locked. Lock Private Space Transitioning diff --git a/src/com/android/launcher3/allapps/PrivateProfileManager.java b/src/com/android/launcher3/allapps/PrivateProfileManager.java index 7e975df713..551fa944bb 100644 --- a/src/com/android/launcher3/allapps/PrivateProfileManager.java +++ b/src/com/android/launcher3/allapps/PrivateProfileManager.java @@ -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); } }