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

Commit 66e31ac4 authored by Michał Brzeziński's avatar Michał Brzeziński Committed by Automerger Merge Worker
Browse files

Merge "Showing action buttons in collapsed QS in split shade" into sc-v2-dev...

Merge "Showing action buttons in collapsed QS in split shade" into sc-v2-dev am: bdf42979 am: 3d4a61fb

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15482450

Change-Id: Iae57baa7a548e4b8e5bab3680ee9918f7879556e
parents 17b5c172 3d4a61fb
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -14,9 +14,10 @@
** See the License for the specific language governing permissions and
** limitations under the License.
-->
<com.android.systemui.qs.QSFooterActionsView

<!-- Action buttons for footer in QS/QQS, containing settings button, power off button etc -->
<com.android.systemui.qs.FooterActionsView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/qs_footer_actions_container"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:gravity="center_vertical">
@@ -101,4 +102,4 @@

    </com.android.systemui.statusbar.AlphaOptimizedFrameLayout>

</com.android.systemui.qs.QSFooterActionsView>
 No newline at end of file
</com.android.systemui.qs.FooterActionsView>
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -68,7 +68,8 @@

        </LinearLayout>

        <include layout="@layout/qs_footer_actions"/>
        <include layout="@layout/footer_actions"
            android:id="@+id/qs_footer_actions"/>

    </LinearLayout>

+12 −1
Original line number Diff line number Diff line
@@ -56,7 +56,18 @@
            android:clipToPadding="false"
            android:focusable="true"
            android:paddingBottom="24dp"
            android:importantForAccessibility="yes" />
            android:importantForAccessibility="yes">

            <include
                layout="@layout/footer_actions"
                android:id="@+id/qqs_footer_actions"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:layout_marginStart="@dimen/qs_footer_margin"
                android:layout_marginEnd="@dimen/qs_footer_margin"
                />
        </com.android.systemui.qs.QuickQSPanel>
    </RelativeLayout>

</com.android.systemui.qs.QuickStatusBarHeader>
+60 −10
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

import android.content.Intent
@@ -16,6 +32,8 @@ import com.android.systemui.animation.ActivityLaunchAnimator
import com.android.systemui.globalactions.GlobalActionsDialogLite
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.qs.FooterActionsController.ExpansionState.COLLAPSED
import com.android.systemui.qs.FooterActionsController.ExpansionState.EXPANDED
import com.android.systemui.qs.dagger.QSFlagsModule.PM_LITE_ENABLED
import com.android.systemui.statusbar.phone.MultiUserSwitchController
import com.android.systemui.statusbar.phone.SettingsButton
@@ -27,8 +45,13 @@ import com.android.systemui.util.ViewController
import javax.inject.Inject
import javax.inject.Named

class QSFooterActionsController @Inject constructor(
    view: QSFooterActionsView,
/**
 * Manages [FooterActionsView] behaviour, both when it's placed in QS or QQS (split shade).
 * Main difference between QS and QQS behaviour is condition when buttons should be visible,
 * determined by [buttonsVisibleState]
 */
class FooterActionsController @Inject constructor(
    view: FooterActionsView,
    private val qsPanelController: QSPanelController,
    private val activityStarter: ActivityStarter,
    private val userManager: UserManager,
@@ -40,15 +63,20 @@ class QSFooterActionsController @Inject constructor(
    private val tunerService: TunerService,
    private val globalActionsDialog: GlobalActionsDialogLite,
    private val uiEventLogger: UiEventLogger,
    @Named(PM_LITE_ENABLED) private val showPMLiteButton: Boolean
) : ViewController<QSFooterActionsView>(view) {
    @Named(PM_LITE_ENABLED) private val showPMLiteButton: Boolean,
    private val buttonsVisibleState: ExpansionState
) : ViewController<FooterActionsView>(view) {

    enum class ExpansionState { COLLAPSED, EXPANDED }

    private var listening: Boolean = false

    var expanded = false
        set(value) {
            if (field != value) {
                field = value
            mView.setExpanded(value, isTunerEnabled(),
                    multiUserSwitchController.isMultiUserEnabled)
                updateView()
            }
        }

    private val settingsButton: SettingsButton = view.findViewById(R.id.settings_button)
@@ -64,7 +92,7 @@ class QSFooterActionsController @Inject constructor(
    private val onClickListener = View.OnClickListener { v ->
        // Don't do anything until views are unhidden. Don't do anything if the tap looks
        // suspicious.
        if (!expanded || falsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
        if (!buttonsVisible() || falsingManager.isFalseTap(FalsingManager.LOW_PENALTY)) {
            return@OnClickListener
        }
        if (v === settingsButton) {
@@ -98,10 +126,26 @@ class QSFooterActionsController @Inject constructor(
        }
    }

    private fun buttonsVisible(): Boolean {
        return when (buttonsVisibleState) {
            EXPANDED -> expanded
            COLLAPSED -> !expanded
        }
    }

    override fun onInit() {
        multiUserSwitchController.init()
    }

    fun hideFooter() {
        mView.visibility = View.GONE
    }

    fun showFooter() {
        mView.visibility = View.VISIBLE
        updateView()
    }

    private fun startSettingsActivity() {
        val animationController = settingsButtonContainer?.let {
            ActivityLaunchAnimator.Controller.fromView(
@@ -128,7 +172,12 @@ class QSFooterActionsController @Inject constructor(
            activityStarter.postQSRunnableDismissingKeyguard { qsPanelController.showEdit(view) }
        })

        mView.updateEverything(isTunerEnabled(), multiUserSwitchController.isMultiUserEnabled)
        updateView()
    }

    private fun updateView() {
        mView.updateEverything(buttonsVisible(), isTunerEnabled(),
                multiUserSwitchController.isMultiUserEnabled)
    }

    override fun onViewDetached() {
@@ -148,7 +197,8 @@ class QSFooterActionsController @Inject constructor(
    }

    fun disable(state2: Int) {
        mView.disable(state2, isTunerEnabled(), multiUserSwitchController.isMultiUserEnabled)
        mView.disable(buttonsVisible(), state2, isTunerEnabled(),
                multiUserSwitchController.isMultiUserEnabled)
    }

    fun setExpansion(headerExpansionFraction: Float) {
+67 −0
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

import android.os.UserManager
import com.android.internal.logging.MetricsLogger
import com.android.internal.logging.UiEventLogger
import com.android.systemui.globalactions.GlobalActionsDialogLite
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.plugins.FalsingManager
import com.android.systemui.qs.FooterActionsController.ExpansionState
import com.android.systemui.qs.dagger.QSFlagsModule
import com.android.systemui.statusbar.phone.MultiUserSwitchController
import com.android.systemui.statusbar.policy.DeviceProvisionedController
import com.android.systemui.statusbar.policy.UserInfoController
import com.android.systemui.tuner.TunerService
import javax.inject.Inject
import javax.inject.Named

class FooterActionsControllerBuilder @Inject constructor(
    private val qsPanelController: QSPanelController,
    private val activityStarter: ActivityStarter,
    private val userManager: UserManager,
    private val userInfoController: UserInfoController,
    private val multiUserSwitchController: MultiUserSwitchController,
    private val deviceProvisionedController: DeviceProvisionedController,
    private val falsingManager: FalsingManager,
    private val metricsLogger: MetricsLogger,
    private val tunerService: TunerService,
    private val globalActionsDialog: GlobalActionsDialogLite,
    private val uiEventLogger: UiEventLogger,
    @Named(QSFlagsModule.PM_LITE_ENABLED) private val showPMLiteButton: Boolean
) {
    private lateinit var view: FooterActionsView
    private lateinit var buttonsVisibleState: ExpansionState

    fun withView(view: FooterActionsView): FooterActionsControllerBuilder {
        this.view = view
        return this
    }

    fun withButtonsVisibleWhen(state: ExpansionState): FooterActionsControllerBuilder {
        buttonsVisibleState = state
        return this
    }

    fun build(): FooterActionsController {
        return FooterActionsController(view, qsPanelController, activityStarter, userManager,
                userInfoController, multiUserSwitchController, deviceProvisionedController,
                falsingManager, metricsLogger, tunerService, globalActionsDialog, uiEventLogger,
                showPMLiteButton, buttonsVisibleState)
    }
}
 No newline at end of file
Loading