1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-10 04:52:38 +01:00

Document uri parse usage for ringtones

This commit is contained in:
Allan Wang 2019-06-13 17:02:22 -07:00
parent 5094c9f259
commit 682227c17b
No known key found for this signature in database
GPG Key ID: C93E3F9C679D7A56
2 changed files with 5 additions and 1 deletions

View File

@ -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
}

View File

@ -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)
}