Merge "[a11y] When multi-user switcher is selected in lockscreen and Talkback is enabled, play helpful explanation." into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
168133e3eb
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
<!-- need to keep this outer view in order to have a correctly sized anchor
|
<!-- 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 -->
|
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:id="@+id/user_switcher_anchor"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
android:textDirection="locale"
|
android:textDirection="locale"
|
||||||
android:layout_width="@dimen/bouncer_user_switcher_width"
|
android:layout_width="@dimen/bouncer_user_switcher_width"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
</LinearLayout>>
|
</com.android.keyguard.KeyguardUserSwitcherAnchor>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -887,7 +887,8 @@
|
|||||||
<!-- Accessibility label for the button that opens the user switcher. -->
|
<!-- Accessibility label for the button that opens the user switcher. -->
|
||||||
<string name="accessibility_multi_user_switch_switcher">Switch user</string>
|
<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. -->
|
<!-- Accessibility label for the user icon on the lock screen. -->
|
||||||
|
|
||||||
|
|||||||
@@ -1129,11 +1129,13 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
|||||||
Log.e(TAG, "Current user in user switcher is null.");
|
Log.e(TAG, "Current user in user switcher is null.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final String currentUserName = mUserSwitcherController.getCurrentUserName();
|
||||||
Drawable userIcon = findUserIcon(currentUser.info.id);
|
Drawable userIcon = findUserIcon(currentUser.info.id);
|
||||||
((ImageView) mView.findViewById(R.id.user_icon)).setImageDrawable(userIcon);
|
((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) {
|
BaseUserAdapter adapter = new BaseUserAdapter(mUserSwitcherController) {
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
@@ -1213,7 +1215,6 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
|||||||
|
|
||||||
anchor.setOnClickListener((v) -> {
|
anchor.setOnClickListener((v) -> {
|
||||||
if (mFalsingManager.isFalseTap(LOW_PENALTY)) return;
|
if (mFalsingManager.isFalseTap(LOW_PENALTY)) return;
|
||||||
|
|
||||||
mPopup = new KeyguardUserSwitcherPopupMenu(v.getContext(), mFalsingManager);
|
mPopup = new KeyguardUserSwitcherPopupMenu(v.getContext(), mFalsingManager);
|
||||||
mPopup.setAnchorView(anchor);
|
mPopup.setAnchorView(anchor);
|
||||||
mPopup.setAdapter(adapter);
|
mPopup.setAdapter(adapter);
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user