@@ -36,7 +36,8 @@ data class NotificationConfig(
36
36
val subtitle : String? ,
37
37
val smallIcon : Int = android.R .drawable.ic_dialog_info,
38
38
val countdownDuration : Long = 5000 ,
39
- val payload : String?
39
+ val payload : String? ,
40
+ val body : String?
40
41
)
41
42
42
43
@@ -60,12 +61,11 @@ class AnimatedNotificationManager(
60
61
try {
61
62
val extras = intent.extras
62
63
val params: WritableMap = Arguments .createMap()
64
+ params.putString(" id" , extras!! .getString(" id" ))
63
65
params.putString(" action" , extras!! .getString(" action" ))
64
66
params.putString(" payload" , extras!! .getString(" payload" ))
65
67
Log .d(TAG , extras?.getString(" payload" )? : " " )
66
- if (extras!! .getString(" action" ) == " cancel" ){
67
- disableCurrentNotification = true
68
- }
68
+ disableCurrentNotification = true
69
69
context.getJSModule(DeviceEventManagerModule .RCTDeviceEventEmitter ::class .java)
70
70
.emit(
71
71
" notificationClick" ,
@@ -115,7 +115,8 @@ class AnimatedNotificationManager(
115
115
val remoteViews = RemoteViews (context.packageName, R .layout.gen_notification_open)
116
116
117
117
if (config.gifUrl != = null ){
118
- val frames = processGif(config.gifUrl, memoryLimitMB = GIF_MEMORY_LIMIT_MB )
118
+ val gifProcessor = GifProcessor ()
119
+ val frames = gifProcessor.processGif(config.gifUrl, memoryLimitMB = GIF_MEMORY_LIMIT_MB )
119
120
120
121
frames.forEach { frame ->
121
122
val frameView = RemoteViews (context.packageName, R .layout.giffy_image)
@@ -143,25 +144,30 @@ class AnimatedNotificationManager(
143
144
}
144
145
} else null
145
146
146
- val subtitleHtml = if (config.title != null ) {
147
+ val bodyHtml = if (config.title != null ) {
147
148
if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .N ) {
148
- Html .fromHtml(config.subtitle , Html .FROM_HTML_MODE_COMPACT )
149
+ Html .fromHtml(config.body , Html .FROM_HTML_MODE_COMPACT )
149
150
} else {
150
- Html .fromHtml(config.subtitle )
151
+ Html .fromHtml(config.body )
151
152
}
152
153
} else null
153
154
154
155
if (titleHtml != null )
155
156
remoteViews.setTextViewText(R .id.title, titleHtml)
156
157
157
- if (subtitleHtml != null )
158
- remoteViews.setTextViewText(R .id.subtitle, subtitleHtml )
158
+ if (bodyHtml != null )
159
+ remoteViews.setTextViewText(R .id.body, bodyHtml )
159
160
}
160
161
161
162
private fun configureChronometer (remoteViews : RemoteViews , countdownDuration : Long ) {
163
+ if (countdownDuration != = null ){
162
164
val chronometerBaseTime = countdownDuration
163
165
remoteViews.setChronometerCountDown(R .id.simpleChronometer, true )
164
166
remoteViews.setChronometer(R .id.simpleChronometer, chronometerBaseTime, null , true )
167
+ } else {
168
+ remoteViews.setViewVisibility(R .id.simpleChronometer, View .GONE )
169
+ }
170
+
165
171
}
166
172
167
173
private fun buildNotification (remoteViews : RemoteViews , config : NotificationConfig ): NotificationCompat .Builder {
@@ -204,6 +210,9 @@ class AnimatedNotificationManager(
204
210
.setOnlyAlertOnce(true )
205
211
.setAutoCancel(true )
206
212
.setDeleteIntent(onDismissPendingIntent)
213
+ .apply {
214
+ config.subtitle?.let { setSubText(it) }
215
+ }
207
216
.setContentIntent(pendingIntent)
208
217
209
218
0 commit comments