Apply system animation scale to parts of Tachiyomi that don't respect it by default (#5794)
* Add initial code for scaling animations, apply scale to reader nav overlay * Rename extension function, apply system animator scale to ActionToolbar * Apply system animator scale to expanding manga cover animation * Apply system animator scale to image crossfade (also disables animated covers when browsing) * Add documentation, make MotionScene Transition comment a bit more clear * Disable animated covers in MangaInfoHeaderAdapter if animator duration scale is 0 * Disable animated covers in Library if animator duration scale is 0 * Convert loadAny listener to extension function
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package eu.kanade.tachiyomi.util.system
|
||||
|
||||
import android.content.Context
|
||||
import android.view.animation.Animation
|
||||
import androidx.constraintlayout.motion.widget.MotionScene.Transition
|
||||
|
||||
/** Scale the duration of this [Animation] by [Context.animatorDurationScale] */
|
||||
fun Animation.applySystemAnimatorScale(context: Context) {
|
||||
this.duration = (this.duration * context.animatorDurationScale).toLong()
|
||||
}
|
||||
|
||||
/** Scale the duration of this [Transition] by [Context.animatorDurationScale] */
|
||||
fun Transition.applySystemAnimatorScale(context: Context) {
|
||||
// End layout of cover expanding animation tends to break when the transition is less than ~25ms
|
||||
this.duration = (this.duration * context.animatorDurationScale).toInt().coerceAtLeast(25)
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import android.net.ConnectivityManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.PowerManager
|
||||
import android.provider.Settings
|
||||
import android.util.TypedValue
|
||||
import android.view.Display
|
||||
import android.view.View
|
||||
@@ -203,6 +204,12 @@ val Context.displayCompat: Display?
|
||||
getSystemService<WindowManager>()?.defaultDisplay
|
||||
}
|
||||
|
||||
/** Gets the duration multiplier for general animations on the device
|
||||
* @see Settings.Global.ANIMATOR_DURATION_SCALE
|
||||
*/
|
||||
val Context.animatorDurationScale: Float
|
||||
get() = Settings.Global.getFloat(this.contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1f)
|
||||
|
||||
/**
|
||||
* Convenience method to acquire a partial wake lock.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user