• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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.unfold
18 
19 import com.android.keyguard.KeyguardUnfoldTransition
20 import com.android.systemui.dagger.SysUISingleton
21 import com.android.systemui.shade.NotificationPanelUnfoldAnimationController
22 import com.android.systemui.statusbar.phone.StatusBarMoveFromCenterAnimationController
23 import com.android.systemui.unfold.util.UnfoldKeyguardVisibilityManager
24 import com.android.systemui.unfold.util.NaturalRotationUnfoldProgressProvider
25 import com.android.systemui.unfold.util.ScopedUnfoldTransitionProgressProvider
26 import com.android.systemui.util.kotlin.getOrNull
27 import dagger.BindsInstance
28 import dagger.Module
29 import dagger.Provides
30 import dagger.Subcomponent
31 import java.util.Optional
32 import javax.inject.Named
33 import javax.inject.Scope
34 
35 @Scope
36 @MustBeDocumented
37 @Retention(AnnotationRetention.RUNTIME)
38 annotation class SysUIUnfoldScope
39 
40 /**
41  * Creates an injectable [SysUIUnfoldComponent] that provides objects that have been scoped with
42  * [@SysUIUnfoldScope].
43  *
44  * Since [SysUIUnfoldComponent] depends upon:
45  * * [Optional<UnfoldTransitionProgressProvider>]
46  * * [Optional<ScopedUnfoldTransitionProgressProvider>]
47  * * [Optional<NaturalRotationProgressProvider>]
48  *
49  * no objects will get constructed if these parameters are empty.
50  */
51 @Module(subcomponents = [SysUIUnfoldComponent::class])
52 class SysUIUnfoldModule {
53 
54     @Provides
55     @SysUISingleton
provideSysUIUnfoldComponentnull56     fun provideSysUIUnfoldComponent(
57         provider: Optional<UnfoldTransitionProgressProvider>,
58         rotationProvider: Optional<NaturalRotationUnfoldProgressProvider>,
59         @Named(UNFOLD_STATUS_BAR) scopedProvider: Optional<ScopedUnfoldTransitionProgressProvider>,
60         factory: SysUIUnfoldComponent.Factory
61     ): Optional<SysUIUnfoldComponent> {
62         val p1 = provider.getOrNull()
63         val p2 = rotationProvider.getOrNull()
64         val p3 = scopedProvider.getOrNull()
65         return if (p1 == null || p2 == null || p3 == null) {
66             Optional.empty()
67         } else {
68             Optional.of(factory.create(p1, p2, p3))
69         }
70     }
71 }
72 
73 @SysUIUnfoldScope
74 @Subcomponent
75 interface SysUIUnfoldComponent {
76 
77     @Subcomponent.Factory
78     interface Factory {
createnull79         fun create(
80             @BindsInstance p1: UnfoldTransitionProgressProvider,
81             @BindsInstance p2: NaturalRotationUnfoldProgressProvider,
82             @BindsInstance p3: ScopedUnfoldTransitionProgressProvider
83         ): SysUIUnfoldComponent
84     }
85 
86     fun getKeyguardUnfoldTransition(): KeyguardUnfoldTransition
87 
88     fun getStatusBarMoveFromCenterAnimationController(): StatusBarMoveFromCenterAnimationController
89 
90     fun getNotificationPanelUnfoldAnimationController(): NotificationPanelUnfoldAnimationController
91 
92     fun getFoldAodAnimationController(): FoldAodAnimationController
93 
94     fun getUnfoldTransitionWallpaperController(): UnfoldTransitionWallpaperController
95 
96     fun getUnfoldHapticsPlayer(): UnfoldHapticsPlayer
97 
98     fun getUnfoldLightRevealOverlayAnimation(): UnfoldLightRevealOverlayAnimation
99 
100     fun getUnfoldKeyguardVisibilityManager(): UnfoldKeyguardVisibilityManager
101 }
102