1 /*
2  * Copyright (C) 2019 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.launcher3.uioverrides.states;
17 
18 import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND;
19 
20 import android.graphics.Color;
21 
22 import com.android.launcher3.DeviceProfile;
23 import com.android.launcher3.Launcher;
24 import com.android.launcher3.R;
25 import com.android.launcher3.util.Themes;
26 
27 /**
28  * State to indicate we are about to launch a recent task. Note that this state is only used when
29  * quick switching from launcher; quick switching from an app uses LauncherSwipeHandler.
30  * @see com.android.quickstep.GestureState.GestureEndTarget#NEW_TASK
31  */
32 public class QuickSwitchState extends BackgroundAppState {
33 
QuickSwitchState(int id)34     public QuickSwitchState(int id) {
35         super(id, LAUNCHER_STATE_BACKGROUND);
36     }
37 
38     @Override
getWorkspaceScaleAndTranslation(Launcher launcher)39     public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
40         float shiftRange = launcher.getAllAppsController().getShiftRange();
41         float shiftProgress = getVerticalProgress(launcher) - NORMAL.getVerticalProgress(launcher);
42         float translationY = shiftProgress * shiftRange;
43         return new ScaleAndTranslation(0.9f, 0, translationY);
44     }
45 
46     @Override
getWorkspaceScrimColor(Launcher launcher)47     public int getWorkspaceScrimColor(Launcher launcher) {
48         if (launcher.areDesktopTasksVisible()) {
49             // No scrim while desktop tasks are visible
50             return Color.TRANSPARENT;
51         }
52         DeviceProfile dp = launcher.getDeviceProfile();
53         if (dp.isTaskbarPresentInApps) {
54             return launcher.getColor(R.color.taskbar_background);
55         }
56         return Themes.getAttrColor(launcher, R.attr.overviewScrimColor);
57     }
58 
59     @Override
getVerticalProgress(Launcher launcher)60     public float getVerticalProgress(Launcher launcher) {
61         // Don't move all apps shelf while quick-switching (just let it fade).
62         return 1f;
63     }
64 
65     @Override
getVisibleElements(Launcher launcher)66     public int getVisibleElements(Launcher launcher) {
67         return NONE;
68     }
69 
70     @Override
isTaskbarStashed(Launcher launcher)71     public boolean isTaskbarStashed(Launcher launcher) {
72         return !launcher.getDeviceProfile().isTaskbarPresentInApps;
73     }
74 
75     @Override
isTaskbarAlignedWithHotseat(Launcher launcher)76     public boolean isTaskbarAlignedWithHotseat(Launcher launcher) {
77         return false;
78     }
79 }
80