Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9dbd8f32 authored by Brad Hinegardner's avatar Brad Hinegardner Committed by Automerger Merge Worker
Browse files

Merge "[a11y] When multi-user switcher is selected in lockscreen and Talkback...

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

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



Change-Id: I8e8353b5ae17eac6bba2c11371fae737482dae0c
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents af548848 432c0bb3
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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>
+2 −1
Original line number Diff line number Diff line
@@ -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. -->

+4 −3
Original line number Diff line number Diff line
@@ -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);
+39 −0
Original line number Diff line number Diff line
/*
 * 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
    }
}
+53 −0
Original line number Diff line number Diff line
/*
 * 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)
    }
}