WIP constant ring
This commit is contained in:
parent
55ad2e65b5
commit
be22d5cb07
5 changed files with 40 additions and 6 deletions
|
@ -18,6 +18,7 @@ data class Subscription(
|
|||
@ColumnInfo(name = "mutedUntil") val mutedUntil: Long,
|
||||
@ColumnInfo(name = "minPriority") val minPriority: Int,
|
||||
@ColumnInfo(name = "autoDelete") val autoDelete: Long, // Seconds
|
||||
//@ColumnInfo(name = "insistent") val insistent: Boolean?, // Seconds
|
||||
@ColumnInfo(name = "lastNotificationId") val lastNotificationId: String?, // Used for polling, with since=<id>
|
||||
@ColumnInfo(name = "icon") val icon: String?, // content://-URI (or later other identifier)
|
||||
@ColumnInfo(name = "upAppId") val upAppId: String?, // UnifiedPush application package name
|
||||
|
|
|
@ -319,6 +319,7 @@ class NotificationService(val context: Context) {
|
|||
*/
|
||||
class DeleteBroadcastReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
Log.d(TAG, "Media player: Stopping insistent ring")
|
||||
val mediaPlayer = Repository.getInstance(context).mediaPlayer
|
||||
mediaPlayer.stop()
|
||||
}
|
||||
|
@ -392,20 +393,22 @@ class NotificationService(val context: Context) {
|
|||
return
|
||||
}
|
||||
try {
|
||||
Log.d(TAG, "Playing insistent alarm")
|
||||
val mediaPlayer = repository.mediaPlayer
|
||||
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
val alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
|
||||
if (audioManager.getStreamVolume(AudioManager.STREAM_ALARM) != 0) {
|
||||
Log.d(TAG, "Media player: Playing insistent alarm on alarm channel")
|
||||
mediaPlayer.reset()
|
||||
mediaPlayer.setDataSource(context, alert)
|
||||
mediaPlayer.setAudioAttributes(AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_ALARM).build())
|
||||
mediaPlayer.isLooping = true;
|
||||
mediaPlayer.prepare()
|
||||
mediaPlayer.start()
|
||||
} else {
|
||||
Log.d(TAG, "Media player: Alarm volume is 0; not playing insistent alarm")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed playing insistent alarm", e)
|
||||
Log.w(TAG, "Media player: Failed to play insistent alarm", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -254,6 +254,13 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
|
|||
|
||||
// Mark this subscription as "open" so we don't receive notifications for it
|
||||
repository.detailViewSubscriptionId.set(subscriptionId)
|
||||
|
||||
// Stop insistent playback (if running, otherwise it'll throw)
|
||||
try {
|
||||
repository.mediaPlayer.stop()
|
||||
} catch (_: Exception) {
|
||||
// Ignore errors
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
@ -297,7 +304,6 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
|
|||
}
|
||||
}
|
||||
}
|
||||
repository.mediaPlayer.stop()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
|
|
@ -110,6 +110,7 @@ class DetailSettingsActivity : AppCompatActivity() {
|
|||
loadMutedUntilPref()
|
||||
loadMinPriorityPref()
|
||||
loadAutoDeletePref()
|
||||
//loadInsistentMaxPriority()
|
||||
loadIconSetPref()
|
||||
loadIconRemovePref()
|
||||
} else {
|
||||
|
@ -252,7 +253,30 @@ class DetailSettingsActivity : AppCompatActivity() {
|
|||
maybeAppendGlobal(summary, global)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private fun loadInsistentMaxPriority() {
|
||||
val appBaseUrl = getString(R.string.app_base_url)
|
||||
val prefId = context?.getString(R.string.detail_settings_notifications_instant_key) ?: return
|
||||
val pref: SwitchPreference? = findPreference(prefId)
|
||||
pref?.isVisible = true
|
||||
pref?.isChecked = subscription.instant
|
||||
pref?.preferenceDataStore = object : PreferenceDataStore() {
|
||||
override fun putBoolean(key: String?, value: Boolean) {
|
||||
save(subscription.copy(instant = value), refresh = true)
|
||||
}
|
||||
override fun getBoolean(key: String?, defValue: Boolean): Boolean {
|
||||
return subscription.instant
|
||||
}
|
||||
}
|
||||
pref?.summaryProvider = Preference.SummaryProvider<SwitchPreference> { preference ->
|
||||
if (preference.isChecked) {
|
||||
getString(R.string.detail_settings_notifications_instant_summary_on)
|
||||
} else {
|
||||
getString(R.string.detail_settings_notifications_instant_summary_off)
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
private fun loadIconSetPref() {
|
||||
val prefId = context?.getString(R.string.detail_settings_appearance_icon_set_key) ?: return
|
||||
iconSetPref = findPreference(prefId) ?: return
|
||||
|
|
|
@ -280,8 +280,8 @@
|
|||
<string name="settings_notifications_auto_delete_one_month">After one month</string>
|
||||
<string name="settings_notifications_auto_delete_three_months">After 3 months</string>
|
||||
<string name="settings_notifications_insistent_max_priority_title">Keep alerting for highest priority</string>
|
||||
<string name="settings_notifications_insistent_max_priority_summary_enabled">Max priority notifications continuously play the notification sound until dismissed. This overrides Do Not Disturb mode.</string>
|
||||
<string name="settings_notifications_insistent_max_priority_summary_disabled">Max priority notifications alert only once. If enabled, the notification sound will repeat and override Do Not Disturb mode.</string>
|
||||
<string name="settings_notifications_insistent_max_priority_summary_enabled">Max priority notifications continuously alert until dismissed</string>
|
||||
<string name="settings_notifications_insistent_max_priority_summary_disabled">If enabled, the notification sound will continuously repeat until dismissed</string>
|
||||
<string name="settings_general_header">General</string>
|
||||
<string name="settings_general_default_base_url_title">Default server</string>
|
||||
<string name="settings_general_default_base_url_message">Enter your server\'s root URL to use your own server as a default when subscribing to new topics and/or sharing to topics.</string>
|
||||
|
|
Loading…
Reference in a new issue