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

Commit 6bcd7320 authored by Jim Miller's avatar Jim Miller Committed by Adam Cohen
Browse files

Switch back to user switcher in keyguard

Change-Id: I9acfb61fd34ad24a299e1f11f792e9e240f2b065
parent 61cd69c3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
<!-- This is a view that shows general status information in Keyguard. -->
<com.android.internal.policy.impl.keyguard.KeyguardWidgetFrame
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/keyguard_multi_user_selector"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

+1 −0
Original line number Diff line number Diff line
@@ -1299,6 +1299,7 @@
  <java-symbol type="id" name="kg_widget_region" />
  <java-symbol type="id" name="left_strip" />
  <java-symbol type="id" name="right_strip" />
  <java-symbol type="id" name="keyguard_multi_user_selector" />

  <java-symbol type="integer" name="config_carDockRotation" />
  <java-symbol type="integer" name="config_defaultUiModeType" />
+4 −0
Original line number Diff line number Diff line
@@ -820,4 +820,8 @@ public class KeyguardHostView extends KeyguardViewBase {
        }
    }

    public void goToUserSwitcher() {
        mAppWidgetContainer.setCurrentPage(getWidgetPosition(R.id.keyguard_multi_user_selector));
    }

}
+5 −5
Original line number Diff line number Diff line
@@ -71,10 +71,6 @@ class KeyguardMultiUserAvatar extends FrameLayout {

    public KeyguardMultiUserAvatar(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        Resources res = context.getResources();
        mActiveTextColor = res.getColor(R.color.kg_multi_user_text_active);
        mInactiveTextColor = res.getColor(R.color.kg_multi_user_text_inactive);
    }

    public void setup(UserInfo user, KeyguardMultiUserSelectorView userSelector) {
@@ -84,6 +80,10 @@ class KeyguardMultiUserAvatar extends FrameLayout {
    }

    private void init() {
        Resources res = mContext.getResources();
        mActiveTextColor = res.getColor(R.color.kg_multi_user_text_active);
        mInactiveTextColor = res.getColor(R.color.kg_multi_user_text_inactive);

        mUserImage = (ImageView) findViewById(R.id.keyguard_user_avatar);
        mUserName = (TextView) findViewById(R.id.keyguard_user_name);        

+21 −7
Original line number Diff line number Diff line
@@ -24,9 +24,11 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.os.IBinder;
import android.os.Parcelable;
import android.os.SystemProperties;
import android.util.Log;
import android.util.Slog;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -89,7 +91,7 @@ public class KeyguardViewManager {

        boolean enableScreenRotation = shouldEnableScreenRotation();

        maybeCreateKeyguardLocked(enableScreenRotation);
        maybeCreateKeyguardLocked(enableScreenRotation, false);
        maybeEnableScreenRotation(enableScreenRotation);

        // Disable common aspects of the system/status/navigation bars that are not appropriate or
@@ -120,13 +122,19 @@ public class KeyguardViewManager {
        @Override
        protected void onConfigurationChanged(Configuration newConfig) {
            super.onConfigurationChanged(newConfig);
            maybeCreateKeyguardLocked(shouldEnableScreenRotation());
            maybeCreateKeyguardLocked(shouldEnableScreenRotation(), false);
        }
    }

    private void maybeCreateKeyguardLocked(boolean enableScreenRotation) {
    SparseArray<Parcelable> mStateContainer = new SparseArray<Parcelable>();

    private void maybeCreateKeyguardLocked(boolean enableScreenRotation, boolean userSwitched) {
        final boolean isActivity = (mContext instanceof Activity); // for test activity

        if (mKeyguardHost != null) {
            mKeyguardHost.saveHierarchyState(mStateContainer);
        }

        if (mKeyguardHost == null) {
            if (DEBUG) Log.d(TAG, "keyguard host is null, creating it...");

@@ -161,11 +169,13 @@ public class KeyguardViewManager {
            mWindowLayoutParams = lp;
            mViewManager.addView(mKeyguardHost, lp);
        }
        inflateKeyguardView();
        inflateKeyguardView(userSwitched);
        mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams);

        mKeyguardHost.restoreHierarchyState(mStateContainer);
    }

    private void inflateKeyguardView() {
    private void inflateKeyguardView(boolean userSwitched) {
        View v = mKeyguardHost.findViewById(R.id.keyguard_host_view);
        if (v != null) {
            mKeyguardHost.removeView(v);
@@ -179,6 +189,10 @@ public class KeyguardViewManager {
        mKeyguardView.setLockPatternUtils(mLockPatternUtils);
        mKeyguardView.setViewMediatorCallback(mViewMediatorCallback);

        if (userSwitched) {
            mKeyguardView.goToUserSwitcher();
        }

        if (mScreenOn) {
            mKeyguardView.show();
        }
@@ -219,11 +233,11 @@ public class KeyguardViewManager {
    /**
     * Reset the state of the view.
     */
    public synchronized void reset() {
    public synchronized void reset(boolean userSwitched) {
        if (DEBUG) Log.d(TAG, "reset()");
        // User might have switched, check if we need to go back to keyguard
        // TODO: It's preferable to stay and show the correct lockscreen or unlock if none
        maybeCreateKeyguardLocked(shouldEnableScreenRotation());
        maybeCreateKeyguardLocked(shouldEnableScreenRotation(), userSwitched);
    }

    public synchronized void onScreenTurnedOff() {
Loading