Update gesture navigation intent tutorial steps handling

Updated gesture navigation to use either a comma-separated string or a string array for defining tutorial steps.

Fixes: 184002732
Test: manual
Change-Id: Ib2f8f78ccd57100d978db799b785fd9dffe9fb7f
This commit is contained in:
Schneider Victor-tulias 2021-06-23 12:38:52 -07:00
parent 835fab2305
commit f0c2158a5f
1 changed files with 21 additions and 8 deletions

View File

@ -18,6 +18,7 @@ package com.android.quickstep.interaction;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
@ -141,21 +142,33 @@ public class GestureSandboxActivity extends FragmentActivity {
private TutorialType[] getTutorialSteps(Bundle extras) {
TutorialType[] defaultSteps = new TutorialType[] {TutorialType.LEFT_EDGE_BACK_NAVIGATION};
mCurrentStep = 1;
mNumSteps = 1;
if (extras == null || !extras.containsKey(KEY_TUTORIAL_STEPS)) {
return defaultSteps;
}
String[] tutorialStepNames = extras.getStringArray(KEY_TUTORIAL_STEPS);
Object savedSteps = extras.get(KEY_TUTORIAL_STEPS);
int currentStep = extras.getInt(KEY_CURRENT_STEP, -1);
String[] savedStepsNames;
if (tutorialStepNames == null) {
if (savedSteps instanceof String) {
savedStepsNames = TextUtils.isEmpty((String) savedSteps)
? null : ((String) savedSteps).split(",");
} else if (savedSteps instanceof String[]) {
savedStepsNames = (String[]) savedSteps;
} else {
return defaultSteps;
}
TutorialType[] tutorialSteps = new TutorialType[tutorialStepNames.length];
for (int i = 0; i < tutorialStepNames.length; i++) {
tutorialSteps[i] = TutorialType.valueOf(tutorialStepNames[i]);
if (savedStepsNames == null) {
return defaultSteps;
}
TutorialType[] tutorialSteps = new TutorialType[savedStepsNames.length];
for (int i = 0; i < savedStepsNames.length; i++) {
tutorialSteps[i] = TutorialType.valueOf(savedStepsNames[i]);
}
mCurrentStep = Math.max(currentStep, 1);