For #9044 - Replace DownloadNotificationBottomSheetDialog with unobtrusive view
- Renamed DownloadNotification and removed DownloadState.dismissed dependency - Improved DynamicDownloadDialog behaviour when scrolling - DynamicDownloadDialog remains attached to tab until dismissed - Fixed onTryAgain not working for resumed DownloadDialogsfennec/production
parent
86273270fb
commit
7feae98944
@ -1,113 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.downloads
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import kotlinx.android.synthetic.main.download_notification_layout.*
|
||||
import mozilla.components.browser.state.state.content.DownloadState
|
||||
import mozilla.components.feature.downloads.AbstractFetchDownloadService
|
||||
import mozilla.components.feature.downloads.toMegabyteString
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.components.metrics.Event
|
||||
import org.mozilla.fenix.ext.metrics
|
||||
import org.mozilla.fenix.theme.ThemeManager
|
||||
|
||||
class DownloadNotificationBottomSheetDialog(
|
||||
context: Context,
|
||||
private val download: DownloadState,
|
||||
private val didFail: Boolean,
|
||||
private val tryAgain: (Long) -> Unit,
|
||||
private val onCannotOpenFile: () -> Unit
|
||||
// We must pass in the BottomSheetDialog theme for the transparent window background to apply properly
|
||||
) : BottomSheetDialog(context, R.style.Theme_MaterialComponents_BottomSheetDialog) {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setContentView(R.layout.download_notification_layout)
|
||||
|
||||
if (didFail) {
|
||||
download_notification_title.text =
|
||||
context.getString(R.string.mozac_feature_downloads_failed_notification_text2)
|
||||
|
||||
download_notification_icon.setImageResource(
|
||||
mozilla.components.feature.downloads.R.drawable.mozac_feature_download_ic_download_failed
|
||||
)
|
||||
|
||||
download_notification_action_button.apply {
|
||||
text = context.getString(
|
||||
mozilla.components.feature.downloads.R.string.mozac_feature_downloads_button_try_again
|
||||
)
|
||||
setOnClickListener {
|
||||
tryAgain(download.id)
|
||||
context.metrics.track(Event.InAppNotificationDownloadTryAgain)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val titleText = context.getString(
|
||||
R.string.mozac_feature_downloads_completed_notification_text2
|
||||
) + " (${download.contentLength?.toMegabyteString()})"
|
||||
|
||||
download_notification_title.text = titleText
|
||||
|
||||
download_notification_icon.setImageResource(
|
||||
mozilla.components.feature.downloads.R.drawable.mozac_feature_download_ic_download_complete
|
||||
)
|
||||
|
||||
download_notification_action_button.apply {
|
||||
text = context.getString(
|
||||
mozilla.components.feature.downloads.R.string.mozac_feature_downloads_button_open
|
||||
)
|
||||
setOnClickListener {
|
||||
val fileWasOpened = AbstractFetchDownloadService.openFile(
|
||||
context = context,
|
||||
contentType = download.contentType,
|
||||
filePath = download.filePath
|
||||
)
|
||||
|
||||
if (!fileWasOpened) {
|
||||
onCannotOpenFile()
|
||||
}
|
||||
|
||||
context.metrics.track(Event.InAppNotificationDownloadOpen)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
download_notification_close_button.setOnClickListener {
|
||||
dismiss()
|
||||
}
|
||||
|
||||
download_notification_filename.text = download.fileName
|
||||
|
||||
setOnShowListener {
|
||||
val bottomSheet =
|
||||
findViewById<View>(com.google.android.material.R.id.design_bottom_sheet) as FrameLayout
|
||||
val behavior = BottomSheetBehavior.from(bottomSheet)
|
||||
behavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||
window?.apply {
|
||||
setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
|
||||
setLayout(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
)
|
||||
navigationBarColor = ContextCompat.getColor(
|
||||
context,
|
||||
ThemeManager.resolveAttribute(
|
||||
R.attr.foundation, context
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.downloads
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import kotlinx.android.extensions.LayoutContainer
|
||||
import kotlinx.android.synthetic.main.download_dialog_layout.view.*
|
||||
import mozilla.components.browser.state.state.content.DownloadState
|
||||
import mozilla.components.feature.downloads.AbstractFetchDownloadService
|
||||
import mozilla.components.feature.downloads.toMegabyteString
|
||||
import org.mozilla.fenix.FeatureFlags
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.components.metrics.Event
|
||||
import org.mozilla.fenix.ext.metrics
|
||||
import org.mozilla.fenix.ext.settings
|
||||
|
||||
/**
|
||||
* [DynamicDownloadDialog] is used to show a view in the current tab to the user, triggered when
|
||||
* downloadFeature.onDownloadStopped gets invoked. It uses [DynamicDownloadDialogBehavior] to
|
||||
* hide when the users scrolls through a website as to not impede his activities.
|
||||
* */
|
||||
|
||||
class DynamicDownloadDialog(
|
||||
private val container: ViewGroup,
|
||||
private val downloadState: DownloadState?,
|
||||
private val didFail: Boolean,
|
||||
private val tryAgain: (Long) -> Unit,
|
||||
private val onCannotOpenFile: () -> Unit,
|
||||
private val view: View,
|
||||
private val toolbarHeight: Int,
|
||||
private val onDismiss: () -> Unit
|
||||
) : LayoutContainer {
|
||||
|
||||
override val containerView: View?
|
||||
get() = container
|
||||
|
||||
private val settings = container.context.settings()
|
||||
|
||||
init {
|
||||
setupDownloadDialog(view)
|
||||
}
|
||||
|
||||
private fun setupDownloadDialog(view: View) {
|
||||
if (downloadState == null) return
|
||||
view.apply {
|
||||
if (FeatureFlags.dynamicBottomToolbar && layoutParams is CoordinatorLayout.LayoutParams) {
|
||||
(layoutParams as CoordinatorLayout.LayoutParams).apply {
|
||||
|
||||
behavior =
|
||||
DynamicDownloadDialogBehavior<View>(
|
||||
context,
|
||||
null,
|
||||
toolbarHeight.toFloat()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (settings.shouldUseBottomToolbar) {
|
||||
val params: ViewGroup.MarginLayoutParams =
|
||||
view.layoutParams as ViewGroup.MarginLayoutParams
|
||||
params.bottomMargin = toolbarHeight
|
||||
}
|
||||
|
||||
if (didFail) {
|
||||
view.download_dialog_title.text =
|
||||
container.context.getString(R.string.mozac_feature_downloads_failed_notification_text2)
|
||||
|
||||
view.download_dialog_icon.setImageResource(
|
||||
mozilla.components.feature.downloads.R.drawable.mozac_feature_download_ic_download_failed
|
||||
)
|
||||
|
||||
view.download_dialog_action_button.apply {
|
||||
text = context.getString(
|
||||
mozilla.components.feature.downloads.R.string.mozac_feature_downloads_button_try_again
|
||||
)
|
||||
setOnClickListener {
|
||||
tryAgain(downloadState.id)
|
||||
context.metrics.track(Event.InAppNotificationDownloadTryAgain)
|
||||
dismiss(view)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
val titleText = container.context.getString(
|
||||
R.string.mozac_feature_downloads_completed_notification_text2
|
||||
) + " (${downloadState.contentLength?.toMegabyteString()})"
|
||||
|
||||
view.download_dialog_title.text = titleText
|
||||
|
||||
view.download_dialog_icon.setImageResource(
|
||||
mozilla.components.feature.downloads.R.drawable.mozac_feature_download_ic_download_complete
|
||||
)
|
||||
|
||||
view.download_dialog_action_button.apply {
|
||||
text = context.getString(
|
||||
mozilla.components.feature.downloads.R.string.mozac_feature_downloads_button_open
|
||||
)
|
||||
setOnClickListener {
|
||||
val fileWasOpened = AbstractFetchDownloadService.openFile(
|
||||
context = context,
|
||||
contentType = downloadState.contentType,
|
||||
filePath = downloadState.filePath
|
||||
)
|
||||
|
||||
if (!fileWasOpened) {
|
||||
onCannotOpenFile()
|
||||
}
|
||||
|
||||
context.metrics.track(Event.InAppNotificationDownloadOpen)
|
||||
dismiss(view)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
view.download_dialog_close_button.setOnClickListener {
|
||||
dismiss(view)
|
||||
}
|
||||
|
||||
view.download_dialog_filename.text = downloadState.fileName
|
||||
}
|
||||
|
||||
fun show() {
|
||||
view.visibility = View.VISIBLE
|
||||
|
||||
if (FeatureFlags.dynamicBottomToolbar) {
|
||||
(view.layoutParams as CoordinatorLayout.LayoutParams).apply {
|
||||
(behavior as DynamicDownloadDialogBehavior).forceExpand(view)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun dismiss(view: View) {
|
||||
view.visibility = View.GONE
|
||||
onDismiss()
|
||||
}
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.downloads
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.view.ViewCompat
|
||||
import mozilla.components.concept.engine.EngineView
|
||||
import mozilla.components.support.ktx.android.view.findViewInHierarchy
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
* A [CoordinatorLayout.Behavior] implementation to be used when placing [DynamicDownloadDialog]
|
||||
* at the bottom of the screen. Based off of BrowserToolbarBottomBehavior.
|
||||
*
|
||||
* This implementation will:
|
||||
* - Show/Hide the [DynamicDownloadDialog] automatically when scrolling vertically.
|
||||
* - Snap the [DynamicDownloadDialog] to be hidden or visible when the user stops scrolling.
|
||||
*/
|
||||
|
||||
private const val SNAP_ANIMATION_DURATION = 150L
|
||||
|
||||
class DynamicDownloadDialogBehavior<V : View>(
|
||||
context: Context?,
|
||||
attrs: AttributeSet?,
|
||||
private val bottomToolbarHeight: Float = 0f
|
||||
) : CoordinatorLayout.Behavior<V>(context, attrs) {
|
||||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
internal var expanded: Boolean = true
|
||||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
internal var shouldSnapAfterScroll: Boolean = false
|
||||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
internal var snapAnimator: ValueAnimator = ValueAnimator()
|
||||
.apply {
|
||||
interpolator = DecelerateInterpolator()
|
||||
duration = SNAP_ANIMATION_DURATION
|
||||
}
|
||||
|
||||
/**
|
||||
* Reference to [EngineView] used to check user's [android.view.MotionEvent]s.
|
||||
*/
|
||||
private var engineView: EngineView? = null
|
||||
|
||||
/**
|
||||
* Depending on how user's touch was consumed by EngineView / current website,
|
||||
*
|
||||
* we will animate the dynamic download notification dialog if:
|
||||
* - touches were used for zooming / panning operations in the website.
|
||||
*
|
||||
* We will do nothing if:
|
||||
* - the website is not scrollable
|
||||
* - the website handles the touch events itself through it's own touch event listeners.
|
||||
*/
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
internal val shouldScroll: Boolean
|
||||
get() = engineView?.getInputResult() == EngineView.InputResult.INPUT_RESULT_HANDLED
|
||||
|
||||
override fun onStartNestedScroll(
|
||||
coordinatorLayout: CoordinatorLayout,
|
||||
child: V,
|
||||
directTargetChild: View,
|
||||
target: View,
|
||||
axes: Int,
|
||||
type: Int
|
||||
): Boolean {
|
||||
return if (shouldScroll && axes == ViewCompat.SCROLL_AXIS_VERTICAL) {
|
||||
shouldSnapAfterScroll = type == ViewCompat.TYPE_TOUCH
|
||||
snapAnimator.cancel()
|
||||
true
|
||||
} else if (engineView?.getInputResult() == EngineView.InputResult.INPUT_RESULT_UNHANDLED) {
|
||||
// Force expand the notification dialog if event is unhandled, otherwise user could get stuck in a
|
||||
// state where they cannot show it
|
||||
forceExpand(child)
|
||||
snapAnimator.cancel()
|
||||
false
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStopNestedScroll(
|
||||
coordinatorLayout: CoordinatorLayout,
|
||||
child: V,
|
||||
target: View,
|
||||
type: Int
|
||||
) {
|
||||
if (shouldSnapAfterScroll || type == ViewCompat.TYPE_NON_TOUCH) {
|
||||
if (expanded) {
|
||||
if (child.translationY >= bottomToolbarHeight / 2)
|
||||
animateSnap(child, SnapDirection.DOWN)
|
||||
else animateSnap(child, SnapDirection.UP)
|
||||
} else {
|
||||
if (child.translationY < (bottomToolbarHeight + child.height.toFloat() / 2))
|
||||
animateSnap(child, SnapDirection.UP)
|
||||
else animateSnap(child, SnapDirection.DOWN)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNestedPreScroll(
|
||||
coordinatorLayout: CoordinatorLayout,
|
||||
child: V,
|
||||
target: View,
|
||||
dx: Int,
|
||||
dy: Int,
|
||||
consumed: IntArray,
|
||||
type: Int
|
||||
) {
|
||||
if (shouldScroll) {
|
||||
super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed, type)
|
||||
child.translationY = max(
|
||||
0f,
|
||||
min(
|
||||
child.height.toFloat() + bottomToolbarHeight,
|
||||
child.translationY + dy
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun layoutDependsOn(
|
||||
parent: CoordinatorLayout,
|
||||
child: V,
|
||||
dependency: View
|
||||
): Boolean {
|
||||
engineView = parent.findViewInHierarchy { it is EngineView } as? EngineView
|
||||
return super.layoutDependsOn(parent, child, dependency)
|
||||
}
|
||||
|
||||
fun forceExpand(view: View) {
|
||||
animateSnap(view, SnapDirection.UP)
|
||||
}
|
||||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
internal fun animateSnap(child: View, direction: SnapDirection) = with(snapAnimator) {
|
||||
expanded = direction == SnapDirection.UP
|
||||
addUpdateListener { child.translationY = it.animatedValue as Float }
|
||||
setFloatValues(
|
||||
child.translationY,
|
||||
if (direction == SnapDirection.UP) 0f else child.height.toFloat() + bottomToolbarHeight
|
||||
)
|
||||
start()
|
||||
}
|
||||
|
||||
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
|
||||
internal enum class SnapDirection {
|
||||
UP,
|
||||
DOWN
|
||||
}
|
||||
}
|
@ -0,0 +1,178 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.downloads
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.view.View
|
||||
import androidx.core.view.ViewCompat
|
||||
import mozilla.components.support.test.mock
|
||||
import mozilla.components.support.test.robolectric.testContext
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.doReturn
|
||||
import org.mockito.Mockito.spy
|
||||
import org.mockito.Mockito.verify
|
||||
import org.mockito.Mockito.never
|
||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||
|
||||
@RunWith(FenixRobolectricTestRunner::class)
|
||||
class DynamicDownloadDialogBehaviorTest {
|
||||
|
||||
@Test
|
||||
fun `Starting a nested scroll should cancel an ongoing snap animation`() {
|
||||
val behavior = spy(DynamicDownloadDialogBehavior<View>(testContext, attrs = null))
|
||||
doReturn(true).`when`(behavior).shouldScroll
|
||||
|
||||
val animator: ValueAnimator = mock()
|
||||
behavior.snapAnimator = animator
|
||||
|
||||
val acceptsNestedScroll = behavior.onStartNestedScroll(
|
||||
coordinatorLayout = mock(),
|
||||
child = mock(),
|
||||
directTargetChild = mock(),
|
||||
target = mock(),
|
||||
axes = ViewCompat.SCROLL_AXIS_VERTICAL,
|
||||
type = ViewCompat.TYPE_TOUCH
|
||||
)
|
||||
|
||||
assertTrue(acceptsNestedScroll)
|
||||
|
||||
verify(animator).cancel()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Behavior should not accept nested scrolls on the horizontal axis`() {
|
||||
val behavior = DynamicDownloadDialogBehavior<View>(testContext, attrs = null)
|
||||
|
||||
val acceptsNestedScroll = behavior.onStartNestedScroll(
|
||||
coordinatorLayout = mock(),
|
||||
child = mock(),
|
||||
directTargetChild = mock(),
|
||||
target = mock(),
|
||||
axes = ViewCompat.SCROLL_AXIS_HORIZONTAL,
|
||||
type = ViewCompat.TYPE_TOUCH
|
||||
)
|
||||
|
||||
assertFalse(acceptsNestedScroll)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Behavior will snap the dialog up if it is more than 50% visible`() {
|
||||
val behavior = spy(DynamicDownloadDialogBehavior<View>(testContext, attrs = null,
|
||||
bottomToolbarHeight = 10f))
|
||||
doReturn(true).`when`(behavior).shouldScroll
|
||||
|
||||
val animator: ValueAnimator = mock()
|
||||
behavior.snapAnimator = animator
|
||||
|
||||
behavior.expanded = false
|
||||
|
||||
val child = mock<View>()
|
||||
doReturn(100).`when`(child)?.height
|
||||
doReturn(59f).`when`(child)?.translationY
|
||||
|
||||
behavior.onStartNestedScroll(
|
||||
coordinatorLayout = mock(),
|
||||
child = child,
|
||||
directTargetChild = mock(),
|
||||
target = mock(),
|
||||
axes = ViewCompat.SCROLL_AXIS_VERTICAL,
|
||||
type = ViewCompat.TYPE_TOUCH
|
||||
)
|
||||
|
||||
assertTrue(behavior.shouldSnapAfterScroll)
|
||||
|
||||
verify(animator, never()).start()
|
||||
|
||||
behavior.onStopNestedScroll(
|
||||
coordinatorLayout = mock(),
|
||||
child = child,
|
||||
target = mock(),
|
||||
type = 0
|
||||
)
|
||||
|
||||
verify(behavior).animateSnap(child, DynamicDownloadDialogBehavior.SnapDirection.UP)
|
||||
|
||||
verify(animator).start()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Behavior will snap the dialog down if translationY is at least equal to half the toolbarHeight`() {
|
||||
val behavior = spy(DynamicDownloadDialogBehavior<View>(testContext, attrs = null,
|
||||
bottomToolbarHeight = 10f))
|
||||
doReturn(true).`when`(behavior).shouldScroll
|
||||
|
||||
val animator: ValueAnimator = mock()
|
||||
behavior.snapAnimator = animator
|
||||
|
||||
behavior.expanded = true
|
||||
|
||||
val child = mock<View>()
|
||||
doReturn(100).`when`(child).height
|
||||
doReturn(5f).`when`(child).translationY
|
||||
|
||||
behavior.onStartNestedScroll(
|
||||
coordinatorLayout = mock(),
|
||||
child = child,
|
||||
directTargetChild = mock(),
|
||||
target = mock(),
|
||||
axes = ViewCompat.SCROLL_AXIS_VERTICAL,
|
||||
type = ViewCompat.TYPE_TOUCH
|
||||
)
|
||||
|
||||
assertTrue(behavior.shouldSnapAfterScroll)
|
||||
|
||||
verify(animator, never()).start()
|
||||
|
||||
behavior.onStopNestedScroll(
|
||||
coordinatorLayout = mock(),
|
||||
child = child,
|
||||
target = mock(),
|
||||
type = 0
|
||||
)
|
||||
|
||||
verify(behavior).animateSnap(child, DynamicDownloadDialogBehavior.SnapDirection.DOWN)
|
||||
|
||||
verify(animator).start()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Behavior will apply translation to the dialog for nested scroll`() {
|
||||
val behavior = spy(DynamicDownloadDialogBehavior<View>(testContext, attrs = null))
|
||||
doReturn(true).`when`(behavior).shouldScroll
|
||||
|
||||
val child = mock<View>()
|
||||
doReturn(100).`when`(child).height
|
||||
doReturn(0f).`when`(child).translationY
|
||||
|
||||
behavior.onNestedPreScroll(
|
||||
coordinatorLayout = mock(),
|
||||
child = child,
|
||||
target = mock(),
|
||||
dx = 0,
|
||||
dy = 25,
|
||||
consumed = IntArray(0),
|
||||
type = 0
|
||||
)
|
||||
|
||||
verify(child).translationY = 25f
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Behavior will animateSnap UP when forceExpand is called`() {
|
||||
val behavior = spy(DynamicDownloadDialogBehavior<View>(testContext, attrs = null))
|
||||
val dynamicDialogView: View = mock()
|
||||
doReturn(true).`when`(behavior).shouldScroll
|
||||
|
||||
behavior.forceExpand(dynamicDialogView)
|
||||
|
||||
verify(behavior).animateSnap(
|
||||
dynamicDialogView,
|
||||
DynamicDownloadDialogBehavior.SnapDirection.UP
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue