1 /* 2 * Copyright (C) 2020 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.states; 17 18 import static com.android.launcher3.Flags.enableScalingRevealHomeAnimation; 19 import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME; 20 21 import android.content.Context; 22 23 import androidx.core.graphics.ColorUtils; 24 25 import com.android.launcher3.Launcher; 26 import com.android.launcher3.LauncherState; 27 import com.android.launcher3.R; 28 import com.android.launcher3.util.Themes; 29 30 /** 31 * Scale down workspace/hotseat to hint at going to either overview (on pause) or first home screen. 32 */ 33 public class HintState extends LauncherState { 34 35 private static final int STATE_FLAGS = FLAG_WORKSPACE_INACCESSIBLE | FLAG_DISABLE_RESTORE 36 | FLAG_HAS_SYS_UI_SCRIM; 37 38 public static final float DEPTH_5_PERCENT = 0.05f; 39 HintState(int id)40 public HintState(int id) { 41 this(id, LAUNCHER_STATE_HOME); 42 } 43 HintState(int id, int statsLogOrdinal)44 public HintState(int id, int statsLogOrdinal) { 45 super(id, statsLogOrdinal, STATE_FLAGS); 46 } 47 48 @Override getTransitionDuration(Context context, boolean isToState)49 public int getTransitionDuration(Context context, boolean isToState) { 50 return 80; 51 } 52 53 @Override getDepthUnchecked(Context context)54 protected float getDepthUnchecked(Context context) { 55 if (enableScalingRevealHomeAnimation()) { 56 return DEPTH_5_PERCENT; 57 } else { 58 return 0.15f; 59 } 60 } 61 62 @Override getWorkspaceScrimColor(Launcher launcher)63 public int getWorkspaceScrimColor(Launcher launcher) { 64 return ColorUtils.setAlphaComponent( 65 Themes.getAttrColor(launcher, R.attr.overviewScrimColor), 100); 66 } 67 68 @Override getWorkspaceScaleAndTranslation(Launcher launcher)69 public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) { 70 return new ScaleAndTranslation(0.92f, 0, 0); 71 } 72 } 73