diff options
author | Allan Wang <me@allanwang.ca> | 2019-06-13 17:19:25 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2019-06-13 17:19:25 -0700 |
commit | 7ad2a898571db9c0db95caf09cda8632660ff6dd (patch) | |
tree | b956e8354030f9be7bbf48fcb8ea8c7acc685481 /app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt | |
parent | 682227c17b46ff7957f9399b7f610d52f06c1428 (diff) | |
download | frost-7ad2a898571db9c0db95caf09cda8632660ff6dd.tar.gz frost-7ad2a898571db9c0db95caf09cda8632660ff6dd.tar.bz2 frost-7ad2a898571db9c0db95caf09cda8632660ff6dd.zip |
Resolve file uri ourself for ringtones, resolves #1423
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt index 96c601e4..35bf5de2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt @@ -34,6 +34,7 @@ import ca.allanwang.kau.utils.string import com.pitchedapps.frost.R import com.pitchedapps.frost.utils.L import com.pitchedapps.frost.utils.Prefs +import com.pitchedapps.frost.utils.frostUri /** * Created by Allan Wang on 07/04/18. @@ -85,7 +86,7 @@ fun Context.frostNotification(id: String) = * Delegates to channels if Android O and up * Otherwise uses our provided preferences */ -fun NotificationCompat.Builder.setFrostAlert(enable: Boolean, ringtone: String): NotificationCompat.Builder { +fun NotificationCompat.Builder.setFrostAlert(context: Context, enable: Boolean, ringtone: String): NotificationCompat.Builder { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { setGroupAlertBehavior( if (enable) NotificationCompat.GROUP_ALERT_CHILDREN @@ -97,8 +98,7 @@ fun NotificationCompat.Builder.setFrostAlert(enable: Boolean, ringtone: String): var defaults = 0 if (Prefs.notificationVibrate) defaults = defaults or Notification.DEFAULT_VIBRATE if (Prefs.notificationSound) { - // Ringtones have uris of format /content:/media/...; Uri.parse is okay - if (ringtone.isNotBlank()) setSound(Uri.parse(ringtone)) + if (ringtone.isNotBlank()) setSound(context.frostUri(ringtone)) else defaults = defaults or Notification.DEFAULT_SOUND } if (Prefs.notificationLights) defaults = defaults or Notification.DEFAULT_LIGHTS |