@@ -75,20 +75,21 @@ class CustomTimerNotificationModule: ReactContextBaseJavaModule {
75
75
Log .i(" ReactSystemNotification" , " NotificationModule: sendEvent (to JS): $eventName " )
76
76
}
77
77
78
- override fun getName (): String {
78
+ override fun getName (): String {
79
79
return " CustomTimerNotification"
80
80
}
81
- fun convert (n : String ):String {
81
+
82
+ fun convert (n : String ):String {
82
83
if (n.length == 1 ) return " 0" + n;
83
84
return n
84
85
}
85
86
86
-
87
- fun notificationPop (objectData : ReadableMap ,remainingTime : String ,visbleTimer : Boolean ):NotificationCompat .Builder {
87
+ fun notificationPop (objectData : ReadableMap ,remainingTime : String ,visbleTimer : Boolean ):NotificationCompat .Builder {
88
88
val title = objectData.getString(" title" );
89
89
val body = objectData.getString(" body" );
90
90
val payload = objectData.getString(" payload" );
91
91
val id = objectData.getInt(" id" );
92
+ val isCountDown = objectData.getBoolean(" isCountDown" )
92
93
93
94
val datetime = objectData.getString(" date" )
94
95
val sdf = SimpleDateFormat (" dd-MM-yyyy HH:mm:ss" , Locale .ENGLISH )
@@ -120,7 +121,7 @@ class CustomTimerNotificationModule: ReactContextBaseJavaModule {
120
121
notificationLayout.setTextViewText(R .id.text,body)
121
122
122
123
// notificationLayout.setTextViewText(R.id.timer,remainingTime)
123
- notificationLayout.setChronometerCountDown(R .id.simpleChronometer, true );
124
+ notificationLayout.setChronometerCountDown(R .id.simpleChronometer, isCountDown );
124
125
notificationLayout.setChronometer(R .id.simpleChronometer, remainingTime, (" %tM:%tS" ), true );
125
126
126
127
@@ -151,6 +152,7 @@ class CustomTimerNotificationModule: ReactContextBaseJavaModule {
151
152
.setPriority(NotificationCompat .PRIORITY_HIGH )
152
153
.setWhen(endTime.getTimeInMillis());
153
154
val handler = Handler ()
155
+ if (isCountDown)
154
156
handler.postDelayed({
155
157
notificationLayout.setChronometerCountDown(R .id.simpleChronometer, true );
156
158
notificationLayout.setChronometer(R .id.simpleChronometer, remainingTime, (" %tM:%tS" ), false );
@@ -173,11 +175,21 @@ class CustomTimerNotificationModule: ReactContextBaseJavaModule {
173
175
return notificationBuilder
174
176
}
175
177
176
- fun updatePop (objectData : ReadableMap ,remainingTime : String ,visbleTimer : Boolean ){
178
+ fun updatePop (objectData : ReadableMap ,remainingTime : String ,visbleTimer : Boolean ){
177
179
val id = objectData.getInt(" id" );
178
180
val notificationBuilder: NotificationCompat .Builder = notificationPop(objectData,remainingTime,visbleTimer)
179
181
notificationManager.notify(id,notificationBuilder.build())
180
182
}
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
+
181
193
fun removeNotification (id : Int ,foreground : Boolean ) {
182
194
val notificationManager = myContext.getSystemService(NotificationManager ::class .java)
183
195
if (foreground)
0 commit comments