Add sandbox mode to gesture tutorial settings.

Test: manual

Added a Sandbox mode tutorial fragment and controller. This fragment allows the user to try all the gesture commands and receive feedback, whether the gesture was successful or not.

Preview: https://drive.google.com/file/d/1Qmn71ZHMOrv2XjUngb6S4W5jOaBIvF1_/view?usp=sharing

Change-Id: I7d28ce25daa38fa6d05b18d43d02b77c1fc8a264
This commit is contained in:
Schneider Victor-tulias 2020-09-24 13:27:30 -07:00
parent 6873cb82f3
commit 2ec0ade64a
6 changed files with 175 additions and 2 deletions

View File

@ -149,6 +149,21 @@
<!-- Feedback shown during interactive parts of Assistant gesture tutorial when the gesture doesn't go far enough. [CHAR LIMIT=100] --> <!-- Feedback shown during interactive parts of Assistant gesture tutorial when the gesture doesn't go far enough. [CHAR LIMIT=100] -->
<string name="assistant_gesture_feedback_swipe_not_long_enough" translatable="false">Try swiping further</string> <string name="assistant_gesture_feedback_swipe_not_long_enough" translatable="false">Try swiping further</string>
<!-- Title shown in sandbox mode part of gesture tutorial. [CHAR LIMIT=30] -->
<string name="sandbox_mode_title" translatable="false">Sandbox Mode</string>
<!-- Subtitle shown in sandbox mode part of gesture tutorial. [CHAR LIMIT=60] -->
<string name="sandbox_mode_subtitle" translatable="false">Try any navigation gesture</string>
<!-- Feedback shown in sandbox mode when the back gesture is successfully issued. [CHAR LIMIT=60] -->
<string name="sandbox_mode_back_gesture_feedback_successful" translatable="false">Back gesture successful</string>
<!-- Feedback shown in sandbox mode when the assistant gesture is a successfully issued. [CHAR LIMIT=60] -->
<string name="sandbox_mode_assistant_gesture_feedback_successful" translatable="false">Assistant gesture successful</string>
<!-- Feedback shown in sandbox mode when the home gesture is a successfully issued. [CHAR LIMIT=60] -->
<string name="sandbox_mode_home_gesture_feedback_successful" translatable="false">Home gesture successful</string>
<!-- Feedback shown in sandbox mode when the overview gesture is a successfully issued. [CHAR LIMIT=60] -->
<string name="sandbox_mode_overview_gesture_feedback_successful" translatable="false">Overview gesture successful</string>
<!-- Feedback shown in sandbox mode when the back gesture swipe is too far from the edge. [CHAR LIMIT=60] -->
<string name="sandbox_mode_back_gesture_feedback_swipe_too_far_from_edge" translatable="false">Make sure you swipe from the left/right edge of the screen</string>
<!-- Title shown on the confirmation screen after successful gesture. [CHAR LIMIT=30] --> <!-- Title shown on the confirmation screen after successful gesture. [CHAR LIMIT=30] -->
<string name="gesture_tutorial_confirm_title" translatable="false">All set</string> <string name="gesture_tutorial_confirm_title" translatable="false">All set</string>
<!-- Button text shown on a button on the confirm screen to leave the tutorial. [CHAR LIMIT=14] --> <!-- Button text shown on a button on the confirm screen to leave the tutorial. [CHAR LIMIT=14] -->

View File

@ -0,0 +1,102 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.quickstep.interaction;
import android.graphics.PointF;
import android.view.View;
import androidx.annotation.Nullable;
import com.android.launcher3.R;
import com.android.quickstep.interaction.EdgeBackGestureHandler.BackGestureResult;
import com.android.quickstep.interaction.NavBarGestureHandler.NavBarGestureResult;
/** A {@link TutorialController} for the Sandbox Mode. */
public class SandboxModeTutorialController extends SwipeUpGestureTutorialController {
SandboxModeTutorialController(SandboxModeTutorialFragment fragment, TutorialType tutorialType) {
super(fragment, tutorialType);
}
@Nullable
@Override
Integer getTitleStringId() {
return R.string.sandbox_mode_title;
}
@Nullable
@Override
Integer getSubtitleStringId() {
return R.string.sandbox_mode_subtitle;
}
@Nullable
@Override
Integer getActionButtonStringId() {
return R.string.gesture_tutorial_action_button_label_done;
}
@Override
void onActionButtonClicked(View button) {
mTutorialFragment.closeTutorial();
}
@Override
public void onBackGestureAttempted(BackGestureResult result) {
switch (result) {
case BACK_COMPLETED_FROM_LEFT:
case BACK_COMPLETED_FROM_RIGHT:
showRippleEffect(null);
showFeedback(R.string.sandbox_mode_back_gesture_feedback_successful);
break;
case BACK_CANCELLED_FROM_RIGHT:
showFeedback(R.string.back_gesture_feedback_cancelled_right_edge);
break;
case BACK_CANCELLED_FROM_LEFT:
showFeedback(R.string.back_gesture_feedback_cancelled_left_edge);
break;
case BACK_NOT_STARTED_TOO_FAR_FROM_EDGE:
showFeedback(R.string.sandbox_mode_back_gesture_feedback_swipe_too_far_from_edge);
break;
}
}
@Override
public void onNavBarGestureAttempted(NavBarGestureResult result, PointF finalVelocity) {
switch (result) {
case ASSISTANT_COMPLETED:
showRippleEffect(null);
showFeedback(R.string.sandbox_mode_assistant_gesture_feedback_successful);
break;
case HOME_GESTURE_COMPLETED:
animateFakeTaskViewHome(finalVelocity, () -> {
showFeedback(R.string.sandbox_mode_home_gesture_feedback_successful);
});
break;
case OVERVIEW_GESTURE_COMPLETED:
fadeOutFakeTaskView(true, () -> {
showFeedback(R.string.sandbox_mode_overview_gesture_feedback_successful);
});
break;
case HOME_OR_OVERVIEW_NOT_STARTED_WRONG_SWIPE_DIRECTION:
case HOME_OR_OVERVIEW_CANCELLED:
case HOME_NOT_STARTED_TOO_FAR_FROM_EDGE:
case OVERVIEW_NOT_STARTED_TOO_FAR_FROM_EDGE:
showFeedback(R.string.home_gesture_feedback_swipe_too_far_from_edge);
break;
}
}
}

View File

@ -0,0 +1,43 @@
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.quickstep.interaction;
import android.view.MotionEvent;
import android.view.View;
import com.android.quickstep.interaction.TutorialController.TutorialType;
/** Shows the general navigation gesture sandbox environment. */
public class SandboxModeTutorialFragment extends TutorialFragment {
@Override
TutorialController createController(TutorialType type) {
return new SandboxModeTutorialController(this, type);
}
@Override
Class<? extends TutorialController> getControllerClass() {
return SandboxModeTutorialController.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);
}
}

View File

@ -213,7 +213,8 @@ abstract class TutorialController implements BackGestureAttemptCallback,
return mTutorialType == TutorialType.BACK_NAVIGATION_COMPLETE return mTutorialType == TutorialType.BACK_NAVIGATION_COMPLETE
|| mTutorialType == TutorialType.HOME_NAVIGATION_COMPLETE || mTutorialType == TutorialType.HOME_NAVIGATION_COMPLETE
|| mTutorialType == TutorialType.OVERVIEW_NAVIGATION_COMPLETE || mTutorialType == TutorialType.OVERVIEW_NAVIGATION_COMPLETE
|| mTutorialType == TutorialType.ASSISTANT_COMPLETE; || mTutorialType == TutorialType.ASSISTANT_COMPLETE
|| mTutorialType == TutorialType.SANDBOX_MODE;
} }
/** Denotes the type of the tutorial. */ /** Denotes the type of the tutorial. */
@ -226,6 +227,7 @@ abstract class TutorialController implements BackGestureAttemptCallback,
OVERVIEW_NAVIGATION, OVERVIEW_NAVIGATION,
OVERVIEW_NAVIGATION_COMPLETE, OVERVIEW_NAVIGATION_COMPLETE,
ASSISTANT, ASSISTANT,
ASSISTANT_COMPLETE ASSISTANT_COMPLETE,
SANDBOX_MODE
} }
} }

View File

@ -76,6 +76,8 @@ abstract class TutorialFragment extends Fragment implements OnTouchListener {
case ASSISTANT: case ASSISTANT:
case ASSISTANT_COMPLETE: case ASSISTANT_COMPLETE:
return new AssistantGestureTutorialFragment(); return new AssistantGestureTutorialFragment();
case SANDBOX_MODE:
return new SandboxModeTutorialFragment();
default: default:
Log.e(LOG_TAG, "Failed to find an appropriate fragment for " + tutorialType.name()); Log.e(LOG_TAG, "Failed to find an appropriate fragment for " + tutorialType.name());
} }

View File

@ -306,6 +306,15 @@ public class DeveloperOptionsFragment extends PreferenceFragmentCompat {
return true; return true;
}); });
sandboxCategory.addPreference(launchAssistantTutorialPreference); sandboxCategory.addPreference(launchAssistantTutorialPreference);
Preference launchSandboxModeTutorialPreference = new Preference(context);
launchSandboxModeTutorialPreference.setKey("launchSandboxMode");
launchSandboxModeTutorialPreference.setTitle("Launch Sandbox Mode");
launchSandboxModeTutorialPreference.setSummary("Practice navigation gestures");
launchSandboxModeTutorialPreference.setOnPreferenceClickListener(preference -> {
startActivity(launchSandboxIntent.putExtra("tutorial_type", "SANDBOX_MODE"));
return true;
});
sandboxCategory.addPreference(launchSandboxModeTutorialPreference);
} }
private String toName(String action) { private String toName(String action) {