1 /* 2 * Copyright (C) 2018 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.content.Context; 21 import android.graphics.Color; 22 23 import com.android.launcher3.BaseDraggingActivity; 24 import com.android.launcher3.DeviceProfile; 25 import com.android.launcher3.Launcher; 26 import com.android.launcher3.allapps.AllAppsTransitionController; 27 import com.android.quickstep.util.LayoutUtils; 28 import com.android.quickstep.views.RecentsView; 29 30 /** 31 * State indicating that the Launcher is behind an app 32 */ 33 public class BackgroundAppState extends OverviewState { 34 35 private static final int STATE_FLAGS = FLAG_DISABLE_RESTORE | FLAG_OVERVIEW_UI 36 | FLAG_WORKSPACE_INACCESSIBLE | FLAG_NON_INTERACTIVE | FLAG_CLOSE_POPUPS; 37 BackgroundAppState(int id)38 public BackgroundAppState(int id) { 39 this(id, LAUNCHER_STATE_BACKGROUND); 40 } 41 BackgroundAppState(int id, int logContainer)42 protected BackgroundAppState(int id, int logContainer) { 43 super(id, logContainer, STATE_FLAGS); 44 } 45 46 @Override getVerticalProgress(Launcher launcher)47 public float getVerticalProgress(Launcher launcher) { 48 if (launcher.getDeviceProfile().isVerticalBarLayout()) { 49 return super.getVerticalProgress(launcher); 50 } 51 RecentsView recentsView = launcher.getOverviewPanel(); 52 int transitionLength = LayoutUtils.getShelfTrackingDistance(launcher, 53 launcher.getDeviceProfile(), 54 recentsView.getPagedOrientationHandler()); 55 AllAppsTransitionController controller = launcher.getAllAppsController(); 56 float scrollRange = Math.max(controller.getShiftRange(), 1); 57 float progressDelta = (transitionLength / scrollRange); 58 return super.getVerticalProgress(launcher) + progressDelta; 59 } 60 61 @Override getOverviewScaleAndOffset(Launcher launcher)62 public float[] getOverviewScaleAndOffset(Launcher launcher) { 63 return getOverviewScaleAndOffsetForBackgroundState(launcher); 64 } 65 66 @Override getOverviewFullscreenProgress()67 public float getOverviewFullscreenProgress() { 68 return 1; 69 } 70 71 @Override getVisibleElements(Launcher launcher)72 public int getVisibleElements(Launcher launcher) { 73 return super.getVisibleElements(launcher) 74 & ~OVERVIEW_ACTIONS 75 & ~CLEAR_ALL_BUTTON 76 & ~VERTICAL_SWIPE_INDICATOR 77 | TASKBAR; 78 } 79 80 @Override displayOverviewTasksAsGrid(DeviceProfile deviceProfile)81 public boolean displayOverviewTasksAsGrid(DeviceProfile deviceProfile) { 82 return false; 83 } 84 85 @Override getDepthUnchecked(Context context)86 protected float getDepthUnchecked(Context context) { 87 return 1; 88 } 89 90 @Override getWorkspaceScrimColor(Launcher launcher)91 public int getWorkspaceScrimColor(Launcher launcher) { 92 return Color.TRANSPARENT; 93 } 94 getOverviewScaleAndOffsetForBackgroundState( BaseDraggingActivity activity)95 public static float[] getOverviewScaleAndOffsetForBackgroundState( 96 BaseDraggingActivity activity) { 97 return new float[] { 98 ((RecentsView) activity.getOverviewPanel()).getMaxScaleForFullScreen(), 99 NO_OFFSET}; 100 } 101 } 102