1 /* 2 * Copyright (C) 2023 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 android.content.Context 19 import com.android.launcher3.Flags.enableScalingRevealHomeAnimation 20 import com.android.launcher3.Launcher 21 import com.android.launcher3.LauncherState 22 import com.android.launcher3.logging.StatsLogManager 23 import com.android.launcher3.views.ActivityContext 24 25 /** Definition for Edit Mode state used for home gardening multi-select */ 26 class EditModeState(id: Int) : LauncherState(id, StatsLogManager.LAUNCHER_STATE_HOME, STATE_FLAGS) { 27 28 companion object { 29 const val DEPTH_15_PERCENT = 0.15f 30 31 private val STATE_FLAGS = 32 (FLAG_MULTI_PAGE or 33 FLAG_WORKSPACE_INACCESSIBLE or 34 FLAG_DISABLE_RESTORE or 35 FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED or 36 FLAG_WORKSPACE_HAS_BACKGROUNDS) 37 } 38 getTransitionDurationnull39 override fun getTransitionDuration(context: ActivityContext, isToState: Boolean) = 150 40 41 override fun <T> getDepthUnchecked(context: T): Float where T : Context?, T : ActivityContext? { 42 if (enableScalingRevealHomeAnimation()) { 43 return DEPTH_15_PERCENT 44 } else { 45 return 0.5f 46 } 47 } 48 getWorkspaceScaleAndTranslationnull49 override fun getWorkspaceScaleAndTranslation(launcher: Launcher): ScaleAndTranslation { 50 val scale = launcher.deviceProfile.getWorkspaceSpringLoadScale(launcher) 51 return ScaleAndTranslation(scale, 0f, 0f) 52 } 53 getHotseatScaleAndTranslationnull54 override fun getHotseatScaleAndTranslation(launcher: Launcher): ScaleAndTranslation { 55 val scale = launcher.deviceProfile.getWorkspaceSpringLoadScale(launcher) 56 return ScaleAndTranslation(scale, 0f, 0f) 57 } 58 getWorkspaceBackgroundAlphanull59 override fun getWorkspaceBackgroundAlpha(launcher: Launcher): Float { 60 return 0.2f 61 } 62 onLeavingStatenull63 override fun onLeavingState(launcher: Launcher?, toState: LauncherState?) { 64 // cleanup any changes to workspace 65 } 66 } 67