• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.communal.widgets
18 
19 import com.android.systemui.animation.ActivityTransitionAnimator
20 import com.android.systemui.animation.DelegateTransitionAnimatorController
21 import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor
22 import com.android.systemui.communal.shared.model.CommunalScenes
23 
24 /**
25  * An [ActivityTransitionAnimator.Controller] that takes care of updating the state of the Communal
26  * Hub at the right time.
27  */
28 class CommunalTransitionAnimatorController(
29     delegate: ActivityTransitionAnimator.Controller,
30     private val communalSceneInteractor: CommunalSceneInteractor,
31 ) : DelegateTransitionAnimatorController(delegate) {
onIntentStartednull32     override fun onIntentStarted(willAnimate: Boolean) {
33         if (!willAnimate) {
34             // Other callbacks won't happen, so reset the state here.
35             communalSceneInteractor.setIsLaunchingWidget(false)
36         }
37         delegate.onIntentStarted(willAnimate)
38     }
39 
onTransitionAnimationStartnull40     override fun onTransitionAnimationStart(isExpandingFullyAbove: Boolean) {
41         delegate.onTransitionAnimationStart(isExpandingFullyAbove)
42         // TODO(b/330672236): move this to onTransitionAnimationEnd() without the delay.
43         communalSceneInteractor.snapToScene(
44             CommunalScenes.Blank,
45             "CommunalTransitionAnimatorController",
46             ActivityTransitionAnimator.TIMINGS.totalDuration
47         )
48     }
49 
onTransitionAnimationCancellednull50     override fun onTransitionAnimationCancelled(newKeyguardOccludedState: Boolean?) {
51         communalSceneInteractor.setIsLaunchingWidget(false)
52         delegate.onTransitionAnimationCancelled(newKeyguardOccludedState)
53     }
54 
onTransitionAnimationEndnull55     override fun onTransitionAnimationEnd(isExpandingFullyAbove: Boolean) {
56         communalSceneInteractor.setIsLaunchingWidget(false)
57         delegate.onTransitionAnimationEnd(isExpandingFullyAbove)
58     }
59 }
60