blob: e192e06f4fef981b166912ab936d99c36b422e29 [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
42 /**
43 * Set the info for this Bubble to display
44 *
45 * @param bubbleInfo the BubbleInfo to display in this Bubble.
46 */
yueg48f93f42018-03-09 16:49:38 -080047 void setBubbleInfo(@NonNull BubbleInfo bubbleInfo);
Eric Erfanian938468d2017-10-24 14:05:52 -070048
49 /**
50 * Update the state and behavior of actions.
51 *
52 * @param actions the new state of the bubble's actions
53 */
yueg48f93f42018-03-09 16:49:38 -080054 void updateActions(@NonNull List<BubbleInfo.Action> actions);
Eric Erfanian938468d2017-10-24 14:05:52 -070055
yuega5a08d82017-10-31 14:11:53 -070056 /**
57 * Update the avatar from photo.
58 *
59 * @param avatar the new photo avatar in the bubble's primary button
60 */
yuegb6e16f52018-01-31 12:02:19 -080061 void updatePhotoAvatar(@NonNull Drawable avatar);
yuega5a08d82017-10-31 14:11:53 -070062
63 /**
64 * Update the avatar.
65 *
66 * @param avatar the new avatar in the bubble's primary button
67 */
yuegb6e16f52018-01-31 12:02:19 -080068 void updateAvatar(@NonNull Drawable avatar);
Eric Erfanian938468d2017-10-24 14:05:52 -070069
70 /**
yueg6518fdb2018-01-09 17:30:36 -080071 * Display text. The bubble's drawer is not expandable while text is showing, and the drawer will
72 * be closed if already open.
Eric Erfanian938468d2017-10-24 14:05:52 -070073 *
74 * @param text the text to display to the user
75 */
yuegb6e16f52018-01-31 12:02:19 -080076 void showText(@NonNull CharSequence text);
Eric Erfanian938468d2017-10-24 14:05:52 -070077}