Merge "Update TutorialFragments to work without hand gesture animations." into ub-launcher3-master

This commit is contained in:
Schneider Victor-tulias 2020-09-30 22:26:01 +00:00 committed by Android (Google) Code Review
commit 6873cb82f3
6 changed files with 23 additions and 12 deletions

View File

@ -24,7 +24,7 @@ import com.android.quickstep.interaction.TutorialController.TutorialType;
/** Shows the Home gesture interactive tutorial. */
public class AssistantGestureTutorialFragment extends TutorialFragment {
@Override
int getHandAnimationResId() {
Integer getHandAnimationResId() {
return R.drawable.assistant_gesture;
}

View File

@ -24,7 +24,7 @@ import com.android.quickstep.interaction.TutorialController.TutorialType;
/** Shows the Back gesture interactive tutorial. */
public class BackGestureTutorialFragment extends TutorialFragment {
@Override
int getHandAnimationResId() {
Integer getHandAnimationResId() {
return R.drawable.back_gesture;
}

View File

@ -21,7 +21,7 @@ import com.android.quickstep.interaction.TutorialController.TutorialType;
/** Shows the Home gesture interactive tutorial. */
public class HomeGestureTutorialFragment extends TutorialFragment {
@Override
int getHandAnimationResId() {
Integer getHandAnimationResId() {
return R.drawable.home_gesture;
}

View File

@ -21,7 +21,7 @@ import com.android.quickstep.interaction.TutorialController.TutorialType;
/** Shows the Overview gesture interactive tutorial. */
public class OverviewGestureTutorialFragment extends TutorialFragment {
@Override
int getHandAnimationResId() {
Integer getHandAnimationResId() {
return R.drawable.overview_gesture;
}

View File

@ -52,7 +52,7 @@ abstract class TutorialController implements BackGestureAttemptCallback,
final View mFakeTaskView;
final View mRippleView;
final RippleDrawable mRippleDrawable;
final TutorialHandAnimation mHandCoachingAnimation;
@Nullable final TutorialHandAnimation mHandCoachingAnimation;
final ImageView mHandCoachingView;
final Button mActionTextButton;
final Button mActionButton;
@ -145,13 +145,16 @@ abstract class TutorialController implements BackGestureAttemptCallback,
void onActionTextButtonClicked(View button) {}
void showHandCoachingAnimation() {
if (isComplete()) {
if (isComplete() || mHandCoachingAnimation == null) {
return;
}
mHandCoachingAnimation.startLoopedAnimation(mTutorialType);
}
void hideHandCoachingAnimation() {
if (mHandCoachingAnimation == null) {
return;
}
mHandCoachingAnimation.stop();
mHandCoachingView.setVisibility(View.INVISIBLE);
}

View File

@ -43,7 +43,7 @@ abstract class TutorialFragment extends Fragment implements OnTouchListener {
TutorialType mTutorialType;
@Nullable TutorialController mTutorialController = null;
View mRootView;
TutorialHandAnimation mHandCoachingAnimation;
@Nullable TutorialHandAnimation mHandCoachingAnimation = null;
EdgeBackGestureHandler mEdgeBackGestureHandler;
NavBarGestureHandler mNavBarGestureHandler;
private View mLauncherView;
@ -82,7 +82,9 @@ abstract class TutorialFragment extends Fragment implements OnTouchListener {
return null;
}
abstract int getHandAnimationResId();
@Nullable Integer getHandAnimationResId() {
return null;
}
abstract TutorialController createController(TutorialType type);
@ -116,8 +118,11 @@ abstract class TutorialFragment extends Fragment implements OnTouchListener {
return insets;
});
mRootView.setOnTouchListener(this);
mHandCoachingAnimation =
new TutorialHandAnimation(getContext(), mRootView, getHandAnimationResId());
Integer handAnimationResId = getHandAnimationResId();
if (handAnimationResId != null) {
mHandCoachingAnimation =
new TutorialHandAnimation(getContext(), mRootView, handAnimationResId);
}
InvariantDeviceProfile dp = InvariantDeviceProfile.INSTANCE.get(getContext());
mLauncherView = new SandboxLauncherRenderer(getContext(), dp, true).getRenderedView();
((ViewGroup) mRootView).addView(mLauncherView, 0);
@ -133,7 +138,10 @@ abstract class TutorialFragment extends Fragment implements OnTouchListener {
@Override
public void onPause() {
super.onPause();
mHandCoachingAnimation.stop();
if (mHandCoachingAnimation != null) {
mHandCoachingAnimation.stop();
}
}
@Override
@ -183,7 +191,7 @@ abstract class TutorialFragment extends Fragment implements OnTouchListener {
return mLauncherView;
}
TutorialHandAnimation getHandAnimation() {
@Nullable TutorialHandAnimation getHandAnimation() {
return mHandCoachingAnimation;
}