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

Commit 212b756f authored by Peter Kalauskas's avatar Peter Kalauskas Committed by Android (Google) Code Review
Browse files

Merge "Move keyguard multi-user icon into container view" into sc-v2-dev

parents 00d9e530 56276a2c
Loading
Loading
Loading
Loading
+19 −13
Original line number Diff line number Diff line
@@ -15,10 +15,15 @@
  ~ limitations under the License
  -->
<!-- This is a view that shows a user switcher in Keyguard. -->
<com.android.systemui.statusbar.phone.UserAvatarView
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:systemui="http://schemas.android.com/apk/res-auto"
    android:id="@+id/keyguard_qs_user_switch_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="end">
    <com.android.systemui.statusbar.phone.UserAvatarView
        android:id="@+id/kg_multi_user_avatar"
        android:layout_width="@dimen/kg_framed_avatar_size"
        android:layout_height="@dimen/kg_framed_avatar_size"
        android:layout_centerHorizontal="true"
@@ -31,3 +36,4 @@
        systemui:framePadding="0dp"
        systemui:frameWidth="0dp">
    </com.android.systemui.statusbar.phone.UserAvatarView>
</FrameLayout>
 No newline at end of file
+3 −3
Original line number Diff line number Diff line
@@ -16,7 +16,8 @@

package com.android.keyguard.dagger;

import com.android.systemui.statusbar.phone.UserAvatarView;
import android.widget.FrameLayout;

import com.android.systemui.statusbar.policy.KeyguardQsUserSwitchController;

import dagger.BindsInstance;
@@ -31,8 +32,7 @@ public interface KeyguardQsUserSwitchComponent {
    /** Simple factory for {@link KeyguardUserSwitcherComponent}. */
    @Subcomponent.Factory
    interface Factory {
        KeyguardQsUserSwitchComponent build(
                @BindsInstance UserAvatarView userAvatarView);
        KeyguardQsUserSwitchComponent build(@BindsInstance FrameLayout userAvatarContainer);
    }

    /** Builds a {@link KeyguardQsUserSwitchController}. */
+5 −5
Original line number Diff line number Diff line
@@ -798,13 +798,13 @@ public class NotificationPanelViewController extends PanelViewController {
        mKeyguardStatusBar = mView.findViewById(R.id.keyguard_header);
        mBigClockContainer = mView.findViewById(R.id.big_clock_container);

        UserAvatarView userAvatarView = null;
        FrameLayout userAvatarContainer = null;
        KeyguardUserSwitcherView keyguardUserSwitcherView = null;

        if (mKeyguardUserSwitcherEnabled && mUserManager.isUserSwitcherEnabled()) {
            if (mKeyguardQsUserSwitchEnabled) {
                ViewStub stub = mView.findViewById(R.id.keyguard_qs_user_switch_stub);
                userAvatarView = (UserAvatarView) stub.inflate();
                userAvatarContainer = (FrameLayout) stub.inflate();
            } else {
                ViewStub stub = mView.findViewById(R.id.keyguard_user_switcher_stub);
                keyguardUserSwitcherView = (KeyguardUserSwitcherView) stub.inflate();
@@ -820,7 +820,7 @@ public class NotificationPanelViewController extends PanelViewController {

        updateViewControllers(
                mView.findViewById(R.id.keyguard_status_view),
                userAvatarView,
                userAvatarContainer,
                keyguardUserSwitcherView);
        mNotificationContainerParent = mView.findViewById(R.id.notification_container_parent);
        NotificationStackScrollLayout stackScrollLayout = mView.findViewById(
@@ -910,7 +910,7 @@ public class NotificationPanelViewController extends PanelViewController {
    }

    private void updateViewControllers(KeyguardStatusView keyguardStatusView,
            UserAvatarView userAvatarView,
            FrameLayout userAvatarView,
            KeyguardUserSwitcherView keyguardUserSwitcherView) {
        // Re-associate the KeyguardStatusViewController
        KeyguardStatusViewComponent statusViewComponent =
@@ -1066,7 +1066,7 @@ public class NotificationPanelViewController extends PanelViewController {
                !mKeyguardQsUserSwitchEnabled
                        && mKeyguardUserSwitcherEnabled
                        && isUserSwitcherEnabled;
        UserAvatarView userAvatarView = (UserAvatarView) reInflateStub(
        FrameLayout userAvatarView = (FrameLayout) reInflateStub(
                R.id.keyguard_qs_user_switch_view /* viewId */,
                R.id.keyguard_qs_user_switch_stub /* stubId */,
                R.layout.keyguard_qs_user_switch /* layoutId */,
+11 −9
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.FrameLayout;

import com.android.keyguard.KeyguardConstants;
import com.android.keyguard.KeyguardVisibilityHelper;
@@ -56,7 +57,7 @@ import javax.inject.Provider;
 * Manages the user switch on the Keyguard that is used for opening the QS user panel.
 */
@KeyguardUserSwitcherScope
public class KeyguardQsUserSwitchController extends ViewController<UserAvatarView> {
public class KeyguardQsUserSwitchController extends ViewController<FrameLayout> {

    private static final String TAG = "KeyguardQsUserSwitchController";
    private static final boolean DEBUG = KeyguardConstants.DEBUG;
@@ -76,6 +77,7 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie
    private final KeyguardVisibilityHelper mKeyguardVisibilityHelper;
    private final KeyguardUserDetailAdapter mUserDetailAdapter;
    private NotificationPanelViewController mNotificationPanelViewController;
    private UserAvatarView mUserAvatarView;
    UserSwitcherController.UserRecord mCurrentUser;

    // State info for the user switch and keyguard
@@ -111,7 +113,7 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie

    @Inject
    public KeyguardQsUserSwitchController(
            UserAvatarView view,
            FrameLayout view,
            Context context,
            @Main Resources resources,
            ScreenLifecycle screenLifecycle,
@@ -143,6 +145,7 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie
    protected void onInit() {
        super.onInit();
        if (DEBUG) Log.d(TAG, "onInit");
        mUserAvatarView = mView.findViewById(R.id.kg_multi_user_avatar);
        mAdapter = new UserSwitcherController.BaseUserAdapter(mUserSwitcherController) {
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
@@ -150,11 +153,10 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie
            }
        };

        mView.setOnClickListener(v -> {
        mUserAvatarView.setOnClickListener(v -> {
            if (mFalsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
                return;
            }

            if (isListAnimating()) {
                return;
            }
@@ -163,7 +165,7 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie
            openQsUserPanel();
        });

        mView.setAccessibilityDelegate(new View.AccessibilityDelegate() {
        mUserAvatarView.setAccessibilityDelegate(new View.AccessibilityDelegate() {
            public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
                super.onInitializeAccessibilityNodeInfo(host, info);
                info.addAction(new AccessibilityNodeInfo.AccessibilityAction(
@@ -237,12 +239,12 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie
                    R.string.accessibility_multi_user_switch_switcher);
        }

        if (!TextUtils.equals(mView.getContentDescription(), contentDescription)) {
            mView.setContentDescription(contentDescription);
        if (!TextUtils.equals(mUserAvatarView.getContentDescription(), contentDescription)) {
            mUserAvatarView.setContentDescription(contentDescription);
        }

        int userId = mCurrentUser != null ? mCurrentUser.resolveId() : UserHandle.USER_NULL;
        mView.setDrawableWithBadge(getCurrentUserIcon().mutate(), userId);
        mUserAvatarView.setDrawableWithBadge(getCurrentUserIcon().mutate(), userId);
    }

    Drawable getCurrentUserIcon() {
@@ -269,7 +271,7 @@ public class KeyguardQsUserSwitchController extends ViewController<UserAvatarVie
     * Get the height of the keyguard user switcher view when closed.
     */
    public int getUserIconHeight() {
        return mView.getHeight();
        return mUserAvatarView.getHeight();
    }

    /**