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

Commit a62a54ff authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android Git Automerger
Browse files

am 879c4491: Merge "Implement new multi-user affordance."

* commit '879c4491af838286878b63af1dbc92eb55f1cc8c':
  Implement new multi-user affordance.
parents 56845144 fe051aa3
Loading
Loading
Loading
Loading
+13 −3
Original line number Original line Diff line number Diff line
@@ -25,7 +25,7 @@
    android:orientation="horizontal"
    android:orientation="horizontal"
    android:gravity="center_vertical"
    android:gravity="center_vertical"
    android:baselineAligned="false"
    android:baselineAligned="false"
    android:elevation="14dp"
    android:elevation="10dp"
    >
    >


    <View
    <View
@@ -74,12 +74,22 @@
        android:ellipsize="marquee"
        android:ellipsize="marquee"
        android:textAppearance="?android:attr/textAppearanceMedium" />
        android:textAppearance="?android:attr/textAppearanceMedium" />


    <com.android.systemui.statusbar.phone.MultiUserSwitch android:id="@+id/multi_user_switch"
        android:layout_width="40dp"
        android:layout_height="@dimen/status_bar_header_height"
        android:layout_alignParentEnd="true"
        android:background="@null"
        android:scaleType="centerInside"
        android:padding="6dp"
        />

    <FrameLayout android:id="@+id/system_icons_container"
    <FrameLayout android:id="@+id/system_icons_container"
        android:layout_width="wrap_content"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/status_bar_header_height"
        android:layout_height="@dimen/status_bar_header_height"
        android:layout_alignParentEnd="true"
        android:layout_toStartOf="@id/multi_user_switch"
        android:layout_marginEnd="16dp"
        android:layout_marginEnd="4dp"
        />
        />

    <TextView
    <TextView
        android:id="@+id/header_debug_info"
        android:id="@+id/header_debug_info"
        android:visibility="invisible"
        android:visibility="invisible"
+2 −1
Original line number Original line Diff line number Diff line
@@ -22,7 +22,8 @@
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_height="match_parent"
        android:background="#dd000000">
        android:background="#dd000000"
        android:elevation="12dp">
    <FrameLayout
    <FrameLayout
            android:layout_width="match_parent"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_height="wrap_content"
+90 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2014 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.systemui.statusbar.phone;

import android.content.Context;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.drawable.Drawable;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.ContactsContract;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;

import com.android.systemui.R;
import com.android.systemui.settings.UserSwitcherHostView;
import com.android.systemui.statusbar.policy.UserInfoController;

/**
 * Image button for the multi user switcher.
 */
public class MultiUserSwitch extends ImageButton implements View.OnClickListener,
        UserInfoController.OnUserInfoChangedListener {

    private ViewGroup mOverlayParent;

    public MultiUserSwitch(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        setOnClickListener(this);
    }

    public void setOverlayParent(ViewGroup parent) {
        mOverlayParent = parent;
    }

    @Override
    public void onClick(View v) {
        final UserManager um = UserManager.get(getContext());
        if (um.isUserSwitcherEnabled()) {
            final UserSwitcherHostView switcher =
                    (UserSwitcherHostView) LayoutInflater.from(getContext()).inflate(
                            R.layout.user_switcher_host, mOverlayParent, false);
            switcher.setFinishRunnable(new Runnable() {
                @Override
                public void run() {
                    mOverlayParent.removeView(switcher);
                }
            });
            switcher.refreshUsers();
            mOverlayParent.addView(switcher);
        } else {
            Intent intent = ContactsContract.QuickContact.composeQuickContactsIntent(
                    getContext(), v, ContactsContract.Profile.CONTENT_URI,
                    ContactsContract.QuickContact.MODE_LARGE, null);
            getContext().startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
        }
    }

    public void setUserInfoController(UserInfoController userInfoController) {
        userInfoController.addListener(this);
    }

    @Override
    public void onUserInfoChanged(String name, Drawable picture) {
        setImageDrawable(picture);
    }
}
+1 −0
Original line number Original line Diff line number Diff line
@@ -95,6 +95,7 @@ public class NotificationPanelView extends PanelView implements
        super.onFinishInflate();
        super.onFinishInflate();
        mHeader = (StatusBarHeaderView) findViewById(R.id.header);
        mHeader = (StatusBarHeaderView) findViewById(R.id.header);
        mHeader.getBackgroundView().setOnClickListener(this);
        mHeader.getBackgroundView().setOnClickListener(this);
        mHeader.setOverlayParent(this);
        mKeyguardStatusView = findViewById(R.id.keyguard_status_view);
        mKeyguardStatusView = findViewById(R.id.keyguard_status_view);
        mStackScrollerContainer = findViewById(R.id.notification_container_parent);
        mStackScrollerContainer = findViewById(R.id.notification_container_parent);
        mQsContainer = (QuickSettingsContainerView) findViewById(R.id.quick_settings_container);
        mQsContainer = (QuickSettingsContainerView) findViewById(R.id.quick_settings_container);
+7 −0
Original line number Original line Diff line number Diff line
@@ -111,6 +111,7 @@ import com.android.systemui.statusbar.policy.HeadsUpNotificationView;
import com.android.systemui.statusbar.policy.LocationController;
import com.android.systemui.statusbar.policy.LocationController;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.RotationLockController;
import com.android.systemui.statusbar.policy.RotationLockController;
import com.android.systemui.statusbar.policy.UserInfoController;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout.OnChildLocationsChangedListener;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout.OnChildLocationsChangedListener;
import com.android.systemui.statusbar.stack.StackScrollState.ViewState;
import com.android.systemui.statusbar.stack.StackScrollState.ViewState;
@@ -184,6 +185,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
    LocationController mLocationController;
    LocationController mLocationController;
    NetworkController mNetworkController;
    NetworkController mNetworkController;
    RotationLockController mRotationLockController;
    RotationLockController mRotationLockController;
    UserInfoController mUserInfoController;


    int mNaturalBarHeight = -1;
    int mNaturalBarHeight = -1;
    int mIconSize = -1;
    int mIconSize = -1;
@@ -670,6 +672,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
                || QuickSettings.DEBUG_GONE_TILES) {
                || QuickSettings.DEBUG_GONE_TILES) {
            mRotationLockController = new RotationLockController(mContext);
            mRotationLockController = new RotationLockController(mContext);
        }
        }
        mUserInfoController = new UserInfoController(mContext);
        final SignalClusterView signalCluster =
        final SignalClusterView signalCluster =
                (SignalClusterView)mStatusBarView.findViewById(R.id.signal_cluster);
                (SignalClusterView)mStatusBarView.findViewById(R.id.signal_cluster);


@@ -737,6 +740,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
            mQS = null; // fly away, be free
            mQS = null; // fly away, be free
        }
        }


        // User info. Trigger first load.
        mHeader.setUserInfoController(mUserInfoController);
        mUserInfoController.reloadUserInfo();

        PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        mBroadcastReceiver.onReceive(mContext,
        mBroadcastReceiver.onReceive(mContext,
                new Intent(pm.isScreenOn() ? Intent.ACTION_SCREEN_ON : Intent.ACTION_SCREEN_OFF));
                new Intent(pm.isScreenOn() ? Intent.ACTION_SCREEN_ON : Intent.ACTION_SCREEN_OFF));
Loading