couple backgrounded timer related improvements

This commit is contained in:
tibbi
2018-08-10 22:16:35 +02:00
parent 1581e0ce56
commit 0574d834e7

View File

@ -240,7 +240,7 @@ class TimerFragment : Fragment() {
activity?.startActivity(this) activity?.startActivity(this)
} }
} }
} else if (!isForegrounded) { } else if (diff > 0 && !isForegrounded && isRunning) {
showNotification(formattedDuration) showNotification(formattedDuration)
} }
@ -253,8 +253,9 @@ class TimerFragment : Fragment() {
val label = getString(R.string.timer) val label = getString(R.string.timer)
val notificationManager = context!!.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val notificationManager = context!!.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
if (isOreoPlus()) { if (isOreoPlus()) {
val importance = NotificationManager.IMPORTANCE_DEFAULT val importance = NotificationManager.IMPORTANCE_HIGH
NotificationChannel(channelId, label, importance).apply { NotificationChannel(channelId, label, importance).apply {
setSound(null, null)
notificationManager.createNotificationChannel(this) notificationManager.createNotificationChannel(this)
} }
} }
@ -264,7 +265,8 @@ class TimerFragment : Fragment() {
.setContentText(formattedDuration) .setContentText(formattedDuration)
.setSmallIcon(R.drawable.ic_timer) .setSmallIcon(R.drawable.ic_timer)
.setContentIntent(context!!.getOpenTimerTabIntent()) .setContentIntent(context!!.getOpenTimerTabIntent())
.setPriority(Notification.PRIORITY_DEFAULT) .setPriority(Notification.PRIORITY_HIGH)
.setSound(null)
.setOngoing(true) .setOngoing(true)
.setAutoCancel(true) .setAutoCancel(true)
.setChannelId(channelId) .setChannelId(channelId)