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

Commit 8398c126 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update vibrations in the All set page to match the SUW welcome page." into tm-qpr-dev

parents 261dec20 2edbe235
Loading
Loading
Loading
Loading
+42 −37
Original line number Original line Diff line number Diff line
@@ -149,19 +149,35 @@ public class AllSetActivity extends Activity {
    }
    }


    private void startBackgroundAnimation() {
    private void startBackgroundAnimation() {
        if (Utilities.ATLEAST_S && mVibrator != null && mVibrator.areAllPrimitivesSupported(
        if (!Utilities.ATLEAST_S || mVibrator == null) {
                VibrationEffect.Composition.PRIMITIVE_THUD)) {
            return;
        }
        boolean supportsThud = mVibrator.areAllPrimitivesSupported(
                VibrationEffect.Composition.PRIMITIVE_THUD);

        if (!supportsThud && !mVibrator.areAllPrimitivesSupported(
                VibrationEffect.Composition.PRIMITIVE_TICK)) {
            return;
        }
        if (mBackgroundAnimatorListener == null) {
        if (mBackgroundAnimatorListener == null) {
            VibrationEffect vibrationEffect = VibrationEffect.startComposition()
                    .addPrimitive(supportsThud
                                    ? VibrationEffect.Composition.PRIMITIVE_THUD
                                    : VibrationEffect.Composition.PRIMITIVE_TICK,
                            /* scale= */ 1.0f,
                            /* delay= */ 50)
                    .compose();

            mBackgroundAnimatorListener =
            mBackgroundAnimatorListener =
                    new Animator.AnimatorListener() {
                    new Animator.AnimatorListener() {
                        @Override
                        @Override
                        public void onAnimationStart(Animator animation) {
                        public void onAnimationStart(Animator animation) {
                                runOnUiHelperThread(() -> mVibrator.vibrate(getVibrationEffect()));
                            runOnUiHelperThread(() -> mVibrator.vibrate(vibrationEffect));
                        }
                        }


                        @Override
                        @Override
                        public void onAnimationRepeat(Animator animation) {
                        public void onAnimationRepeat(Animator animation) {
                                runOnUiHelperThread(() -> mVibrator.vibrate(getVibrationEffect()));
                            runOnUiHelperThread(() -> mVibrator.vibrate(vibrationEffect));
                        }
                        }


                        @Override
                        @Override
@@ -176,20 +192,9 @@ public class AllSetActivity extends Activity {
                    };
                    };
        }
        }
        mAnimatedBackground.addAnimatorListener(mBackgroundAnimatorListener);
        mAnimatedBackground.addAnimatorListener(mBackgroundAnimatorListener);
        }
        mAnimatedBackground.playAnimation();
        mAnimatedBackground.playAnimation();
    }
    }


    /**
     * Sets up the vibration effect for the next round of animation. The parameters vary between
     * different illustrations.
     */
    private VibrationEffect getVibrationEffect() {
        return VibrationEffect.startComposition()
                .addPrimitive(VibrationEffect.Composition.PRIMITIVE_THUD, 1.0f, 50)
                .compose();
    }

    @Override
    @Override
    protected void onResume() {
    protected void onResume() {
        super.onResume();
        super.onResume();