blob: cc7ac7c6fd65bd3710c794b4555e34bf6dfcd99e [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
19import android.app.PendingIntent;
20import android.graphics.drawable.Drawable;
21import android.graphics.drawable.Icon;
22import android.support.annotation.ColorInt;
23import android.support.annotation.NonNull;
24import android.support.annotation.Nullable;
25import android.support.annotation.Px;
26import com.google.auto.value.AutoValue;
27import java.util.Collections;
28import java.util.List;
29
30/** Info for displaying a {@link NewBubble} */
31@AutoValue
32public abstract class NewBubbleInfo {
33 @ColorInt
34 public abstract int getPrimaryColor();
35
36 public abstract Icon getPrimaryIcon();
37
yuega5a08d82017-10-31 14:11:53 -070038 @Nullable
39 public abstract Drawable getAvatar();
40
Eric Erfanian938468d2017-10-24 14:05:52 -070041 @Px
42 public abstract int getStartingYPosition();
43
44 @NonNull
45 public abstract List<Action> getActions();
46
47 public static Builder builder() {
48 return new AutoValue_NewBubbleInfo.Builder().setActions(Collections.emptyList());
49 }
50
51 public static Builder from(@NonNull NewBubbleInfo bubbleInfo) {
52 return builder()
53 .setPrimaryColor(bubbleInfo.getPrimaryColor())
54 .setPrimaryIcon(bubbleInfo.getPrimaryIcon())
55 .setStartingYPosition(bubbleInfo.getStartingYPosition())
yuegc875a5b2017-12-11 14:40:13 -080056 .setActions(bubbleInfo.getActions())
57 .setAvatar(bubbleInfo.getAvatar());
Eric Erfanian938468d2017-10-24 14:05:52 -070058 }
59
60 /** Builder for {@link NewBubbleInfo} */
61 @AutoValue.Builder
62 public abstract static class Builder {
63
64 public abstract Builder setPrimaryColor(@ColorInt int primaryColor);
65
66 public abstract Builder setPrimaryIcon(@NonNull Icon primaryIcon);
67
yuega5a08d82017-10-31 14:11:53 -070068 public abstract Builder setAvatar(@Nullable Drawable avatar);
69
Eric Erfanian938468d2017-10-24 14:05:52 -070070 public abstract Builder setStartingYPosition(@Px int startingYPosition);
71
72 public abstract Builder setActions(List<Action> actions);
73
74 public abstract NewBubbleInfo build();
75 }
76
77 /** Represents actions to be shown in the bubble when expanded */
78 @AutoValue
79 public abstract static class Action {
80
81 public abstract Drawable getIconDrawable();
82
yueg84ac49b2017-11-01 16:22:28 -070083 @NonNull
Eric Erfanian938468d2017-10-24 14:05:52 -070084 public abstract CharSequence getName();
85
86 @NonNull
87 public abstract PendingIntent getIntent();
88
yueg2a422f72018-01-24 15:20:10 -080089 public abstract boolean isCheckable();
Eric Erfanian938468d2017-10-24 14:05:52 -070090
91 public abstract boolean isChecked();
92
93 public static Builder builder() {
yueg2a422f72018-01-24 15:20:10 -080094 return new AutoValue_NewBubbleInfo_Action.Builder().setCheckable(true).setChecked(false);
Eric Erfanian938468d2017-10-24 14:05:52 -070095 }
96
97 public static Builder from(@NonNull Action action) {
98 return builder()
99 .setIntent(action.getIntent())
100 .setChecked(action.isChecked())
yueg2a422f72018-01-24 15:20:10 -0800101 .setCheckable(action.isCheckable())
Eric Erfanian938468d2017-10-24 14:05:52 -0700102 .setName(action.getName())
103 .setIconDrawable(action.getIconDrawable());
104 }
105
106 /** Builder for {@link Action} */
107 @AutoValue.Builder
108 public abstract static class Builder {
109
110 public abstract Builder setIconDrawable(Drawable iconDrawable);
111
yueg84ac49b2017-11-01 16:22:28 -0700112 public abstract Builder setName(@NonNull CharSequence name);
Eric Erfanian938468d2017-10-24 14:05:52 -0700113
114 public abstract Builder setIntent(@NonNull PendingIntent intent);
115
yueg2a422f72018-01-24 15:20:10 -0800116 public abstract Builder setCheckable(boolean enabled);
Eric Erfanian938468d2017-10-24 14:05:52 -0700117
118 public abstract Builder setChecked(boolean checked);
119
120 public abstract Action build();
121 }
122 }
123}