aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/services
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/services')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/NotificationReceiver.kt34
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt2
2 files changed, 1 insertions, 35 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationReceiver.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationReceiver.kt
deleted file mode 100644
index c903ff72..00000000
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationReceiver.kt
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.pitchedapps.frost.services
-
-import android.app.PendingIntent
-import android.content.BroadcastReceiver
-import android.content.Context
-import android.content.Intent
-import android.support.v4.app.NotificationManagerCompat
-import com.pitchedapps.frost.utils.L
-
-/**
- * Created by Allan Wang on 2017-08-04.
- *
- * Cancels a notification
- */
-private const val NOTIF_TAG_TO_CANCEL = "notif_tag_to_cancel"
-private const val NOTIF_ID_TO_CANCEL = "notif_id_to_cancel"
-
-class NotificationReceiver : BroadcastReceiver() {
- override fun onReceive(context: Context, intent: Intent) {
- L.d("NotificationReceiver triggered")
- val notifTag = intent.getStringExtra(NOTIF_TAG_TO_CANCEL)
- val notifId = intent.getIntExtra(NOTIF_ID_TO_CANCEL, -1)
- if (notifId != -1) {
- L.d("NotificationReceiver: Cancelling $notifTag $notifId")
- NotificationManagerCompat.from(context).cancel(notifTag, notifId)
- }
- }
-}
-
-fun Context.getNotificationPendingCancelIntent(tag: String?, notifId: Int): PendingIntent {
- val cancelIntent = Intent(this, NotificationReceiver::class.java)
- .putExtra(NOTIF_TAG_TO_CANCEL, tag).putExtra(NOTIF_ID_TO_CANCEL, notifId)
- return PendingIntent.getBroadcast(this, 0, cancelIntent, 0)
-} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt
index 9e53889e..989ac127 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/UpdateReceiver.kt
@@ -13,8 +13,8 @@ import com.pitchedapps.frost.utils.Prefs
*/
class UpdateReceiver : BroadcastReceiver() {
- //todo check action warning
override fun onReceive(context: Context, intent: Intent) {
+ if (intent.action != Intent.ACTION_MY_PACKAGE_REPLACED) return
L.d("Frost has updated")
context.scheduleNotifications(Prefs.notificationFreq) //Update notifications
}