Update gesture navigation tutorial with new specs for foldable devices.

- Added new layout files for mock screens.
- Added new mock hotseat

Bug: 198434693
Test: launched and completed tutorial on regular phone and foldable device.
Change-Id: I1ad04f9e8e3a012528d6fd8fbaa0366687c65d06
This commit is contained in:
Schneider Victor-tulias
2021-09-30 13:56:46 -07:00
parent 22762d91cd
commit 97b85ee6cb
18 changed files with 1296 additions and 150 deletions

View File

@@ -49,12 +49,16 @@ final class BackGestureTutorialController extends TutorialController {
@LayoutRes
int getMockAppTaskCurrentPageLayoutResId() {
return R.layout.gesture_tutorial_mock_conversation;
return mTutorialFragment.isLargeScreen()
? R.layout.gesture_tutorial_foldable_mock_conversation
: R.layout.gesture_tutorial_mock_conversation;
}
@LayoutRes
int getMockAppTaskPreviousPageLayoutResId() {
return R.layout.gesture_tutorial_mock_conversation_list;
return mTutorialFragment.isLargeScreen()
? R.layout.gesture_tutorial_foldable_mock_conversation_list
: R.layout.gesture_tutorial_mock_conversation_list;
}
@Override

View File

@@ -43,7 +43,9 @@ final class HomeGestureTutorialController extends SwipeUpGestureTutorialControll
@Override
protected int getMockAppTaskLayoutResId() {
return R.layout.gesture_tutorial_mock_webpage;
return mTutorialFragment.isLargeScreen()
? R.layout.gesture_tutorial_foldable_mock_webpage
: R.layout.gesture_tutorial_mock_webpage;
}
@Override

View File

@@ -53,7 +53,9 @@ final class OverviewGestureTutorialController extends SwipeUpGestureTutorialCont
@Override
protected int getMockAppTaskLayoutResId() {
return R.layout.gesture_tutorial_mock_conversation_list;
return mTutorialFragment.isLargeScreen()
? R.layout.gesture_tutorial_foldable_mock_conversation_list
: R.layout.gesture_tutorial_mock_conversation_list;
}
@Override

View File

@@ -57,17 +57,6 @@ public class OverviewGestureTutorialFragment extends TutorialFragment {
}
});
Animator swipeAnimator =
controller.createFingerDotOverviewSwipeAnimator(fingerDotStartTranslationY);
swipeAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
mFakePreviousTaskView.setVisibility(View.VISIBLE);
controller.onMotionPaused(true /*arbitrary value*/);
}
});
AnimatorSet fingerDotDisappearanceAnimator =
controller.createFingerDotDisappearanceAnimatorSet();
fingerDotDisappearanceAnimator.addListener(new AnimatorListenerAdapter() {
@@ -89,7 +78,7 @@ public class OverviewGestureTutorialFragment extends TutorialFragment {
ArrayList<Animator> animators = new ArrayList<>();
animators.add(fingerDotAppearanceAnimator);
animators.add(swipeAnimator);
animators.add(controller.createFingerDotOverviewSwipeAnimator(fingerDotStartTranslationY));
animators.add(controller.createAnimationPause());
animators.add(fingerDotDisappearanceAnimator);
animators.add(animationPause);

View File

@@ -320,8 +320,8 @@ abstract class SwipeUpGestureTutorialController extends TutorialController {
@Override
public RectF getWindowTargetRect() {
int fakeHomeIconSizePx = Utilities.dpToPx(60);
int fakeHomeIconLeft = mFakeHotseatView.getLeft();
int fakeHomeIconTop = mFakeHotseatView.getTop();
int fakeHomeIconLeft = getHotseatIconLeft();
int fakeHomeIconTop = getHotseatIconTop();
return new RectF(fakeHomeIconLeft, fakeHomeIconTop,
fakeHomeIconLeft + fakeHomeIconSizePx,
fakeHomeIconTop + fakeHomeIconSizePx);
@@ -374,8 +374,19 @@ abstract class SwipeUpGestureTutorialController extends TutorialController {
}
protected Animator createFingerDotOverviewSwipeAnimator(float fingerDotStartTranslationY) {
return createFingerDotSwipeUpAnimator(fingerDotStartTranslationY)
Animator overviewSwipeAnimator = createFingerDotSwipeUpAnimator(fingerDotStartTranslationY)
.setDuration(OVERVIEW_SWIPE_ANIMATION_DURATION_MILLIS);
overviewSwipeAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
mFakePreviousTaskView.setVisibility(View.VISIBLE);
onMotionPaused(true /*arbitrary value*/);
}
});
return overviewSwipeAnimator;
}

View File

@@ -85,7 +85,8 @@ abstract class TutorialController implements BackGestureAttemptCallback,
final TextView mFeedbackTitleView;
final ImageView mEdgeGestureVideoView;
final RelativeLayout mFakeLauncherView;
final ImageView mFakeHotseatView;
final FrameLayout mFakeHotseatView;
@Nullable View mHotseatIconView;
final ClipIconView mFakeIconView;
final FrameLayout mFakeTaskView;
final AnimatedTaskView mFakePreviousTaskView;
@@ -164,13 +165,25 @@ abstract class TutorialController implements BackGestureAttemptCallback,
}
}
public int getHotseatIconTop() {
return mHotseatIconView == null
? 0 : mFakeHotseatView.getTop() + mHotseatIconView.getTop();
}
public int getHotseatIconLeft() {
return mHotseatIconView == null
? 0 : mFakeHotseatView.getLeft() + mHotseatIconView.getLeft();
}
void setTutorialType(TutorialType tutorialType) {
mTutorialType = tutorialType;
}
@DrawableRes
@LayoutRes
protected int getMockHotseatResId() {
return R.drawable.default_sandbox_mock_launcher;
return mTutorialFragment.isLargeScreen()
? R.layout.gesture_tutorial_foldable_mock_hotseat
: R.layout.gesture_tutorial_mock_hotseat;
}
@LayoutRes
@@ -384,6 +397,7 @@ abstract class TutorialController implements BackGestureAttemptCallback,
hideActionButton();
updateSubtext();
updateDrawables();
updateLayout();
mGestureCompleted = false;
if (mFakeHotseatView != null) {
@@ -416,10 +430,14 @@ abstract class TutorialController implements BackGestureAttemptCallback,
}
void updateFakeAppTaskViewLayout(@LayoutRes int mockAppTaskLayoutResId) {
mFakeTaskView.removeAllViews();
if (mockAppTaskLayoutResId != NO_ID) {
mFakeTaskView.addView(
inflate(mContext, mockAppTaskLayoutResId, null),
updateFakeViewLayout(mFakeTaskView, mockAppTaskLayoutResId);
}
void updateFakeViewLayout(ViewGroup view, @LayoutRes int mockLayoutResId) {
view.removeAllViews();
if (mockLayoutResId != NO_ID) {
view.addView(
inflate(mContext, mockLayoutResId, null),
new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
@@ -438,9 +456,9 @@ abstract class TutorialController implements BackGestureAttemptCallback,
mTutorialFragment.updateFeedbackAnimation();
mFakeLauncherView.setBackgroundColor(
mContext.getColor(R.color.gesture_tutorial_fake_wallpaper_color));
mFakeHotseatView.setImageDrawable(AppCompatResources.getDrawable(
mContext, getMockHotseatResId()));
updateFakeAppTaskViewLayout(getMockAppTaskLayoutResId());
updateFakeViewLayout(mFakeHotseatView, getMockHotseatResId());
mHotseatIconView = mFakeHotseatView.findViewById(R.id.hotseat_icon_1);
updateFakeViewLayout(mFakeTaskView, getMockAppTaskLayoutResId());
mFakeTaskView.animate().alpha(1).setListener(
AnimatorListeners.forSuccessCallback(() -> mFakeTaskView.animate().cancel()));
mFakePreviousTaskView.setFakeTaskViewFillColor(mContext.getResources().getColor(
@@ -450,6 +468,21 @@ abstract class TutorialController implements BackGestureAttemptCallback,
}
}
private void updateLayout() {
if (mContext != null) {
RelativeLayout.LayoutParams feedbackLayoutParams =
(RelativeLayout.LayoutParams) mFeedbackView.getLayoutParams();
feedbackLayoutParams.setMarginStart(mContext.getResources().getDimensionPixelSize(
mTutorialFragment.isLargeScreen()
? R.dimen.gesture_tutorial_foldable_feedback_margin_start_end
: R.dimen.gesture_tutorial_feedback_margin_start_end));
feedbackLayoutParams.setMarginEnd(mContext.getResources().getDimensionPixelSize(
mTutorialFragment.isLargeScreen()
? R.dimen.gesture_tutorial_foldable_feedback_margin_start_end
: R.dimen.gesture_tutorial_feedback_margin_start_end));
}
}
private AlertDialog createSkipTutorialDialog() {
if (mContext instanceof GestureSandboxActivity) {
GestureSandboxActivity sandboxActivity = (GestureSandboxActivity) mContext;