mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
allow customizing the audio stream used by reminders
This commit is contained in:
@@ -58,6 +58,7 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
setupWeeklyEnd()
|
setupWeeklyEnd()
|
||||||
setupVibrate()
|
setupVibrate()
|
||||||
setupReminderSound()
|
setupReminderSound()
|
||||||
|
setupReminderAudioStream()
|
||||||
setupUseSameSnooze()
|
setupUseSameSnooze()
|
||||||
setupLoopReminders()
|
setupLoopReminders()
|
||||||
setupSnoozeTime()
|
setupSnoozeTime()
|
||||||
@@ -315,6 +316,27 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
settings_reminder_sound.text = alarmSound.title
|
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() {
|
private fun setupVibrate() {
|
||||||
settings_vibrate.isChecked = config.vibrateOnReminder
|
settings_vibrate.isChecked = config.vibrateOnReminder
|
||||||
settings_vibrate_holder.setOnClickListener {
|
settings_vibrate_holder.setOnClickListener {
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package com.simplemobiletools.calendar.helpers
|
package com.simplemobiletools.calendar.helpers
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.media.AudioManager
|
||||||
import com.simplemobiletools.calendar.R
|
import com.simplemobiletools.calendar.R
|
||||||
import com.simplemobiletools.calendar.extensions.scheduleCalDAVSync
|
import com.simplemobiletools.calendar.extensions.scheduleCalDAVSync
|
||||||
import com.simplemobiletools.commons.extensions.getDefaultAlarmTitle
|
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)
|
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()
|
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
|
var replaceDescription: Boolean
|
||||||
get() = prefs.getBoolean(REPLACE_DESCRIPTION, false)
|
get() = prefs.getBoolean(REPLACE_DESCRIPTION, false)
|
||||||
set(replaceDescription) = prefs.edit().putBoolean(REPLACE_DESCRIPTION, replaceDescription).apply()
|
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 DIM_PAST_EVENTS = "dim_past_events"
|
||||||
const val LAST_SOUND_URI = "last_sound_uri"
|
const val LAST_SOUND_URI = "last_sound_uri"
|
||||||
const val LAST_REMINDER_CHANNEL_ID = "last_reminder_channel_ID"
|
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
|
// repeat_rule for monthly and yearly repetition
|
||||||
const val REPEAT_SAME_DAY = 1 // i.e. 25th every month, or 3rd june (if 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>
|
||||||
|
|
||||||
|
<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
|
<RelativeLayout
|
||||||
android:id="@+id/settings_use_same_snooze_holder"
|
android:id="@+id/settings_use_same_snooze_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Reference in New Issue
Block a user