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.deskclock 18 19 import androidx.annotation.IntDef 20 21 /** 22 * Implemented by containers that house the fab and its associated buttons. Also implemented by 23 * containers that know how to contact the **true** fab container to ferry through 24 * commands. 25 */ 26 interface FabContainer { 27 @IntDef(flag = true, value = [ 28 FAB_IMMEDIATE, 29 FAB_SHRINK_AND_EXPAND, 30 FAB_MORPH, 31 FAB_REQUEST_FOCUS, 32 BUTTONS_IMMEDIATE, 33 BUTTONS_SHRINK_AND_EXPAND, 34 BUTTONS_DISABLE, 35 FAB_AND_BUTTONS_IMMEDIATE, 36 FAB_AND_BUTTONS_SHRINK_AND_EXPAND, 37 FAB_AND_BUTTONS_SHRINK, 38 FAB_AND_BUTTONS_EXPAND 39 ]) 40 annotation class UpdateFabFlag 41 42 /** 43 * Requests that this container update the fab and/or its buttons because their state has 44 * changed. The update may be immediate or it may be animated depending on the choice of 45 * `updateTypes`. 46 * 47 * @param updateTypes indicates the types of update to apply to the fab and its buttons 48 */ updateFabnull49 fun updateFab(@UpdateFabFlag updateTypes: Int) 50 51 companion object { 52 /** Bit field for updates */ 53 /** Bit 0-1 */ 54 const val FAB_ANIMATION_MASK = 3 55 56 /** Signals that the fab should be updated in place with no animation. */ 57 const val FAB_IMMEDIATE = 1 58 59 /** Signals the fab should be "animated away", updated, and "animated back". */ 60 const val FAB_SHRINK_AND_EXPAND = 2 61 62 /** Signals that the fab should morph into a new state in place. */ 63 const val FAB_MORPH = 3 64 65 /** Bit 2 */ 66 const val FAB_REQUEST_FOCUS_MASK = 4 67 68 /** Signals that the fab should request focus. */ 69 const val FAB_REQUEST_FOCUS = 4 70 71 /** Bit 3-4 */ 72 const val BUTTONS_ANIMATION_MASK = 24 73 74 /** Signals that the buttons should be updated in place with no animation. */ 75 const val BUTTONS_IMMEDIATE = 8 76 77 /** Signals that the buttons should be "animated away", updated, and "animated back". */ 78 const val BUTTONS_SHRINK_AND_EXPAND = 16 79 80 /** Bit 5 */ 81 const val BUTTONS_DISABLE_MASK = 32 82 83 /** Disable the buttons of the fab so they do not respond to clicks. */ 84 const val BUTTONS_DISABLE = 32 85 86 /** Bit 6-7 */ 87 const val FAB_AND_BUTTONS_SHRINK_EXPAND_MASK = 192 88 89 /** Signals the fab and buttons should be "animated away". */ 90 const val FAB_AND_BUTTONS_SHRINK = 128 91 92 /** Signals the fab and buttons should be "animated back". */ 93 const val FAB_AND_BUTTONS_EXPAND = 64 94 95 /** Convenience flags */ 96 const val FAB_AND_BUTTONS_IMMEDIATE = FAB_IMMEDIATE or BUTTONS_IMMEDIATE 97 const val FAB_AND_BUTTONS_SHRINK_AND_EXPAND = 98 FAB_SHRINK_AND_EXPAND or BUTTONS_SHRINK_AND_EXPAND 99 } 100 }