diff options
author | LuK1337 <priv.luk@gmail.com> | 2023-02-18 09:38:20 +0100 |
---|---|---|
committer | Sebastiano Barezzi <seba@sebaubuntu.dev> | 2023-03-04 17:39:07 +0100 |
commit | 0fe6fad97311b4962ac4c8683864a8a21f10daf8 (patch) | |
tree | f5d458fe4134cb470f56dfb8ca79c947a9407a85 | |
parent | 6d39d8a48b73a06938dc80c983640b8d5c594d0c (diff) |
Aperture: Animate SecondaryTopBarButton's verticalBias on rotation
This makes sure that button icons are properly aligned for 90/180/270
degrees rotations.
Change-Id: Ifbd5e36b8836506df98a90b48e0709721519d370
-rw-r--r-- | app/src/main/java/org/lineageos/aperture/CameraActivity.kt | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt index c20f6e5..c1eae05 100644 --- a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt +++ b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt @@ -65,6 +65,7 @@ import androidx.core.view.children import androidx.core.view.doOnLayout import androidx.core.view.isInvisible import androidx.core.view.isVisible +import androidx.core.view.updateLayoutParams import androidx.lifecycle.MutableLiveData import androidx.preference.PreferenceManager import coil.decode.VideoFrameDecoder @@ -1861,7 +1862,24 @@ open class CameraActivity : AppCompatActivity() { secondaryTopBarLayout.getChildAt(0) )?.let { layout -> for (child in layout.children) { - Button::class.safeCast(child)?.smoothRotate(compensationValue) + Button::class.safeCast(child)?.let { + it.smoothRotate(compensationValue) + ValueAnimator.ofFloat( + (it.layoutParams as ConstraintLayout.LayoutParams).verticalBias, + when (screenRotation) { + Rotation.ROTATION_0 -> 0.0f + Rotation.ROTATION_180 -> 1.0f + Rotation.ROTATION_90, + Rotation.ROTATION_270 -> 0.5f + } + ).apply { + addUpdateListener { anim -> + it.updateLayoutParams<ConstraintLayout.LayoutParams> { + verticalBias = anim.animatedValue as Float + } + } + }.start() + } } } |