Update visibility when attached

updateVisibility would normally be called during init, but a display or
font size change will have the same visibility before and after, so it
was being skipped. Instead let's just call it explicitly when the view
is attached

Fixes: 159646762
Test: atest KeyguardMediaControllerTest
Test: manual, change font size and observe no gap
Change-Id: Idad51d804c3e08ff673bea61924214a7ff6c0ccd
This commit is contained in:
Beth Thibodeau
2020-06-26 15:59:59 -04:00
parent 402d723892
commit f54131ffeb
2 changed files with 7 additions and 3 deletions

View File

@@ -64,6 +64,9 @@ class KeyguardMediaController @Inject constructor(
// Let's now initialize this view, which also creates the host view for us.
mediaHost.init(MediaHierarchyManager.LOCATION_LOCKSCREEN)
mediaView.setContentView(mediaHost.hostView)
// Ensure the visibility is correct
updateVisibility()
}
private fun updateVisibility() {

View File

@@ -36,6 +36,7 @@ import org.mockito.ArgumentCaptor
import org.mockito.Captor
import org.mockito.Mock
import org.mockito.Mockito.`when`
import org.mockito.Mockito.atLeastOnce
import org.mockito.Mockito.verify
import org.mockito.junit.MockitoJUnit
@@ -70,7 +71,7 @@ class KeyguardMediaControllerTest : SysuiTestCase() {
`when`(mediaHost.visible).thenReturn(false)
triggerVisibilityListener()
verify(mediaHeaderView).visibility = eq(GONE)
verify(mediaHeaderView, atLeastOnce()).visibility = eq(GONE)
}
@Test
fun testAttach_visibleOnKeyguard() {
@@ -80,7 +81,7 @@ class KeyguardMediaControllerTest : SysuiTestCase() {
.thenReturn(true)
triggerVisibilityListener()
verify(mediaHeaderView).visibility = eq(VISIBLE)
verify(mediaHeaderView, atLeastOnce()).visibility = eq(VISIBLE)
}
@Test
fun testAttach_hiddenOnKeyguard_whenNotificationsAreHidden() {
@@ -90,7 +91,7 @@ class KeyguardMediaControllerTest : SysuiTestCase() {
.thenReturn(false)
triggerVisibilityListener()
verify(mediaHeaderView).visibility = eq(GONE)
verify(mediaHeaderView, atLeastOnce()).visibility = eq(GONE)
}
private fun triggerVisibilityListener() {