• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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.shade
18 
19 import android.content.Context
20 import android.view.ViewGroup
21 import com.android.systemui.R
22 import com.android.systemui.plugins.statusbar.StatusBarStateController
23 import com.android.systemui.statusbar.StatusBarState.SHADE
24 import com.android.systemui.statusbar.StatusBarState.SHADE_LOCKED
25 import com.android.systemui.shared.animation.UnfoldConstantTranslateAnimator
26 import com.android.systemui.shared.animation.UnfoldConstantTranslateAnimator.Direction.END
27 import com.android.systemui.shared.animation.UnfoldConstantTranslateAnimator.Direction.START
28 import com.android.systemui.shared.animation.UnfoldConstantTranslateAnimator.ViewIdToTranslate
29 import com.android.systemui.unfold.SysUIUnfoldScope
30 import com.android.systemui.unfold.util.NaturalRotationUnfoldProgressProvider
31 import javax.inject.Inject
32 
33 @SysUIUnfoldScope
34 class NotificationPanelUnfoldAnimationController
35 @Inject
36 constructor(
37     private val context: Context,
38     statusBarStateController: StatusBarStateController,
39     progressProvider: NaturalRotationUnfoldProgressProvider,
40 ) {
41 
<lambda>null42     private val filterShade: () -> Boolean = { statusBarStateController.getState() == SHADE ||
43         statusBarStateController.getState() == SHADE_LOCKED }
44 
<lambda>null45     private val translateAnimator by lazy {
46         UnfoldConstantTranslateAnimator(
47             viewsIdToTranslate =
48                 setOf(
49                     ViewIdToTranslate(R.id.quick_settings_panel, START, filterShade),
50                     ViewIdToTranslate(R.id.notification_stack_scroller, END, filterShade),
51                     ViewIdToTranslate(R.id.statusIcons, END, filterShade),
52                     ViewIdToTranslate(R.id.privacy_container, END, filterShade),
53                     ViewIdToTranslate(R.id.batteryRemainingIcon, END, filterShade),
54                     ViewIdToTranslate(R.id.carrier_group, END, filterShade),
55                     ViewIdToTranslate(R.id.clock, START, filterShade),
56                     ViewIdToTranslate(R.id.date, START, filterShade)),
57             progressProvider = progressProvider)
58     }
59 
setupnull60     fun setup(root: ViewGroup) {
61         val translationMax =
62             context.resources.getDimensionPixelSize(R.dimen.notification_side_paddings).toFloat()
63         translateAnimator.init(root, translationMax)
64     }
65 }
66