• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.shade.transition
18 
19 import android.content.Context
20 import android.content.res.Configuration
21 import com.android.systemui.dagger.SysUISingleton
22 import com.android.systemui.statusbar.policy.ConfigurationController
23 import com.android.systemui.util.LargeScreenUtils
24 import javax.inject.Inject
25 
26 /** Interpolator responsible for the shade when on large screens. */
27 @SysUISingleton
28 internal class LargeScreenShadeInterpolatorImpl
29 @Inject
30 internal constructor(
31     configurationController: ConfigurationController,
32     private val context: Context,
33     private val splitShadeInterpolator: SplitShadeInterpolator,
34     private val portraitShadeInterpolator: LargeScreenPortraitShadeInterpolator,
35 ) : LargeScreenShadeInterpolator {
36 
37     private var inSplitShade = false
38 
39     init {
40         configurationController.addCallback(
41             object : ConfigurationController.ConfigurationListener {
onConfigChangednull42                 override fun onConfigChanged(newConfig: Configuration?) {
43                     updateResources()
44                 }
45             }
46         )
47         updateResources()
48     }
49 
updateResourcesnull50     private fun updateResources() {
51         inSplitShade = LargeScreenUtils.shouldUseSplitNotificationShade(context.resources)
52     }
53 
54     private val impl: LargeScreenShadeInterpolator
55         get() =
56             if (inSplitShade) {
57                 splitShadeInterpolator
58             } else {
59                 portraitShadeInterpolator
60             }
61 
getBehindScrimAlphanull62     override fun getBehindScrimAlpha(fraction: Float) = impl.getBehindScrimAlpha(fraction)
63 
64     override fun getNotificationScrimAlpha(fraction: Float) =
65         impl.getNotificationScrimAlpha(fraction)
66 
67     override fun getNotificationContentAlpha(fraction: Float) =
68         impl.getNotificationContentAlpha(fraction)
69 
70     override fun getNotificationFooterAlpha(fraction: Float) =
71         impl.getNotificationFooterAlpha(fraction)
72 
73     override fun getQsAlpha(fraction: Float) = impl.getQsAlpha(fraction)
74 }
75