playback: disable audio focus setting on api 31

Disable the ability to customize audio focus on Android 12 and up.

Android 12 automatically regulates audio streams even further than it
did in previous versions, to the point where the audio focus setting
no longer makes sense on that version. I may extend the removal to all
versions in the future.
This commit is contained in:
OxygenCobalt 2022-02-15 06:30:53 -07:00
parent 30ad7f99db
commit 5b57d77d02
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
6 changed files with 8 additions and 2 deletions

View file

@ -9,6 +9,9 @@
#### What's Fixed
- Fixed issue where playback would start unexpectedly when opening the app
#### What's Changed
- Disabled audio focus customization on Android 12 [#75]
## v2.2.0
#### What's New:
- Added Arabic translations [Courtesy of hasanpasha]

View file

@ -127,7 +127,6 @@ class PlaybackFragment : Fragment() {
}
binding.playbackLoop.setImageResource(resId)
binding.playbackLoop.isActivated = loopMode != LoopMode.NONE
}
playbackModel.position.observe(viewLifecycleOwner) { pos ->

View file

@ -20,6 +20,7 @@ package org.oxycblt.auxio.playback.system
import android.content.Context
import android.media.AudioManager
import android.os.Build
import androidx.core.math.MathUtils
import androidx.media.AudioAttributesCompat
import androidx.media.AudioFocusRequestCompat
@ -233,7 +234,7 @@ class AudioReactor(
// --- INTERNAL AUDIO FOCUS ---
override fun onAudioFocusChange(focusChange: Int) {
if (!settingsManager.doAudioFocus) {
if (!settingsManager.doAudioFocus && Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
// Don't do audio focus if its not enabled
return
}

View file

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="enable_theme_settings">false</bool>
<bool name="enable_audio_focus_setting">false</bool>
</resources>

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="enable_theme_settings">true</bool>
<bool name="enable_audio_focus_setting">true</bool>
<integer name="recycler_spans">1</integer>
</resources>

View file

@ -82,6 +82,7 @@
app:defaultValue="true"
app:iconSpaceReserved="false"
app:key="KEY_AUDIO_FOCUS"
app:isPreferenceVisible="@bool/enable_audio_focus_setting"
app:summary="@string/set_focus_desc"
app:title="@string/set_focus" />