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 17 package com.android.wm.shell.bubbles.animation 18 19 /** Utils related to the fling to dismiss animation. */ 20 object FlingToDismissUtils { 21 22 /** The target width surrounding the dismiss target on a small width screen, e.g. phone. */ 23 private const val FLING_TO_DISMISS_TARGET_WIDTH_SMALL = 3f 24 /** 25 * The target width surrounding the dismiss target on a medium width screen, e.g. tablet in 26 * portrait. 27 */ 28 private const val FLING_TO_DISMISS_TARGET_WIDTH_MEDIUM = 4.5f 29 /** 30 * The target width surrounding the dismiss target on a large width screen, e.g. tablet in 31 * landscape. 32 */ 33 private const val FLING_TO_DISMISS_TARGET_WIDTH_LARGE = 6f 34 35 /** Returns the dismiss target width for the specified [screenWidthPx]. */ 36 @JvmStatic getFlingToDismissTargetWidthnull37 fun getFlingToDismissTargetWidth(screenWidthPx: Int) = when { 38 screenWidthPx >= 2000 -> FLING_TO_DISMISS_TARGET_WIDTH_LARGE 39 screenWidthPx >= 1500 -> FLING_TO_DISMISS_TARGET_WIDTH_MEDIUM 40 else -> FLING_TO_DISMISS_TARGET_WIDTH_SMALL 41 } 42 } 43