Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaNotificationInfo.java

Issue 1847063005: [Media, UI] Change MediaNotification style to MediaStyle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed nits Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.media.ui; 5 package org.chromium.chrome.browser.media.ui;
6 6
7 import android.content.Intent; 7 import android.content.Intent;
8 import android.graphics.Bitmap; 8 import android.graphics.Bitmap;
9 import android.text.TextUtils; 9 import android.text.TextUtils;
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 * Use this class to construct an instance of {@link MediaNotificationInfo}. 42 * Use this class to construct an instance of {@link MediaNotificationInfo}.
43 */ 43 */
44 public static final class Builder { 44 public static final class Builder {
45 45
46 private MediaMetadata mMetadata = null; 46 private MediaMetadata mMetadata = null;
47 private boolean mIsPaused = false; 47 private boolean mIsPaused = false;
48 private String mOrigin = ""; 48 private String mOrigin = "";
49 private int mTabId = Tab.INVALID_TAB_ID; 49 private int mTabId = Tab.INVALID_TAB_ID;
50 private boolean mIsPrivate = true; 50 private boolean mIsPrivate = true;
51 private int mIcon = -1; 51 private int mIcon = -1;
52 private Bitmap mLargeIcon = null;
52 private int mActions = ACTION_PLAY_PAUSE | ACTION_SWIPEAWAY; 53 private int mActions = ACTION_PLAY_PAUSE | ACTION_SWIPEAWAY;
53 private int mId = INVALID_ID; 54 private int mId = INVALID_ID;
54 private Intent mContentIntent = null; 55 private Intent mContentIntent = null;
55 private Bitmap mImage = null;
56 private MediaNotificationListener mListener = null; 56 private MediaNotificationListener mListener = null;
57 57
58 /** 58 /**
59 * Initializes the builder with the default values. 59 * Initializes the builder with the default values.
60 */ 60 */
61 public Builder() { 61 public Builder() {
62 } 62 }
63 63
64 public MediaNotificationInfo build() { 64 public MediaNotificationInfo build() {
65 assert mMetadata != null; 65 assert mMetadata != null;
66 assert mOrigin != null; 66 assert mOrigin != null;
67 assert mListener != null; 67 assert mListener != null;
68 68
69 return new MediaNotificationInfo( 69 return new MediaNotificationInfo(
70 mMetadata, 70 mMetadata,
71 mIsPaused, 71 mIsPaused,
72 mOrigin, 72 mOrigin,
73 mTabId, 73 mTabId,
74 mIsPrivate, 74 mIsPrivate,
75 mIcon, 75 mIcon,
76 mLargeIcon,
76 mActions, 77 mActions,
77 mId, 78 mId,
78 mImage,
79 mContentIntent, 79 mContentIntent,
80 mListener); 80 mListener);
81 } 81 }
82 82
83 public Builder setMetadata(MediaMetadata metadata) { 83 public Builder setMetadata(MediaMetadata metadata) {
84 mMetadata = metadata; 84 mMetadata = metadata;
85 return this; 85 return this;
86 } 86 }
87 87
88 public Builder setPaused(boolean isPaused) { 88 public Builder setPaused(boolean isPaused) {
(...skipping 14 matching lines...) Expand all
103 public Builder setPrivate(boolean isPrivate) { 103 public Builder setPrivate(boolean isPrivate) {
104 mIsPrivate = isPrivate; 104 mIsPrivate = isPrivate;
105 return this; 105 return this;
106 } 106 }
107 107
108 public Builder setIcon(int icon) { 108 public Builder setIcon(int icon) {
109 mIcon = icon; 109 mIcon = icon;
110 return this; 110 return this;
111 } 111 }
112 112
113 public Builder setLargeIcon(Bitmap icon) {
114 mLargeIcon = icon;
115 return this;
116 }
117
113 public Builder setActions(int actions) { 118 public Builder setActions(int actions) {
114 mActions = actions; 119 mActions = actions;
115 return this; 120 return this;
116 } 121 }
117 122
118 public Builder setId(int id) { 123 public Builder setId(int id) {
119 mId = id; 124 mId = id;
120 return this; 125 return this;
121 } 126 }
122 127
123 public Builder setImage(Bitmap image) {
124 mImage = image;
125 return this;
126 }
127
128 public Builder setContentIntent(Intent intent) { 128 public Builder setContentIntent(Intent intent) {
129 mContentIntent = intent; 129 mContentIntent = intent;
130 return this; 130 return this;
131 } 131 }
132 132
133 public Builder setListener(MediaNotificationListener listener) { 133 public Builder setListener(MediaNotificationListener listener) {
134 mListener = listener; 134 mListener = listener;
135 return this; 135 return this;
136 } 136 }
137 } 137 }
(...skipping 27 matching lines...) Expand all
165 * Whether the media notification should be considered as private. 165 * Whether the media notification should be considered as private.
166 */ 166 */
167 public final boolean isPrivate; 167 public final boolean isPrivate;
168 168
169 /** 169 /**
170 * The id of the notification icon from R.drawable. 170 * The id of the notification icon from R.drawable.
171 */ 171 */
172 public final int icon; 172 public final int icon;
173 173
174 /** 174 /**
175 * The Bitmap resource used for a large icon.
176 */
177 public final Bitmap largeIcon;
178
179 /**
175 * The id to use for the notification itself. 180 * The id to use for the notification itself.
176 */ 181 */
177 public final int id; 182 public final int id;
178 183
179 /** 184 /**
180 * The bitmap of the image, if any.
181 */
182 public final Bitmap image;
183
184 /**
185 * The intent to send when the notification is selected. 185 * The intent to send when the notification is selected.
186 */ 186 */
187 public final Intent contentIntent; 187 public final Intent contentIntent;
188 188
189 /** 189 /**
190 * The listener for the control events. 190 * The listener for the control events.
191 */ 191 */
192 public final MediaNotificationListener listener; 192 public final MediaNotificationListener listener;
193 193
194 /** 194 /**
(...skipping 17 matching lines...) Expand all
212 return (mActions & ACTION_SWIPEAWAY) != 0; 212 return (mActions & ACTION_SWIPEAWAY) != 0;
213 } 213 }
214 214
215 /** 215 /**
216 * Create a new MediaNotificationInfo. 216 * Create a new MediaNotificationInfo.
217 * @param metadata The metadata associated with the media. 217 * @param metadata The metadata associated with the media.
218 * @param isPaused The current state of the media, paused or not. 218 * @param isPaused The current state of the media, paused or not.
219 * @param origin The origin of the tab containing the media. 219 * @param origin The origin of the tab containing the media.
220 * @param tabId The id of the tab containing the media. 220 * @param tabId The id of the tab containing the media.
221 * @param isPrivate Whether the media notification should be considered as p rivate. 221 * @param isPrivate Whether the media notification should be considered as p rivate.
222 * @param image An image associated with the media, displayed in icons etc..
223 * @param contentIntent the intent to send when the notification is selected . 222 * @param contentIntent the intent to send when the notification is selected .
224 * @param listener The listener for the control events. 223 * @param listener The listener for the control events.
225 */ 224 */
226 private MediaNotificationInfo( 225 private MediaNotificationInfo(
227 MediaMetadata metadata, 226 MediaMetadata metadata,
228 boolean isPaused, 227 boolean isPaused,
229 String origin, 228 String origin,
230 int tabId, 229 int tabId,
231 boolean isPrivate, 230 boolean isPrivate,
232 int icon, 231 int icon,
232 Bitmap largeIcon,
233 int actions, 233 int actions,
234 int id, 234 int id,
235 Bitmap image,
236 Intent contentIntent, 235 Intent contentIntent,
237 MediaNotificationListener listener) { 236 MediaNotificationListener listener) {
238 this.metadata = metadata; 237 this.metadata = metadata;
239 this.isPaused = isPaused; 238 this.isPaused = isPaused;
240 this.origin = origin; 239 this.origin = origin;
241 this.tabId = tabId; 240 this.tabId = tabId;
242 this.isPrivate = isPrivate; 241 this.isPrivate = isPrivate;
243 this.icon = icon; 242 this.icon = icon;
243 this.largeIcon = largeIcon;
244 this.mActions = actions; 244 this.mActions = actions;
245 this.id = id; 245 this.id = id;
246 this.contentIntent = contentIntent; 246 this.contentIntent = contentIntent;
247 this.image = image;
248 this.listener = listener; 247 this.listener = listener;
249 } 248 }
250 249
251 @Override 250 @Override
252 public boolean equals(Object obj) { 251 public boolean equals(Object obj) {
253 if (obj == this) return true; 252 if (obj == this) return true;
254 if (!(obj instanceof MediaNotificationInfo)) return false; 253 if (!(obj instanceof MediaNotificationInfo)) return false;
255 254
256 MediaNotificationInfo other = (MediaNotificationInfo) obj; 255 MediaNotificationInfo other = (MediaNotificationInfo) obj;
257 return isPaused == other.isPaused 256 return isPaused == other.isPaused
258 && isPrivate == other.isPrivate 257 && isPrivate == other.isPrivate
259 && tabId == other.tabId 258 && tabId == other.tabId
260 && icon == other.icon 259 && icon == other.icon
260 && (largeIcon == other.largeIcon
261 || (largeIcon != null && largeIcon.sameAs(other.largeIco n)))
261 && mActions == other.mActions 262 && mActions == other.mActions
262 && id == other.id 263 && id == other.id
263 && (metadata == other.metadata 264 && (metadata == other.metadata
264 || (metadata != null && metadata.equals(other.metadata)) ) 265 || (metadata != null && metadata.equals(other.metadata)) )
265 && TextUtils.equals(origin, other.origin) 266 && TextUtils.equals(origin, other.origin)
266 && (image == other.image || (image != null && image.sameAs(other .image)))
267 && (contentIntent == other.contentIntent 267 && (contentIntent == other.contentIntent
268 || (contentIntent != null && contentIntent.equals(other. contentIntent))) 268 || (contentIntent != null && contentIntent.equals(other. contentIntent)))
269 && (listener == other.listener 269 && (listener == other.listener
270 || (listener != null && listener.equals(other.listener)) ); 270 || (listener != null && listener.equals(other.listener)) );
271 } 271 }
272 272
273 @Override 273 @Override
274 public int hashCode() { 274 public int hashCode() {
275 int result = isPaused ? 1 : 0; 275 int result = isPaused ? 1 : 0;
276 result = 31 * result + (isPrivate ? 1 : 0); 276 result = 31 * result + (isPrivate ? 1 : 0);
277 result = 31 * result + (metadata == null ? 0 : metadata.hashCode()); 277 result = 31 * result + (metadata == null ? 0 : metadata.hashCode());
278 result = 31 * result + (origin == null ? 0 : origin.hashCode()); 278 result = 31 * result + (origin == null ? 0 : origin.hashCode());
279 result = 31 * result + (image == null ? 0 : image.hashCode());
280 result = 31 * result + (contentIntent == null ? 0 : contentIntent.hashCo de()); 279 result = 31 * result + (contentIntent == null ? 0 : contentIntent.hashCo de());
281 result = 31 * result + tabId; 280 result = 31 * result + tabId;
282 result = 31 * result + icon; 281 result = 31 * result + icon;
282 result = 31 * result + (largeIcon == null ? 0 : largeIcon.hashCode());
283 result = 31 * result + mActions; 283 result = 31 * result + mActions;
284 result = 31 * result + id; 284 result = 31 * result + id;
285 result = 31 * result + listener.hashCode(); 285 result = 31 * result + listener.hashCode();
286 return result; 286 return result;
287 } 287 }
288 } 288 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698