@@ -75,20 +75,21 @@ class CustomTimerNotificationModule: ReactContextBaseJavaModule {
7575 Log .i(" ReactSystemNotification" , " NotificationModule: sendEvent (to JS): $eventName " )
7676 }
7777
78- override fun getName (): String {
78+ override fun getName (): String {
7979 return " CustomTimerNotification"
8080 }
81- fun convert (n : String ):String {
81+
82+ fun convert (n : String ):String {
8283 if (n.length == 1 ) return " 0" + n;
8384 return n
8485 }
8586
86-
87- fun notificationPop (objectData : ReadableMap ,remainingTime : String ,visbleTimer : Boolean ):NotificationCompat .Builder {
87+ fun notificationPop (objectData : ReadableMap ,remainingTime : String ,visbleTimer : Boolean ):NotificationCompat .Builder {
8888 val title = objectData.getString(" title" );
8989 val body = objectData.getString(" body" );
9090 val payload = objectData.getString(" payload" );
9191 val id = objectData.getInt(" id" );
92+ val isCountDown = objectData.getBoolean(" isCountDown" )
9293
9394 val datetime = objectData.getString(" date" )
9495 val sdf = SimpleDateFormat (" dd-MM-yyyy HH:mm:ss" , Locale .ENGLISH )
@@ -120,7 +121,7 @@ class CustomTimerNotificationModule: ReactContextBaseJavaModule {
120121 notificationLayout.setTextViewText(R .id.text,body)
121122
122123 // notificationLayout.setTextViewText(R.id.timer,remainingTime)
123- notificationLayout.setChronometerCountDown(R .id.simpleChronometer, true );
124+ notificationLayout.setChronometerCountDown(R .id.simpleChronometer, isCountDown );
124125 notificationLayout.setChronometer(R .id.simpleChronometer, remainingTime, (" %tM:%tS" ), true );
125126
126127
@@ -151,6 +152,7 @@ class CustomTimerNotificationModule: ReactContextBaseJavaModule {
151152 .setPriority(NotificationCompat .PRIORITY_HIGH )
152153 .setWhen(endTime.getTimeInMillis());
153154 val handler = Handler ()
155+ if (isCountDown)
154156 handler.postDelayed({
155157 notificationLayout.setChronometerCountDown(R .id.simpleChronometer, true );
156158 notificationLayout.setChronometer(R .id.simpleChronometer, remainingTime, (" %tM:%tS" ), false );
@@ -173,11 +175,21 @@ class CustomTimerNotificationModule: ReactContextBaseJavaModule {
173175 return notificationBuilder
174176 }
175177
176- fun updatePop (objectData : ReadableMap ,remainingTime : String ,visbleTimer : Boolean ){
178+ fun updatePop (objectData : ReadableMap ,remainingTime : String ,visbleTimer : Boolean ){
177179 val id = objectData.getInt(" id" );
178180 val notificationBuilder: NotificationCompat .Builder = notificationPop(objectData,remainingTime,visbleTimer)
179181 notificationManager.notify(id,notificationBuilder.build())
180182}
183+
184+ @ReactMethod
185+ fun RemoveTimer (objectData : ReadableMap ) {
186+ val id = objectData.getInt(" id" );
187+ val foreground = objectData.getBoolean(" foreground" );
188+
189+ removeNotification (id,foreground);
190+ }
191+
192+
181193 fun removeNotification (id : Int ,foreground : Boolean ) {
182194 val notificationManager = myContext.getSystemService(NotificationManager ::class .java)
183195 if (foreground)
0 commit comments