From 23615689bd3b69252747f408240dc52d557dbc04 Mon Sep 17 00:00:00 2001 From: Alexander Capehart Date: Sun, 22 Jun 2025 16:45:39 -0600 Subject: [PATCH 1/3] music: make file tree cache configurable --- .../oxycblt/auxio/music/MusicRepository.kt | 9 ++- .../org/oxycblt/auxio/music/MusicSettings.kt | 8 ++- .../auxio/music/shim/NoOpFileTreeCache.kt | 61 +++++++++++++++++++ app/src/main/res/values/settings.xml | 1 + app/src/main/res/values/strings.xml | 2 + app/src/main/res/xml/preferences_root.xml | 5 ++ 6 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/org/oxycblt/auxio/music/shim/NoOpFileTreeCache.kt diff --git a/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt b/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt index f83f202e9..8574205b2 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/MusicRepository.kt @@ -29,6 +29,7 @@ import kotlinx.coroutines.withContext import kotlinx.coroutines.yield import org.oxycblt.auxio.image.covers.SettingCovers import org.oxycblt.auxio.music.MusicRepository.IndexingWorker +import org.oxycblt.auxio.music.shim.NoOpFileTreeCache import org.oxycblt.auxio.music.shim.WriteOnlyFileTreeCache import org.oxycblt.auxio.music.shim.WriteOnlyMutableCache import org.oxycblt.musikr.IndexingProgress @@ -396,8 +397,12 @@ constructor( val cache = if (withCache) cache else WriteOnlyMutableCache(cache) val covers = settingCovers.mutate(context, newRevision) val fileTreeCache = - if (withCache) FileTreeCache.from(context) - else WriteOnlyFileTreeCache(FileTreeCache.from(context)) + if (musicSettings.useFileTreeCache) { + if (withCache) FileTreeCache.from(context) + else WriteOnlyFileTreeCache(FileTreeCache.from(context)) + } else { + NoOpFileTreeCache() + } val query = Query(source = locations, exclude = excludedLocations) val storage = Storage(cache, covers, storedPlaylists, fileTreeCache) val interpretation = Interpretation(nameFactory, separators, withHidden) diff --git a/app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt b/app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt index 8317f67d8..08ee7a3a6 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt @@ -51,6 +51,8 @@ interface MusicSettings : Settings { var separators: String /** Whether to enable more advanced sorting by articles and numbers. */ val intelligentSorting: Boolean + /** Whether to use the file-system cache for improved loading times. */ + val useFileTreeCache: Boolean interface Listener { /** Called when the current music locations changed. */ @@ -133,6 +135,9 @@ class MusicSettingsImpl @Inject constructor(@ApplicationContext private val cont override val intelligentSorting: Boolean get() = sharedPreferences.getBoolean(getString(R.string.set_key_auto_sort_names), true) + override val useFileTreeCache: Boolean + get() = sharedPreferences.getBoolean(getString(R.string.set_key_fs_cache), true) + override fun onSettingChanged(key: String, listener: MusicSettings.Listener) { // TODO: Differentiate "hard reloads" (Need the cache) and "Soft reloads" // (just need to manipulate data) @@ -145,7 +150,8 @@ class MusicSettingsImpl @Inject constructor(@ApplicationContext private val cont getString(R.string.set_key_separators), getString(R.string.set_key_auto_sort_names), getString(R.string.set_key_with_hidden), - getString(R.string.set_key_exclude_non_music) -> { + getString(R.string.set_key_exclude_non_music), + getString(R.string.set_key_fs_cache) -> { L.d("Dispatching indexing setting change for $key") listener.onIndexingSettingChanged() } diff --git a/app/src/main/java/org/oxycblt/auxio/music/shim/NoOpFileTreeCache.kt b/app/src/main/java/org/oxycblt/auxio/music/shim/NoOpFileTreeCache.kt new file mode 100644 index 000000000..a28de5139 --- /dev/null +++ b/app/src/main/java/org/oxycblt/auxio/music/shim/NoOpFileTreeCache.kt @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 Auxio Project + * NoOpFileTreeCache.kt is part of Auxio. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.oxycblt.auxio.music.shim + +import android.net.Uri +import org.oxycblt.musikr.fs.device.CachedDirectory +import org.oxycblt.musikr.fs.device.CachedFile +import org.oxycblt.musikr.fs.device.FileTree +import org.oxycblt.musikr.fs.device.FileTreeCache + +/** + * A no-op implementation of [FileTreeCache] that doesn't cache anything. This implementation always + * returns cache misses and discards all updates. + */ +class NoOpFileTreeCache : FileTreeCache { + override fun read(): FileTree = NoOpFileTree() +} + +/** + * A no-op implementation of [FileTree] that doesn't cache anything. All queries return null (cache + * miss) and all updates are discarded. + */ +class NoOpFileTree : FileTree { + override suspend fun queryDirectory(uri: Uri): CachedDirectory? { + // Always return null to simulate a cache miss + return null + } + + override suspend fun updateDirectory(uri: Uri, directory: CachedDirectory) { + // Do nothing - discard the update + } + + override suspend fun queryFile(uri: Uri): CachedFile? { + // Always return null to simulate a cache miss + return null + } + + override suspend fun updateFile(uri: Uri, file: CachedFile) { + // Do nothing - discard the update + } + + override suspend fun write() { + // Do nothing - no cache to write + } +} diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml index 86e8d255a..fd5d1857b 100644 --- a/app/src/main/res/values/settings.xml +++ b/app/src/main/res/values/settings.xml @@ -15,6 +15,7 @@ auxio_observing auxio_music_dirs auxio_excluded_dirs + auxio_fs_cache auxio_cover_mode2 auxio_square_covers auxio_exclude_non_music diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 26d456242..9111f1465 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -315,6 +315,8 @@ Music folders Manage where music should be loaded from New folder + Use file-system cache + Improves loading times, but can prevent new music from being added Excluded folders Manage folders to exclude from music loading Refresh music diff --git a/app/src/main/res/xml/preferences_root.xml b/app/src/main/res/xml/preferences_root.xml index 12f8fb94b..a45aa9142 100644 --- a/app/src/main/res/xml/preferences_root.xml +++ b/app/src/main/res/xml/preferences_root.xml @@ -33,6 +33,11 @@ app:summary="@string/set_locations_desc" app:title="@string/set_locations" /> + + Date: Sun, 22 Jun 2025 19:31:02 -0600 Subject: [PATCH 2/3] music: update file tree cache setting position --- .../java/org/oxycblt/auxio/music/MusicSettings.kt | 2 +- app/src/main/res/xml/preferences_root.xml | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt b/app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt index 08ee7a3a6..01f6e15e9 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt @@ -136,7 +136,7 @@ class MusicSettingsImpl @Inject constructor(@ApplicationContext private val cont get() = sharedPreferences.getBoolean(getString(R.string.set_key_auto_sort_names), true) override val useFileTreeCache: Boolean - get() = sharedPreferences.getBoolean(getString(R.string.set_key_fs_cache), true) + get() = sharedPreferences.getBoolean(getString(R.string.set_key_fs_cache), false) override fun onSettingChanged(key: String, listener: MusicSettings.Listener) { // TODO: Differentiate "hard reloads" (Need the cache) and "Soft reloads" diff --git a/app/src/main/res/xml/preferences_root.xml b/app/src/main/res/xml/preferences_root.xml index a45aa9142..0b4009a44 100644 --- a/app/src/main/res/xml/preferences_root.xml +++ b/app/src/main/res/xml/preferences_root.xml @@ -33,16 +33,18 @@ app:summary="@string/set_locations_desc" app:title="@string/set_locations" /> - - + + + Date: Sun, 22 Jun 2025 19:56:09 -0600 Subject: [PATCH 3/3] build: bump to v4.0.6 --- CHANGELOG.md | 10 ++++++++++ app/build.gradle | 4 ++-- fastlane/metadata/android/en-US/changelogs/65.txt | 4 ++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/65.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 439efa33e..f05f3f5fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 4.0.6 + +#### What's Improved +- Added option to enable/disable the file tree cache (disabled by default) +to prevent the library from not being updated on Samsung devices + +#### What's Fixed +- Fixed loading failing/crashing the app on some devices +- Fixed file tree cache being stored in cache storage rather than app storage + ## 4.0.5 #### What's Improved diff --git a/app/build.gradle b/app/build.gradle index 713ae9f14..e12d5daf3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,8 +18,8 @@ android { defaultConfig { applicationId namespace - versionName "4.0.5" - versionCode 64 + versionName "4.0.6" + versionCode 65 minSdk min_sdk targetSdk target_sdk diff --git a/fastlane/metadata/android/en-US/changelogs/65.txt b/fastlane/metadata/android/en-US/changelogs/65.txt new file mode 100644 index 000000000..92c904f12 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/65.txt @@ -0,0 +1,4 @@ +Auxio 4.0.0 completely overhauls the user experience, with a refreshed design based on the latest Material Design specs +and a brand new music loader with signifigant improvements to device and tag support. +This patch fixes music loading failing/crashing on some devices and makes a caching system that prevented the music library from updating on some devices. +For more information, see https://github.com/OxygenCobalt/Auxio/releases/tag/v4.0.6.