aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com/pitchedapps
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/services/FrostNotifications.kt19
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt4
3 files changed, 21 insertions, 5 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
index 2de04187..ad06f3a6 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
@@ -16,6 +16,7 @@ import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader
import com.mikepenz.materialdrawer.util.DrawerImageLoader
import com.pitchedapps.frost.facebook.FbCookie
import com.pitchedapps.frost.services.scheduleNotifications
+import com.pitchedapps.frost.services.setupNotificationChannels
import com.pitchedapps.frost.utils.FrostPglAdBlock
import com.pitchedapps.frost.utils.L
import com.pitchedapps.frost.utils.Prefs
@@ -61,6 +62,8 @@ class FrostApp : Application() {
applicationContext.scheduleNotifications(Prefs.notificationFreq)
+ setupNotificationChannels(applicationContext)
+
/**
* Drawer profile loading logic
* Reload the image on every version update
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
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
index 46830e65..dbace074 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
@@ -39,7 +39,7 @@ object Prefs : KPref() {
var exitConfirmation: Boolean by kpref("exit_confirmation", true)
- var notificationFreq: Long by kpref("notification_freq", -1L)
+ var notificationFreq: Long by kpref("notification_freq", 60L)
var versionCode: Int by kpref("version_code", -1)
@@ -104,7 +104,7 @@ object Prefs : KPref() {
var notificationAllAccounts: Boolean by kpref("notification_all_accounts", true)
- var notificationsInstantMessages: Boolean by kpref("notification_im", false)
+ var notificationsInstantMessages: Boolean by kpref("notification_im", true)
var notificationsImAllAccounts: Boolean by kpref("notification_im_all_accounts", false)