1 /*
2  * Copyright 2021 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 
17 package com.android.launcher3.uioverrides.states;
18 
19 import android.content.Context;
20 
21 import com.android.launcher3.Launcher;
22 import com.android.quickstep.util.SplitAnimationTimings;
23 import com.android.quickstep.views.RecentsView;
24 
25 /**
26  * New Overview substate representing state where 1 app for split screen has been selected and
27  * pinned and user is selecting the second one
28  */
29 public class SplitScreenSelectState extends OverviewState {
SplitScreenSelectState(int id)30     public SplitScreenSelectState(int id) {
31         super(id);
32     }
33 
34     @Override
getVisibleElements(Launcher launcher)35     public int getVisibleElements(Launcher launcher) {
36         return SPLIT_PLACHOLDER_VIEW;
37     }
38 
39     @Override
getSplitSelectTranslation(Launcher launcher)40     public float getSplitSelectTranslation(Launcher launcher) {
41         RecentsView recentsView = launcher.getOverviewPanel();
42         return recentsView.getSplitSelectTranslation();
43     }
44 
45     @Override
getTransitionDuration(Context context, boolean isToState)46     public int getTransitionDuration(Context context, boolean isToState) {
47         boolean isTablet = ((Launcher) context).getDeviceProfile().isTablet;
48         if (isToState && isTablet) {
49             return SplitAnimationTimings.TABLET_ENTER_DURATION;
50         } else if (isToState && !isTablet) {
51             return SplitAnimationTimings.PHONE_ENTER_DURATION;
52         } else {
53             return SplitAnimationTimings.ABORT_DURATION;
54         }
55     }
56 
57     @Override
shouldPreserveDataStateOnReapply()58     public boolean shouldPreserveDataStateOnReapply() {
59         return true;
60     }
61 }
62