playback: do not check for version w/notification
Do not check for the version when managing the notification. Some OEMs will update the android system, causing the version number to change, but will THEN not update the system UI, completely breaking my compat hacks. Because you know. Reasons. Fix this by always applying future and obsolete methods of updating the media notification regardless of the context. Resolves #219.
This commit is contained in:
parent
4d8c2abd09
commit
5b2817b2f2
3 changed files with 33 additions and 49 deletions
|
|
@ -14,8 +14,9 @@
|
|||
- Added a way to access the system equalizer from the playback menu.
|
||||
|
||||
#### What's Fixed
|
||||
- Fixed "@android:string/<ok/cancel>" strings from appearing in dialog
|
||||
- Fixed "@android:string/<ok/cancel>" strings from appearing in dialog
|
||||
buttons
|
||||
- Fixed issue where LG phones would not show metadata in the notification
|
||||
|
||||
#### What's Changed
|
||||
- Menus are now opened using a new button to the side of all items
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.SystemClock
|
||||
import android.support.v4.media.MediaDescriptionCompat
|
||||
|
|
@ -62,9 +61,6 @@ import org.oxycblt.auxio.util.logD
|
|||
* @author OxygenCobalt
|
||||
*
|
||||
* TODO: Remove the player callback once smooth seeking is implemented
|
||||
*
|
||||
* TODO: Rework what is considered to "start foreground" and what is not from the context of this
|
||||
* object. This could help reduce the amount of post calls I send on Android 13 onwards, hopefully.
|
||||
*/
|
||||
class MediaSessionComponent(
|
||||
private val context: Context,
|
||||
|
|
@ -229,11 +225,7 @@ class MediaSessionComponent(
|
|||
|
||||
override fun onPlayingChanged(isPlaying: Boolean) {
|
||||
invalidateSessionState()
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
|
||||
// Android 13 automatically handles the playing state.
|
||||
notification.updatePlaying(playbackManager.isPlaying)
|
||||
}
|
||||
notification.updatePlaying(playbackManager.isPlaying)
|
||||
|
||||
if (!provider.isBusy) {
|
||||
// Still probably want to start the notification though regardless of the version,
|
||||
|
|
@ -409,49 +401,45 @@ class MediaSessionComponent(
|
|||
|
||||
state.setState(playerState, player.currentPosition, 1.0f, SystemClock.elapsedRealtime())
|
||||
|
||||
// Android 13+ leverages custom actions.
|
||||
// Android 13+ leverages custom actions in the notification.
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
val extraAction =
|
||||
if (settings.useAltNotifAction) {
|
||||
PlaybackStateCompat.CustomAction.Builder(
|
||||
PlaybackService.ACTION_INVERT_SHUFFLE,
|
||||
context.getString(R.string.desc_change_repeat),
|
||||
if (playbackManager.isShuffled) {
|
||||
R.drawable.ic_shuffle_on_24
|
||||
} else {
|
||||
R.drawable.ic_shuffle_off_24
|
||||
})
|
||||
} else {
|
||||
PlaybackStateCompat.CustomAction.Builder(
|
||||
PlaybackService.ACTION_INC_REPEAT_MODE,
|
||||
context.getString(R.string.desc_change_repeat),
|
||||
playbackManager.repeatMode.icon)
|
||||
}
|
||||
|
||||
val exitAction =
|
||||
val extraAction =
|
||||
if (settings.useAltNotifAction) {
|
||||
PlaybackStateCompat.CustomAction.Builder(
|
||||
PlaybackService.ACTION_EXIT,
|
||||
context.getString(R.string.desc_exit),
|
||||
R.drawable.ic_close_24)
|
||||
.build()
|
||||
PlaybackService.ACTION_INVERT_SHUFFLE,
|
||||
context.getString(R.string.desc_change_repeat),
|
||||
if (playbackManager.isShuffled) {
|
||||
R.drawable.ic_shuffle_on_24
|
||||
} else {
|
||||
R.drawable.ic_shuffle_off_24
|
||||
})
|
||||
} else {
|
||||
PlaybackStateCompat.CustomAction.Builder(
|
||||
PlaybackService.ACTION_INC_REPEAT_MODE,
|
||||
context.getString(R.string.desc_change_repeat),
|
||||
playbackManager.repeatMode.icon)
|
||||
}
|
||||
|
||||
state.addCustomAction(extraAction.build())
|
||||
state.addCustomAction(exitAction)
|
||||
}
|
||||
val exitAction =
|
||||
PlaybackStateCompat.CustomAction.Builder(
|
||||
PlaybackService.ACTION_EXIT,
|
||||
context.getString(R.string.desc_exit),
|
||||
R.drawable.ic_close_24)
|
||||
.build()
|
||||
|
||||
state.addCustomAction(extraAction.build())
|
||||
state.addCustomAction(exitAction)
|
||||
|
||||
mediaSession.setPlaybackState(state.build())
|
||||
}
|
||||
|
||||
private fun invalidateSecondaryAction() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
invalidateSessionState()
|
||||
invalidateSessionState()
|
||||
|
||||
if (settings.useAltNotifAction) {
|
||||
notification.updateShuffled(playbackManager.isShuffled)
|
||||
} else {
|
||||
if (settings.useAltNotifAction) {
|
||||
notification.updateShuffled(playbackManager.isShuffled)
|
||||
} else {
|
||||
notification.updateRepeatMode(playbackManager.repeatMode)
|
||||
}
|
||||
notification.updateRepeatMode(playbackManager.repeatMode)
|
||||
}
|
||||
|
||||
if (!provider.isBusy) {
|
||||
|
|
|
|||
|
|
@ -67,11 +67,6 @@ class NotificationComponent(private val context: Context, sessionToken: MediaSes
|
|||
// --- STATE FUNCTIONS ---
|
||||
|
||||
fun updateMetadata(metadata: MediaMetadataCompat) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
// Notification is automatically filled in by media session, ignore
|
||||
return
|
||||
}
|
||||
|
||||
setContentTitle(metadata.getString(MediaMetadataCompat.METADATA_KEY_TITLE))
|
||||
setContentText(metadata.getText(MediaMetadataCompat.METADATA_KEY_ARTIST))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue