diff --git a/app/src/main/java/org/oxycblt/auxio/loading/LoadingFragment.kt b/app/src/main/java/org/oxycblt/auxio/loading/LoadingFragment.kt
index d762c19d2..da81f0a45 100644
--- a/app/src/main/java/org/oxycblt/auxio/loading/LoadingFragment.kt
+++ b/app/src/main/java/org/oxycblt/auxio/loading/LoadingFragment.kt
@@ -73,6 +73,16 @@ class LoadingFragment : Fragment() {
return binding.root
}
+ override fun onResume() {
+ super.onResume()
+
+ if (MusicStore.getInstance().loaded) {
+ findNavController().navigate(
+ LoadingFragmentDirections.actionToMain()
+ )
+ }
+ }
+
// --- PERMISSIONS ---
private fun noPermissions(): Boolean {
diff --git a/app/src/main/java/org/oxycblt/auxio/music/processing/MusicLoader.kt b/app/src/main/java/org/oxycblt/auxio/music/processing/MusicLoader.kt
index c67fa23cf..5cf1f10ad 100644
--- a/app/src/main/java/org/oxycblt/auxio/music/processing/MusicLoader.kt
+++ b/app/src/main/java/org/oxycblt/auxio/music/processing/MusicLoader.kt
@@ -62,8 +62,6 @@ class MusicLoader(private val app: Application) {
Genres.DEFAULT_SORT_ORDER
)
- val genrePlaceholder = app.getString(R.string.placeholder_genre)
-
// And then process those into Genre objects
genreCursor?.use { cursor ->
val idIndex = cursor.getColumnIndexOrThrow(Genres._ID)
@@ -71,7 +69,7 @@ class MusicLoader(private val app: Application) {
while (cursor.moveToNext()) {
val id = cursor.getLong(idIndex)
- val name = cursor.getStringOrNull(nameIndex) ?: genrePlaceholder
+ val name = cursor.getStringOrNull(nameIndex) ?: continue // No non-broken genre would be missing a name
genres.add(Genre(id, name))
}
@@ -119,12 +117,7 @@ class MusicLoader(private val app: Application) {
artistName = artistPlaceholder
}
- albums.add(
- Album(
- id = id, name = name, artistName = artistName,
- coverUri = coverUri, year = year
- )
- )
+ albums.add(Album(id, name, artistName, coverUri, year))
}
cursor.close()
@@ -170,12 +163,7 @@ class MusicLoader(private val app: Application) {
val track = cursor.getInt(trackIndex)
val duration = cursor.getLong(durationIndex)
- songs.add(
- Song(
- id, title, albumId,
- track, duration
- )
- )
+ songs.add(Song(id, title, albumId, track, duration))
}
cursor.close()
@@ -187,6 +175,7 @@ class MusicLoader(private val app: Application) {
// Then try to associate any genres with their respective songs
// This is stupidly inefficient, but I don't have another choice really.
+ // Blame the android devs for deciding to design MediaStore this way.
for (genre in genres) {
val songGenreCursor = resolver.query(
Genres.Members.getContentUri("external", genre.id),
@@ -207,6 +196,23 @@ class MusicLoader(private val app: Application) {
}
}
+ /*
+ // Fix that will group songs w/o genres into an unknown genre
+ // Currently disabled until it would actually benefit someone, otherwise its just
+ // a performance deadweight.
+ val songsWithoutGenres = songs.filter { it.genre == null }
+
+ if (songsWithoutGenres.isNotEmpty()) {
+ val unknownGenre = Genre(name = app.getString(R.string.placeholder_genre))
+
+ songsWithoutGenres.forEach {
+ unknownGenre.addSong(it)
+ }
+
+ genres.add(unknownGenre)
+ }
+ */
+
logD("Song search finished with ${songs.size} found")
}
}
diff --git a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackViewModel.kt b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackViewModel.kt
index e42d8cfed..767e8e0a4 100644
--- a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackViewModel.kt
+++ b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackViewModel.kt
@@ -298,6 +298,18 @@ class PlaybackViewModel : ViewModel(), PlaybackStateManager.Callback {
// --- SAVE/RESTORE FUNCTIONS ---
+ /**
+ * Force save the current [PlaybackStateManager] state to the database. Called by SettingsListFragment.
+ * @param context [Context] required.
+ */
+ fun savePlaybackState(context: Context) {
+ viewModelScope.launch {
+ playbackManager.saveStateToDatabase(context)
+
+ context.getString(R.string.debug_state_saved).createToast(context)
+ }
+ }
+
/**
* Get [PlaybackStateManager] to restore its state from the database, if needed. Called by MainFragment.
* @param context [Context] required.
@@ -310,18 +322,6 @@ class PlaybackViewModel : ViewModel(), PlaybackStateManager.Callback {
}
}
- /**
- * Force save the current [PlaybackStateManager] state to the database. Called by SettingsListFragment.
- * @param context [Context] required.
- */
- fun save(context: Context) {
- viewModelScope.launch {
- playbackManager.saveStateToDatabase(context)
-
- context.getString(R.string.debug_state_saved).createToast(context)
- }
- }
-
/** Attempt to restore the current playback state from an existing [PlaybackStateManager] instance */
private fun restorePlaybackState() {
logD("Attempting to restore playback state.")
diff --git a/app/src/main/java/org/oxycblt/auxio/settings/SettingsListFragment.kt b/app/src/main/java/org/oxycblt/auxio/settings/SettingsListFragment.kt
index 68ee7d3a7..5e8c054d2 100644
--- a/app/src/main/java/org/oxycblt/auxio/settings/SettingsListFragment.kt
+++ b/app/src/main/java/org/oxycblt/auxio/settings/SettingsListFragment.kt
@@ -14,7 +14,6 @@ import coil.Coil
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.customview.customView
import com.afollestad.materialdialogs.utils.invalidateDividers
-import org.oxycblt.auxio.BuildConfig
import org.oxycblt.auxio.R
import org.oxycblt.auxio.logD
import org.oxycblt.auxio.playback.PlaybackViewModel
@@ -48,13 +47,6 @@ class SettingsListFragment : PreferenceFragmentCompat() {
private fun recursivelyHandleChildren(pref: Preference) {
if (pref is PreferenceCategory) {
- // Show the debug category if this build is a debug build
- if (pref.title == getString(R.string.debug_title) && BuildConfig.DEBUG) {
- logD("Showing debug category.")
-
- pref.isVisible = true
- }
-
// If this preference is a category of its own, handle its own children
pref.children.forEach { recursivelyHandleChildren(it) }
} else {
@@ -133,7 +125,7 @@ class SettingsListFragment : PreferenceFragmentCompat() {
SettingsManager.Keys.KEY_DEBUG_SAVE -> {
onPreferenceClickListener = Preference.OnPreferenceClickListener {
- playbackModel.save(requireContext())
+ playbackModel.savePlaybackState(requireContext())
true
}
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 71c88c72d..7a0900bc1 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -51,7 +51,7 @@
Einstellungen
Aussehen
- Theme
+ Thema
Automatisch
Hell
Dunkel
@@ -59,7 +59,7 @@
Unbekannte Akzentfarbe
Anzeige
- Musikbibliothek-Items
+ Musikbibliothekitems
Benachrichtigung farblich anpassen
Albumcover am Benachrichtigung zeigen
Albumcover anzeigen
@@ -86,6 +86,8 @@
Lassen zufällig an, wenn ein neues Lied anspielen
Zurückspulen, bevor zurück springen
Zurückspulen, bevor zum vorheriger Lied springen
+ Wiedergabezustand abspeichern
+ der aktuell Wiedergabezustand jetzt abspeichern
Keine Musik gefunden
diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml
index 0997283ab..26564e8ea 100644
--- a/app/src/main/res/values/donottranslate.xml
+++ b/app/src/main/res/values/donottranslate.xml
@@ -8,11 +8,4 @@
%1$s / %2$s / %3$s
%1$s, %2$s
<b>%1$s</b>: %2$s
-
-
-
- Debug
- Save playback state
- Force save the current playback state
- State saved
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 7a5b075a0..01a3b4662 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -42,6 +42,8 @@
Go to artist
Go to album
+ State saved
+
About
Version
View on Github
@@ -88,6 +90,8 @@
Keep shuffle on when playing a new song
Rewind before skipping back
Rewind before skipping to the previous song
+ Save playback state
+ Save the current playback state now
No music found
diff --git a/app/src/main/res/xml/prefs_main.xml b/app/src/main/res/xml/prefs_main.xml
index bba55b50f..1c7a0bc67 100644
--- a/app/src/main/res/xml/prefs_main.xml
+++ b/app/src/main/res/xml/prefs_main.xml
@@ -126,18 +126,10 @@
app:key="KEY_PREV_REWIND"
app:summary="@string/setting_behavior_rewind_prev_desc" />
-
-
-
-
-
+ app:summary="@string/setting_behavior_save_desc" />
\ No newline at end of file