@@ -79,16 +79,16 @@ class MainActivity : AppCompatActivity() {
7979 " LOCATION" -> {
8080 if (idWS == 0 ) {
8181 idWS = it
82- sendPermanentPush(" LetMeIn " , " ${getString(R .string.req_sent )} (45s )" , it)
82+ sendPermanentPush(getString( R .string.req_sent) , " ${getString(R .string.req_sent_exp )} (${response?.currentTime} s )" , it)
8383 }
8484 }
85- " COUNTDOWN" -> updatePush(" ${getString(R .string.req_sent )} (${response?.currentTime} s)" , it)
85+ " COUNTDOWN" -> updatePush(" ${getString(R .string.req_sent_exp )} (${response?.currentTime} s)" , it)
8686 " TIMEOUT" -> {
87- sendTemporaryPush(" LetMeIn " , getString(R .string.req_timeout ))
87+ sendTemporaryPush(getString( R .string.req_timeout) , getString(R .string.req_timeout_exp ))
8888 this .close()
8989 }
9090 " ACKNOWLEDGE" -> {
91- sendTemporaryPush(" LetMeIn " , getString(R .string.req_ack ))
91+ sendTemporaryPush(getString( R .string.req_ack) , getString(R .string.req_ack_exp ))
9292 this .close()
9393 }
9494 }
@@ -99,18 +99,18 @@ class MainActivity : AppCompatActivity() {
9999 override fun onClose (code : Int , reason : String? , remote : Boolean ) {
100100 println (" Connection was closed! Reason: $reason " )
101101 notificationManager.cancel(idWS)
102- sendTemporaryPush(" Error" , getString(R .string.req_error))
103102 }
104103
105104 override fun onError (ex : Exception ? ) {
106105 println (" Connection ran into an error: ${ex.toString()} " )
107106 ex?.printStackTrace()
108107 notificationManager.cancel(idWS)
108+ sendTemporaryPush(getString(R .string.req_error), getString(R .string.req_error_exp), 2024 )
109109 }
110110 }
111111 }
112112
113- fun sendPermanentPush (title : String , description : String , code : Int = 2023) {
113+ fun sendPermanentPush (subject : String , description : String , code : Int = 2023) {
114114 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
115115 notificationChannel =
116116 NotificationChannel (channelId, description, NotificationManager .IMPORTANCE_HIGH )
@@ -123,18 +123,21 @@ class MainActivity : AppCompatActivity() {
123123 }
124124 builder.setSmallIcon(R .drawable.csh_logo)
125125 .setLargeIcon(BitmapFactory .decodeResource(this .resources, R .drawable.csh_logo))
126+ .setContentTitle(subject)
126127 .setContentText(description)
127- .setContentTitle(title)
128128 .setAutoCancel(false )
129129 .setOngoing(true )
130130 .setOnlyAlertOnce(true )
131+ .setColor(Color .MAGENTA )
132+ .style = Notification .BigTextStyle ()
133+ .bigText(description)
131134 notificationManager.notify(code, builder.build())
132135 }
133136
134- fun sendTemporaryPush (title : String , description : String , code : Int = 2023) {
137+ fun sendTemporaryPush (subject : String , description : String , code : Int = 2023) {
135138 if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
136139 notificationChannel =
137- NotificationChannel (channelId, description, NotificationManager .IMPORTANCE_HIGH )
140+ NotificationChannel (channelId, description, NotificationManager .IMPORTANCE_LOW )
138141 notificationChannel.lightColor = Color .MAGENTA
139142 notificationManager.createNotificationChannel(notificationChannel)
140143
@@ -144,13 +147,18 @@ class MainActivity : AppCompatActivity() {
144147 }
145148 builder.setSmallIcon(R .drawable.csh_logo)
146149 .setLargeIcon(BitmapFactory .decodeResource(this .resources, R .drawable.csh_logo))
150+ .setContentTitle(subject)
147151 .setContentText(description)
148- .setContentTitle(title)
152+ .setColor(Color .MAGENTA )
153+ .style = Notification .BigTextStyle ()
154+ .bigText(description)
149155 notificationManager.notify(code, builder.build())
150156 }
151157
152158 fun updatePush (description : String , code : Int = 2023) {
153159 builder.setContentText(description)
160+ .style = Notification .BigTextStyle ()
161+ .bigText(description)
154162 notificationManager.notify(code, builder.build())
155163 }
156164
0 commit comments