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

Commit e992fab1 authored by Andy Wickham's avatar Andy Wickham
Browse files

Adds ripple effect for successful Back gestures in tutorial.

Emanates from where the gesture was started.

Demo: https://drive.google.com/open?id=1oaXOSUiZP6Hi7J6W4H2NIFVVu0tQfKWm
Bug: 148542211
Change-Id: I38874b8b731864cbfdf963a5e44a59c8c3d30c51
parent 64a91132
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -18,6 +18,12 @@
    android:layout_height="match_parent"
    android:background="@color/gesture_tutorial_background_color">

    <View
        android:id="@+id/gesture_tutorial_ripple_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/gesture_tutorial_ripple"/>

    <ImageView
        android:id="@+id/gesture_tutorial_fragment_hand_coaching"
        android:layout_width="match_parent"
+6 −2
Original line number Diff line number Diff line
@@ -113,8 +113,10 @@ final class BackGestureTutorialController extends TutorialController {
    private void handleAttemptFromRight(BackGestureResult result) {
        switch (result) {
            case BACK_COMPLETED_FROM_RIGHT:
                hideFeedback();
                hideHandCoachingAnimation();
                mTutorialFragment.changeController(LEFT_EDGE_BACK_NAVIGATION);
                showRippleEffect(
                        () -> mTutorialFragment.changeController(LEFT_EDGE_BACK_NAVIGATION));
                break;
            case BACK_CANCELLED_FROM_RIGHT:
                showFeedback(R.string.back_gesture_feedback_cancelled_right_edge);
@@ -133,8 +135,10 @@ final class BackGestureTutorialController extends TutorialController {
    private void handleAttemptFromLeft(BackGestureResult result) {
        switch (result) {
            case BACK_COMPLETED_FROM_LEFT:
                hideFeedback();
                hideHandCoachingAnimation();
                mTutorialFragment.changeController(BACK_NAVIGATION_COMPLETE);
                showRippleEffect(
                        () -> mTutorialFragment.changeController(BACK_NAVIGATION_COMPLETE));
                break;
            case BACK_CANCELLED_FROM_LEFT:
                showFeedback(R.string.back_gesture_feedback_cancelled_left_edge);
+11 −0
Original line number Diff line number Diff line
@@ -15,6 +15,9 @@
 */
package com.android.quickstep.interaction;

import android.view.MotionEvent;
import android.view.View;

import com.android.launcher3.R;
import com.android.quickstep.interaction.TutorialController.TutorialType;

@@ -34,4 +37,12 @@ public class BackGestureTutorialFragment extends TutorialFragment {
    Class<? extends TutorialController> getControllerClass() {
        return BackGestureTutorialController.class;
    }

    @Override
    public boolean onTouch(View view, MotionEvent motionEvent) {
        if (motionEvent.getAction() == MotionEvent.ACTION_DOWN && mTutorialController != null) {
            mTutorialController.setRippleHotspot(motionEvent.getX(), motionEvent.getY());
        }
        return super.onTouch(view, motionEvent);
    }
}
+21 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
 */
package com.android.quickstep.interaction;

import android.graphics.drawable.RippleDrawable;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
@@ -34,6 +35,7 @@ abstract class TutorialController implements BackGestureAttemptCallback,

    private static final int FEEDBACK_VISIBLE_MS = 3000;
    private static final int FEEDBACK_ANIMATION_MS = 500;
    private static final int RIPPLE_VISIBLE_MS = 300;

    final TutorialFragment mTutorialFragment;
    TutorialType mTutorialType;
@@ -42,6 +44,8 @@ abstract class TutorialController implements BackGestureAttemptCallback,
    final TextView mTitleTextView;
    final TextView mSubtitleTextView;
    final TextView mFeedbackView;
    final View mRippleView;
    final RippleDrawable mRippleDrawable;
    final TutorialHandAnimation mHandCoachingAnimation;
    final ImageView mHandCoachingView;
    final Button mActionTextButton;
@@ -58,6 +62,8 @@ abstract class TutorialController implements BackGestureAttemptCallback,
        mTitleTextView = rootView.findViewById(R.id.gesture_tutorial_fragment_title_view);
        mSubtitleTextView = rootView.findViewById(R.id.gesture_tutorial_fragment_subtitle_view);
        mFeedbackView = rootView.findViewById(R.id.gesture_tutorial_fragment_feedback_view);
        mRippleView = rootView.findViewById(R.id.gesture_tutorial_ripple_view);
        mRippleDrawable = (RippleDrawable) mRippleView.getBackground();
        mHandCoachingAnimation = tutorialFragment.getHandAnimation();
        mHandCoachingView = rootView.findViewById(R.id.gesture_tutorial_fragment_hand_coaching);
        mHandCoachingView.bringToFront();
@@ -109,6 +115,21 @@ abstract class TutorialController implements BackGestureAttemptCallback,
        mFeedbackView.setAlpha(0);
    }

    void setRippleHotspot(float x, float y) {
        mRippleDrawable.setHotspot(x, y);
    }

    void showRippleEffect(@Nullable Runnable onCompleteRunnable) {
        mRippleDrawable.setState(
                new int[] {android.R.attr.state_pressed, android.R.attr.state_enabled});
        mRippleView.postDelayed(() -> {
            mRippleDrawable.setState(new int[] {});
            if (onCompleteRunnable != null) {
                onCompleteRunnable.run();
            }
        }, RIPPLE_VISIBLE_MS);
    }

    void onActionButtonClicked(View button) {}

    void onActionTextButtonClicked(View button) {}
+6 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<ripple android:color="@color/gesture_tutorial_ripple_color"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/mask"
        android:drawable="@color/gesture_tutorial_background_color" />
</ripple>
 No newline at end of file
Loading