Skip to main content

Posts

Featured

Accessibility - Animations

Purpose In my previous blog post on pausable animated backgrounds , I mentioned hiding animations from people sensitive to movement. Well, we can actually detect if the user set that as a preference on their device. Our goal is to ensure user motion preferences are observed . Detection fun Context. prefersReducedMotionFlow () = callbackFlow { val uri = Settings.Global.getUriFor( Settings.Global. ANIMATOR_DURATION_SCALE ) fun isReduced () = Settings.Global.getFloat( contentResolver , Settings.Global. ANIMATOR_DURATION_SCALE , 1f ) == 0f val observer = object : ContentObserver( Handler(Looper.getMainLooper()) ) { override fun onChange (selfChange: Boolean) { trySend(isReduced()) } } contentResolver .registerContentObserver( uri, false , observer ) send(isReduced()) awaitClose { contentResolver .unregisterContentObserver(observer) } } Remember...

Latest Posts

Room3 Alpha - Example (compatible with Room 2)

Animated Background with Pause

MVI / MVVM - Examples