diff options
author | Allan Wang <me@allanwang.ca> | 2019-06-13 17:02:22 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2019-06-13 17:02:22 -0700 |
commit | 682227c17b46ff7957f9399b7f610d52f06c1428 (patch) | |
tree | 1a591311ab883d7320f0ff87117638b87d4068c0 /app/src/main | |
parent | 5094c9f259bdca4f6be7472016cceeb289dae21e (diff) | |
download | frost-682227c17b46ff7957f9399b7f610d52f06c1428.tar.gz frost-682227c17b46ff7957f9399b7f610d52f06c1428.tar.bz2 frost-682227c17b46ff7957f9399b7f610d52f06c1428.zip |
Document uri parse usage for ringtones
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt | 1 | ||||
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt | 5 |
2 files changed, 5 insertions, 1 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 bba2a9a1..96c601e4 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationUtils.kt @@ -97,6 +97,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)) else defaults = defaults or Notification.DEFAULT_SOUND } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt index 777b4edd..91d87e3b 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt @@ -136,6 +136,7 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = { enabler = Prefs::notificationSound textGetter = { if (it.isBlank()) string(R.string.kau_default) + // Ringtones have uris of format /content:/media/...; Uri.parse is okay else RingtoneManager.getRingtone(this@getNotificationPrefs, Uri.parse(it)) ?.getTitle(this@getNotificationPrefs) ?: "---" //todo figure out why this happens @@ -146,8 +147,10 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = { putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false) putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true) putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION) - if (item.pref.isNotBlank()) + if (item.pref.isNotBlank()) { + // Ringtones have uris of format /content:/media/...; Uri.parse is okay putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(item.pref)) + } } startActivityForResult(intent, code) } |