set high priority and public visibility to notifications

This commit is contained in:
tibbi 2017-05-05 20:49:35 +02:00
parent 69d0c45a4f
commit fbcb380cc0

View file

@ -1,5 +1,6 @@
package com.simplemobiletools.calendar.extensions
import android.annotation.TargetApi
import android.app.AlarmManager
import android.app.Notification
import android.app.NotificationManager
@ -18,6 +19,7 @@ import com.simplemobiletools.calendar.helpers.*
import com.simplemobiletools.calendar.models.Event
import com.simplemobiletools.calendar.receivers.NotificationReceiver
import com.simplemobiletools.commons.extensions.getContrastColor
import com.simplemobiletools.commons.extensions.isLollipopPlus
import org.joda.time.DateTime
import org.joda.time.DateTimeZone
@ -94,7 +96,7 @@ private fun isWrongDay(event: Event, startTS: Int, reminderSeconds: Int): Boolea
if (event.repeatInterval == DAY)
return false
return !(startTS + reminderSeconds).isTsOnValidDay(event)
return !(startTS + reminderSeconds).isTsOnProperDay(event)
}
private fun getNewTS(ts: Int, isMonthly: Boolean): Int {
@ -188,6 +190,7 @@ fun Context.notifyEvent(event: Event) {
notificationManager.notify(event.id, notification)
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private fun getNotification(context: Context, pendingIntent: PendingIntent, title: String, content: String): Notification {
val soundUri = Uri.parse(context.config.reminderSound)
val builder = Notification.Builder(context)
@ -195,10 +198,14 @@ private fun getNotification(context: Context, pendingIntent: PendingIntent, titl
.setContentText(content)
.setSmallIcon(R.drawable.ic_calendar)
.setContentIntent(pendingIntent)
.setPriority(Notification.PRIORITY_HIGH)
.setDefaults(Notification.DEFAULT_LIGHTS)
.setAutoCancel(true)
.setSound(soundUri)
if (context.isLollipopPlus())
builder.setVisibility(Notification.VISIBILITY_PUBLIC)
if (context.config.vibrateOnReminder)
builder.setVibrate(longArrayOf(0, 300, 300, 300))