Set targetSdk to 33 (#267)

This commit is contained in:
vfsfitvnm 2022-10-19 18:17:49 +02:00
parent a8431e13ee
commit 9bd227e807
5 changed files with 45 additions and 30 deletions

View file

@ -10,7 +10,7 @@ android {
defaultConfig {
applicationId = "it.vfsfitvnm.vimusic"
minSdk = 21
targetSdk = 32
targetSdk = 33
versionCode = 18
versionName = "0.5.2"
}

View file

@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />

View file

@ -86,6 +86,7 @@ import it.vfsfitvnm.vimusic.utils.forceSeekToNext
import it.vfsfitvnm.vimusic.utils.forceSeekToPrevious
import it.vfsfitvnm.vimusic.utils.getEnum
import it.vfsfitvnm.vimusic.utils.intent
import it.vfsfitvnm.vimusic.utils.isAtLeastAndroid13
import it.vfsfitvnm.vimusic.utils.isInvincibilityEnabledKey
import it.vfsfitvnm.vimusic.utils.isShowingThumbnailInLockscreenKey
import it.vfsfitvnm.vimusic.utils.mediaItems
@ -310,7 +311,8 @@ class PlayerService : InvincibleService(), Player.Listener, PlaybackStatsListene
playTime = totalPlayTimeMs
)
)
} catch (_: SQLException) { }
} catch (_: SQLException) {
}
}
}
}
@ -426,8 +428,18 @@ class PlayerService : InvincibleService(), Player.Listener, PlaybackStatsListene
}
private fun maybeShowSongCoverInLockScreen() {
val bitmap = if (isShowingThumbnailInLockscreen) bitmapProvider.bitmap else null
metadataBuilder.putBitmap(MediaMetadata.METADATA_KEY_ALBUM_ART, bitmap)
val bitmap =
if (isAtLeastAndroid13 || isShowingThumbnailInLockscreen) bitmapProvider.bitmap else null
metadataBuilder.putBitmap(MediaMetadata.METADATA_KEY_ART, bitmap)
if (isAtLeastAndroid13 && player.currentMediaItemIndex == 0) {
metadataBuilder.putText(
MediaMetadata.METADATA_KEY_TITLE,
"${player.mediaMetadata.title} "
)
}
mediaSession.setMetadata(metadataBuilder.build())
}
@ -460,21 +472,14 @@ class PlayerService : InvincibleService(), Player.Listener, PlaybackStatsListene
override fun onEvents(player: Player, events: Player.Events) {
if (player.duration != C.TIME_UNSET) {
metadataBuilder
.putText(
MediaMetadata.METADATA_KEY_TITLE,
player.currentMediaItem?.mediaMetadata?.title
)
.putText(
MediaMetadata.METADATA_KEY_ARTIST,
player.currentMediaItem?.mediaMetadata?.artist
)
.putText(
MediaMetadata.METADATA_KEY_ALBUM,
player.currentMediaItem?.mediaMetadata?.albumTitle
)
.putLong(MediaMetadata.METADATA_KEY_DURATION, player.duration)
.build().let(mediaSession::setMetadata)
mediaSession.setMetadata(
metadataBuilder
.putText(MediaMetadata.METADATA_KEY_TITLE, player.mediaMetadata.title)
.putText(MediaMetadata.METADATA_KEY_ARTIST, player.mediaMetadata.artist)
.putText(MediaMetadata.METADATA_KEY_ALBUM, player.mediaMetadata.albumTitle)
.putLong(MediaMetadata.METADATA_KEY_DURATION, player.duration)
.build()
)
}
stateBuilder
@ -538,6 +543,7 @@ class PlayerService : InvincibleService(), Player.Listener, PlaybackStatsListene
isShowingThumbnailInLockscreen = sharedPreferences.getBoolean(key, true)
maybeShowSongCoverInLockScreen()
}
trackLoopEnabledKey, queueLoopEnabledKey -> {
player.repeatMode = when {
preferences.getBoolean(trackLoopEnabledKey, false) -> Player.REPEAT_MODE_ONE

View file

@ -1,11 +1,15 @@
package it.vfsfitvnm.vimusic.ui.screens.settings
import android.os.Build
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
@ -16,9 +20,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import it.vfsfitvnm.vimusic.LocalPlayerAwareWindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.asPaddingValues
import androidx.compose.foundation.layout.only
import it.vfsfitvnm.vimusic.enums.ColorPaletteMode
import it.vfsfitvnm.vimusic.enums.ColorPaletteName
import it.vfsfitvnm.vimusic.enums.ThumbnailRoundness
@ -27,6 +28,7 @@ import it.vfsfitvnm.vimusic.ui.styling.LocalAppearance
import it.vfsfitvnm.vimusic.utils.applyFontPaddingKey
import it.vfsfitvnm.vimusic.utils.colorPaletteModeKey
import it.vfsfitvnm.vimusic.utils.colorPaletteNameKey
import it.vfsfitvnm.vimusic.utils.isAtLeastAndroid13
import it.vfsfitvnm.vimusic.utils.isShowingThumbnailInLockscreenKey
import it.vfsfitvnm.vimusic.utils.rememberPreference
import it.vfsfitvnm.vimusic.utils.thumbnailRoundnessKey
@ -114,15 +116,17 @@ fun AppearanceSettings() {
onCheckedChange = { applyFontPadding = it }
)
SettingsGroupSpacer()
if (!isAtLeastAndroid13) {
SettingsGroupSpacer()
SettingsEntryGroupText(title = "LOCKSCREEN")
SettingsEntryGroupText(title = "LOCKSCREEN")
SwitchSettingEntry(
title = "Show song cover",
text = "Use the playing song cover as the lockscreen wallpaper",
isChecked = isShowingThumbnailInLockscreen,
onCheckedChange = { isShowingThumbnailInLockscreen = it }
)
SwitchSettingEntry(
title = "Show song cover",
text = "Use the playing song cover as the lockscreen wallpaper",
isChecked = isShowingThumbnailInLockscreen,
onCheckedChange = { isShowingThumbnailInLockscreen = it }
)
}
}
}

View file

@ -1,6 +1,7 @@
package it.vfsfitvnm.vimusic.utils
import android.net.Uri
import android.os.Build
import android.text.format.DateUtils
import androidx.core.net.toUri
import androidx.core.os.bundleOf
@ -111,3 +112,6 @@ suspend fun Result<Innertube.PlaylistOrAlbumPage>.completed(): Result<Innertube.
return Result.success(playlistPage)
}
inline val isAtLeastAndroid13
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU