1 /* 2 * Copyright (C) 2017 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.LauncherAnimUtils.ALL_APPS_TRANSITION_MS; 19 import static com.android.launcher3.anim.Interpolators.DEACCEL_2; 20 21 import com.android.launcher3.AbstractFloatingView; 22 import com.android.launcher3.Launcher; 23 import com.android.launcher3.LauncherState; 24 import com.android.launcher3.allapps.AllAppsContainerView; 25 import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; 26 import com.android.quickstep.SysUINavigationMode; 27 28 /** 29 * Definition for AllApps state 30 */ 31 public class AllAppsState extends LauncherState { 32 33 private static final int STATE_FLAGS = FLAG_DISABLE_ACCESSIBILITY; 34 35 private static final PageAlphaProvider PAGE_ALPHA_PROVIDER = new PageAlphaProvider(DEACCEL_2) { 36 @Override 37 public float getPageAlpha(int pageIndex) { 38 return 0; 39 } 40 }; 41 AllAppsState(int id)42 public AllAppsState(int id) { 43 super(id, ContainerType.ALLAPPS, ALL_APPS_TRANSITION_MS, STATE_FLAGS); 44 } 45 46 @Override onStateEnabled(Launcher launcher)47 public void onStateEnabled(Launcher launcher) { 48 AbstractFloatingView.closeAllOpenViews(launcher); 49 dispatchWindowStateChanged(launcher); 50 } 51 52 @Override getDescription(Launcher launcher)53 public String getDescription(Launcher launcher) { 54 AllAppsContainerView appsView = launcher.getAppsView(); 55 return appsView.getDescription(); 56 } 57 58 @Override getVerticalProgress(Launcher launcher)59 public float getVerticalProgress(Launcher launcher) { 60 return 0f; 61 } 62 63 @Override getWorkspaceScaleAndTranslation(Launcher launcher)64 public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) { 65 ScaleAndTranslation scaleAndTranslation = LauncherState.OVERVIEW 66 .getWorkspaceScaleAndTranslation(launcher); 67 if (SysUINavigationMode.getMode(launcher) == SysUINavigationMode.Mode.NO_BUTTON) { 68 float normalScale = 1; 69 // Scale down halfway to where we'd be in overview, to prepare for a potential pause. 70 scaleAndTranslation.scale = (scaleAndTranslation.scale + normalScale) / 2; 71 } else { 72 scaleAndTranslation.scale = 1; 73 } 74 return scaleAndTranslation; 75 } 76 77 @Override getWorkspacePageAlphaProvider(Launcher launcher)78 public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) { 79 return PAGE_ALPHA_PROVIDER; 80 } 81 82 @Override getVisibleElements(Launcher launcher)83 public int getVisibleElements(Launcher launcher) { 84 return ALL_APPS_HEADER | ALL_APPS_HEADER_EXTRA | ALL_APPS_CONTENT; 85 } 86 87 @Override getOverviewScaleAndTranslation(Launcher launcher)88 public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) { 89 float slightParallax = -launcher.getDeviceProfile().allAppsCellHeightPx * 0.3f; 90 return new ScaleAndTranslation(0.9f, 0f, slightParallax); 91 } 92 93 @Override getHistoryForState(LauncherState previousState)94 public LauncherState getHistoryForState(LauncherState previousState) { 95 return previousState == OVERVIEW ? OVERVIEW : NORMAL; 96 } 97 } 98