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.systemui.animation.back
18
19 import android.util.DisplayMetrics
20
21 /**
22 * SysUI transitions - Dismiss app (ST1) Return to launching surface or place of origin
23 * https://carbon.googleplex.com/predictive-back-for-apps/pages/st-1-dismiss-app
24 */
BackAnimationSpecnull25 fun BackAnimationSpec.Companion.dismissAppForSysUi(
26 displayMetricsProvider: () -> DisplayMetrics,
27 ): BackAnimationSpec =
28 BackAnimationSpec.createFloatingSurfaceAnimationSpec(
29 displayMetricsProvider = displayMetricsProvider,
30 maxMarginXdp = 8f,
31 maxMarginYdp = 8f,
32 minScale = 0.8f,
33 )
34
35 /**
36 * SysUI transitions - Cross task (ST2) Return to previous task/app, keeping the current one open
37 * https://carbon.googleplex.com/predictive-back-for-apps/pages/st-2-cross-task
38 */
39 fun BackAnimationSpec.Companion.crossTaskForSysUi(
40 displayMetricsProvider: () -> DisplayMetrics,
41 ): BackAnimationSpec =
42 BackAnimationSpec.createFloatingSurfaceAnimationSpec(
43 displayMetricsProvider = displayMetricsProvider,
44 maxMarginXdp = 8f,
45 maxMarginYdp = 8f,
46 minScale = 0.8f,
47 )
48
49 /**
50 * SysUI transitions - Inner area dismiss (ST3) Dismiss non-detachable surface
51 * https://carbon.googleplex.com/predictive-back-for-apps/pages/st-3-inner-area-dismiss
52 */
53 fun BackAnimationSpec.Companion.innerAreaDismissForSysUi(
54 displayMetricsProvider: () -> DisplayMetrics,
55 ): BackAnimationSpec =
56 BackAnimationSpec.createFloatingSurfaceAnimationSpec(
57 displayMetricsProvider = displayMetricsProvider,
58 maxMarginXdp = 0f,
59 maxMarginYdp = 0f,
60 minScale = 0.9f,
61 )
62
63 /**
64 * SysUI transitions - Floating system surfaces (ST4)
65 * https://carbon.googleplex.com/predictive-back-for-apps/pages/st-4-floating-system-surfaces
66 */
67 fun BackAnimationSpec.Companion.floatingSystemSurfacesForSysUi(
68 displayMetricsProvider: () -> DisplayMetrics,
69 ): BackAnimationSpec =
70 BackAnimationSpec.createFloatingSurfaceAnimationSpec(
71 displayMetricsProvider = displayMetricsProvider,
72 maxMarginXdp = 8f,
73 maxMarginYdp = 8f,
74 minScale = 0.9f,
75 )
76
77 /**
78 * SysUI transitions - Bottomsheet (AT3)
79 * https://carbon.googleplex.com/predictive-back-for-apps/pages/at-3-bottom-sheets
80 */
81 fun BackAnimationSpec.Companion.bottomSheetForSysUi(
82 displayMetricsProvider: () -> DisplayMetrics,
83 ): BackAnimationSpec = BackAnimationSpec.createBottomsheetAnimationSpec(displayMetricsProvider)
84