blob: 1b853cf49ae04fbb26d8fcb643eb888b81647397 [file] [log] [blame]
Eric Erfanian938468d2017-10-24 14:05:52 -07001/*
yueg48f93f42018-03-09 16:49:38 -08002 * Copyright (C) 2018 The Android Open Source Project
Eric Erfanian938468d2017-10-24 14:05:52 -07003 *
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
yueg48f93f42018-03-09 16:49:38 -080017package com.android.bubble;
Eric Erfanian938468d2017-10-24 14:05:52 -070018
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 java.util.List;
22
23/**
yueg48f93f42018-03-09 16:49:38 -080024 * 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
yuegb6e16f52018-01-31 12:02:19 -080026 * request permission if necessary
Eric Erfanian938468d2017-10-24 14:05:52 -070027 */
yueg48f93f42018-03-09 16:49:38 -080028public interface Bubble {
yueg81a77ff2017-12-05 10:29:03 -080029
Eric Erfanian938468d2017-10-24 14:05:52 -070030 /**
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 */
yuegb6e16f52018-01-31 12:02:19 -080034 void show();
Eric Erfanian938468d2017-10-24 14:05:52 -070035
36 /** Hide the bubble. */
yuegb6e16f52018-01-31 12:02:19 -080037 void hide();
Eric Erfanian938468d2017-10-24 14:05:52 -070038
Eric Erfanian938468d2017-10-24 14:05:52 -070039 /** Returns whether the bubble is currently visible */
yuegb6e16f52018-01-31 12:02:19 -080040 boolean isVisible();
Eric Erfanian938468d2017-10-24 14:05:52 -070041
yuegc6d21862018-03-30 12:31:47 -070042 /** Returns whether the bubble is currently dismissed */
43 boolean isDismissed();
44
Eric Erfanian938468d2017-10-24 14:05:52 -070045 /**
46 * Set the info for this Bubble to display
47 *
48 * @param bubbleInfo the BubbleInfo to display in this Bubble.
49 */
yueg48f93f42018-03-09 16:49:38 -080050 void setBubbleInfo(@NonNull BubbleInfo bubbleInfo);
Eric Erfanian938468d2017-10-24 14:05:52 -070051
52 /**
53 * Update the state and behavior of actions.
54 *
55 * @param actions the new state of the bubble's actions
56 */
yueg48f93f42018-03-09 16:49:38 -080057 void updateActions(@NonNull List<BubbleInfo.Action> actions);
Eric Erfanian938468d2017-10-24 14:05:52 -070058
yuega5a08d82017-10-31 14:11:53 -070059 /**
60 * Update the avatar from photo.
61 *
62 * @param avatar the new photo avatar in the bubble's primary button
63 */
yuegb6e16f52018-01-31 12:02:19 -080064 void updatePhotoAvatar(@NonNull Drawable avatar);
yuega5a08d82017-10-31 14:11:53 -070065
66 /**
67 * Update the avatar.
68 *
69 * @param avatar the new avatar in the bubble's primary button
70 */
yuegb6e16f52018-01-31 12:02:19 -080071 void updateAvatar(@NonNull Drawable avatar);
Eric Erfanian938468d2017-10-24 14:05:52 -070072
73 /**
yueg6518fdb2018-01-09 17:30:36 -080074 * Display text. The bubble's drawer is not expandable while text is showing, and the drawer will
75 * be closed if already open.
Eric Erfanian938468d2017-10-24 14:05:52 -070076 *
77 * @param text the text to display to the user
78 */
yuegb6e16f52018-01-31 12:02:19 -080079 void showText(@NonNull CharSequence text);
Eric Erfanian938468d2017-10-24 14:05:52 -070080}