2 * Copyright (C) 2012 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android
.support
.v4
.app
;
19 import android
.annotation
.TargetApi
;
20 import android
.app
.Notification
;
21 import android
.app
.PendingIntent
;
22 import android
.content
.Context
;
23 import android
.graphics
.Bitmap
;
24 import android
.os
.Build
;
25 import android
.widget
.RemoteViews
;
26 import java
.util
.ArrayList
;
28 @TargetApi(Build
.VERSION_CODES
.JELLY_BEAN
)
29 class NotificationCompatJellybean
{
30 private Notification
.Builder b
;
31 @SuppressWarnings("deprecation")
32 public NotificationCompatJellybean(Context context
, Notification n
,
33 CharSequence contentTitle
, CharSequence contentText
, CharSequence contentInfo
,
34 RemoteViews tickerView
, int number
,
35 PendingIntent contentIntent
, PendingIntent fullScreenIntent
, Bitmap largeIcon
,
36 int mProgressMax
, int mProgress
, boolean mProgressIndeterminate
,
37 boolean useChronometer
, int priority
, CharSequence subText
) {
38 b
= new Notification
.Builder(context
)
40 .setSmallIcon(n
.icon
, n
.iconLevel
)
41 .setContent(n
.contentView
)
42 .setTicker(n
.tickerText
, tickerView
)
43 .setSound(n
.sound
, n
.audioStreamType
)
44 .setVibrate(n
.vibrate
)
45 .setLights(n
.ledARGB
, n
.ledOnMS
, n
.ledOffMS
)
46 .setOngoing((n
.flags
& Notification
.FLAG_ONGOING_EVENT
) != 0)
47 .setOnlyAlertOnce((n
.flags
& Notification
.FLAG_ONLY_ALERT_ONCE
) != 0)
48 .setAutoCancel((n
.flags
& Notification
.FLAG_AUTO_CANCEL
) != 0)
49 .setDefaults(n
.defaults
)
50 .setContentTitle(contentTitle
)
51 .setContentText(contentText
)
53 .setContentInfo(contentInfo
)
54 .setContentIntent(contentIntent
)
55 .setDeleteIntent(n
.deleteIntent
)
56 .setFullScreenIntent(fullScreenIntent
,
57 (n
.flags
& Notification
.FLAG_HIGH_PRIORITY
) != 0)
58 .setLargeIcon(largeIcon
)
60 .setUsesChronometer(useChronometer
)
61 .setPriority(priority
)
62 .setProgress(mProgressMax
, mProgress
, mProgressIndeterminate
);
65 public void addAction(int icon
, CharSequence title
, PendingIntent intent
) {
66 b
.addAction(icon
, title
, intent
);
69 public void addBigTextStyle(CharSequence bigContentTitle
, boolean useSummary
,
70 CharSequence summaryText
, CharSequence bigText
) {
71 Notification
.BigTextStyle style
= new Notification
.BigTextStyle(b
)
72 .setBigContentTitle(bigContentTitle
)
75 style
.setSummaryText(summaryText
);
79 public void addBigPictureStyle(CharSequence bigContentTitle
, boolean useSummary
,
80 CharSequence summaryText
, Bitmap bigPicture
) {
81 Notification
.BigPictureStyle style
= new Notification
.BigPictureStyle(b
)
82 .setBigContentTitle(bigContentTitle
)
83 .bigPicture(bigPicture
);
85 style
.setSummaryText(summaryText
);
89 public void addInboxStyle(CharSequence bigContentTitle
, boolean useSummary
,
90 CharSequence summaryText
, ArrayList
<CharSequence
> texts
) {
91 Notification
.InboxStyle style
= new Notification
.InboxStyle(b
)
92 .setBigContentTitle(bigContentTitle
);
94 style
.setSummaryText(summaryText
);
96 for (CharSequence text
: texts
) {
101 public Notification
build() {