all: fix sloppy code

Fix some dumb and sloppy code that I made in the rush to complete
2.2.0.
This commit is contained in:
OxygenCobalt 2022-02-07 20:08:18 -07:00
parent 245e0f5dc1
commit 4a326cc4ff
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
4 changed files with 11 additions and 18 deletions

View file

@ -1,11 +1,12 @@
# Changelog
## dev [v2.2.1 or v2.3.0]
- Updated chinese translations [courtesy of cccClyde]
## v2.2.0
#### What's New:
- Added arabic translations [courtesy of hasanpasha]
- Better russian translations [courtesy of lisiczka43]
- Added Arabic translations [Courtesy of hasanpasha]
- Improved Russian translations [Courtesy of lisiczka43]
- Added option to reload the music library
#### What's Improved:
@ -18,9 +19,10 @@ artist they are grouped up in
#### What's Fixed:
- Fixed crash on some devices configured to use French or Czech translations
- Malformed indicies should now be corrected when the playback state is restored
- Malformed indices should now be corrected when the playback state is restored
- Fixed issue where track numbers would not be shown in the native language's numeric format
- Fixed issue where the preference view would apply the M3 switches inconsistently
- Fixed issue where the now playing indicator on the playback screen would use an internal name
#### Dev/Meta:
- Removed 1.4.X compat

View file

@ -72,7 +72,6 @@ import java.lang.Exception
*
* @author OxygenCobalt
*/
@Suppress("InlinedApi")
class MusicLoader {
data class Library(
val genres: List<Genre>,
@ -107,6 +106,7 @@ class MusicLoader {
)
}
@Suppress("InlinedApi")
private fun loadSongs(context: Context): List<Song> {
var songs = mutableListOf<Song>()
val blacklistDatabase = ExcludedDatabase.getInstance(context)
@ -285,7 +285,7 @@ class MusicLoader {
private fun readGenres(context: Context, songs: List<Song>): List<Genre> {
val genres = mutableListOf<Genre>()
val genreCursor = context.contentResolver.query(
val genreCursor = context.applicationContext.contentResolver.query(
MediaStore.Audio.Genres.EXTERNAL_CONTENT_URI,
arrayOf(
MediaStore.Audio.Genres._ID,
@ -338,7 +338,7 @@ class MusicLoader {
val genreSongs = mutableListOf<Song>()
// Don't even bother blacklisting here as useless iterations are less expensive than IO
val songCursor = context.contentResolver.query(
val songCursor = context.applicationContext.contentResolver.query(
MediaStore.Audio.Genres.Members.getContentUri("external", genreId),
arrayOf(MediaStore.Audio.Genres.Members._ID),
null, null, null
@ -356,7 +356,7 @@ class MusicLoader {
}
}
// Some genres might be empty due to MediaStore empty.
// Some genres might be empty due to MediaStore insanity.
// If that is the case, we drop them.
return genreSongs.ifEmpty { null }
}

View file

@ -519,8 +519,6 @@ class PlaybackStateManager private constructor() {
val database = PlaybackStateDatabase.getInstance(context)
logD("$mPlaybackMode")
database.writeState(
PlaybackStateDatabase.SavedState(
mSong, mPosition, mParent, mIndex,
@ -595,14 +593,6 @@ class PlaybackStateManager private constructor() {
private fun unpackQueue(queue: MutableList<Song>) {
mQueue = queue
// Sanity check: Ensure that the
mSong?.let { song ->
while (mQueue.getOrNull(mIndex) != song) {
mIndex--
}
}
pushQueueUpdate()
}
@ -633,6 +623,7 @@ class PlaybackStateManager private constructor() {
if (correctedIndex > -1) {
logD("Correcting malformed index to $correctedIndex")
mIndex = correctedIndex
pushQueueUpdate()
}
}
}

View file

@ -177,7 +177,7 @@
</plurals>
<plurals name="fmt_album_count">
<item quantity="zero">ألبومات d%</item>
<item quantity="zero">%d ألبومات</item>
<item quantity="one">%d البوم</item>
<item quantity="two">%d ألبومات</item>
<item quantity="few">%d ألبومات</item>