allow customizing the audio stream used by reminders
This commit is contained in:
parent
045ea7b978
commit
11cbad20ba
4 changed files with 62 additions and 0 deletions
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -246,6 +246,40 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_reminder_audio_stream_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingBottom="@dimen/activity_margin"
|
||||
android:paddingLeft="@dimen/normal_margin"
|
||||
android:paddingRight="@dimen/normal_margin"
|
||||
android:paddingTop="@dimen/activity_margin">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_reminder_audio_stream_label"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@+id/settings_reminder_audio_stream"
|
||||
android:layout_toStartOf="@+id/settings_reminder_audio_stream"
|
||||
android:paddingLeft="@dimen/medium_margin"
|
||||
android:paddingRight="@dimen/medium_margin"
|
||||
android:text="@string/reminder_stream"/>
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_reminder_audio_stream"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginEnd="@dimen/small_margin"
|
||||
android:layout_marginRight="@dimen/small_margin"
|
||||
android:background="@null"
|
||||
android:clickable="false"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_use_same_snooze_holder"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Reference in a new issue