diff options
author | Allan Wang <me@allanwang.ca> | 2017-08-20 16:55:27 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-08-20 16:55:27 -0700 |
commit | a6bdfc3985ba09084893896b62cbd66dc9300400 (patch) | |
tree | 56a1489f8b8dee7a1091aa142565ef39a3a31ff0 /app/src/main | |
parent | 130b0ebf98817fd490645fc954d096f7b9803017 (diff) | |
download | frost-a6bdfc3985ba09084893896b62cbd66dc9300400.tar.gz frost-a6bdfc3985ba09084893896b62cbd66dc9300400.tar.bz2 frost-a6bdfc3985ba09084893896b62cbd66dc9300400.zip |
Fix/null ringtone from uri
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt | 18 |
1 files changed, 7 insertions, 11 deletions
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 429b74fb..30684826 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Notifications.kt @@ -25,13 +25,11 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = { text(R.string.notification_frequency, { Prefs.notificationFreq }, { Prefs.notificationFreq = it }) { val options = longArrayOf(-1, 15, 30, 60, 120, 180, 300, 1440, 2880) val texts = options.map { minuteToText(it) } - onClick = { - _, _, item -> + onClick = { _, _, item -> materialDialogThemed { title(R.string.notification_frequency) items(texts) - itemsCallbackSingleChoice(options.indexOf(item.pref), { - _, _, which, _ -> + itemsCallbackSingleChoice(options.indexOf(item.pref), { _, _, which, _ -> item.pref = options[which] scheduleNotifications(item.pref) true @@ -44,8 +42,7 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = { plainText(R.string.notification_keywords) { descRes = R.string.notification_keywords_desc - onClick = { - _, _, _ -> + onClick = { _, _, _ -> val keywordView = Keywords(this@getNotificationPrefs) materialDialogThemed { title(R.string.notification_keywords) @@ -71,10 +68,10 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = { enabler = { Prefs.notificationSound } textGetter = { if (it.isBlank()) string(R.string.kau_default) - else RingtoneManager.getRingtone(this@getNotificationPrefs, Uri.parse(it)).getTitle(this@getNotificationPrefs) + else RingtoneManager.getRingtone(this@getNotificationPrefs, Uri.parse(it)) + ?.getTitle(this@getNotificationPrefs) ?: "---" //todo figure out why this happens } - onClick = { - _, _, item -> + onClick = { _, _, item -> val intent = Intent(RingtoneManager.ACTION_RINGTONE_PICKER).apply { putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, string(R.string.select_ringtone)) putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false) @@ -102,8 +99,7 @@ fun SettingsActivity.getNotificationPrefs(): KPrefAdapterBuilder.() -> Unit = { plainText(R.string.notification_fetch_now) { descRes = R.string.notification_fetch_now_desc - onClick = { - _, _, _ -> + onClick = { _, _, _ -> val text = if (fetchNotifications()) R.string.notification_fetch_success else R.string.notification_fetch_fail frostSnackbar(text) true |