mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-19 08:09:12 +01:00
Fix Z-ordering of preview media.
This commit is contained in:
@@ -9,7 +9,7 @@ import androidx.viewpager2.widget.ViewPager2;
|
||||
/**
|
||||
* Based on https://developer.android.com/training/animation/screen-slide#depth-page
|
||||
*/
|
||||
public final class DepthPageTransformer implements ViewPager.PageTransformer, ViewPager2.PageTransformer {
|
||||
public final class DepthPageTransformer implements ViewPager.PageTransformer {
|
||||
private static final float MIN_SCALE = 0.75f;
|
||||
|
||||
public void transformPage(@NonNull View view, float position) {
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.thoughtcrime.securesms.animation
|
||||
|
||||
import android.view.View
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
|
||||
private const val MIN_SCALE = 0.75f
|
||||
|
||||
/**
|
||||
* Lifted from https://developer.android.com/develop/ui/views/animations/screen-slide-2#depth-page
|
||||
*/
|
||||
@RequiresApi(21)
|
||||
class DepthPageTransformer2 : ViewPager2.PageTransformer {
|
||||
|
||||
override fun transformPage(view: View, position: Float) {
|
||||
view.apply {
|
||||
val pageWidth = width
|
||||
when {
|
||||
position < -1 -> alpha = 0f
|
||||
position <= 0 -> {
|
||||
alpha = 1f
|
||||
translationX = 0f
|
||||
translationZ = 0f
|
||||
scaleX = 1f
|
||||
scaleY = 1f
|
||||
}
|
||||
position <= 1 -> {
|
||||
alpha = 1 - position
|
||||
|
||||
translationX = pageWidth * -position
|
||||
translationZ = -1f
|
||||
|
||||
val scaleFactor = (MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position)))
|
||||
scaleX = scaleFactor
|
||||
scaleY = scaleFactor
|
||||
}
|
||||
else -> alpha = 0f
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user