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