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

Commit 1970915c authored by Peter Kalauskas's avatar Peter Kalauskas
Browse files

New keyguard user switcher

 - Use ViewController for KeyguardUserSwitcher, name this
   KeyguardUserSwitcherController

 - Create KeyguardUserSwitcherListView. Separate view container and
   controller code.

 - Daggerize KeyguardUserSwitcherController

 - Move KeyguardUserSwitcher from NotificationsQuickSettingsContainer to
   NotificationPanelView

 - Hide clock and notification when keyguard user switcher is open

 - Show "End guest session" button when switcher is open and user is
   guest

 - Introduce listener for user switcher state

 - Change icon of guest when current so that it does not show exit icon

 - Disallow guest exit via user switcher list item

 - Propagate dark amount to keyguard user switcher

 - Updated styles

Known issues:

 - If repeatedly pressing KEYCODE_POWER while switching between users,
   the clock will sometimes get stuck in INVISIBLE state: b/179930842

 - Multiple StrictMode violations are still present: b/179913579

Test: atest com.android.keyguard
Test: Build with config_keyguardUserSwitcher=false, enable multi-user,
      check that user icon is in the status bar but not on the keyguard
      above the clock
Test: Build with config_keyguardUserSwitcher=true, check that user icon
      is visible on keyguard above the clock
Test: When config_keyguardUserSwitcher=true, tap user icon to open
      keyguard user switcher, then open and close QS to verify that
      the keyguard user switcher closes
Test: Check that user switcher is always open and visible on the lock
      screen when simple user switcher is enabled:
        adb shell settings put global lockscreenSimpleUserSwitcher 1 &&
          adb shell stop &&
          adb shell start

Bug: 169783558
Change-Id: Iaea4eae358873ae80748ca3eb9329f22bb2bb2ef
parent 0c27903d
Loading
Loading
Loading
Loading
+7 −11
Original line number Original line Diff line number Diff line
@@ -14,14 +14,10 @@
  ~ See the License for the specific language governing permissions and
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License
  ~ limitations under the License
  -->
  -->
<com.android.keyguard.AlphaOptimizedLinearLayout

    xmlns:android="http://schemas.android.com/apk/res/android"
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    android:id="@+id/keyguard_user_switcher_inner"
    <item
    android:orientation="vertical"
        android:state_activated="true"
    android:layout_height="wrap_content"
        android:color="@color/kg_user_switcher_avatar_background" />
    android:layout_width="wrap_content"
    <item android:color="@color/kg_user_switcher_avatar_background" />
    android:layout_marginTop="@dimen/status_bar_header_height_keyguard"
</selector>
    android:layout_gravity="end"
    android:gravity="end"
    android:paddingTop="4dp">
</com.android.keyguard.AlphaOptimizedLinearLayout>
+25 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>

<!--
  ~ Copyright (C) 2021 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
  -->

<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
    <stroke
        android:width="@dimen/end_guest_button_border_size"
        android:color="?android:attr/colorControlHighlight" />
    <corners android:radius="@dimen/end_guest_button_corner_radius" />
</shape>
+28 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2021 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.
  -->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="48dp"
        android:height="48dp"
        android:viewportWidth="100"
        android:viewportHeight="100">

    <path
        android:fillColor="@color/kg_user_switcher_avatar_background"
        android:pathData="M50,50m-50,0a50,50 0,1 1,100 0a50,50 0,1 1,-100 0"/>

</vector>
+47 −7
Original line number Original line Diff line number Diff line
@@ -14,10 +14,50 @@
  ~ See the License for the specific language governing permissions and
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License
  ~ limitations under the License
  -->
  -->
<view xmlns:android="http://schemas.android.com/apk/res/android"
<!-- This is a view that shows a user switcher in Keyguard. -->
        class="com.android.systemui.statusbar.policy.KeyguardUserSwitcher$Container"
<com.android.systemui.statusbar.policy.KeyguardUserSwitcherView
        android:visibility="gone"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/keyguard_user_switcher_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_height="match_parent"
        android:layout_width="match_parent">
    android:layout_gravity="end">
    <!-- KeyguardUserSwitcher loads keyguard_user_switcher_inner.xml here -->

</view>
    <com.android.systemui.statusbar.policy.KeyguardUserSwitcherListView
 No newline at end of file
        android:id="@+id/keyguard_user_switcher_list"
        android:orientation="vertical"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_gravity="top|end"
        android:gravity="end" />

    <LinearLayout
        android:id="@+id/end_guest_button"
        android:layout_height="@dimen/end_guest_button_layout_height"
        android:layout_width="wrap_content"
        android:layout_gravity="center_horizontal|bottom"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="@dimen/end_guest_button_margin_bottom"
        android:orientation="horizontal"
        android:gravity="center"
        android:paddingLeft="@dimen/end_guest_button_padding_horizontal"
        android:paddingRight="@dimen/end_guest_button_padding_horizontal"
        android:background="@drawable/end_guest_button_background"
        android:visibility="gone">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:src="@drawable/ic_exit_to_app"
            android:background="@android:color/transparent"
            android:color="?attr/wallpaperTextColor" />
        <TextView
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:gravity="center"
            android:fontFamily="@*android:string/config_bodyFontFamilyMedium"
            android:textColor="?attr/wallpaperTextColor"
            android:textSize="13sp"
            android:text="@string/guest_exit_button" />
    </LinearLayout>

</com.android.systemui.statusbar.policy.KeyguardUserSwitcherView>
+21 −20
Original line number Original line Diff line number Diff line
@@ -19,29 +19,30 @@
<!-- LinearLayout -->
<!-- LinearLayout -->
<com.android.systemui.statusbar.policy.KeyguardUserDetailItemView
<com.android.systemui.statusbar.policy.KeyguardUserDetailItemView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:sysui="http://schemas.android.com/apk/res-auto"
        xmlns:systemui="http://schemas.android.com/apk/res-auto"
        android:layout_width="wrap_content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_height="wrap_content"
        android:padding="8dp"
        android:padding="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginEnd="8dp"
        android:gravity="center_vertical"
        android:gravity="end|center_vertical"
        android:clickable="true"
        android:clickable="true"
        android:background="@drawable/ripple_drawable"
        android:background="@drawable/kg_user_switcher_rounded_bg"
        sysui:regularTextAppearance="@style/TextAppearance.StatusBar.Expanded.UserSwitcher"
        systemui:activatedTextAppearance="@style/TextAppearance.StatusBar.Expanded.UserSwitcher"
        sysui:activatedTextAppearance="@style/TextAppearance.StatusBar.Expanded.UserSwitcher.Activated">
        systemui:regularTextAppearance="@style/TextAppearance.StatusBar.Expanded.UserSwitcher">
    <TextView android:id="@+id/user_name"
    <TextView
        android:id="@+id/user_name"
        android:layout_width="wrap_content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_height="wrap_content"
            android:layout_marginEnd="13dp"
        android:layout_marginStart="20dp"
            android:textAppearance="@style/TextAppearance.StatusBar.Expanded.UserSwitcher"
        android:layout_marginEnd="16dp" />
            />
    <com.android.systemui.statusbar.phone.UserAvatarView
    <com.android.systemui.statusbar.phone.UserAvatarView android:id="@+id/user_picture"
        android:id="@+id/user_picture"
        android:layout_width="@dimen/kg_framed_avatar_size"
        android:layout_width="@dimen/kg_framed_avatar_size"
        android:layout_height="@dimen/kg_framed_avatar_size"
        android:layout_height="@dimen/kg_framed_avatar_size"
            android:contentDescription="@null"
        systemui:avatarPadding="0dp"
            sysui:frameWidth="@dimen/keyguard_user_switcher_border_thickness"
        systemui:badgeDiameter="18dp"
            sysui:framePadding="2.5dp"
        systemui:badgeMargin="1dp"
            sysui:badgeDiameter="18dp"
        systemui:frameWidth="0dp"
            sysui:badgeMargin="1dp"
        systemui:framePadding="0dp"
            sysui:frameColor="@color/kg_user_switcher_rounded_background_color" />
        systemui:frameColor="@color/kg_user_avatar_frame" />
</com.android.systemui.statusbar.policy.KeyguardUserDetailItemView>
</com.android.systemui.statusbar.policy.KeyguardUserDetailItemView>
Loading