From 711c230ac14f59ae511e268ed3c917a175f877e6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 13 Mar 2018 17:40:52 +0100 Subject: [PATCH] handle another case of Alarm sound URI fetching --- .../com/simplemobiletools/clock/extensions/Context.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/clock/extensions/Context.kt index 2d18f4a..f65a7ed 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/extensions/Context.kt @@ -9,7 +9,6 @@ import android.content.ComponentName import android.content.Context import android.content.Intent import android.media.RingtoneManager -import android.net.Uri import android.text.SpannableString import android.text.style.RelativeSizeSpan import android.widget.Toast @@ -78,7 +77,11 @@ fun Context.getAlarms(): ArrayList { while (cursor.moveToNext()) { val title = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX) - val uri = Uri.parse("${cursor.getString(RingtoneManager.URI_COLUMN_INDEX)}/${cursor.getString(RingtoneManager.ID_COLUMN_INDEX)}").toString() + var uri = cursor.getString(RingtoneManager.URI_COLUMN_INDEX) + val id = cursor.getString(RingtoneManager.ID_COLUMN_INDEX) + if (!uri.endsWith(id)) { + uri += "/$id" + } val alarmSound = AlarmSound(title, uri) alarms.add(alarmSound) }