From 08caa01dca2083fe76e754f7d96a4c815fa529bd Mon Sep 17 00:00:00 2001 From: OxygenCobalt Date: Fri, 3 Jun 2022 20:12:27 -0600 Subject: [PATCH] music: add indexer service Add a dedicated service towards the loading of the music library. This new service was created for two reasons: 1. Music loading is slow and resource-intensive, so putting it on the ViewModel layer just didn't seem right and made it vulnerable to the OS simply stopping the loading process. 2. For automatic rescanning [#72], there must be something watching the music library and waiting for a change in the background. This would require a service as that is probably the least insane way to do that kind of background work. I have no garuntees how viable the service might be. If anything, it might be halted by some insane android restriction or issue that makes it more or less impossible to use for most apps, and I will have to largely drop truly automatic rescanning. --- app/src/main/AndroidManifest.xml | 8 + .../java/org/oxycblt/auxio/IntegerTable.kt | 4 +- .../java/org/oxycblt/auxio/MainActivity.kt | 2 + .../java/org/oxycblt/auxio/MainFragment.kt | 5 - .../org/oxycblt/auxio/home/HomeFragment.kt | 6 +- .../java/org/oxycblt/auxio/music/Indexer.kt | 9 +- .../org/oxycblt/auxio/music/IndexerService.kt | 172 ++++++++++++++++++ .../oxycblt/auxio/music/IndexerViewModel.kt | 34 +--- .../org/oxycblt/auxio/music/MusicStore.kt | 5 +- .../auxio/playback/PlaybackPanelFragment.kt | 1 + .../auxio/playback/PlaybackViewModel.kt | 3 +- .../playback/system/NotificationComponent.kt | 8 +- .../org/oxycblt/auxio/util/ContextUtil.kt | 4 +- .../java/org/oxycblt/auxio/widgets/Forms.kt | 19 +- app/src/main/res/drawable/ic_indexer.xml | 11 ++ app/src/main/res/values/strings.xml | 1 + 16 files changed, 233 insertions(+), 59 deletions(-) create mode 100644 app/src/main/java/org/oxycblt/auxio/music/IndexerService.kt create mode 100644 app/src/main/res/drawable/ic_indexer.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 66e423a74..855c606ea 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -67,6 +67,13 @@ + + + A simple, rational music player for android. Music Playback + Music Loading View and control music playback