• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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;
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 
27 /**
28  * Definition for AllApps state
29  */
30 public class AllAppsState extends LauncherState {
31 
32     private static final int STATE_FLAGS = FLAG_DISABLE_ACCESSIBILITY;
33 
34     private static final PageAlphaProvider PAGE_ALPHA_PROVIDER = new PageAlphaProvider(DEACCEL_2) {
35         @Override
36         public float getPageAlpha(int pageIndex) {
37             return 0;
38         }
39     };
40 
AllAppsState(int id)41     public AllAppsState(int id) {
42         super(id, ContainerType.ALLAPPS, ALL_APPS_TRANSITION_MS, STATE_FLAGS);
43     }
44 
45     @Override
onStateEnabled(Launcher launcher)46     public void onStateEnabled(Launcher launcher) {
47         AbstractFloatingView.closeAllOpenViews(launcher);
48         dispatchWindowStateChanged(launcher);
49     }
50 
51     @Override
getDescription(Launcher launcher)52     public String getDescription(Launcher launcher) {
53         AllAppsContainerView appsView = launcher.getAppsView();
54         return appsView.getDescription();
55     }
56 
57     @Override
getVerticalProgress(Launcher launcher)58     public float getVerticalProgress(Launcher launcher) {
59         return 0f;
60     }
61 
62     @Override
getWorkspaceScaleAndTranslation(Launcher launcher)63     public float[] getWorkspaceScaleAndTranslation(Launcher launcher) {
64         float[] scaleAndTranslation = LauncherState.OVERVIEW.getWorkspaceScaleAndTranslation(
65                 launcher);
66         scaleAndTranslation[0] = 1;
67         return scaleAndTranslation;
68     }
69 
70     @Override
getWorkspacePageAlphaProvider(Launcher launcher)71     public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) {
72         return PAGE_ALPHA_PROVIDER;
73     }
74 
75     @Override
getVisibleElements(Launcher launcher)76     public int getVisibleElements(Launcher launcher) {
77         return ALL_APPS_HEADER | ALL_APPS_HEADER_EXTRA | ALL_APPS_CONTENT;
78     }
79 
80     @Override
getOverviewScaleAndTranslationYFactor(Launcher launcher)81     public float[] getOverviewScaleAndTranslationYFactor(Launcher launcher) {
82         return new float[] {0.9f, -0.2f};
83     }
84 
85     @Override
getHistoryForState(LauncherState previousState)86     public LauncherState getHistoryForState(LauncherState previousState) {
87         return previousState == OVERVIEW ? OVERVIEW : NORMAL;
88     }
89 }
90