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 
18 package com.android.systemui.keyguard.shared.model
19 
20 /** DismissAction models */
21 sealed interface DismissAction {
22     val onDismissAction: () -> KeyguardDone
23     val onCancelAction: Runnable
24     val message: String
25     /**
26      * True if the dismiss action will run an animation on the keyguard and requires any views that
27      * would obscure this animation (ie: the primary bouncer) to immediately hide, so the animation
28      * would be visible.
29      */
30     val willAnimateOnLockscreen: Boolean
31     val runAfterKeyguardGone: Boolean
32 
33     class RunImmediately(
34         override val onDismissAction: () -> KeyguardDone,
35         override val onCancelAction: Runnable,
36         override val message: String,
37         override val willAnimateOnLockscreen: Boolean,
38     ) : DismissAction {
39         override val runAfterKeyguardGone: Boolean = false
40     }
41 
42     class RunAfterKeyguardGone(
43         val dismissAction: () -> Unit,
44         override val onCancelAction: Runnable,
45         override val message: String,
46         override val willAnimateOnLockscreen: Boolean,
47     ) : DismissAction {
<lambda>null48         override val onDismissAction: () -> KeyguardDone = {
49             dismissAction()
50             // no-op, when this dismissAction is run after the keyguard is gone,
51             // the keyguard is already done so KeyguardDone timing is irrelevant
52             KeyguardDone.IMMEDIATE
53         }
54         override val runAfterKeyguardGone: Boolean = true
55     }
56 
57     data object None : DismissAction {
<lambda>null58         override val onDismissAction: () -> KeyguardDone = { KeyguardDone.IMMEDIATE }
<lambda>null59         override val onCancelAction: Runnable = Runnable {}
60         override val message: String = ""
61         override val willAnimateOnLockscreen: Boolean = false
62         override val runAfterKeyguardGone: Boolean = false
63     }
64 }
65