mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Utilize logic from lottie to determine animation scale.
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
package org.thoughtcrime.securesms.util
|
||||
|
||||
import android.animation.ValueAnimator
|
||||
import android.content.ContentResolver
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
|
||||
fun ContentResolver.areSystemAnimationsDisabled(): Boolean {
|
||||
return if (Build.VERSION.SDK_INT >= 26) {
|
||||
!ValueAnimator.areAnimatorsEnabled()
|
||||
} else {
|
||||
val durationScale = Settings.Global.getFloat(this, Settings.Global.ANIMATOR_DURATION_SCALE, 1.0f)
|
||||
val transitionScale = Settings.Global.getFloat(this, Settings.Global.TRANSITION_ANIMATION_SCALE, 1.0f)
|
||||
|
||||
!(durationScale > 0f && transitionScale > 0f)
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -16,4 +17,10 @@ public final class ContextUtil {
|
||||
return Objects.requireNonNull(AppCompatResources.getDrawable(context, drawable));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation "borrowed" from com.airbnb.lottie.utils.Utils#getAnimationScale(android.content.Context)
|
||||
*/
|
||||
public static float getAnimationScale(Context context) {
|
||||
return Settings.Global.getFloat(context.getContentResolver(), Settings.Global.ANIMATOR_DURATION_SCALE, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user