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