• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.android.deskclock;
2 
3 import androidx.annotation.IntDef;
4 
5 /**
6  * Implemented by containers that house the fab and its associated buttons. Also implemented by
7  * containers that know how to contact the <strong>true</strong> fab container to ferry through
8  * commands.
9  */
10 public interface FabContainer {
11 
12     /** Bit field for updates */
13 
14     /** Bit 0-1 */
15     int FAB_ANIMATION_MASK = 0b11;
16     /** Signals that the fab should be updated in place with no animation. */
17     int FAB_IMMEDIATE = 0b1;
18     /** Signals the fab should be "animated away", updated, and "animated back". */
19     int FAB_SHRINK_AND_EXPAND = 0b10;
20     /** Signals that the fab should morph into a new state in place. */
21     int FAB_MORPH = 0b11;
22 
23     /** Bit 2 */
24     int FAB_REQUEST_FOCUS_MASK = 0b100;
25     /** Signals that the fab should request focus. */
26     int FAB_REQUEST_FOCUS = 0b100;
27 
28     /** Bit 3-4 */
29     int BUTTONS_ANIMATION_MASK = 0b11000;
30     /** Signals that the buttons should be updated in place with no animation. */
31     int BUTTONS_IMMEDIATE = 0b1000;
32     /** Signals that the buttons should be "animated away", updated, and "animated back". */
33     int BUTTONS_SHRINK_AND_EXPAND = 0b10000;
34 
35     /** Bit 5 */
36     int BUTTONS_DISABLE_MASK = 0b100000;
37     /** Disable the buttons of the fab so they do not respond to clicks. */
38     int BUTTONS_DISABLE = 0b100000;
39 
40     /** Bit 6-7 */
41     int FAB_AND_BUTTONS_SHRINK_EXPAND_MASK = 0b11000000;
42     /** Signals the fab and buttons should be "animated away". */
43     int FAB_AND_BUTTONS_SHRINK = 0b10000000;
44     /** Signals the fab and buttons should be "animated back". */
45     int FAB_AND_BUTTONS_EXPAND = 0b01000000;
46 
47     /** Convenience flags */
48     int FAB_AND_BUTTONS_IMMEDIATE = FAB_IMMEDIATE | BUTTONS_IMMEDIATE;
49     int FAB_AND_BUTTONS_SHRINK_AND_EXPAND = FAB_SHRINK_AND_EXPAND | BUTTONS_SHRINK_AND_EXPAND;
50 
51     @IntDef(
52             flag = true,
53             value = { FAB_IMMEDIATE, FAB_SHRINK_AND_EXPAND, FAB_MORPH, FAB_REQUEST_FOCUS,
54                     BUTTONS_IMMEDIATE, BUTTONS_SHRINK_AND_EXPAND, BUTTONS_DISABLE,
55                     FAB_AND_BUTTONS_IMMEDIATE, FAB_AND_BUTTONS_SHRINK_AND_EXPAND,
56                     FAB_AND_BUTTONS_SHRINK, FAB_AND_BUTTONS_EXPAND }
57     )
58     @interface UpdateFabFlag {}
59 
60     /**
61      * Requests that this container update the fab and/or its buttons because their state has
62      * changed. The update may be immediate or it may be animated depending on the choice of
63      * {@code updateTypes}.
64      *
65      * @param updateTypes indicates the types of update to apply to the fab and its buttons
66      */
updateFab(@pdateFabFlag int updateTypes)67     void updateFab(@UpdateFabFlag int updateTypes);
68 }