Update views in (Q)QS footer when shade opens
The signal indicating that the shade is opening is `setListening(true)`, so tie the checks for the views to that signal. Also, remove the conditional state based on where the footer is. Individual actions don't change visibility depending on QQS vs QS. Test: manual Test: atest com.android.systemui.qs Fixes: 204165361 Change-Id: I86bf6818739f7f8c2890e9450e64dd9aefb691b5
This commit is contained in:
@@ -72,12 +72,6 @@ class FooterActionsController @Inject constructor(
|
||||
private var listening: Boolean = false
|
||||
|
||||
var expanded = false
|
||||
set(value) {
|
||||
if (field != value) {
|
||||
field = value
|
||||
updateView()
|
||||
}
|
||||
}
|
||||
|
||||
private val settingsButton: SettingsButton = view.findViewById(R.id.settings_button)
|
||||
private val settingsButtonContainer: View? = view.findViewById(R.id.settings_button_container)
|
||||
@@ -176,8 +170,7 @@ class FooterActionsController @Inject constructor(
|
||||
}
|
||||
|
||||
private fun updateView() {
|
||||
mView.updateEverything(buttonsVisible(), isTunerEnabled(),
|
||||
multiUserSwitchController.isMultiUserEnabled)
|
||||
mView.updateEverything(isTunerEnabled(), multiUserSwitchController.isMultiUserEnabled)
|
||||
}
|
||||
|
||||
override fun onViewDetached() {
|
||||
@@ -191,14 +184,14 @@ class FooterActionsController @Inject constructor(
|
||||
this.listening = listening
|
||||
if (this.listening) {
|
||||
userInfoController.addCallback(onUserInfoChangedListener)
|
||||
updateView()
|
||||
} else {
|
||||
userInfoController.removeCallback(onUserInfoChangedListener)
|
||||
}
|
||||
}
|
||||
|
||||
fun disable(state2: Int) {
|
||||
mView.disable(buttonsVisible(), state2, isTunerEnabled(),
|
||||
multiUserSwitchController.isMultiUserEnabled)
|
||||
mView.disable(state2, isTunerEnabled(), multiUserSwitchController.isMultiUserEnabled)
|
||||
}
|
||||
|
||||
fun setExpansion(headerExpansionFraction: Float) {
|
||||
|
||||
@@ -107,7 +107,6 @@ class FooterActionsView(context: Context?, attrs: AttributeSet?) : LinearLayout(
|
||||
}
|
||||
|
||||
fun disable(
|
||||
buttonsVisible: Boolean,
|
||||
state2: Int,
|
||||
isTunerEnabled: Boolean,
|
||||
multiUserEnabled: Boolean
|
||||
@@ -115,16 +114,15 @@ class FooterActionsView(context: Context?, attrs: AttributeSet?) : LinearLayout(
|
||||
val disabled = state2 and StatusBarManager.DISABLE2_QUICK_SETTINGS != 0
|
||||
if (disabled == qsDisabled) return
|
||||
qsDisabled = disabled
|
||||
updateEverything(buttonsVisible, isTunerEnabled, multiUserEnabled)
|
||||
updateEverything(isTunerEnabled, multiUserEnabled)
|
||||
}
|
||||
|
||||
fun updateEverything(
|
||||
buttonsVisible: Boolean,
|
||||
isTunerEnabled: Boolean,
|
||||
multiUserEnabled: Boolean
|
||||
) {
|
||||
post {
|
||||
updateVisibilities(buttonsVisible, isTunerEnabled, multiUserEnabled)
|
||||
updateVisibilities(isTunerEnabled, multiUserEnabled)
|
||||
updateClickabilities()
|
||||
isClickable = false
|
||||
}
|
||||
@@ -137,15 +135,14 @@ class FooterActionsView(context: Context?, attrs: AttributeSet?) : LinearLayout(
|
||||
}
|
||||
|
||||
private fun updateVisibilities(
|
||||
buttonsVisible: Boolean,
|
||||
isTunerEnabled: Boolean,
|
||||
multiUserEnabled: Boolean
|
||||
) {
|
||||
settingsContainer.visibility = if (qsDisabled) GONE else VISIBLE
|
||||
tunerIcon.visibility = if (isTunerEnabled) VISIBLE else INVISIBLE
|
||||
multiUserSwitch.visibility = if (buttonsVisible && multiUserEnabled) VISIBLE else GONE
|
||||
multiUserSwitch.visibility = if (multiUserEnabled) VISIBLE else GONE
|
||||
val isDemo = UserManager.isDeviceInDemoMode(context)
|
||||
settingsButton.visibility = if (isDemo || !buttonsVisible) INVISIBLE else VISIBLE
|
||||
settingsButton.visibility = if (isDemo) INVISIBLE else VISIBLE
|
||||
}
|
||||
|
||||
fun onUserInfoChanged(picture: Drawable?, isGuestUser: Boolean) {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.android.systemui.qs
|
||||
|
||||
import com.android.systemui.R
|
||||
import android.os.UserManager
|
||||
import android.testing.AndroidTestingRunner
|
||||
import android.testing.TestableLooper
|
||||
import android.testing.ViewUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.test.filters.SmallTest
|
||||
@@ -9,6 +11,7 @@ import com.android.internal.logging.MetricsLogger
|
||||
import com.android.internal.logging.UiEventLogger
|
||||
import com.android.internal.logging.testing.FakeMetricsLogger
|
||||
import com.android.systemui.Dependency
|
||||
import com.android.systemui.R
|
||||
import com.android.systemui.classifier.FalsingManagerFake
|
||||
import com.android.systemui.globalactions.GlobalActionsDialogLite
|
||||
import com.android.systemui.plugins.ActivityStarter
|
||||
@@ -19,8 +22,11 @@ import com.android.systemui.statusbar.policy.UserInfoController
|
||||
import com.android.systemui.tuner.TunerService
|
||||
import com.android.systemui.utils.leaks.FakeTunerService
|
||||
import com.android.systemui.utils.leaks.LeakCheckedTest
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.ArgumentMatchers.any
|
||||
import org.mockito.ArgumentMatchers.anyBoolean
|
||||
import org.mockito.Mock
|
||||
@@ -30,6 +36,8 @@ import org.mockito.MockitoAnnotations
|
||||
import org.mockito.Mockito.`when` as whenever
|
||||
|
||||
@SmallTest
|
||||
@TestableLooper.RunWithLooper
|
||||
@RunWith(AndroidTestingRunner::class)
|
||||
class FooterActionsControllerTest : LeakCheckedTest() {
|
||||
@Mock
|
||||
private lateinit var userManager: UserManager
|
||||
@@ -53,10 +61,12 @@ class FooterActionsControllerTest : LeakCheckedTest() {
|
||||
private val metricsLogger: MetricsLogger = FakeMetricsLogger()
|
||||
private lateinit var view: FooterActionsView
|
||||
private val falsingManager: FalsingManagerFake = FalsingManagerFake()
|
||||
private lateinit var testableLooper: TestableLooper
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
testableLooper = TestableLooper.get(this)
|
||||
injectLeakCheckedDependencies(*LeakCheckedTest.ALL_SUPPORTED_CLASSES)
|
||||
val fakeTunerService = Dependency.get(TunerService::class.java) as FakeTunerService
|
||||
|
||||
@@ -69,7 +79,14 @@ class FooterActionsControllerTest : LeakCheckedTest() {
|
||||
globalActionsDialog, uiEventLogger, showPMLiteButton = true,
|
||||
buttonsVisibleState = ExpansionState.EXPANDED)
|
||||
controller.init()
|
||||
controller.onViewAttached()
|
||||
ViewUtils.attachView(view)
|
||||
// View looper is the testable looper associated with the test
|
||||
testableLooper.processAllMessages()
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
ViewUtils.detachView(view)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,4 +107,19 @@ class FooterActionsControllerTest : LeakCheckedTest() {
|
||||
// Verify Settings wasn't launched.
|
||||
verify<ActivityStarter>(activityStarter, Mockito.never()).startActivity(any(), anyBoolean())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMultiUserSwitchUpdatedWhenExpansionStarts() {
|
||||
// When expansion starts, listening is set to true
|
||||
val multiUserSwitch = view.requireViewById<View>(R.id.multi_user_switch)
|
||||
|
||||
assertThat(multiUserSwitch.visibility).isNotEqualTo(View.VISIBLE)
|
||||
|
||||
whenever(multiUserSwitchController.isMultiUserEnabled).thenReturn(true)
|
||||
|
||||
controller.setListening(true)
|
||||
testableLooper.processAllMessages()
|
||||
|
||||
assertThat(multiUserSwitch.visibility).isEqualTo(View.VISIBLE)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user