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

Commit a910be6d authored by Fabian Kozynski's avatar Fabian Kozynski
Browse files

Apply dialog style to User switcher dialog.

Apply the unified style and set just the inner content, relying on the
default title and buttons.

Also, fix using the vertical spacing in PseudoGridView.

Test: manual
Test: atest UserSwitchDialogControllerTest
Bug: 203666386
Change-Id: If6a0220979d9f9df584c29f4adce317341577cf4
Merged-In: If6a0220979d9f9df584c29f4adce317341577cf4
parent 1a848af4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -22,6 +22,6 @@
        xmlns:sysui="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        sysui:verticalSpacing="4dp"
        sysui:verticalSpacing="20dp"
        sysui:horizontalSpacing="4dp"
        style="@style/UserDetailView" />
 No newline at end of file
+0 −2
Original line number Diff line number Diff line
@@ -24,8 +24,6 @@
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:gravity="top|center_horizontal"
        android:paddingTop="16dp"
        android:minHeight="112dp"
        android:clipChildren="false"
        android:clipToPadding="false"
        android:focusable="true"
+10 −66
Original line number Diff line number Diff line
@@ -15,75 +15,19 @@
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<androidx.constraintlayout.widget.ConstraintLayout
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:sysui="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="24dp"
    android:layout_marginStart="16dp"
    android:layout_marginEnd="16dp"
    >
    <TextView
        android:id="@+id/title"
        android:layout_height="wrap_content"
        android:layout_width="0dp"
        android:textAlignment="center"
        android:text="@string/qs_user_switch_dialog_title"
        android:textAppearance="@style/TextAppearance.Dialog.Title"
        android:layout_marginBottom="32dp"
        sysui:layout_constraintTop_toTopOf="parent"
        sysui:layout_constraintStart_toStartOf="parent"
        sysui:layout_constraintEnd_toEndOf="parent"
        sysui:layout_constraintBottom_toTopOf="@id/grid"
        />

    <com.android.systemui.qs.PseudoGridView
            android:id="@+id/grid"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
        android:layout_marginBottom="28dp"
        sysui:verticalSpacing="4dp"
            android:layout_gravity="center"
            sysui:verticalSpacing="20dp"
            sysui:horizontalSpacing="4dp"
            sysui:fixedChildWidth="80dp"
        sysui:layout_constraintTop_toBottomOf="@id/title"
        sysui:layout_constraintStart_toStartOf="parent"
        sysui:layout_constraintEnd_toEndOf="parent"
        sysui:layout_constraintBottom_toTopOf="@id/barrier"
    />

    <androidx.constraintlayout.widget.Barrier
        android:id="@+id/barrier"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        sysui:barrierDirection="top"
        sysui:constraint_referenced_ids="settings,done"
        />

    <Button
        android:id="@+id/settings"
        android:layout_width="wrap_content"
        android:layout_height="48dp"
        android:text="@string/quick_settings_more_user_settings"
        sysui:layout_constraintTop_toBottomOf="@id/barrier"
        sysui:layout_constraintBottom_toBottomOf="parent"
        sysui:layout_constraintStart_toStartOf="parent"
        sysui:layout_constraintEnd_toStartOf="@id/done"
        sysui:layout_constraintHorizontal_chainStyle="spread_inside"
        style="@style/Widget.Dialog.Button.BorderButton"
        />

    <Button
        android:id="@+id/done"
        android:layout_width="wrap_content"
        android:layout_height="48dp"
        android:text="@string/quick_settings_done"
        sysui:layout_constraintTop_toBottomOf="@id/barrier"
        sysui:layout_constraintBottom_toBottomOf="parent"
        sysui:layout_constraintStart_toEndOf="@id/settings"
        sysui:layout_constraintEnd_toEndOf="parent"
        style="@style/Widget.Dialog.Button"
        />

</androidx.constraintlayout.widget.ConstraintLayout>
 No newline at end of file
</FrameLayout>
 No newline at end of file
+1 −4
Original line number Diff line number Diff line
@@ -133,10 +133,7 @@ public class PseudoGridView extends ViewGroup {
                    x += width + mHorizontalSpacing;
                }
            }
            y += maxHeight;
            if (row > 0) {
                y += mVerticalSpacing;
            }
            y += maxHeight + mVerticalSpacing;
        }
    }

+0 −82
Original line number Diff line number Diff line
/*
 * 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.
 */

package com.android.systemui.qs.user

import android.content.Context
import android.os.Bundle
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.view.WindowInsets
import android.view.WindowManager
import com.android.systemui.qs.PseudoGridView
import com.android.systemui.statusbar.phone.SystemUIDialog
import com.android.systemui.R

/**
 * Dialog for switching users or creating new ones.
 */
class UserDialog(
    context: Context
) : SystemUIDialog(context) {

    // create() is no-op after creation
    private lateinit var _doneButton: View
    /**
     * Button with text "Done" in dialog.
     */
    val doneButton: View
        get() {
            create()
            return _doneButton
        }

    private lateinit var _settingsButton: View
    /**
     * Button with text "User Settings" in dialog.
     */
    val settingsButton: View
        get() {
            create()
            return _settingsButton
        }

    private lateinit var _grid: PseudoGridView
    /**
     * Grid to populate with user avatar from adapter
     */
    val grid: ViewGroup
        get() {
            create()
            return _grid
        }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        window?.apply {
            setType(WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL)
            attributes.fitInsetsTypes = attributes.fitInsetsTypes or WindowInsets.Type.statusBars()
            attributes.receiveInsetsIgnoringZOrder = true
            setGravity(Gravity.CENTER)
        }
        setContentView(R.layout.qs_user_dialog_content)

        _doneButton = requireViewById(R.id.done)
        _settingsButton = requireViewById(R.id.settings)
        _grid = requireViewById(R.id.grid)
    }
}
 No newline at end of file
Loading