Skip to content

Commit

Permalink
Audio ducking now reads legacy setting
Browse files Browse the repository at this point in the history
  • Loading branch information
jamie23 committed Jul 24, 2023
1 parent 3fdb8f8 commit 3e7b7e0
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 12 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
* Added share option to episode swipe and multiselect menus
([#1190](https://github.com/Automattic/pocket-casts-android/pull/1190)),
([#1191](https://github.com/Automattic/pocket-casts-android/pull/1191))
* Bug Fixes:
* Added audio ducking as an option when playing over notifications
([#1009](https://github.com/Automattic/pocket-casts-android/pull/1009)).
>>>>>>> a8995106b (Audio ducking now reads legacy setting)
7.43
-----
Expand Down Expand Up @@ -64,8 +68,6 @@
([#973](https://github.com/Automattic/pocket-casts-android/pull/973)).
* Improved the Automotive user profile view
([#975](https://github.com/Automattic/pocket-casts-android/pull/975)).
* Added audio ducking as an option when playing over external notifications
([#1009](https://github.com/Automattic/pocket-casts-android/pull/1009)).

7.39
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class NotificationsSettingsFragment :
vibratePreference = manager.findPreference("notificationVibrate")
notificationActions = manager.findPreference("notificationActions")
systemSettingsPreference = manager.findPreference("openSystemSettings")
playOverNotificationPreference = manager.findPreference("notificationAudio")
playOverNotificationPreference = manager.findPreference("overrideNotificationAudio")

// turn preferences off by default, because they are enable async, we don't want this view to remove them from the screen after it loads as it looks jarring
enabledPreferences(false)
Expand Down Expand Up @@ -410,7 +410,7 @@ class NotificationsSettingsFragment :
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
if (Settings.PREFERENCE_NOTIFICATION_VIBRATE == key) {
changeVibrateSummary()
} else if (Settings.PREFERENCE_NOTIFICATION_AUDIO == key) {
} else if (Settings.PREFERENCE_OVERRIDE_NOTIFICATION_AUDIO == key) {
changePlayOverNotificationSummary()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

<PreferenceCategory android:title="@string/settings" >
<ListPreference
android:key="notificationAudio"
android:key="overrideNotificationAudio"
android:title="@string/settings_notification_play_over"
android:persistent="true"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@
<string name="settings_notification_choose_podcasts">Choose podcasts</string>
<string name="settings_notification_hide_on_pause">Hide playback notification on pause</string>
<string name="settings_notification_notify_me">Notify me</string>
<string name="settings_notification_play_over">Play over external notifications</string>
<string name="settings_notification_play_over">Play over notifications</string>
<string name="settings_notification_play_over_never">Never</string>
<string name="settings_notification_play_over_duck">Duck volume</string>
<string name="settings_notification_play_over_always">Always</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ interface Settings {
const val PREFERENCE_SELECT_PODCAST_LIBRARY_SORT = "selectPodcastLibrarySort"
const val PREFERENCE_WARN_WHEN_NOT_ON_WIFI = "warnWhenNotOnWifi"
const val PREFERENCE_SYNC_ON_METERED = "SyncWhenOnMetered"
const val PREFERENCE_NOTIFICATION_AUDIO = "notificationAudio"
const val PREFERENCE_NOTIFICATION_AUDIO_DEFAULT = "2"
const val PREFERENCE_OVERRIDE_AUDIO_LEGACY = "overrideAudioInterruption"
const val PREFERENCE_OVERRIDE_NOTIFICATION_AUDIO = "overrideNotificationAudio"
const val PREFERENCE_USE_EMBEDDED_ARTWORK = "useEmbeddedArtwork"
const val PREFERENCE_LAST_MODIFIED = "lastModified"
const val PREFERENCE_FIRST_SYNC_RUN = "firstSyncRun"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,13 +505,18 @@ class SettingsImpl @Inject constructor(
}

override fun getPlayOverNotification(): PlayOverNotificationSetting {
val value = sharedPreferences.getString(
Settings.PREFERENCE_NOTIFICATION_AUDIO,
Settings.PREFERENCE_NOTIFICATION_AUDIO_DEFAULT
) ?: Settings.PREFERENCE_NOTIFICATION_AUDIO_DEFAULT
val value = sharedPreferences.getString(Settings.PREFERENCE_OVERRIDE_NOTIFICATION_AUDIO, null) ?: legacyPlayOverNotification()
return PlayOverNotificationSetting.fromPreferenceString(value)
}

private fun legacyPlayOverNotification(): String {
if (sharedPreferences.getBoolean(Settings.PREFERENCE_OVERRIDE_AUDIO_LEGACY, false)) {
return PlayOverNotificationSetting.ALWAYS.preferenceInt.toString()
}

return PlayOverNotificationSetting.NEVER.preferenceInt.toString()
}

override fun hasBlockAlreadyRun(label: String): Boolean {
return sharedPreferences.getBoolean("blockAlreadyRun$label", false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ open class FocusManager(private val settings: Settings, context: Context?) : Aud
if (audioFocus != AUDIO_NO_FOCUS_CAN_DUCK_TRANSIENT) return PlayOverNotificationSetting.NEVER
return settings.getPlayOverNotification()
}

interface FocusChangeListener {
fun onFocusGain(shouldResume: Boolean)
fun onFocusLoss(playOverNotification: PlayOverNotificationSetting, transientLoss: Boolean)
Expand Down

0 comments on commit 3e7b7e0

Please sign in to comment.