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