Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.newbubble; |
| 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 com.android.newbubble.NewBubbleInfo.Action; |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 22 | import java.util.List; |
| 23 | |
| 24 | /** |
| 25 | * Creates and manages a bubble window from information in a {@link NewBubbleInfo}. Before creating, |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame^] | 26 | * be sure to check whether bubbles may be shown using {@code Settings.canDrawOverlays(context)} and |
| 27 | * request permission if necessary |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 28 | */ |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame^] | 29 | public interface NewBubble { |
yueg | 81a77ff | 2017-12-05 10:29:03 -0800 | [diff] [blame] | 30 | |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 31 | /** |
| 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 | */ |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame^] | 35 | void show(); |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 36 | |
| 37 | /** Hide the bubble. */ |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame^] | 38 | void hide(); |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 39 | |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame^] | 40 | /** Hide the bubble and reset to initial state */ |
| 41 | void hideAndReset(); |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 42 | |
| 43 | /** Returns whether the bubble is currently visible */ |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame^] | 44 | boolean isVisible(); |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 45 | |
| 46 | /** |
| 47 | * Set the info for this Bubble to display |
| 48 | * |
| 49 | * @param bubbleInfo the BubbleInfo to display in this Bubble. |
| 50 | */ |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame^] | 51 | void setBubbleInfo(@NonNull NewBubbleInfo bubbleInfo); |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 52 | |
| 53 | /** |
| 54 | * Update the state and behavior of actions. |
| 55 | * |
| 56 | * @param actions the new state of the bubble's actions |
| 57 | */ |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame^] | 58 | void updateActions(@NonNull List<Action> actions); |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 59 | |
yueg | a5a08d8 | 2017-10-31 14:11:53 -0700 | [diff] [blame] | 60 | /** |
| 61 | * Update the avatar from photo. |
| 62 | * |
| 63 | * @param avatar the new photo avatar in the bubble's primary button |
| 64 | */ |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame^] | 65 | void updatePhotoAvatar(@NonNull Drawable avatar); |
yueg | a5a08d8 | 2017-10-31 14:11:53 -0700 | [diff] [blame] | 66 | |
| 67 | /** |
| 68 | * Update the avatar. |
| 69 | * |
| 70 | * @param avatar the new avatar in the bubble's primary button |
| 71 | */ |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame^] | 72 | void updateAvatar(@NonNull Drawable avatar); |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 73 | |
| 74 | /** |
yueg | 6518fdb | 2018-01-09 17:30:36 -0800 | [diff] [blame] | 75 | * Display text. The bubble's drawer is not expandable while text is showing, and the drawer will |
| 76 | * be closed if already open. |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 77 | * |
| 78 | * @param text the text to display to the user |
| 79 | */ |
yueg | b6e16f5 | 2018-01-31 12:02:19 -0800 | [diff] [blame^] | 80 | void showText(@NonNull CharSequence text); |
Eric Erfanian | 938468d | 2017-10-24 14:05:52 -0700 | [diff] [blame] | 81 | } |