@@ -36,7 +36,8 @@ data class NotificationConfig(
3636 val subtitle : String? ,
3737 val smallIcon : Int = android.R .drawable.ic_dialog_info,
3838 val countdownDuration : Long = 5000 ,
39- val payload : String?
39+ val payload : String? ,
40+ val body : String?
4041)
4142
4243
@@ -60,12 +61,11 @@ class AnimatedNotificationManager(
6061 try {
6162 val extras = intent.extras
6263 val params: WritableMap = Arguments .createMap()
64+ params.putString(" id" , extras!! .getString(" id" ))
6365 params.putString(" action" , extras!! .getString(" action" ))
6466 params.putString(" payload" , extras!! .getString(" payload" ))
6567 Log .d(TAG , extras?.getString(" payload" )? : " " )
66- if (extras!! .getString(" action" ) == " cancel" ){
67- disableCurrentNotification = true
68- }
68+ disableCurrentNotification = true
6969 context.getJSModule(DeviceEventManagerModule .RCTDeviceEventEmitter ::class .java)
7070 .emit(
7171 " notificationClick" ,
@@ -115,7 +115,8 @@ class AnimatedNotificationManager(
115115 val remoteViews = RemoteViews (context.packageName, R .layout.gen_notification_open)
116116
117117 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 )
119120
120121 frames.forEach { frame ->
121122 val frameView = RemoteViews (context.packageName, R .layout.giffy_image)
@@ -143,25 +144,30 @@ class AnimatedNotificationManager(
143144 }
144145 } else null
145146
146- val subtitleHtml = if (config.title != null ) {
147+ val bodyHtml = if (config.title != null ) {
147148 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 )
149150 } else {
150- Html .fromHtml(config.subtitle )
151+ Html .fromHtml(config.body )
151152 }
152153 } else null
153154
154155 if (titleHtml != null )
155156 remoteViews.setTextViewText(R .id.title, titleHtml)
156157
157- if (subtitleHtml != null )
158- remoteViews.setTextViewText(R .id.subtitle, subtitleHtml )
158+ if (bodyHtml != null )
159+ remoteViews.setTextViewText(R .id.body, bodyHtml )
159160 }
160161
161162 private fun configureChronometer (remoteViews : RemoteViews , countdownDuration : Long ) {
163+ if (countdownDuration != = null ){
162164 val chronometerBaseTime = countdownDuration
163165 remoteViews.setChronometerCountDown(R .id.simpleChronometer, true )
164166 remoteViews.setChronometer(R .id.simpleChronometer, chronometerBaseTime, null , true )
167+ } else {
168+ remoteViews.setViewVisibility(R .id.simpleChronometer, View .GONE )
169+ }
170+
165171 }
166172
167173 private fun buildNotification (remoteViews : RemoteViews , config : NotificationConfig ): NotificationCompat .Builder {
@@ -204,6 +210,9 @@ class AnimatedNotificationManager(
204210 .setOnlyAlertOnce(true )
205211 .setAutoCancel(true )
206212 .setDeleteIntent(onDismissPendingIntent)
213+ .apply {
214+ config.subtitle?.let { setSubText(it) }
215+ }
207216 .setContentIntent(pendingIntent)
208217
209218
0 commit comments