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

Commit 8e26fe9a authored by Tony Wickham's avatar Tony Wickham
Browse files

Add haptic when entering quick scrub

Bug: 77905939
Change-Id: Iaf16c0de9bc82ed903151c6782781a1487bfe922
parent 71ba4486
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -138,17 +138,26 @@ public class QuickScrubController implements OnAlarmListener {
    }

    public void snapToNextTaskIfAvailable() {
        if (!mStartedFromHome && mInQuickScrub && mRecentsView.getChildCount() > 0) {
            mRecentsView.snapToPage(mRecentsView.getNextPage() + 1, QUICK_SCRUB_START_DURATION);
        if (mInQuickScrub && mRecentsView.getChildCount() > 0) {
            int pageToGoTo = mStartedFromHome ? 0 : mRecentsView.getNextPage() + 1;
            goToPageWithHaptic(pageToGoTo, QUICK_SCRUB_START_DURATION, true /* forceHaptic */);
        }
    }

    private void goToPageWithHaptic(int pageToGoTo) {
        goToPageWithHaptic(pageToGoTo, -1 /* overrideDuration */, false /* forceHaptic */);
    }

    private void goToPageWithHaptic(int pageToGoTo, int overrideDuration, boolean forceHaptic) {
        pageToGoTo = Utilities.boundToRange(pageToGoTo, 0, mRecentsView.getPageCount() - 1);
        if (pageToGoTo != mRecentsView.getNextPage()) {
            int duration = Math.abs(pageToGoTo - mRecentsView.getNextPage())
        boolean snappingToPage = pageToGoTo != mRecentsView.getNextPage();
        if (snappingToPage) {
            int duration = overrideDuration > -1 ? overrideDuration
                    : Math.abs(pageToGoTo - mRecentsView.getNextPage())
                            * QUICKSCRUB_SNAP_DURATION_PER_PAGE;
            mRecentsView.snapToPage(pageToGoTo, duration);
        }
        if (snappingToPage || forceHaptic) {
            mRecentsView.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY,
                    HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
        }