• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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.bubble;
18 
19 import android.graphics.drawable.Drawable;
20 import android.support.annotation.NonNull;
21 import java.util.List;
22 
23 /**
24  * Creates and manages a bubble window from information in a {@link BubbleInfo}. Before creating, be
25  * sure to check whether bubbles may be shown using {@code Settings.canDrawOverlays(context)} and
26  * request permission if necessary
27  */
28 public interface Bubble {
29 
30   /**
31    * Make the bubble visible. Will show a short entrance animation as it enters. If the bubble is
32    * already showing this method does nothing.
33    */
show()34   void show();
35 
36   /** Hide the bubble. */
hide()37   void hide();
38 
39   /** Returns whether the bubble is currently visible */
isVisible()40   boolean isVisible();
41 
42   /** Returns whether the bubble is currently dismissed */
isDismissed()43   boolean isDismissed();
44 
45   /**
46    * Set the info for this Bubble to display
47    *
48    * @param bubbleInfo the BubbleInfo to display in this Bubble.
49    */
setBubbleInfo(@onNull BubbleInfo bubbleInfo)50   void setBubbleInfo(@NonNull BubbleInfo bubbleInfo);
51 
52   /**
53    * Update the state and behavior of actions.
54    *
55    * @param actions the new state of the bubble's actions
56    */
updateActions(@onNull List<BubbleInfo.Action> actions)57   void updateActions(@NonNull List<BubbleInfo.Action> actions);
58 
59   /**
60    * Update the avatar from photo.
61    *
62    * @param avatar the new photo avatar in the bubble's primary button
63    */
updatePhotoAvatar(@onNull Drawable avatar)64   void updatePhotoAvatar(@NonNull Drawable avatar);
65 
66   /**
67    * Update the avatar.
68    *
69    * @param avatar the new avatar in the bubble's primary button
70    */
updateAvatar(@onNull Drawable avatar)71   void updateAvatar(@NonNull Drawable avatar);
72 
73   /**
74    * Display text. The bubble's drawer is not expandable while text is showing, and the drawer will
75    * be closed if already open.
76    *
77    * @param text the text to display to the user
78    */
showText(@onNull CharSequence text)79   void showText(@NonNull CharSequence text);
80 }
81