mirror of
https://github.com/cmclark00/RetroMusicPlayer.git
synced 2025-05-18 08:05:20 +01:00
Add support for Android 14-15
This commit is contained in:
parent
6752ae2afa
commit
54393ca888
17 changed files with 81 additions and 39 deletions
|
@ -69,11 +69,11 @@ android {
|
|||
warning 'ImpliedQuantity', 'Instantiatable', 'MissingQuantity', 'MissingTranslation', 'StringFormatInvalid'
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
sourceCompatibility JavaVersion.VERSION_21
|
||||
targetCompatibility JavaVersion.VERSION_21
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "17"
|
||||
jvmTarget = "21"
|
||||
}
|
||||
dependenciesInfo {
|
||||
includeInApk = false
|
||||
|
|
5
app/proguard-rules.pro
vendored
5
app/proguard-rules.pro
vendored
|
@ -20,6 +20,11 @@
|
|||
# debugging stack traces.
|
||||
-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# required after agp 8 made r8 full mode default
|
||||
-keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken
|
||||
-keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken
|
||||
-keep,allowobfuscation,allowshrinking public class * implements java.lang.reflect.Type
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
|
|
|
@ -252,7 +252,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
|
|||
PreferenceUtil.unregisterOnSharedPreferenceChangedListener(this)
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String?) {
|
||||
when (key) {
|
||||
SWIPE_DOWN_DISMISS -> {
|
||||
bottomSheetBehavior.isHideable = PreferenceUtil.swipeDownToDismiss
|
||||
|
|
|
@ -68,6 +68,7 @@ class AppShortcutLauncherActivity : Activity() {
|
|||
INTENT_EXTRA_PLAYLIST to playlist,
|
||||
INTENT_EXTRA_SHUFFLE_MODE to shuffleMode
|
||||
)
|
||||
intent.setPackage(this.packageName)
|
||||
|
||||
intent.putExtras(bundle)
|
||||
|
||||
|
|
|
@ -131,6 +131,29 @@ class SleepTimerDialog : DialogFragment() {
|
|||
SystemClock.elapsedRealtime() + minutes * 60 * 1000
|
||||
PreferenceUtil.nextSleepTimerElapsedRealTime = nextSleepTimerElapsedTime.toInt()
|
||||
val am = requireContext().getSystemService<AlarmManager>()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
if (am?.canScheduleExactAlarms() == false) {
|
||||
Intent().also { intent ->
|
||||
intent.action = Settings.ACTION_REQUEST_SCHEDULE_EXACT_ALARM
|
||||
context.startActivity(intent)
|
||||
}
|
||||
} else {
|
||||
am?.setExact(
|
||||
AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||
nextSleepTimerElapsedTime,
|
||||
pi
|
||||
)
|
||||
|
||||
Toast.makeText(
|
||||
requireContext(),
|
||||
requireContext().resources.getString(
|
||||
R.string.sleep_timer_set,
|
||||
minutes
|
||||
),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
if (VersionUtils.hasS() && am?.canScheduleExactAlarms() != true) {
|
||||
Toast.makeText(
|
||||
|
|
|
@ -374,7 +374,7 @@ abstract class AbsPlayerFragment(@LayoutRes layout: Int) : AbsMusicServiceFragme
|
|||
e1: MotionEvent?,
|
||||
e2: MotionEvent,
|
||||
distanceX: Float,
|
||||
distanceY: Float
|
||||
distanceY: Float,
|
||||
): Boolean {
|
||||
return when {
|
||||
abs(distanceX) > abs(distanceY) -> {
|
||||
|
|
|
@ -69,9 +69,9 @@ class CoverLyricsFragment : AbsMusicServiceFragment(R.layout.fragment_cover_lyri
|
|||
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String?) {
|
||||
if (key == SHOW_LYRICS) {
|
||||
if (sharedPreferences?.getBoolean(key, false) == true) {
|
||||
if (sharedPreferences.getBoolean(key, false) == true) {
|
||||
progressViewUpdateHelper?.start()
|
||||
binding.root.isVisible = true
|
||||
updateLyrics()
|
||||
|
|
|
@ -152,7 +152,7 @@ class PlayerFragment : AbsPlayerFragment(R.layout.fragment_player),
|
|||
)
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String?) {
|
||||
if (key == SNOWFALL) {
|
||||
startOrStopSnow(PreferenceUtil.isSnowFalling)
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import code.name.monkey.retromusic.util.PreferenceUtil
|
|||
|
||||
class NotificationSettingsFragment : AbsSettingsFragment(),
|
||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String?) {
|
||||
if (key == CLASSIC_NOTIFICATION) {
|
||||
if (VERSION.SDK_INT >= VERSION_CODES.O) {
|
||||
findPreference<Preference>(COLORED_NOTIFICATION)?.isEnabled =
|
||||
|
|
|
@ -72,7 +72,7 @@ class NowPlayingSettingsFragment : AbsSettingsFragment(),
|
|||
PreferenceUtil.unregisterOnSharedPreferenceChangedListener(this)
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String?) {
|
||||
when (key) {
|
||||
NOW_PLAYING_SCREEN_ID -> updateNowPlayingScreenSummary()
|
||||
ALBUM_COVER_STYLE -> updateAlbumCoverStyleSummary()
|
||||
|
|
|
@ -39,11 +39,14 @@ import java.io.File
|
|||
|
||||
object RetroGlideExtension {
|
||||
|
||||
private const val DEFAULT_ARTIST_IMAGE =
|
||||
R.drawable.default_artist_art
|
||||
private const val DEFAULT_SONG_IMAGE: Int = R.drawable.default_audio_art
|
||||
private const val DEFAULT_ALBUM_IMAGE = R.drawable.default_album_art
|
||||
private const val DEFAULT_ERROR_IMAGE_BANNER = R.drawable.material_design_default
|
||||
private val DEFAULT_ARTIST_IMAGE
|
||||
get() = R.drawable.default_artist_art
|
||||
private val DEFAULT_SONG_IMAGE: Int
|
||||
get() = R.drawable.default_audio_art
|
||||
private val DEFAULT_ALBUM_IMAGE
|
||||
get() = R.drawable.default_album_art
|
||||
private val DEFAULT_ERROR_IMAGE_BANNER
|
||||
get() = R.drawable.material_design_default
|
||||
|
||||
private val DEFAULT_DISK_CACHE_STRATEGY_ARTIST = DiskCacheStrategy.RESOURCE
|
||||
private val DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.NONE
|
||||
|
|
|
@ -20,7 +20,8 @@ import code.name.monkey.retromusic.R
|
|||
|
||||
object HorizontalAdapterHelper {
|
||||
|
||||
const val LAYOUT_RES = R.layout.item_image
|
||||
val LAYOUT_RES
|
||||
get() = R.layout.item_image
|
||||
|
||||
private const val TYPE_FIRST = 1
|
||||
private const val TYPE_MIDDLE = 2
|
||||
|
|
|
@ -48,7 +48,8 @@ import org.koin.core.component.get
|
|||
import java.io.File
|
||||
|
||||
object SongMenuHelper : KoinComponent {
|
||||
const val MENU_RES = R.menu.menu_item_song
|
||||
val MENU_RES
|
||||
get() = R.menu.menu_item_song
|
||||
|
||||
fun handleMenuClick(activity: FragmentActivity, song: Song, menuItemId: Int): Boolean {
|
||||
val libraryViewModel = activity.getViewModel() as LibraryViewModel
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.media.AudioManager
|
|||
import android.media.MediaPlayer
|
||||
import android.media.PlaybackParams
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.core.net.toUri
|
||||
import androidx.media.AudioAttributesCompat
|
||||
|
@ -157,9 +158,11 @@ abstract class LocalPlayback(val context: Context) : Playback, MediaPlayer.OnErr
|
|||
|
||||
private fun registerBecomingNoisyReceiver() {
|
||||
if (!becomingNoisyReceiverRegistered) {
|
||||
context.registerReceiver(
|
||||
ContextCompat.registerReceiver(
|
||||
context,
|
||||
becomingNoisyReceiver,
|
||||
becomingNoisyReceiverIntentFilter
|
||||
becomingNoisyReceiverIntentFilter,
|
||||
ContextCompat.RECEIVER_EXPORTED
|
||||
)
|
||||
becomingNoisyReceiverRegistered = true
|
||||
}
|
||||
|
|
|
@ -633,7 +633,9 @@ class MusicService : MediaBrowserServiceCompat(),
|
|||
}
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||
override fun onSharedPreferenceChanged(
|
||||
sharedPreferences: SharedPreferences, key: String?,
|
||||
) {
|
||||
when (key) {
|
||||
PLAYBACK_SPEED, PLAYBACK_PITCH -> {
|
||||
updateMediaSessionPlaybackState()
|
||||
|
@ -1276,7 +1278,7 @@ class MusicService : MediaBrowserServiceCompat(),
|
|||
|
||||
private fun registerHeadsetEvents() {
|
||||
if (!headsetReceiverRegistered && isHeadsetPlugged) {
|
||||
registerReceiver(headsetReceiver, headsetReceiverIntentFilter)
|
||||
ContextCompat.registerReceiver(this, headsetReceiver, headsetReceiverIntentFilter, ContextCompat.RECEIVER_EXPORTED)
|
||||
headsetReceiverRegistered = true
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue