• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.quickstep.interaction;
17 
18 import static com.android.quickstep.interaction.GestureSandboxActivity.KEY_GESTURE_COMPLETE;
19 import static com.android.quickstep.interaction.GestureSandboxActivity.KEY_TUTORIAL_TYPE;
20 import static com.android.quickstep.interaction.GestureSandboxActivity.KEY_USE_TUTORIAL_MENU;
21 
22 import android.os.Bundle;
23 import android.view.LayoutInflater;
24 import android.view.View;
25 import android.view.ViewGroup;
26 
27 import androidx.annotation.NonNull;
28 import androidx.annotation.Nullable;
29 
30 import com.android.launcher3.R;
31 
32 /** Displays the gesture nav tutorial menu. */
33 public final class MenuFragment extends GestureSandboxFragment {
34 
35     @NonNull
36     @Override
recreateFragment()37     GestureSandboxFragment recreateFragment() {
38         return new MenuFragment();
39     }
40 
41     @Override
canRecreateFragment()42     boolean canRecreateFragment() {
43         return true;
44     }
45 
46     @Override
onCreateView(@onNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)47     public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
48             @Nullable Bundle savedInstanceState) {
49         final View root = inflater.inflate(
50                 R.layout.gesture_tutorial_step_menu, container, false);
51 
52         root.findViewById(R.id.gesture_tutorial_menu_home_button).setOnClickListener(
53                 v -> launchTutorialStep(TutorialController.TutorialType.HOME_NAVIGATION));
54         root.findViewById(R.id.gesture_tutorial_menu_back_button).setOnClickListener(
55                 v -> launchTutorialStep(TutorialController.TutorialType.BACK_NAVIGATION));
56         root.findViewById(R.id.gesture_tutorial_menu_overview_button).setOnClickListener(
57                 v -> launchTutorialStep(TutorialController.TutorialType.OVERVIEW_NAVIGATION));
58         root.findViewById(R.id.gesture_tutorial_menu_done_button).setOnClickListener(
59                 v -> close());
60 
61         return root;
62     }
63 
64     @Override
shouldDisableSystemGestures()65     boolean shouldDisableSystemGestures() {
66         return false;
67     }
68 
69     @Override
onSaveInstanceState(Bundle savedInstanceState)70     public void onSaveInstanceState(Bundle savedInstanceState) {
71         savedInstanceState.putBoolean(KEY_USE_TUTORIAL_MENU, true);
72         savedInstanceState.remove(KEY_TUTORIAL_TYPE);
73         savedInstanceState.remove(KEY_GESTURE_COMPLETE);
74         super.onSaveInstanceState(savedInstanceState);
75     }
76 
launchTutorialStep(@onNull TutorialController.TutorialType tutorialType)77     private void launchTutorialStep(@NonNull TutorialController.TutorialType tutorialType) {
78         ((GestureSandboxActivity) getActivity()).launchTutorialStep(tutorialType, true);
79     }
80 }
81