Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 61766a73 authored by Bill Lin's avatar Bill Lin
Browse files

Settings Switch animation jank while enabled One-handed mode

Switch is CompoundButton(View) and animating position when user
tap on it. Unfortunatly when set overlay pakcage enabled, Switch
componet will invoke onLayout() and cancelPositionAnimator(),
that result the UX feel jank.

We add a delay(250ms) before execute runtime resouce overlay
to ensure the widget animation finished first.

Test: Manual Settings > Gesture > One Handed Mode > Tap Switch
Bug: 190584055
Change-Id: Ia42fdf3ed699afd51c154cb0a53581ef67959c71
parent e76529cb
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ public class OneHandedController implements RemoteCallable<OneHandedController>
            "persist.debug.one_handed_offset_percentage";
    private static final String ONE_HANDED_MODE_GESTURAL_OVERLAY =
            "com.android.internal.systemui.onehanded.gestural";
    private static final int OVERLAY_ENABLED_DELAY_MS = 250;

    static final String SUPPORT_ONE_HANDED_MODE = "ro.support_one_handed_mode";

@@ -493,9 +494,11 @@ public class OneHandedController implements RemoteCallable<OneHandedController>
        setOneHandedEnabled(enabled);

        // Also checks swipe to notification settings since they all need gesture overlay.
        setEnabledGesturalOverlay(
        // Enabled overlay package may affect the current animation(e.g:Settings switch),
        // so we delay 250ms to enabled overlay after switch animation finish
        mMainExecutor.executeDelayed(() -> setEnabledGesturalOverlay(
                enabled || mOneHandedSettingsUtil.getSettingsSwipeToNotificationEnabled(
                        mContext.getContentResolver(), mUserId));
                        mContext.getContentResolver(), mUserId)), OVERLAY_ENABLED_DELAY_MS);
    }

    @VisibleForTesting