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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/notifications/CustomNotificationBuilder.java

Issue 2632103002: (Android) Replacing deprecated API with current (Closed)
Patch Set: Decreasing amount of deprecated API + cleanup Created 3 years, 11 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.notifications; 5 package org.chromium.chrome.browser.notifications;
6 6
7 import android.app.Notification; 7 import android.app.Notification;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.res.Resources; 9 import android.content.res.Resources;
10 import android.graphics.Bitmap; 10 import android.graphics.Bitmap;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // Note: this is not a NotificationCompat builder so be mindful of the 140 // Note: this is not a NotificationCompat builder so be mindful of the
141 // API level of methods you call on the builder. 141 // API level of methods you call on the builder.
142 Notification.Builder builder = new Notification.Builder(mContext); 142 Notification.Builder builder = new Notification.Builder(mContext);
143 builder.setTicker(mTickerText); 143 builder.setTicker(mTickerText);
144 builder.setContentIntent(mContentIntent); 144 builder.setContentIntent(mContentIntent);
145 builder.setDeleteIntent(mDeleteIntent); 145 builder.setDeleteIntent(mDeleteIntent);
146 builder.setDefaults(mDefaults); 146 builder.setDefaults(mDefaults);
147 builder.setVibrate(mVibratePattern); 147 builder.setVibrate(mVibratePattern);
148 builder.setWhen(mTimestamp); 148 builder.setWhen(mTimestamp);
149 builder.setOnlyAlertOnce(!mRenotify); 149 builder.setOnlyAlertOnce(!mRenotify);
150 builder.setContent(compactView); 150 ApiCompatibilityUtils.setContentViewForNotificationBuilder(builder, comp actView);
151 151
152 // Some things are duplicated in the builder to ensure the notification shows correctly on 152 // Some things are duplicated in the builder to ensure the notification shows correctly on
153 // Wear devices and custom lock screens. 153 // Wear devices and custom lock screens.
154 builder.setContentTitle(mTitle); 154 builder.setContentTitle(mTitle);
155 builder.setContentText(mBody); 155 builder.setContentText(mBody);
156 builder.setSubText(mOrigin); 156 builder.setSubText(mOrigin);
157 builder.setLargeIcon(getNormalizedLargeIcon()); 157 builder.setLargeIcon(getNormalizedLargeIcon());
158 setSmallIconOnBuilder(builder, mSmallIconId, mSmallIconBitmap); 158 setSmallIconOnBuilder(builder, mSmallIconId, mSmallIconBitmap);
159 for (Action action : mActions) { 159 for (Action action : mActions) {
160 addActionToBuilder(builder, action); 160 addActionToBuilder(builder, action);
161 } 161 }
162 if (mSettingsAction != null) { 162 if (mSettingsAction != null) {
163 addActionToBuilder(builder, mSettingsAction); 163 addActionToBuilder(builder, mSettingsAction);
164 } 164 }
165 setGroupOnBuilder(builder, mOrigin); 165 setGroupOnBuilder(builder, mOrigin);
166 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 166 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
167 // Notification.Builder.setPublicVersion was added in Android L. 167 // Notification.Builder.setPublicVersion was added in Android L.
168 builder.setPublicVersion(createPublicNotification(mContext)); 168 builder.setPublicVersion(createPublicNotification(mContext));
169 } 169 }
170 170
171 Notification notification = builder.build(); 171 return ApiCompatibilityUtils.notificationWithBigContentView(builder, big View);
172 notification.bigContentView = bigView;
173 return notification;
174 } 172 }
175 173
176 /** 174 /**
177 * If there are actions, shows the button related views, and adds a button f or each action. 175 * If there are actions, shows the button related views, and adds a button f or each action.
178 */ 176 */
179 private void addActionButtons(RemoteViews bigView) { 177 private void addActionButtons(RemoteViews bigView) {
180 // Remove the existing buttons in case an existing notification is being updated. 178 // Remove the existing buttons in case an existing notification is being updated.
181 bigView.removeAllViews(R.id.buttons); 179 bigView.removeAllViews(R.id.buttons);
182 180
183 // Always set the visibility of the views associated with the action but tons. The current 181 // Always set the visibility of the views associated with the action but tons. The current
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 314 }
317 315
318 /** 316 /**
319 * Whether to use the Material look and feel or fall back to Holo. 317 * Whether to use the Material look and feel or fall back to Holo.
320 */ 318 */
321 @VisibleForTesting 319 @VisibleForTesting
322 static boolean useMaterial() { 320 static boolean useMaterial() {
323 return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; 321 return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
324 } 322 }
325 } 323 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698