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