Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 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 | */ |
Sunny Goyal | 8552517 | 2017-11-06 13:00:42 -0800 | [diff] [blame] | 16 | package com.android.launcher3.uioverrides; |
Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 17 | |
| 18 | import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS; |
Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 19 | |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 20 | import android.view.View; |
Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 21 | |
Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 22 | import com.android.launcher3.Launcher; |
| 23 | import com.android.launcher3.LauncherState; |
Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 24 | import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType; |
Sunny Goyal | 1676458 | 2017-11-06 16:00:34 -0800 | [diff] [blame] | 25 | import com.android.quickstep.RecentsView; |
Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * Definition for overview state |
| 29 | */ |
| 30 | public class OverviewState extends LauncherState { |
| 31 | |
| 32 | // The percent to shrink the workspace during overview mode |
| 33 | public static final float SCALE_FACTOR = 0.7f; |
| 34 | |
Sunny Goyal | c4fa8c3 | 2017-11-07 12:23:58 -0800 | [diff] [blame^] | 35 | private static final int STATE_FLAGS = FLAG_SHOW_SCRIM | FLAG_MULTI_PAGE; |
Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 36 | |
| 37 | public OverviewState(int id) { |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 38 | super(id, ContainerType.WORKSPACE, OVERVIEW_TRANSITION_MS, 1f, STATE_FLAGS); |
Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | @Override |
| 42 | public float[] getWorkspaceScaleAndTranslation(Launcher launcher) { |
Sunny Goyal | 1676458 | 2017-11-06 16:00:34 -0800 | [diff] [blame] | 43 | // TODO: Find a better transition |
Sunny Goyal | c4fa8c3 | 2017-11-07 12:23:58 -0800 | [diff] [blame^] | 44 | return new float[] {0f, 0}; |
Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | @Override |
| 48 | public void onStateEnabled(Launcher launcher) { |
Sunny Goyal | 1676458 | 2017-11-06 16:00:34 -0800 | [diff] [blame] | 49 | ((RecentsView) launcher.getOverviewPanel()).setViewVisible(true); |
Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | @Override |
| 53 | public void onStateDisabled(Launcher launcher) { |
Sunny Goyal | 1676458 | 2017-11-06 16:00:34 -0800 | [diff] [blame] | 54 | ((RecentsView) launcher.getOverviewPanel()).setViewVisible(false); |
Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 55 | } |
Sunny Goyal | be93f26 | 2017-10-20 17:05:27 -0700 | [diff] [blame] | 56 | |
| 57 | @Override |
| 58 | public View getFinalFocus(Launcher launcher) { |
| 59 | return launcher.getOverviewPanel(); |
| 60 | } |
Sunny Goyal | c99cb17 | 2017-10-19 16:15:09 -0700 | [diff] [blame] | 61 | } |