Merge "Specify the parent viewgroup that should hide controls" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
9dfb2b2f0e
@@ -134,7 +134,8 @@ class ControlsActivity @Inject constructor(
|
|||||||
super.onStop()
|
super.onStop()
|
||||||
mExitToDream = false
|
mExitToDream = false
|
||||||
|
|
||||||
uiController.hide()
|
// parent is set in onStart, so the field is initialized when we get here
|
||||||
|
uiController.hide(parent)
|
||||||
controlsSettingsDialogManager.closeDialog()
|
controlsSettingsDialogManager.closeDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,13 @@ interface ControlsUiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun show(parent: ViewGroup, onDismiss: Runnable, activityContext: Context)
|
fun show(parent: ViewGroup, onDismiss: Runnable, activityContext: Context)
|
||||||
fun hide()
|
|
||||||
|
/**
|
||||||
|
* Hide the controls content if it's attached to this parent.
|
||||||
|
*/
|
||||||
|
fun hide(parent: ViewGroup)
|
||||||
|
|
||||||
|
val isShowing: Boolean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the preferred activity to start, depending on if the user has favorited any
|
* Returns the preferred activity to start, depending on if the user has favorited any
|
||||||
|
|||||||
@@ -168,6 +168,9 @@ class ControlsUiControllerImpl @Inject constructor (
|
|||||||
private lateinit var activityContext: Context
|
private lateinit var activityContext: Context
|
||||||
private lateinit var listingCallback: ControlsListingController.ControlsListingCallback
|
private lateinit var listingCallback: ControlsListingController.ControlsListingCallback
|
||||||
|
|
||||||
|
override val isShowing: Boolean
|
||||||
|
get() = !hidden
|
||||||
|
|
||||||
init {
|
init {
|
||||||
dumpManager.registerDumpable(javaClass.name, this)
|
dumpManager.registerDumpable(javaClass.name, this)
|
||||||
}
|
}
|
||||||
@@ -727,21 +730,27 @@ class ControlsUiControllerImpl @Inject constructor (
|
|||||||
controlActionCoordinator.closeDialogs()
|
controlActionCoordinator.closeDialogs()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun hide() {
|
override fun hide(parent: ViewGroup) {
|
||||||
hidden = true
|
// We need to check for the parent because it's possible that we have started showing in a
|
||||||
|
// different activity. In that case, make sure to only clear things associated with the
|
||||||
|
// passed parent
|
||||||
|
if (parent == this.parent) {
|
||||||
|
Log.d(ControlsUiController.TAG, "hide()")
|
||||||
|
hidden = true
|
||||||
|
|
||||||
closeDialogs(true)
|
closeDialogs(true)
|
||||||
controlsController.get().unsubscribe()
|
controlsController.get().unsubscribe()
|
||||||
taskViewController?.dismiss()
|
taskViewController?.dismiss()
|
||||||
taskViewController = null
|
taskViewController = null
|
||||||
|
|
||||||
|
controlsById.clear()
|
||||||
|
controlViewsById.clear()
|
||||||
|
|
||||||
|
controlsListingController.get().removeCallback(listingCallback)
|
||||||
|
|
||||||
|
if (!retainCache) RenderInfo.clearCache()
|
||||||
|
}
|
||||||
parent.removeAllViews()
|
parent.removeAllViews()
|
||||||
controlsById.clear()
|
|
||||||
controlViewsById.clear()
|
|
||||||
|
|
||||||
controlsListingController.get().removeCallback(listingCallback)
|
|
||||||
|
|
||||||
if (!retainCache) RenderInfo.clearCache()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onRefreshState(componentName: ComponentName, controls: List<Control>) {
|
override fun onRefreshState(componentName: ComponentName, controls: List<Control>) {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import android.testing.TestableLooper
|
|||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import androidx.test.filters.SmallTest
|
import androidx.test.filters.SmallTest
|
||||||
import com.android.systemui.R
|
import com.android.systemui.R
|
||||||
@@ -328,7 +329,7 @@ class ControlsUiControllerImplTest : SysuiTestCase() {
|
|||||||
)
|
)
|
||||||
.isTrue()
|
.isTrue()
|
||||||
|
|
||||||
underTest.hide()
|
underTest.hide(parent)
|
||||||
|
|
||||||
clearInvocations(controlsListingController, taskViewFactory)
|
clearInvocations(controlsListingController, taskViewFactory)
|
||||||
controlsSettingsRepository.setAllowActionOnTrivialControlsInLockscreen(false)
|
controlsSettingsRepository.setAllowActionOnTrivialControlsInLockscreen(false)
|
||||||
@@ -387,6 +388,28 @@ class ControlsUiControllerImplTest : SysuiTestCase() {
|
|||||||
assertThat(underTest.resolveActivity()).isEqualTo(ControlsActivity::class.java)
|
assertThat(underTest.resolveActivity()).isEqualTo(ControlsActivity::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testRemoveViewsOnlyForParentPassedInHide() {
|
||||||
|
underTest.show(parent, {}, context)
|
||||||
|
parent.addView(View(context))
|
||||||
|
|
||||||
|
val mockParent: ViewGroup = mock()
|
||||||
|
|
||||||
|
underTest.hide(mockParent)
|
||||||
|
|
||||||
|
verify(mockParent).removeAllViews()
|
||||||
|
assertThat(parent.childCount).isGreaterThan(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testHideDifferentParentDoesntCancelListeners() {
|
||||||
|
underTest.show(parent, {}, context)
|
||||||
|
underTest.hide(mock())
|
||||||
|
|
||||||
|
verify(controlsController, never()).unsubscribe()
|
||||||
|
verify(controlsListingController, never()).removeCallback(any())
|
||||||
|
}
|
||||||
|
|
||||||
private fun setUpPanel(panel: SelectedItem.PanelItem): ControlsServiceInfo {
|
private fun setUpPanel(panel: SelectedItem.PanelItem): ControlsServiceInfo {
|
||||||
val activity = ComponentName("pkg", "activity")
|
val activity = ComponentName("pkg", "activity")
|
||||||
sharedPreferences
|
sharedPreferences
|
||||||
|
|||||||
Reference in New Issue
Block a user