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

Commit d04be1df authored by Matt Pietal's avatar Matt Pietal
Browse files

Fullscreen user switcher

Supports fullscreen user switcher launched from QS, and enabled by
config_enableFullscreenUserSwitcher. Allows adding guests, with
support for adding new users coming shortly. First round of work on
this feature.

Bug: 217365397
Test: atest UserSwitcherControllerTest
Change-Id: Ib81f44c9b950830a7d89b95cbaef53b7228ed5a4
parent 5c5cdad7
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -845,6 +845,18 @@
                  android:visibleToInstantApps="true">
        </activity>

        <activity android:name=".user.UserSwitcherActivity"
                  android:label="@string/accessibility_multi_user_switch_switcher"
                  android:theme="@style/Theme.UserSwitcherActivity"
                  android:excludeFromRecents="true"
                  android:showWhenLocked="true"
                  android:showForAllUsers="true"
                  android:finishOnTaskLaunch="true"
                  android:launchMode="singleInstance"
                  android:configChanges="screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden"
                  android:visibleToInstantApps="true">
        </activity>

        <receiver android:name=".controls.management.ControlsRequestReceiver"
            android:exported="true">
            <intent-filter>
+45 −0
Original line number Diff line number Diff line
# User Switching

Multiple users and the ability to switch between them is controlled by Settings -> System -> Multiple Users.

## Entry Points

### Quick Settings

In the QS footer, an icon becomes available for users to tap on. The view and its onClick actions are handled by [MultiUserSwitchController][2]. Multiple visual implementations are currently in use; one for phones/foldables ([UserSwitchDialogController][6]) and one for tablets ([UserSwitcherActivity][5]).

### Bouncer

May allow changing or adding new users directly from they bouncer. See [KeyguardBouncer][1]

### Keyguard affordance

[KeyguardQsUserSwitchController][4]

## Components

All visual implementations should derive their logic and use the adapter specified in:

### [UserSwitcherController][3]

* Contains the current list of all system users
* Listens for relevant events and broadcasts to make sure this list stays up to date
* Manages user switching and dialogs for exiting from guest users
* Is settings aware regarding adding users from the lockscreen

## Visual Components

### [UserSwitcherActivity][5]

A fullscreen user switching activity, supporting add guest/user actions if configured.

### [UserSwitchDialogController][6]

Renders user switching as a dialog over the current surface, and supports add guest user/actions if configured.

[1]: /frameworks/base/packages/SystemUI/docs/keyguard/bouncer.md
[2]: /frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/MultiUserController.java
[3]: /frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
[4]: /frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardQsUserSwitchController.java
[5]: /frameworks/base/packages/SystemUI/src/com/android/systemui/user/UserSwitcherActivity.kt
[6]: /frameworks/base/packages/SystemUI/src/com/android/systemui/qs/user/UserSwitchDialogController.kt
+9 −1
Original line number Diff line number Diff line
@@ -113,9 +113,17 @@
    <dimen name="bouncer_user_switcher_item_icon_size">28dp</dimen>
    <dimen name="bouncer_user_switcher_item_icon_padding">12dp</dimen>
    <dimen name="bouncer_user_switcher_width">248dp</dimen>
    <dimen name="bouncer_user_switcher_icon_size">190dp</dimen>
    <dimen name="bouncer_user_switcher_popup_header_height">12dp</dimen>
    <dimen name="bouncer_user_switcher_popup_divider_height">4dp</dimen>
    <dimen name="bouncer_user_switcher_item_padding_vertical">10dp</dimen>
    <dimen name="bouncer_user_switcher_item_padding_horizontal">12dp</dimen>

    <!-- 2 * the margin + size should equal the plus_margin -->
    <dimen name="user_switcher_icon_large_margin">16dp</dimen>
    <dimen name="bouncer_user_switcher_icon_size">190dp</dimen>
    <dimen name="bouncer_user_switcher_icon_size_plus_margin">222dp</dimen>

    <dimen name="user_switcher_icon_selected_width">8dp</dimen>
    <dimen name="user_switcher_fullscreen_button_text_size">14sp</dimen>
    <dimen name="user_switcher_fullscreen_button_padding">12dp</dimen>
</resources>
+46 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
* Copyright 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.
*/
-->
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="@dimen/bouncer_user_switcher_icon_size_plus_margin"
    android:height="@dimen/bouncer_user_switcher_icon_size_plus_margin">
  <!-- The final layer is inset, so it needs this background -->
  <item>
    <shape android:shape="oval">
       <solid android:color="@color/user_switcher_fullscreen_bg" />
    </shape>
  </item>
  <!-- When an item is selected, this layer will show a ring around the icon -->
  <item>
    <shape android:shape="oval">
       <stroke
           android:width="@dimen/user_switcher_icon_selected_width"
           android:color="@android:color/transparent" />
    </shape>
  </item>
  <!-- Where the user drawable/bitmap will be placed -->
  <item
      android:drawable="@drawable/kg_bg_avatar"
      android:width="@dimen/bouncer_user_switcher_icon_size"
      android:height="@dimen/bouncer_user_switcher_icon_size"
      android:top="@dimen/user_switcher_icon_large_margin"
      android:left="@dimen/user_switcher_icon_large_margin"
      android:right="@dimen/user_switcher_icon_large_margin"
      android:bottom="@dimen/user_switcher_icon_large_margin" />
</layer-list>
+70 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     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.
-->
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
    android:id="@+id/user_switcher_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginEnd="60dp"
    android:layout_marginStart="60dp">

  <androidx.constraintlayout.helper.widget.Flow
      android:id="@+id/flow"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:flow_horizontalBias="0.5"
      app:flow_verticalAlign="center"
      app:flow_wrapMode="chain"
      app:flow_horizontalGap="64dp"
      app:flow_verticalGap="44dp"
      app:flow_horizontalStyle="packed"/>

  <TextView
      android:id="@+id/cancel"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:gravity="center"
      app:layout_constraintHeight_min="48dp"
      app:layout_constraintEnd_toStartOf="@+id/add"
      app:layout_constraintBottom_toBottomOf="parent"
      android:paddingHorizontal="@dimen/user_switcher_fullscreen_button_padding"
      android:textSize="@dimen/user_switcher_fullscreen_button_text_size"
      android:textColor="?androidprv:attr/colorAccentPrimary"
      android:text="@string/cancel" />

  <TextView
      android:id="@+id/add"
      android:visibility="gone"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="center"
      android:gravity="center"
      app:layout_constraintHeight_min="48dp"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintBottom_toBottomOf="parent"
      android:paddingHorizontal="@dimen/user_switcher_fullscreen_button_padding"
      android:textSize="@dimen/user_switcher_fullscreen_button_text_size"
      android:textColor="?androidprv:attr/colorAccentPrimary"
      android:text="@string/add" />
</androidx.constraintlayout.widget.ConstraintLayout>
Loading