Change equalizer intent logic
This commit is contained in:
@@ -6,6 +6,12 @@
|
|||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
|
||||||
|
<queries>
|
||||||
|
<intent>
|
||||||
|
<action android:name="android.media.action.DISPLAY_AUDIO_EFFECT_CONTROL_PANEL" />
|
||||||
|
</intent>
|
||||||
|
</queries>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".MainApplication"
|
android:name=".MainApplication"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package it.vfsfitvnm.vimusic.ui.screens.settings
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.media.audiofx.AudioEffect
|
import android.media.audiofx.AudioEffect
|
||||||
import android.text.format.DateUtils
|
import android.text.format.DateUtils
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.compose.animation.ExperimentalAnimationApi
|
import androidx.compose.animation.ExperimentalAnimationApi
|
||||||
@@ -66,15 +67,6 @@ fun PlayerSettingsScreen() {
|
|||||||
rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
val audioSessionId = remember(binder) {
|
|
||||||
val hasEqualizer = context.packageManager.resolveActivity(
|
|
||||||
Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL),
|
|
||||||
0
|
|
||||||
) != null
|
|
||||||
|
|
||||||
if (hasEqualizer) binder?.player?.audioSessionId else null
|
|
||||||
}
|
|
||||||
|
|
||||||
val sleepTimerMillisLeft by (binder?.sleepTimerMillisLeft
|
val sleepTimerMillisLeft by (binder?.sleepTimerMillisLeft
|
||||||
?: flowOf(null)).collectAsState(initial = null)
|
?: flowOf(null)).collectAsState(initial = null)
|
||||||
|
|
||||||
@@ -252,17 +244,18 @@ fun PlayerSettingsScreen() {
|
|||||||
title = "Equalizer",
|
title = "Equalizer",
|
||||||
text = "Interact with the system equalizer",
|
text = "Interact with the system equalizer",
|
||||||
onClick = {
|
onClick = {
|
||||||
activityResultLauncher.launch(
|
val intent = Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL).apply {
|
||||||
Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL).apply {
|
putExtra(AudioEffect.EXTRA_AUDIO_SESSION, binder?.player?.audioSessionId)
|
||||||
putExtra(AudioEffect.EXTRA_AUDIO_SESSION, audioSessionId)
|
putExtra(AudioEffect.EXTRA_PACKAGE_NAME, context.packageName)
|
||||||
putExtra(
|
putExtra(AudioEffect.EXTRA_CONTENT_TYPE, AudioEffect.CONTENT_TYPE_MUSIC)
|
||||||
AudioEffect.EXTRA_CONTENT_TYPE,
|
}
|
||||||
AudioEffect.CONTENT_TYPE_MUSIC
|
|
||||||
)
|
if (intent.resolveActivity(context.packageManager) != null) {
|
||||||
}
|
activityResultLauncher.launch(intent)
|
||||||
)
|
} else {
|
||||||
},
|
Toast.makeText(context, "No equalizer app found!", Toast.LENGTH_SHORT).show()
|
||||||
isEnabled = audioSessionId != null
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
SettingsEntry(
|
SettingsEntry(
|
||||||
|
|||||||
Reference in New Issue
Block a user