blob: 8f1be6458699e969bca946f89e1b1997c2babe68 [file] [log] [blame]
Eric Erfanian938468d2017-10-24 14:05:52 -07001/*
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
17package com.android.newbubble;
18
Eric Erfanian938468d2017-10-24 14:05:52 -070019import android.graphics.drawable.Drawable;
Eric Erfanian938468d2017-10-24 14:05:52 -070020import android.support.annotation.NonNull;
Eric Erfanian938468d2017-10-24 14:05:52 -070021import com.android.newbubble.NewBubbleInfo.Action;
Eric Erfanian938468d2017-10-24 14:05:52 -070022import java.util.List;
23
24/**
25 * Creates and manages a bubble window from information in a {@link NewBubbleInfo}. Before creating,
yuegb6e16f52018-01-31 12:02:19 -080026 * be sure to check whether bubbles may be shown using {@code Settings.canDrawOverlays(context)} and
27 * request permission if necessary
Eric Erfanian938468d2017-10-24 14:05:52 -070028 */
yuegb6e16f52018-01-31 12:02:19 -080029public interface NewBubble {
yueg81a77ff2017-12-05 10:29:03 -080030
Eric Erfanian938468d2017-10-24 14:05:52 -070031 /**
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 */
yuegb6e16f52018-01-31 12:02:19 -080035 void show();
Eric Erfanian938468d2017-10-24 14:05:52 -070036
37 /** Hide the bubble. */
yuegb6e16f52018-01-31 12:02:19 -080038 void hide();
Eric Erfanian938468d2017-10-24 14:05:52 -070039
yuegb6e16f52018-01-31 12:02:19 -080040 /** Hide the bubble and reset to initial state */
41 void hideAndReset();
Eric Erfanian938468d2017-10-24 14:05:52 -070042
43 /** Returns whether the bubble is currently visible */
yuegb6e16f52018-01-31 12:02:19 -080044 boolean isVisible();
Eric Erfanian938468d2017-10-24 14:05:52 -070045
46 /**
47 * Set the info for this Bubble to display
48 *
49 * @param bubbleInfo the BubbleInfo to display in this Bubble.
50 */
yuegb6e16f52018-01-31 12:02:19 -080051 void setBubbleInfo(@NonNull NewBubbleInfo bubbleInfo);
Eric Erfanian938468d2017-10-24 14:05:52 -070052
53 /**
54 * Update the state and behavior of actions.
55 *
56 * @param actions the new state of the bubble's actions
57 */
yuegb6e16f52018-01-31 12:02:19 -080058 void updateActions(@NonNull List<Action> actions);
Eric Erfanian938468d2017-10-24 14:05:52 -070059
yuega5a08d82017-10-31 14:11:53 -070060 /**
61 * Update the avatar from photo.
62 *
63 * @param avatar the new photo avatar in the bubble's primary button
64 */
yuegb6e16f52018-01-31 12:02:19 -080065 void updatePhotoAvatar(@NonNull Drawable avatar);
yuega5a08d82017-10-31 14:11:53 -070066
67 /**
68 * Update the avatar.
69 *
70 * @param avatar the new avatar in the bubble's primary button
71 */
yuegb6e16f52018-01-31 12:02:19 -080072 void updateAvatar(@NonNull Drawable avatar);
Eric Erfanian938468d2017-10-24 14:05:52 -070073
74 /**
yueg6518fdb2018-01-09 17:30:36 -080075 * Display text. The bubble's drawer is not expandable while text is showing, and the drawer will
76 * be closed if already open.
Eric Erfanian938468d2017-10-24 14:05:52 -070077 *
78 * @param text the text to display to the user
79 */
yuegb6e16f52018-01-31 12:02:19 -080080 void showText(@NonNull CharSequence text);
Eric Erfanian938468d2017-10-24 14:05:52 -070081}