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

Commit 00a0b1f3 authored by Adrian Roos's avatar Adrian Roos
Browse files

Implement real QS user switcher

Replaces the stop-gap user switcher with the real deal.
Dimensions may need some further adjustments.

Bug: 15545213
Change-Id: I4399635c03553dac935049d5b8297fe5f5c1dc9a
parent 09f1c724
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -16,9 +16,14 @@
  ~ limitations under the License
  -->

<com.android.systemui.qs.tiles.UserDetail
<!-- GridView -->
<com.android.systemui.qs.tiles.UserDetailView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <include layout="@layout/user_switcher_host" />
</com.android.systemui.qs.tiles.UserDetail>
 No newline at end of file
        android:layout_height="match_parent"
        android:verticalSpacing="4dp"
        android:horizontalSpacing="4dp"
        android:numColumns="3"
        android:listSelector="@drawable/ripple_drawable">

</com.android.systemui.qs.tiles.UserDetailView>
 No newline at end of file
+44 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<!--
  ~ Copyright (C) 2014 The Android Open Source Project
  ~
@@ -15,35 +16,29 @@
  ~ limitations under the License
  -->

<LinearLayout
<com.android.systemui.qs.tiles.UserDetailItemView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:systemui="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="64dp"
        android:orientation="horizontal"
        android:gravity="center_vertical"
        tools:context=".settings.UserSwitcherDialog">
    <ImageView
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:gravity="top|center_horizontal"
        android:paddingTop="16dp"
        android:paddingBottom="20dp">

    <com.android.systemui.statusbar.phone.UserAvatarView
            android:id="@+id/user_picture"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_marginStart="4dp"
            android:id="@+id/user_picture"
            tools:src="@drawable/dessert_zombiegingerbread"/>
            android:layout_marginBottom="12dp"
            systemui:frameWidth="2dp"
            systemui:activeFrameColor="@color/current_user_border_color"/>

    <TextView
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:id="@+id/user_name"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:padding="8dp"
            android:gravity="center_vertical"
            tools:text="Hiroshi Lockheimer"
            />
    <ImageView
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:layout_marginEnd="4dp"
            android:src="@*android:drawable/ic_menu_delete"
            android:id="@+id/user_delete"
            android:background="?android:attr/selectableItemBackground"/>
</LinearLayout>
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="14sp"
            android:text="@string/guest_nickname"/>

</com.android.systemui.qs.tiles.UserDetailItemView>
 No newline at end of file
+0 −31
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<!--
  ~ 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
  -->

<!-- FrameLayout -->
<com.android.systemui.settings.UserSwitcherHostView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ListView android:id="@android:id/list"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:listitem="@layout/user_switcher_item"/>

</com.android.systemui.settings.UserSwitcherHostView>
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -108,6 +108,9 @@ public class QSPanel extends ViewGroup {
        mHost = host;
    }

    public QSTileHost getHost() {
        return mHost;
    }

    public void updateResources() {
        final Resources res = mContext.getResources();
+82 −0
Original line number Diff line number Diff line
@@ -17,62 +17,66 @@
package com.android.systemui.qs.tiles;

import com.android.systemui.R;
import com.android.systemui.qs.QSTile;
import com.android.systemui.statusbar.phone.UserAvatarView;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * Quick settings detail view for user switching.
 * Displays one user in the {@link UserDetailView} view.
 */
public class UserDetail extends FrameLayout {
public class UserDetailItemView extends LinearLayout {

    static final Intent USER_SETTINGS_INTENT = new Intent("android.settings.USER_SETTINGS");
    private UserAvatarView mAvatar;
    private TextView mName;

    public UserDetail(Context context) {
    public UserDetailItemView(Context context) {
        this(context, null);
    }

    public UserDetail(Context context, AttributeSet attrs) {
    public UserDetailItemView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public UserDetail(Context context, AttributeSet attrs, int defStyleAttr) {
    public UserDetailItemView(Context context, AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr, 0);
    }

    public UserDetail(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    public UserDetailItemView(Context context, AttributeSet attrs, int defStyleAttr,
            int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    public static QSTile.DetailAdapter USER_DETAIL_ADAPTER = new QSTile.DetailAdapter() {
        @Override
        public int getTitle() {
            return R.string.quick_settings_user_title;
    public static UserDetailItemView convertOrInflate(Context context, View convertView,
            ViewGroup root) {
        if (!(convertView instanceof UserDetailItemView)) {
            convertView = LayoutInflater.from(context).inflate(
                    R.layout.qs_user_detail_item, root, false);
        }

        @Override
        public Boolean getToggleState() {
            return null;
        return (UserDetailItemView) convertView;
    }

        @Override
        public View createDetailView(Context context, View convertView, ViewGroup parent) {
            return LayoutInflater.from(context).inflate(R.layout.qs_user_detail, parent, false);
    public void bind(String name, Bitmap picture) {
        mName.setText(name);
        mAvatar.setBitmap(picture);
    }

        @Override
        public Intent getSettingsIntent() {
            return USER_SETTINGS_INTENT;
    public void bind(String name, Drawable picture) {
        mName.setText(name);
        mAvatar.setDrawable(picture);
    }

    @Override
        public void setToggleState(boolean state) {
    protected void onFinishInflate() {
        mAvatar = (UserAvatarView) findViewById(R.id.user_picture);
        mName = (TextView) findViewById(R.id.user_name);
    }
    };

}
Loading