diff options
author | Allan Wang <me@allanwang.ca> | 2017-10-15 15:07:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-15 15:07:23 -0400 |
commit | d08fd6f8d24430594d63e808740289d395f7227d (patch) | |
tree | 9dd5befd270427413a2735d88b4897532b66d7a6 /app/src/main/kotlin/com/pitchedapps/frost/services | |
parent | a4b3e990228c90c53eaf3ca1424a1e5f6d582d07 (diff) | |
download | frost-d08fd6f8d24430594d63e808740289d395f7227d.tar.gz frost-d08fd6f8d24430594d63e808740289d395f7227d.tar.bz2 frost-d08fd6f8d24430594d63e808740289d395f7227d.zip |
Enhancement/notifications (#416)
* Update notification defaults
* Setup initial channel test
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/services')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt index d296b5f3..9bef9170 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt @@ -1,14 +1,20 @@ package com.pitchedapps.frost.services import android.app.Notification +import android.app.NotificationChannel +import android.app.NotificationManager import android.app.PendingIntent import android.app.job.JobInfo import android.app.job.JobScheduler import android.content.ComponentName import android.content.Context +import android.content.ContextWrapper import android.content.Intent import android.graphics.Bitmap +import android.graphics.Color import android.net.Uri +import android.os.Build +import android.support.annotation.RequiresApi import android.support.v4.app.NotificationCompat import android.support.v4.app.NotificationManagerCompat import ca.allanwang.kau.utils.color @@ -33,7 +39,14 @@ import org.jetbrains.anko.runOnUiThread * * Logic for build notifications, scheduling notifications, and showing notifications */ - +fun setupNotificationChannels(c: Context) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return + val manager = c.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + val mainChannel = NotificationChannel(BuildConfig.APPLICATION_ID, c.getString(R.string.frost_name), NotificationManager.IMPORTANCE_DEFAULT) + mainChannel.lightColor = c.color(R.color.facebook_blue) + mainChannel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC + manager.createNotificationChannel(mainChannel) +} val Context.frostNotification: NotificationCompat.Builder get() = NotificationCompat.Builder(this, BuildConfig.APPLICATION_ID).apply { @@ -161,8 +174,8 @@ data class NotificationContent(val data: CookieModel, val text: String, val timestamp: Long, val profileUrl: String) { - constructor(data:CookieModel, thread: FrostThread) - :this(data, thread.id, thread.url, thread.title, thread.content ?: "", thread.time, thread.img) + constructor(data: CookieModel, thread: FrostThread) + : this(data, thread.id, thread.url, thread.title, thread.content ?: "", thread.time, thread.img) } const val NOTIFICATION_PERIODIC_JOB = 7 |