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.keyguard.domain.interactor 18 19 import com.android.systemui.dagger.SysUISingleton 20 import com.android.systemui.shade.NotificationPanelViewController 21 import com.android.systemui.shade.ShadeFoldAnimator 22 import javax.inject.Inject 23 24 @SysUISingleton 25 class ToAodFoldTransitionInteractor 26 @Inject 27 constructor(private val keyguardClockInteractor: KeyguardClockInteractor) { 28 private var parentAnimator: NotificationPanelViewController.ShadeFoldAnimatorImpl? = null 29 30 // TODO(b/331770313): Migrate to PowerInteractor; Deprecate ShadeFoldAnimator again 31 val foldAnimator = 32 object : ShadeFoldAnimator { 33 prepareFoldToAodAnimationnull34 override fun prepareFoldToAodAnimation() { 35 parentAnimator?.prepareFoldToAodAnimation() 36 } 37 startFoldToAodAnimationnull38 override fun startFoldToAodAnimation( 39 startAction: Runnable, 40 endAction: Runnable, 41 cancelAction: Runnable, 42 ) { 43 parentAnimator?.let { 44 it.buildViewAnimator(startAction, endAction, cancelAction) 45 .setUpdateListener { 46 keyguardClockInteractor.animateFoldToAod(it.animatedFraction) 47 } 48 .start() 49 } 50 } 51 cancelFoldToAodAnimationnull52 override fun cancelFoldToAodAnimation() { 53 parentAnimator?.cancelFoldToAodAnimation() 54 } 55 } 56 initializenull57 fun initialize(parentAnimator: ShadeFoldAnimator) { 58 this.parentAnimator = 59 parentAnimator as? NotificationPanelViewController.ShadeFoldAnimatorImpl? 60 } 61 62 companion object { 63 private val TAG = ToAodFoldTransitionInteractor::class.simpleName!! 64 } 65 } 66