aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationReceiver.kt
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-08-07 14:56:48 -0700
committerGitHub <noreply@github.com>2017-08-07 14:56:48 -0700
commitab7ec131b62ac1567e983c846c921bd3ada11dd4 (patch)
tree1e9e7db2151ba531f438a2ac9c4fc960c913dc46 /app/src/main/kotlin/com/pitchedapps/frost/services/NotificationReceiver.kt
parent7746e63373c905faa6d7e45e45fffc48d3ffff85 (diff)
downloadfrost-ab7ec131b62ac1567e983c846c921bd3ada11dd4.tar.gz
frost-ab7ec131b62ac1567e983c846c921bd3ada11dd4.tar.bz2
frost-ab7ec131b62ac1567e983c846c921bd3ada11dd4.zip
Fix/2FA (#115)
* Create basis for downloading videos * Resolve some download errors and allow video to be opened in external apps * Remove url checks for loging * Update readme with build links * Allow for all apks to build * Fix travis apk uploads * Fix null mapping * Fix some notation * Add commit message to test builds * Remove faulty commit from test release * Add intent overriding to login web client * Add resource logging * Add intent verification without url check * Simplify login activity * Check start activity for result * Add check before resolving intent * Fix wrong index * Temporary fix for 2FA login with U2F (#116) * Clean up and add comments
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/services/NotificationReceiver.kt')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/NotificationReceiver.kt34
1 files changed, 34 insertions, 0 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
new file mode 100644
index 00000000..c903ff72
--- /dev/null
+++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationReceiver.kt
@@ -0,0 +1,34 @@
+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