blob: 44232f39bf66783a6b1bf8da40869c52b63cc17b [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())
56 .setActions(bubbleInfo.getActions());
57 }
58
59 /** Builder for {@link NewBubbleInfo} */
60 @AutoValue.Builder
61 public abstract static class Builder {
62
63 public abstract Builder setPrimaryColor(@ColorInt int primaryColor);
64
65 public abstract Builder setPrimaryIcon(@NonNull Icon primaryIcon);
66
yuega5a08d82017-10-31 14:11:53 -070067 public abstract Builder setAvatar(@Nullable Drawable avatar);
68
Eric Erfanian938468d2017-10-24 14:05:52 -070069 public abstract Builder setStartingYPosition(@Px int startingYPosition);
70
71 public abstract Builder setActions(List<Action> actions);
72
73 public abstract NewBubbleInfo build();
74 }
75
76 /** Represents actions to be shown in the bubble when expanded */
77 @AutoValue
78 public abstract static class Action {
79
80 public abstract Drawable getIconDrawable();
81
82 @Nullable
83 public abstract CharSequence getName();
84
85 @NonNull
86 public abstract PendingIntent getIntent();
87
88 public abstract boolean isEnabled();
89
90 public abstract boolean isChecked();
91
92 public static Builder builder() {
93 return new AutoValue_NewBubbleInfo_Action.Builder().setEnabled(true).setChecked(false);
94 }
95
96 public static Builder from(@NonNull Action action) {
97 return builder()
98 .setIntent(action.getIntent())
99 .setChecked(action.isChecked())
100 .setEnabled(action.isEnabled())
101 .setName(action.getName())
102 .setIconDrawable(action.getIconDrawable());
103 }
104
105 /** Builder for {@link Action} */
106 @AutoValue.Builder
107 public abstract static class Builder {
108
109 public abstract Builder setIconDrawable(Drawable iconDrawable);
110
111 public abstract Builder setName(@Nullable CharSequence name);
112
113 public abstract Builder setIntent(@NonNull PendingIntent intent);
114
115 public abstract Builder setEnabled(boolean enabled);
116
117 public abstract Builder setChecked(boolean checked);
118
119 public abstract Action build();
120 }
121 }
122}