blob: 785593c5cf3327185ca72b5ce4317df5db1621b2 [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
Eric Erfanian938468d2017-10-24 14:05:52 -070040 /** Returns whether the bubble is currently visible */
yuegb6e16f52018-01-31 12:02:19 -080041 boolean isVisible();
Eric Erfanian938468d2017-10-24 14:05:52 -070042
43 /**
44 * Set the info for this Bubble to display
45 *
46 * @param bubbleInfo the BubbleInfo to display in this Bubble.
47 */
yuegb6e16f52018-01-31 12:02:19 -080048 void setBubbleInfo(@NonNull NewBubbleInfo bubbleInfo);
Eric Erfanian938468d2017-10-24 14:05:52 -070049
50 /**
51 * Update the state and behavior of actions.
52 *
53 * @param actions the new state of the bubble's actions
54 */
yuegb6e16f52018-01-31 12:02:19 -080055 void updateActions(@NonNull List<Action> actions);
Eric Erfanian938468d2017-10-24 14:05:52 -070056
yuega5a08d82017-10-31 14:11:53 -070057 /**
58 * Update the avatar from photo.
59 *
60 * @param avatar the new photo avatar in the bubble's primary button
61 */
yuegb6e16f52018-01-31 12:02:19 -080062 void updatePhotoAvatar(@NonNull Drawable avatar);
yuega5a08d82017-10-31 14:11:53 -070063
64 /**
65 * Update the avatar.
66 *
67 * @param avatar the new avatar in the bubble's primary button
68 */
yuegb6e16f52018-01-31 12:02:19 -080069 void updateAvatar(@NonNull Drawable avatar);
Eric Erfanian938468d2017-10-24 14:05:52 -070070
71 /**
yueg6518fdb2018-01-09 17:30:36 -080072 * Display text. The bubble's drawer is not expandable while text is showing, and the drawer will
73 * be closed if already open.
Eric Erfanian938468d2017-10-24 14:05:52 -070074 *
75 * @param text the text to display to the user
76 */
yuegb6e16f52018-01-31 12:02:19 -080077 void showText(@NonNull CharSequence text);
Eric Erfanian938468d2017-10-24 14:05:52 -070078}