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
|
||||
|
||||
#### 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]
|
||||
- Added new "Include" option to restrict indexing to a particular folder [#154]
|
||||
- Added a new view for song properties (Such as Bitrate)
|
||||
- The playback bar now has a new design, with an improved progress indicator and a
|
||||
skip action
|
||||
- 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 skip action
|
||||
|
||||
#### What's Improved
|
||||
- The toolbar in the home UI now collapses when scrolling
|
||||
- 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)
|
||||
- "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
|
||||
- Playback controls are now easier to reach when gesture navigation is enabled
|
||||
- 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]
|
||||
- Fixed unusable excluded directory UI
|
||||
- Songs with no data (i.e size of 0) are now filtered out
|
||||
- Fixed non-sensical menu items from appearing on songs
|
||||
- Fixed issue where multiple menus would open if long-clicks occured simultaniously
|
||||
- Fixed nonsensical menu items from appearing on songs
|
||||
- Fixed issue where multiple menus would open if long-clicks occured simultaneously
|
||||
|
||||
#### Dev/Meta
|
||||
- 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`
|
||||
- Unified icon sizing
|
||||
- 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) {
|
||||
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)
|
||||
|
||||
for (option in sortItem.subMenu) {
|
||||
for (option in sortMenu) {
|
||||
if (option.itemId == toHighlight.itemId) {
|
||||
option.isChecked = true
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import android.content.Intent
|
|||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.app.ServiceCompat
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
|
@ -136,7 +137,7 @@ class IndexerService : Service(), Indexer.Callback {
|
|||
|
||||
private fun stopForegroundSession() {
|
||||
if (isForeground) {
|
||||
stopForeground(true)
|
||||
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE)
|
||||
isForeground = false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import android.content.Intent
|
|||
import android.content.IntentFilter
|
||||
import android.media.AudioManager
|
||||
import android.os.IBinder
|
||||
import androidx.core.app.ServiceCompat
|
||||
import com.google.android.exoplayer2.C
|
||||
import com.google.android.exoplayer2.ExoPlayer
|
||||
import com.google.android.exoplayer2.MediaItem
|
||||
|
@ -159,7 +160,7 @@ class PlaybackService :
|
|||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
|
||||
stopForeground(true)
|
||||
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE)
|
||||
isForeground = false
|
||||
|
||||
// Pause just in case this destruction was unexpected.
|
||||
|
@ -356,7 +357,7 @@ class PlaybackService :
|
|||
|
||||
/** Stop the foreground state and hide the notification */
|
||||
private fun stopAndSave() {
|
||||
stopForeground(true)
|
||||
ServiceCompat.stopForeground(this, ServiceCompat.STOP_FOREGROUND_REMOVE)
|
||||
isForeground = false
|
||||
saveScope.launch { playbackManager.saveState(this@PlaybackService) }
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
<string name="lbl_relative_path">Parent path</string>
|
||||
<string name="lbl_format">Format</string>
|
||||
<string name="lbl_size">Size</string>
|
||||
<string name="lbl_bitrate">Bitrate</string>
|
||||
<string name="lbl_bitrate">Bit rate</string>
|
||||
<string name="lbl_sample_rate">Sample rate</string>
|
||||
|
||||
<string name="lbl_state_saved">State saved</string>
|
||||
|
|
Loading…
Reference in a new issue