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.unfold.util.NaturalRotationUnfoldProgressProvider 21 import com.android.systemui.unfold.util.ScopedUnfoldTransitionProgressProvider 22 import com.android.systemui.dagger.SysUISingleton 23 import com.android.systemui.statusbar.phone.StatusBarMoveFromCenterAnimationController 24 import dagger.BindsInstance 25 import dagger.Module 26 import dagger.Provides 27 import dagger.Subcomponent 28 import java.util.Optional 29 import javax.inject.Named 30 import javax.inject.Scope 31 32 @Scope 33 @MustBeDocumented 34 @Retention(AnnotationRetention.RUNTIME) 35 annotation class SysUIUnfoldScope 36 37 /** 38 * Creates an injectable [SysUIUnfoldComponent] that provides objects that have been scoped with 39 * [@SysUIUnfoldScope]. Since [SysUIUnfoldComponent] depends upon: 40 * * [Optional<UnfoldTransitionProgressProvider>] 41 * * [Optional<ScopedUnfoldTransitionProgressProvider>] 42 * * [Optional<NaturalRotationProgressProvider>] 43 * no objects will get constructed if these parameters are empty. 44 */ 45 @Module(subcomponents = [SysUIUnfoldComponent::class]) 46 class SysUIUnfoldModule { 47 constructor() {} 48 49 @Provides 50 @SysUISingleton 51 fun provideSysUIUnfoldComponent( 52 provider: Optional<UnfoldTransitionProgressProvider>, 53 rotationProvider: Optional<NaturalRotationUnfoldProgressProvider>, 54 @Named(UNFOLD_STATUS_BAR) scopedProvider: Optional<ScopedUnfoldTransitionProgressProvider>, 55 factory: SysUIUnfoldComponent.Factory 56 ) = 57 provider.flatMap { p1 -> 58 rotationProvider.flatMap { p2 -> 59 scopedProvider.map { p3 -> factory.create(p1, p2, p3) } 60 } 61 } 62 } 63 64 @SysUIUnfoldScope 65 @Subcomponent 66 interface SysUIUnfoldComponent { 67 68 @Subcomponent.Factory 69 interface Factory { 70 fun create( 71 @BindsInstance p1: UnfoldTransitionProgressProvider, 72 @BindsInstance p2: NaturalRotationUnfoldProgressProvider, 73 @BindsInstance p3: ScopedUnfoldTransitionProgressProvider 74 ): SysUIUnfoldComponent 75 } 76 77 fun getKeyguardUnfoldTransition(): KeyguardUnfoldTransition 78 79 fun getStatusBarMoveFromCenterAnimationController(): StatusBarMoveFromCenterAnimationController 80 81 fun getUnfoldTransitionWallpaperController(): UnfoldTransitionWallpaperController 82 83 fun getUnfoldLightRevealOverlayAnimation(): UnfoldLightRevealOverlayAnimation 84 } 85