Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 1 | /* |
yueg | 48f93f4 | 2018-03-09 16:49:38 -0800 | [diff] [blame] | 2 | * Copyright (C) 2018 The Android Open Source Project |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 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 | |
yueg | 48f93f4 | 2018-03-09 16:49:38 -0800 | [diff] [blame] | 17 | package com.android.bubble; |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 18 | |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 19 | import android.graphics.drawable.Drawable; |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 20 | import android.support.annotation.NonNull; |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 21 | import java.util.List; |
| 22 | |
| 23 | /** |
yueg | 48f93f4 | 2018-03-09 16:49:38 -0800 | [diff] [blame] | 24 | * 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 |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame] | 26 | * request permission if necessary |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 27 | */ |
yueg | 48f93f4 | 2018-03-09 16:49:38 -0800 | [diff] [blame] | 28 | public interface Bubble { |
yueg | 81a77ff | 2017-12-05 10:29:03 -0800 | [diff] [blame] | 29 | |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 30 | /** |
| 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 | */ |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame] | 34 | void show(); |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 35 | |
| 36 | /** Hide the bubble. */ |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame] | 37 | void hide(); |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 38 | |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 39 | /** Returns whether the bubble is currently visible */ |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame] | 40 | boolean isVisible(); |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 41 | |
yueg | c6d2186 | 2018-03-30 12:31:47 -0700 | [diff] [blame] | 42 | /** Returns whether the bubble is currently dismissed */ |
| 43 | boolean isDismissed(); |
| 44 | |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 45 | /** |
| 46 | * Set the info for this Bubble to display |
| 47 | * |
| 48 | * @param bubbleInfo the BubbleInfo to display in this Bubble. |
| 49 | */ |
yueg | 48f93f4 | 2018-03-09 16:49:38 -0800 | [diff] [blame] | 50 | void setBubbleInfo(@NonNull BubbleInfo bubbleInfo); |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * Update the state and behavior of actions. |
| 54 | * |
| 55 | * @param actions the new state of the bubble's actions |
| 56 | */ |
yueg | 48f93f4 | 2018-03-09 16:49:38 -0800 | [diff] [blame] | 57 | void updateActions(@NonNull List<BubbleInfo.Action> actions); |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 58 | |
yueg | a5a08d8 | 2017-10-31 14:11:53 -0700 | [diff] [blame] | 59 | /** |
| 60 | * Update the avatar from photo. |
| 61 | * |
| 62 | * @param avatar the new photo avatar in the bubble's primary button |
| 63 | */ |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame] | 64 | void updatePhotoAvatar(@NonNull Drawable avatar); |
yueg | a5a08d8 | 2017-10-31 14:11:53 -0700 | [diff] [blame] | 65 | |
| 66 | /** |
| 67 | * Update the avatar. |
| 68 | * |
| 69 | * @param avatar the new avatar in the bubble's primary button |
| 70 | */ |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame] | 71 | void updateAvatar(@NonNull Drawable avatar); |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 72 | |
| 73 | /** |
yueg | 6518fdb | 2018-01-09 17:30:36 -0800 | [diff] [blame] | 74 | * Display text. The bubble's drawer is not expandable while text is showing, and the drawer will |
| 75 | * be closed if already open. |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 76 | * |
| 77 | * @param text the text to display to the user |
| 78 | */ |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame] | 79 | void showText(@NonNull CharSequence text); |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 80 | } |