1 // Copyright 2019 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package org.chromium.ui.gfx; 6 7 import android.annotation.TargetApi; 8 import android.os.Build; 9 import android.provider.Settings; 10 11 import org.chromium.base.ContextUtils; 12 import org.chromium.base.annotations.CalledByNative; 13 import org.chromium.base.annotations.JNINamespace; 14 15 /** 16 * Provides utility methods relating to system animation state on the current platform (i.e. Android 17 * in this case). See ui/gfx/animation/animation_android.cc. 18 */ 19 @JNINamespace("gfx") 20 public class Animation { 21 @CalledByNative 22 @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) prefersReducedMotion()23 private static boolean prefersReducedMotion() { 24 // We default to assuming that animations are enabled, to avoid impacting the experience for 25 // users that don't have ANIMATOR_DURATION_SCALE defined. 26 final float defaultScale = 1f; 27 float durationScale = 28 Settings.Global.getFloat(ContextUtils.getApplicationContext().getContentResolver(), 29 Settings.Global.ANIMATOR_DURATION_SCALE, defaultScale); 30 return durationScale == 0.0; 31 } 32 } 33