OLD | NEW |
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; | 5 package org.chromium.chrome.browser.media; |
6 | 6 |
7 import android.app.Notification; | 7 import android.app.Notification; |
8 import android.app.NotificationManager; | 8 import android.app.NotificationManager; |
9 import android.app.PendingIntent; | 9 import android.app.PendingIntent; |
10 import android.app.Service; | 10 import android.app.Service; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 notificationContentTextId = R.string.video_audio_call_notification_t
ext_2; | 152 notificationContentTextId = R.string.video_audio_call_notification_t
ext_2; |
153 notificationIconId = R.drawable.webrtc_video; | 153 notificationIconId = R.drawable.webrtc_video; |
154 } else if (mediaType == MEDIATYPE_VIDEO_ONLY) { | 154 } else if (mediaType == MEDIATYPE_VIDEO_ONLY) { |
155 notificationContentTextId = R.string.video_call_notification_text_2; | 155 notificationContentTextId = R.string.video_call_notification_text_2; |
156 notificationIconId = R.drawable.webrtc_video; | 156 notificationIconId = R.drawable.webrtc_video; |
157 } else if (mediaType == MEDIATYPE_AUDIO_ONLY) { | 157 } else if (mediaType == MEDIATYPE_AUDIO_ONLY) { |
158 notificationContentTextId = R.string.audio_call_notification_text_2; | 158 notificationContentTextId = R.string.audio_call_notification_text_2; |
159 notificationIconId = R.drawable.webrtc_audio; | 159 notificationIconId = R.drawable.webrtc_audio; |
160 } | 160 } |
161 | 161 |
162 Intent tabIntent = Tab.createBringTabToFrontIntent(notificationId); | |
163 PendingIntent contentIntent = PendingIntent.getActivity( | |
164 mContext, notificationId, tabIntent, 0); | |
165 String contentText = mContext.getResources().getString(notificationConte
ntTextId) + ". " | 162 String contentText = mContext.getResources().getString(notificationConte
ntTextId) + ". " |
166 + mContext.getResources().getString( | 163 + mContext.getResources().getString( |
167 R.string.media_notification_link_text, url); | 164 R.string.media_notification_link_text, url); |
168 | 165 |
169 NotificationCompat.Builder builder = new NotificationCompat.Builder(mCon
text) | 166 NotificationCompat.Builder builder = new NotificationCompat.Builder(mCon
text) |
170 .setAutoCancel(false) | 167 .setAutoCancel(false) |
171 .setOngoing(true) | 168 .setOngoing(true) |
172 .setContentIntent(contentIntent) | |
173 .setContentTitle(mContext.getString(R.string.app_name)) | 169 .setContentTitle(mContext.getString(R.string.app_name)) |
174 .setContentText(contentText) | 170 .setContentText(contentText) |
175 .setSmallIcon(notificationIconId) | 171 .setSmallIcon(notificationIconId) |
176 .setLocalOnly(true); | 172 .setLocalOnly(true); |
177 | 173 |
| 174 Intent tabIntent = Tab.createBringTabToFrontIntent(notificationId); |
| 175 if (tabIntent != null) { |
| 176 PendingIntent contentIntent = PendingIntent.getActivity( |
| 177 mContext, notificationId, tabIntent, 0); |
| 178 builder.setContentIntent(contentIntent); |
| 179 } |
| 180 |
178 Notification notification = new NotificationCompat.BigTextStyle(builder) | 181 Notification notification = new NotificationCompat.BigTextStyle(builder) |
179 .bigText(contentText).build(); | 182 .bigText(contentText).build(); |
180 mNotificationManager.notify(NOTIFICATION_NAMESPACE, notificationId, noti
fication); | 183 mNotificationManager.notify(NOTIFICATION_NAMESPACE, notificationId, noti
fication); |
181 mNotifications.put(notificationId, mediaType); | 184 mNotifications.put(notificationId, mediaType); |
182 updateSharedPreferencesEntry(notificationId, false); | 185 updateSharedPreferencesEntry(notificationId, false); |
183 } | 186 } |
184 | 187 |
185 /** | 188 /** |
186 * Update shared preferences entry with ids of the visible notifications. | 189 * Update shared preferences entry with ids of the visible notifications. |
187 * @param notificationId Id of the notification. | 190 * @param notificationId Id of the notification. |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 public static void clearMediaNotifications(Context context) { | 285 public static void clearMediaNotifications(Context context) { |
283 SharedPreferences sharedPreferences = | 286 SharedPreferences sharedPreferences = |
284 PreferenceManager.getDefaultSharedPreferences(context); | 287 PreferenceManager.getDefaultSharedPreferences(context); |
285 Set<String> notificationIds = | 288 Set<String> notificationIds = |
286 sharedPreferences.getStringSet(WEBRTC_NOTIFICATION_IDS, null); | 289 sharedPreferences.getStringSet(WEBRTC_NOTIFICATION_IDS, null); |
287 if (notificationIds == null || notificationIds.isEmpty()) return; | 290 if (notificationIds == null || notificationIds.isEmpty()) return; |
288 | 291 |
289 context.startService(new Intent(context, MediaCaptureNotificationService
.class)); | 292 context.startService(new Intent(context, MediaCaptureNotificationService
.class)); |
290 } | 293 } |
291 } | 294 } |
OLD | NEW |