diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt index df198de7a..e70436cbc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/SettingsActivity.kt @@ -58,6 +58,7 @@ class SettingsActivity : SimpleActivity() { setupWeeklyEnd() setupVibrate() setupReminderSound() + setupReminderAudioStream() setupUseSameSnooze() setupLoopReminders() setupSnoozeTime() @@ -315,6 +316,27 @@ class SettingsActivity : SimpleActivity() { settings_reminder_sound.text = alarmSound.title } + private fun setupReminderAudioStream() { + settings_reminder_audio_stream.text = getAudioStreamText() + settings_reminder_audio_stream_holder.setOnClickListener { + val items = arrayListOf( + RadioItem(AudioManager.STREAM_ALARM, res.getString(R.string.alarm_stream)), + RadioItem(AudioManager.STREAM_SYSTEM, res.getString(R.string.system_stream)), + RadioItem(AudioManager.STREAM_NOTIFICATION, res.getString(R.string.notification_stream))) + + RadioGroupDialog(this@SettingsActivity, items, config.reminderAudioStream) { + config.reminderAudioStream = it as Int + settings_reminder_audio_stream.text = getAudioStreamText() + } + } + } + + private fun getAudioStreamText() = getString(when (config.reminderAudioStream) { + AudioManager.STREAM_ALARM -> R.string.alarm_stream + AudioManager.STREAM_SYSTEM -> R.string.system_stream + else -> R.string.notification_stream + }) + private fun setupVibrate() { settings_vibrate.isChecked = config.vibrateOnReminder settings_vibrate_holder.setOnClickListener { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt index 4e80731a5..a5d17c122 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Config.kt @@ -1,6 +1,7 @@ package com.simplemobiletools.calendar.helpers import android.content.Context +import android.media.AudioManager import com.simplemobiletools.calendar.R import com.simplemobiletools.calendar.extensions.scheduleCalDAVSync import com.simplemobiletools.commons.extensions.getDefaultAlarmTitle @@ -94,6 +95,10 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getInt(LAST_USED_LOCAL_EVENT_TYPE_ID, DBHelper.REGULAR_EVENT_TYPE_ID) set(lastUsedLocalEventTypeId) = prefs.edit().putInt(LAST_USED_LOCAL_EVENT_TYPE_ID, lastUsedLocalEventTypeId).apply() + var reminderAudioStream: Int + get() = prefs.getInt(REMINDER_AUDIO_STREAM, AudioManager.STREAM_ALARM) + set(reminderAudioStream) = prefs.edit().putInt(REMINDER_AUDIO_STREAM, reminderAudioStream).apply() + var replaceDescription: Boolean get() = prefs.getBoolean(REPLACE_DESCRIPTION, false) set(replaceDescription) = prefs.edit().putBoolean(REPLACE_DESCRIPTION, replaceDescription).apply() diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt index cfcf35e2f..3107f0e96 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/helpers/Constants.kt @@ -53,6 +53,7 @@ const val LOOP_REMINDERS = "loop_reminders" const val DIM_PAST_EVENTS = "dim_past_events" const val LAST_SOUND_URI = "last_sound_uri" const val LAST_REMINDER_CHANNEL_ID = "last_reminder_channel_ID" +const val REMINDER_AUDIO_STREAM = "reminder_audio_stream" // repeat_rule for monthly and yearly repetition const val REPEAT_SAME_DAY = 1 // i.e. 25th every month, or 3rd june (if yearly repetition) diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 1cbb9b137..1fd52386b 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -246,6 +246,40 @@ + + + + + + + +