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.Launcher 20 import com.android.launcher3.LauncherState 21 import com.android.launcher3.logging.StatsLogManager 22 import com.android.launcher3.views.ActivityContext 23 24 /** Definition for Edit Mode state used for home gardening multi-select */ 25 class EditModeState(id: Int) : LauncherState(id, StatsLogManager.LAUNCHER_STATE_HOME, STATE_FLAGS) { 26 27 companion object { 28 private val STATE_FLAGS = 29 (FLAG_MULTI_PAGE or 30 FLAG_WORKSPACE_INACCESSIBLE or 31 FLAG_DISABLE_RESTORE or 32 FLAG_WORKSPACE_ICONS_CAN_BE_DRAGGED or 33 FLAG_WORKSPACE_HAS_BACKGROUNDS) 34 } 35 getTransitionDurationnull36 override fun <T> getTransitionDuration(context: T, isToState: Boolean): Int where 37 T : Context?, 38 T : ActivityContext? { 39 return 150 40 } 41 getDepthUncheckednull42 override fun <T> getDepthUnchecked(context: T): Float where T : Context?, T : ActivityContext? { 43 return 0.5f 44 } 45 getWorkspaceScaleAndTranslationnull46 override fun getWorkspaceScaleAndTranslation(launcher: Launcher): ScaleAndTranslation { 47 val scale = launcher.deviceProfile.getWorkspaceSpringLoadScale(launcher) 48 return ScaleAndTranslation(scale, 0f, 0f) 49 } 50 getHotseatScaleAndTranslationnull51 override fun getHotseatScaleAndTranslation(launcher: Launcher): ScaleAndTranslation { 52 val scale = launcher.deviceProfile.getWorkspaceSpringLoadScale(launcher) 53 return ScaleAndTranslation(scale, 0f, 0f) 54 } 55 getWorkspaceBackgroundAlphanull56 override fun getWorkspaceBackgroundAlpha(launcher: Launcher): Float { 57 return 0.2f 58 } 59 onLeavingStatenull60 override fun onLeavingState(launcher: Launcher?, toState: LauncherState?) { 61 // cleanup any changes to workspace 62 } 63 } 64