Allow the dismiss target size to be overridden

For floating tasks the normal target size is too small to really
fit the task window, this allows the dismiss target to have a
different size set via a resource id.

Test: manual - override the size (in different CL), observe that
               the target is at that size.
Bug: 237678727
Change-Id: I85edae739992662852d4cf40c250714a100a67bb
This commit is contained in:
Mady Mellor
2022-08-16 12:10:04 -07:00
parent 73d8f6cea3
commit ca7e3d3001

View File

@@ -24,8 +24,8 @@ import android.util.IntProperty
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.view.WindowManager
import android.view.WindowInsets
import android.view.WindowManager
import android.widget.FrameLayout
import androidx.dynamicanimation.animation.DynamicAnimation
import androidx.dynamicanimation.animation.SpringForce.DAMPING_RATIO_LOW_BOUNCY
@@ -41,6 +41,7 @@ class DismissView(context: Context) : FrameLayout(context) {
var circle = DismissCircleView(context)
var isShowing = false
var targetSizeResId: Int
private val animator = PhysicsAnimator.getInstance(circle)
private val spring = PhysicsAnimator.SpringConfig(STIFFNESS_LOW, DAMPING_RATIO_LOW_BOUNCY)
@@ -70,7 +71,8 @@ class DismissView(context: Context) : FrameLayout(context) {
setVisibility(View.INVISIBLE)
setBackgroundDrawable(gradientDrawable)
val targetSize: Int = resources.getDimensionPixelSize(R.dimen.dismiss_circle_size)
targetSizeResId = R.dimen.dismiss_circle_size
val targetSize: Int = resources.getDimensionPixelSize(targetSizeResId)
addView(circle, LayoutParams(targetSize, targetSize,
Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL))
// start with circle offscreen so it's animated up
@@ -126,7 +128,7 @@ class DismissView(context: Context) : FrameLayout(context) {
layoutParams.height = resources.getDimensionPixelSize(
R.dimen.floating_dismiss_gradient_height)
val targetSize: Int = resources.getDimensionPixelSize(R.dimen.dismiss_circle_size)
val targetSize = resources.getDimensionPixelSize(targetSizeResId)
circle.layoutParams.width = targetSize
circle.layoutParams.height = targetSize
circle.requestLayout()
@@ -153,4 +155,4 @@ class DismissView(context: Context) : FrameLayout(context) {
setPadding(0, 0, 0, navInset.bottom +
resources.getDimensionPixelSize(R.dimen.floating_dismiss_bottom_margin))
}
}
}