all: use compat when stopping foreground services
Use ServiceCompat.stopForeground instead of stopForeground. This is preliminary preparation for Android 13. I can only change SDK versions however when the Android Gradle Plugin makes a new release though.
This commit is contained in:
parent
f187900d0c
commit
cf8e887f9a
5 changed files with 16 additions and 14 deletions
15
CHANGELOG.md
15
CHANGELOG.md
|
@ -3,18 +3,17 @@
|
||||||
## v2.4.0
|
## v2.4.0
|
||||||
|
|
||||||
#### What's New
|
#### What's New
|
||||||
- Excluded directories has been revampled into "Music folders"
|
- Excluded directories has been revamped into "Music folders"
|
||||||
- Folders on external drives can now be excluded [#134]
|
- Folders on external drives can now be excluded [#134]
|
||||||
- Added new "Include" option to restrict indexing to a particular folder [#154]
|
- Added new "Include" option to restrict indexing to a particular folder [#154]
|
||||||
- Added a new view for song properties (Such as Bitrate)
|
- Added a new view for song properties (Such as Bitrate) [#144]
|
||||||
- The playback bar now has a new design, with an improved progress indicator and a
|
- The playback bar now has a new design, with an improved progress indicator and a skip action
|
||||||
skip action
|
|
||||||
|
|
||||||
#### What's Improved
|
#### What's Improved
|
||||||
- The toolbar in the home UI now collapses when scrolling
|
- The toolbar in the home UI now collapses when scrolling
|
||||||
- The toolbar layout is now consistent with Material Design 3
|
- The toolbar layout is now consistent with Material Design 3
|
||||||
- Genre parsing now handles multiple integer values and cover/remix indicators (May wipe playback state)
|
- Genre parsing now handles multiple integer values and cover/remix indicators (May wipe playback state)
|
||||||
- "Rounded album covers" option is no longer dependent on "Show album covers" option
|
- "Rounded album covers" option is no longer dependent on "Show album covers" option [#152]
|
||||||
- Added song actions to the playback panel
|
- Added song actions to the playback panel
|
||||||
- Playback controls are now easier to reach when gesture navigation is enabled
|
- Playback controls are now easier to reach when gesture navigation is enabled
|
||||||
- Added Play Next/Add to Queue options to artists and genres
|
- Added Play Next/Add to Queue options to artists and genres
|
||||||
|
@ -25,12 +24,12 @@
|
||||||
- Playback bar now picks the larger inset in case that gesture inset is missing [#149]
|
- Playback bar now picks the larger inset in case that gesture inset is missing [#149]
|
||||||
- Fixed unusable excluded directory UI
|
- Fixed unusable excluded directory UI
|
||||||
- Songs with no data (i.e size of 0) are now filtered out
|
- Songs with no data (i.e size of 0) are now filtered out
|
||||||
- Fixed non-sensical menu items from appearing on songs
|
- Fixed nonsensical menu items from appearing on songs
|
||||||
- Fixed issue where multiple menus would open if long-clicks occured simultaniously
|
- Fixed issue where multiple menus would open if long-clicks occured simultaneously
|
||||||
|
|
||||||
#### Dev/Meta
|
#### Dev/Meta
|
||||||
- New translations [Fjuro -> Czech, Konstantin Tutsch -> German]
|
- New translations [Fjuro -> Czech, Konstantin Tutsch -> German]
|
||||||
- Moved music loading to a foreground service
|
- Moved music loading to a foreground service [#72]
|
||||||
- Phased out `ImageButton` for `MaterialButton`
|
- Phased out `ImageButton` for `MaterialButton`
|
||||||
- Unified icon sizing
|
- Unified icon sizing
|
||||||
- Properly handle volumes throughout the entire music loading process
|
- Properly handle volumes throughout the entire music loading process
|
||||||
|
|
|
@ -245,11 +245,12 @@ class HomeFragment : ViewBindingFragment<FragmentHomeBinding>(), Toolbar.OnMenuI
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSortMenu(displayMode: DisplayMode, isVisible: (Int) -> Boolean) {
|
private fun updateSortMenu(displayMode: DisplayMode, isVisible: (Int) -> Boolean) {
|
||||||
val sortItem = requireNotNull(sortItem) { "Cannot update sort menu while detached" }
|
val sortMenu =
|
||||||
|
requireNotNull(sortItem?.subMenu) { "Cannot update sort menu while detached" }
|
||||||
|
|
||||||
val toHighlight = homeModel.getSortForDisplay(displayMode)
|
val toHighlight = homeModel.getSortForDisplay(displayMode)
|
||||||
|
|
||||||
for (option in sortItem.subMenu) {
|
for (option in sortMenu) {
|
||||||
if (option.itemId == toHighlight.itemId) {
|
if (option.itemId == toHighlight.itemId) {
|
||||||
option.isChecked = true
|
option.isChecked = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
|
import androidx.core.app.ServiceCompat
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
|
@ -136,7 +137,7 @@ class IndexerService : Service(), Indexer.Callback {
|
||||||
|
|
||||||
private fun stopForegroundSession() {
|
private fun stopForegroundSession() {
|
||||||
if (isForeground) {
|
if (isForeground) {
|
||||||
stopForeground(true)
|
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE)
|
||||||
isForeground = false
|
isForeground = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import android.content.Intent
|
||||||
import android.content.IntentFilter
|
import android.content.IntentFilter
|
||||||
import android.media.AudioManager
|
import android.media.AudioManager
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
|
import androidx.core.app.ServiceCompat
|
||||||
import com.google.android.exoplayer2.C
|
import com.google.android.exoplayer2.C
|
||||||
import com.google.android.exoplayer2.ExoPlayer
|
import com.google.android.exoplayer2.ExoPlayer
|
||||||
import com.google.android.exoplayer2.MediaItem
|
import com.google.android.exoplayer2.MediaItem
|
||||||
|
@ -159,7 +160,7 @@ class PlaybackService :
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
|
|
||||||
stopForeground(true)
|
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE)
|
||||||
isForeground = false
|
isForeground = false
|
||||||
|
|
||||||
// Pause just in case this destruction was unexpected.
|
// Pause just in case this destruction was unexpected.
|
||||||
|
@ -356,7 +357,7 @@ class PlaybackService :
|
||||||
|
|
||||||
/** Stop the foreground state and hide the notification */
|
/** Stop the foreground state and hide the notification */
|
||||||
private fun stopAndSave() {
|
private fun stopAndSave() {
|
||||||
stopForeground(true)
|
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE)
|
||||||
isForeground = false
|
isForeground = false
|
||||||
saveScope.launch { playbackManager.saveState(this@PlaybackService) }
|
saveScope.launch { playbackManager.saveState(this@PlaybackService) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue