1 /*
2  * Copyright (C) 2020 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.controls.ui
18 
19 import android.service.controls.Control
20 
21 /**
22  * All control interactions should be routed through this coordinator. It handles dispatching of
23  * actions, haptic support, and all detail panels
24  */
25 interface ControlActionCoordinator {
26 
27     /**
28      * Close any dialogs which may have been open
29      */
closeDialogsnull30     fun closeDialogs()
31 
32     /**
33      * Create a [BooleanAction], and inform the service of a request to change the device state
34      *
35      * @param cvh [ControlViewHolder] for the control
36      * @param templateId id of the control's template, as given by the service
37      * @param isChecked new requested state of the control
38      */
39     fun toggle(cvh: ControlViewHolder, templateId: String, isChecked: Boolean)
40 
41     /**
42      * For non-toggle controls, touching may create a dialog or invoke a [CommandAction].
43      *
44      * @param cvh [ControlViewHolder] for the control
45      * @param templateId id of the control's template, as given by the service
46      * @param control the control as sent by the service
47      */
48     fun touch(cvh: ControlViewHolder, templateId: String, control: Control)
49 
50     /**
51      * When a ToggleRange control is interacting with, a drag event is sent.
52      *
53      * @param isEdge did the drag event reach a control edge
54      */
55     fun drag(isEdge: Boolean)
56 
57     /**
58      * Send a request to update the value of a device using the [FloatAction].
59      *
60      * @param cvh [ControlViewHolder] for the control
61      * @param templateId id of the control's template, as given by the service
62      * @param newValue value to set for the device
63      */
64     fun setValue(cvh: ControlViewHolder, templateId: String, newValue: Float)
65 
66     /**
67      * Actions may have been put on hold while the device is unlocked. Invoke this action if
68      * present.
69      */
70     fun runPendingAction(controlId: String)
71 
72     /**
73      * User interaction with a control may be blocked for a period of time while actions are being
74      * executed by the application.  When the response returns, run this method to enable further
75      * user interaction.
76      */
77     fun enableActionOnTouch(controlId: String)
78 
79     /**
80      * All long presses will be shown in a 3/4 height bottomsheet panel, in order for the user to
81      * retain context with their favorited controls in the power menu.
82      */
83     fun longPress(cvh: ControlViewHolder)
84 }
85