OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 package org.chromium.chrome.browser.notifications; | |
6 | |
7 import android.app.Notification; | |
8 import android.app.PendingIntent; | |
9 import android.content.Context; | |
10 import android.graphics.Bitmap; | |
11 import android.support.v4.app.NotificationCompat; | |
12 | |
13 /** | |
14 * Wraps a NotificationCompat.Builder object. | |
15 * Created by awdf on 2/16/17. | |
Peter Beverloo
2017/02/24 00:43:01
nit: delete (does your editor do this)?
awdf
2017/02/24 00:56:33
darn, thought I got them all. And yes, but I will
| |
16 */ | |
17 public class NotificationCompatBuilder implements ChromeNotificationBuilder { | |
18 private final NotificationCompat.Builder mBuilder; | |
19 | |
20 public NotificationCompatBuilder(Context context) { | |
21 mBuilder = new NotificationCompat.Builder(context); | |
22 } | |
23 | |
24 @Override | |
25 public ChromeNotificationBuilder setAutoCancel(boolean autoCancel) { | |
26 mBuilder.setAutoCancel(autoCancel); | |
27 return this; | |
28 } | |
29 | |
30 @Override | |
31 public ChromeNotificationBuilder setContentIntent(PendingIntent contentInten t) { | |
32 mBuilder.setContentIntent(contentIntent); | |
33 return this; | |
34 } | |
35 | |
36 @Override | |
37 public ChromeNotificationBuilder setContentTitle(String title) { | |
38 mBuilder.setContentTitle(title); | |
39 return this; | |
40 } | |
41 | |
42 @Override | |
43 public ChromeNotificationBuilder setContentText(String text) { | |
44 mBuilder.setContentText(text); | |
45 return this; | |
46 } | |
47 | |
48 @Override | |
49 public ChromeNotificationBuilder setSmallIcon(int icon) { | |
50 mBuilder.setSmallIcon(icon); | |
51 return this; | |
52 } | |
53 | |
54 @Override | |
55 public ChromeNotificationBuilder setTicker(String text) { | |
56 mBuilder.setTicker(text); | |
57 return this; | |
58 } | |
59 | |
60 @Override | |
61 public ChromeNotificationBuilder setLocalOnly(boolean localOnly) { | |
62 mBuilder.setLocalOnly(localOnly); | |
63 return this; | |
64 } | |
65 | |
66 @Override | |
67 public ChromeNotificationBuilder setGroup(String group) { | |
68 mBuilder.setGroup(group); | |
69 return this; | |
70 } | |
71 | |
72 @Override | |
73 public ChromeNotificationBuilder setOngoing(boolean ongoing) { | |
74 mBuilder.setOngoing(ongoing); | |
75 return this; | |
76 } | |
77 | |
78 @Override | |
79 public ChromeNotificationBuilder setVisibility(int visibility) { | |
80 mBuilder.setVisibility(visibility); | |
81 return this; | |
82 } | |
83 | |
84 @Override | |
85 public ChromeNotificationBuilder setShowWhen(boolean showWhen) { | |
86 mBuilder.setShowWhen(showWhen); | |
87 return this; | |
88 } | |
89 | |
90 @Override | |
91 public ChromeNotificationBuilder addAction(int icon, String title, PendingIn tent intent) { | |
92 mBuilder.addAction(icon, title, intent); | |
93 return this; | |
94 } | |
95 | |
96 @Override | |
97 public ChromeNotificationBuilder setDeleteIntent(PendingIntent intent) { | |
98 mBuilder.setDeleteIntent(intent); | |
99 return this; | |
100 } | |
101 | |
102 @Override | |
103 public ChromeNotificationBuilder setPriority(int pri) { | |
104 mBuilder.setPriority(pri); | |
105 return this; | |
106 } | |
107 | |
108 @Override | |
109 public ChromeNotificationBuilder setProgress(int max, int percentage, boolea n indeterminate) { | |
110 mBuilder.setProgress(max, percentage, indeterminate); | |
111 return this; | |
112 } | |
113 | |
114 @Override | |
115 public ChromeNotificationBuilder setSubText(String text) { | |
116 mBuilder.setSubText(text); | |
117 return this; | |
118 } | |
119 | |
120 @Override | |
121 public ChromeNotificationBuilder setContentInfo(String info) { | |
122 mBuilder.setContentInfo(info); | |
123 return this; | |
124 } | |
125 | |
126 @Override | |
127 public ChromeNotificationBuilder setWhen(long time) { | |
128 mBuilder.setWhen(time); | |
129 return this; | |
130 } | |
131 | |
132 @Override | |
133 public ChromeNotificationBuilder setLargeIcon(Bitmap icon) { | |
134 mBuilder.setLargeIcon(icon); | |
135 return this; | |
136 } | |
137 | |
138 @Override | |
139 public ChromeNotificationBuilder setVibrate(long[] vibratePattern) { | |
140 mBuilder.setVibrate(vibratePattern); | |
141 return this; | |
142 } | |
143 | |
144 @Override | |
145 public Notification buildWithBigTextStyle(String bigText) { | |
146 NotificationCompat.BigTextStyle bigTextStyle = | |
147 new NotificationCompat.BigTextStyle(mBuilder); | |
148 bigTextStyle.bigText(bigText); | |
149 return bigTextStyle.build(); | |
150 } | |
151 | |
152 @Override | |
153 public Notification build() { | |
154 return mBuilder.build(); | |
155 } | |
156 } | |
OLD | NEW |