Skip to content

Commit

Permalink
real fix in the push notifications (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
danieltigse authored and jorgeblacio committed Sep 9, 2019
1 parent ae1a0bf commit 8316999
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 84
versionName "0.21.7"
versionCode 85
versionName "0.21.8"
applicationId "com.criptext.mail"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ class PushAPIRequestHandler(private val not: CriptextNotification,
private fun handleNotificationCount(notificationId: Int, key: KeyValueStorage.StringKey, id: Int){
val notCount = storage.getInt(key, 0)
manager.cancel(notificationId)
if((notCount - 1) == 0) {
if((notCount - 1) <= 0) {
manager.cancel(id)
}
storage.putInt(key, notCount - 1)
storage.putInt(key, if(notCount <= 0) 0 else notCount - 1)
}

private fun postNotification(cn: CriptextNotification,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ class NewMailActionService : IntentService("New Mail Action Service") {
}
DELETE -> {
val notCount = storage.getInt(KeyValueStorage.StringKey.NewMailNotificationCount, 0)
if((notCount - 1) == 0) {
if((notCount - 1) <= 0) {
manager.cancel(CriptextNotification.INBOX_ID)
}
val newNotCount = if(notCount == 0) notCount else notCount - 1
storage.putInt(KeyValueStorage.StringKey.NewMailNotificationCount, newNotCount)
storage.putInt(KeyValueStorage.StringKey.NewMailNotificationCount,
if(notCount <= 0) 0 else notCount - 1)
}
else -> throw IllegalArgumentException("Unsupported action: " + data.action)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ class MessagingService : FirebaseMessagingService(){
.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val notCount = storage.getInt(key, 0)
manager.cancel(notificationId)
if((notCount - 1) == 0) {
if((notCount - 1) <= 0) {
manager.cancel(headerId)
}
storage.putInt(key, notCount - 1)
storage.putInt(key, if(notCount <= 0) 0 else notCount - 1)
}

companion object {
Expand Down

0 comments on commit 8316999

Please sign in to comment.