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.anim.Interpolators.DEACCEL_2;
19 import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_ALLAPPS;
20 
21 import android.content.Context;
22 
23 import com.android.launcher3.Launcher;
24 import com.android.launcher3.LauncherState;
25 import com.android.launcher3.R;
26 import com.android.launcher3.allapps.AllAppsContainerView;
27 import com.android.launcher3.util.Themes;
28 
29 /**
30  * Definition for AllApps state
31  */
32 public class AllAppsState extends LauncherState {
33 
34     private static final int STATE_FLAGS = FLAG_WORKSPACE_INACCESSIBLE | FLAG_CLOSE_POPUPS;
35 
36     private static final PageAlphaProvider PAGE_ALPHA_PROVIDER = new PageAlphaProvider(DEACCEL_2) {
37         @Override
38         public float getPageAlpha(int pageIndex) {
39             return 0;
40         }
41     };
42 
AllAppsState(int id)43     public AllAppsState(int id) {
44         super(id, LAUNCHER_STATE_ALLAPPS, STATE_FLAGS);
45     }
46 
47     @Override
getTransitionDuration(Context context)48     public int getTransitionDuration(Context context) {
49         return 320;
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         scaleAndTranslation.scale = 1;
68         return scaleAndTranslation;
69     }
70 
71     @Override
isTaskbarStashed(Launcher launcher)72     public boolean isTaskbarStashed(Launcher launcher) {
73         return true;
74     }
75 
76     @Override
getDepthUnchecked(Context context)77     protected float getDepthUnchecked(Context context) {
78         // The scrim fades in at approximately 50% of the swipe gesture.
79         // This means that the depth should be greater than 1, in order to fully zoom out.
80         return 2f;
81     }
82 
83     @Override
getWorkspacePageAlphaProvider(Launcher launcher)84     public PageAlphaProvider getWorkspacePageAlphaProvider(Launcher launcher) {
85         return PAGE_ALPHA_PROVIDER;
86     }
87 
88     @Override
getVisibleElements(Launcher launcher)89     public int getVisibleElements(Launcher launcher) {
90         return ALL_APPS_CONTENT;
91     }
92 
93     @Override
getHistoryForState(LauncherState previousState)94     public LauncherState getHistoryForState(LauncherState previousState) {
95         return previousState == OVERVIEW ? OVERVIEW : NORMAL;
96     }
97 
98     @Override
getWorkspaceScrimColor(Launcher launcher)99     public int getWorkspaceScrimColor(Launcher launcher) {
100         return Themes.getAttrColor(launcher, R.attr.allAppsScrimColor);
101     }
102 }
103