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

Commit 49e5d822 authored by Miranda Kephart's avatar Miranda Kephart Committed by Android (Google) Code Review
Browse files

Merge "Pass in fling velocity for gesture progress" into ub-launcher3-qt-dev

parents 32ba3c11 b063775e
Loading
Loading
Loading
Loading
+37 −22
Original line number Diff line number Diff line
@@ -221,32 +221,36 @@ public class AssistantTouchConsumer extends DelegateInputConsumer
    private void updateAssistantProgress() {
        if (!mLaunchedAssistant) {
            mLastProgress = Math.min(mDistance * 1f / mDistThreshold, 1) * mTimeFraction;
            updateAssistant(SWIPE);
            try {
                if (mDistance >= mDistThreshold && mTimeFraction >= 1) {
                    mSysUiProxy.onAssistantGestureCompletion(0);
                    startAssistantInternal(SWIPE);

                    Bundle args = new Bundle();
                    args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
                    mSysUiProxy.startAssistant(args);
                    mLaunchedAssistant = true;
                } else {
                    mSysUiProxy.onAssistantProgress(mLastProgress);
                }
            } catch (RemoteException e) {
                Log.w(TAG, "Failed to send SysUI start/send assistant progress: " + mLastProgress,
                    e);
            }
        }
    }

    private void updateAssistant(int gestureType) {
        try {
            mSysUiProxy.onAssistantProgress(mLastProgress);
            if (gestureType == FLING || (mDistance >= mDistThreshold && mTimeFraction >= 1)) {
    private void startAssistantInternal(int gestureType) {
        UserEventDispatcher.newInstance(mContext)
            .logActionOnContainer(gestureType, mDirection, NAVBAR);
                Bundle args = new Bundle();
                args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);

                BaseDraggingActivity launcherActivity = mActivityControlHelper.getCreatedActivity();
        BaseDraggingActivity launcherActivity = mActivityControlHelper
            .getCreatedActivity();
        if (launcherActivity != null) {
            launcherActivity.getRootView().performHapticFeedback(
                13, // HapticFeedbackConstants.GESTURE_END
                HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING);
        }

                mSysUiProxy.startAssistant(args);
                mLaunchedAssistant = true;
            }
        } catch (RemoteException e) {
            Log.w(TAG, "Failed to send SysUI start/send assistant progress: " + mLastProgress, e);
        }
    }

    public static boolean withinTouchRegion(Context context, MotionEvent ev) {
@@ -271,7 +275,18 @@ public class AssistantTouchConsumer extends DelegateInputConsumer
    public void onDragEnd(float velocity, boolean fling) {
        if (fling && !mLaunchedAssistant) {
            mLastProgress = 1;
            updateAssistant(FLING);
            try {
                mSysUiProxy.onAssistantGestureCompletion(velocity);
                startAssistantInternal(FLING);

                Bundle args = new Bundle();
                args.putInt(INVOCATION_TYPE_KEY, INVOCATION_TYPE_GESTURE);
                mSysUiProxy.startAssistant(args);
                mLaunchedAssistant = true;
            } catch (RemoteException e) {
                Log.w(TAG, "Failed to send SysUI start/send assistant progress: " + mLastProgress,
                    e);
            }
        }
    }
}