mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-04-15 18:57:22 +02:00
make sure custom picked alarm sounds play well
This commit is contained in:
parent
aecfb9f5f1
commit
c1b056c858
@ -238,6 +238,7 @@ fun Context.getTimerNotification(pendingIntent: PendingIntent, addDeleteIntent:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grantReadUriPermission(config.timerSoundUri)
|
||||||
val reminderActivityIntent = getReminderActivityIntent()
|
val reminderActivityIntent = getReminderActivityIntent()
|
||||||
val builder = NotificationCompat.Builder(this)
|
val builder = NotificationCompat.Builder(this)
|
||||||
.setContentTitle(getString(R.string.timer))
|
.setContentTitle(getString(R.string.timer))
|
||||||
@ -269,6 +270,14 @@ fun Context.getTimerNotification(pendingIntent: PendingIntent, addDeleteIntent:
|
|||||||
return notification
|
return notification
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Context.grantReadUriPermission(uriString: String) {
|
||||||
|
try {
|
||||||
|
// ensure custom reminder sounds play well
|
||||||
|
grantUriPermission("com.android.systemui", Uri.parse(uriString), Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
||||||
|
} catch (ignored: Exception) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun Context.getHideTimerPendingIntent(): PendingIntent {
|
fun Context.getHideTimerPendingIntent(): PendingIntent {
|
||||||
val intent = Intent(this, HideTimerReceiver::class.java)
|
val intent = Intent(this, HideTimerReceiver::class.java)
|
||||||
return PendingIntent.getBroadcast(this, TIMER_NOTIF_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
return PendingIntent.getBroadcast(this, TIMER_NOTIF_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||||
@ -296,12 +305,7 @@ fun Context.getAlarmNotification(pendingIntent: PendingIntent, alarm: Alarm, add
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
grantReadUriPermission(alarm.soundUri)
|
||||||
// ensure custom reminder sounds play well
|
|
||||||
grantUriPermission("com.android.systemui", Uri.parse(alarm.soundUri), Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
|
||||||
} catch (ignored: Exception) {
|
|
||||||
}
|
|
||||||
|
|
||||||
val reminderActivityIntent = getReminderActivityIntent()
|
val reminderActivityIntent = getReminderActivityIntent()
|
||||||
val builder = NotificationCompat.Builder(this)
|
val builder = NotificationCompat.Builder(this)
|
||||||
.setContentTitle(label)
|
.setContentTitle(label)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user