1/*
2 * Copyright (C) 2012 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 android.support.v4.app;
18
19import android.app.Notification;
20import android.app.PendingIntent;
21import android.content.Context;
22import android.graphics.Bitmap;
23import android.widget.RemoteViews;
24
25class NotificationCompatIceCreamSandwich {
26
27    public static class Builder implements NotificationBuilderWithBuilderAccessor {
28
29        private Notification.Builder b;
30
31        public Builder(Context context, Notification n, CharSequence contentTitle,
32                CharSequence contentText, CharSequence contentInfo, RemoteViews tickerView,
33                int number, PendingIntent contentIntent, PendingIntent fullScreenIntent,
34                Bitmap largeIcon, int progressMax, int progress, boolean progressIndeterminate) {
35            b = new Notification.Builder(context)
36                    .setWhen(n.when)
37                    .setSmallIcon(n.icon, n.iconLevel)
38                    .setContent(n.contentView)
39                    .setTicker(n.tickerText, tickerView)
40                    .setSound(n.sound, n.audioStreamType)
41                    .setVibrate(n.vibrate)
42                    .setLights(n.ledARGB, n.ledOnMS, n.ledOffMS)
43                    .setOngoing((n.flags & Notification.FLAG_ONGOING_EVENT) != 0)
44                    .setOnlyAlertOnce((n.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0)
45                    .setAutoCancel((n.flags & Notification.FLAG_AUTO_CANCEL) != 0)
46                    .setDefaults(n.defaults)
47                    .setContentTitle(contentTitle)
48                    .setContentText(contentText)
49                    .setContentInfo(contentInfo)
50                    .setContentIntent(contentIntent)
51                    .setDeleteIntent(n.deleteIntent)
52                    .setFullScreenIntent(fullScreenIntent,
53                            (n.flags & Notification.FLAG_HIGH_PRIORITY) != 0)
54                    .setLargeIcon(largeIcon)
55                    .setNumber(number)
56                    .setProgress(progressMax, progress, progressIndeterminate);
57        }
58
59        @Override
60        public Notification.Builder getBuilder() {
61            return b;
62        }
63
64        @Override
65        public Notification build() {
66            return b.getNotification();
67        }
68    }
69}
70