Merge "[a11y] When multi-user switcher is selected in lockscreen and Talkback is enabled, play helpful explanation." into tm-qpr-dev am: 168133e3eb am: 432c0bb3d8

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19135806

Change-Id: I8e8353b5ae17eac6bba2c11371fae737482dae0c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Brad Hinegardner
2022-08-10 16:36:38 +00:00
committed by Automerger Merge Worker
5 changed files with 100 additions and 6 deletions

View File

@@ -35,7 +35,7 @@
<!-- need to keep this outer view in order to have a correctly sized anchor
for the dropdown menu, as well as dropdown background in the right place -->
<LinearLayout
<com.android.keyguard.KeyguardUserSwitcherAnchor
android:id="@+id/user_switcher_anchor"
android:orientation="horizontal"
android:layout_height="wrap_content"
@@ -48,7 +48,7 @@
android:textDirection="locale"
android:layout_width="@dimen/bouncer_user_switcher_width"
android:layout_height="wrap_content" />
</LinearLayout>>
</com.android.keyguard.KeyguardUserSwitcherAnchor>
</LinearLayout>

View File

@@ -887,7 +887,8 @@
<!-- Accessibility label for the button that opens the user switcher. -->
<string name="accessibility_multi_user_switch_switcher">Switch user</string>
<!-- Accessibility label for the button that opens the user switcher and announces the current user. -->
<!-- Accessibility role description for the element that opens the user switcher list. -->
<string name="accessibility_multi_user_list_switcher">pulldown menu</string>
<!-- Accessibility label for the user icon on the lock screen. -->

View File

@@ -1129,11 +1129,13 @@ public class KeyguardSecurityContainer extends FrameLayout {
Log.e(TAG, "Current user in user switcher is null.");
return;
}
final String currentUserName = mUserSwitcherController.getCurrentUserName();
Drawable userIcon = findUserIcon(currentUser.info.id);
((ImageView) mView.findViewById(R.id.user_icon)).setImageDrawable(userIcon);
mUserSwitcher.setText(mUserSwitcherController.getCurrentUserName());
mUserSwitcher.setText(currentUserName);
KeyguardUserSwitcherAnchor anchor = mView.findViewById(R.id.user_switcher_anchor);
ViewGroup anchor = mView.findViewById(R.id.user_switcher_anchor);
BaseUserAdapter adapter = new BaseUserAdapter(mUserSwitcherController) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
@@ -1213,7 +1215,6 @@ public class KeyguardSecurityContainer extends FrameLayout {
anchor.setOnClickListener((v) -> {
if (mFalsingManager.isFalseTap(LOW_PENALTY)) return;
mPopup = new KeyguardUserSwitcherPopupMenu(v.getContext(), mFalsingManager);
mPopup.setAnchorView(anchor);
mPopup.setAdapter(adapter);

View File

@@ -0,0 +1,39 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.keyguard
import android.content.Context
import android.util.AttributeSet
import android.view.accessibility.AccessibilityNodeInfo
import android.widget.LinearLayout
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
import com.android.systemui.R
/**
* Custom View for the multi-user switcher pull-down menu anchor
*/
class KeyguardUserSwitcherAnchor @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null
) : LinearLayout(context, attrs) {
override fun createAccessibilityNodeInfo(): AccessibilityNodeInfo {
val info = super.createAccessibilityNodeInfo()
AccessibilityNodeInfoCompat.wrap(info).roleDescription =
context.getString(R.string.accessibility_multi_user_list_switcher)
return info
}
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.keyguard
import android.testing.AndroidTestingRunner
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
import androidx.test.filters.SmallTest
import com.android.systemui.R
import com.android.systemui.SysuiTestCase
import com.google.common.truth.Truth.assertThat
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidTestingRunner::class)
@SmallTest
class KeyguardUserSwitcherAnchorTest : SysuiTestCase() {
private lateinit var keyguardUserSwitcherAnchor: KeyguardUserSwitcherAnchor
@Before
fun setUp() {
keyguardUserSwitcherAnchor = KeyguardUserSwitcherAnchor(context)
}
@Test
fun roleDescription_is_set_to_pulldown_menu() {
// GIVEN
val roleDescriptionString =
context.getString(R.string.accessibility_multi_user_list_switcher)
// WHEN
val result = keyguardUserSwitcherAnchor.createAccessibilityNodeInfo()
// THEN
assertThat(
AccessibilityNodeInfoCompat.wrap(result).roleDescription
).isEqualTo(roleDescriptionString)
}
}