Use 1.x preference abstraction (#8020)
* Use 1.x preference abstraction - Uses SharedPreferences compared to 1.x impl which uses DataStore but it breaks all settings screens currently - Move PreferencesHelper to new PreferenceStore - PreferencesHelper should be split into smaller preference stores and be in core or domain - Remove flow preferences as new PreferenceStore handles changes for us Co-authored-by: inorichi <3521738+inorichi@users.noreply.github.com> * Fix PreferenceMutableState not updating * Fix changes not emitting on first subscription Co-authored-by: inorichi <3521738+inorichi@users.noreply.github.com>
This commit is contained in:
@@ -47,7 +47,7 @@ class DownloadCache(
|
||||
private var rootDir = RootDirectory(getDirectoryFromPreference())
|
||||
|
||||
init {
|
||||
preferences.downloadsDirectory().asFlow()
|
||||
preferences.downloadsDirectory().changes()
|
||||
.onEach {
|
||||
lastRenew = 0L // invalidate cache
|
||||
rootDir = RootDirectory(getDirectoryFromPreference())
|
||||
|
||||
@@ -414,7 +414,7 @@ class DownloadManager(
|
||||
|
||||
return if (categoriesForManga.intersect(categoriesToExclude).isNotEmpty()) {
|
||||
chapters.filterNot { it.read }
|
||||
} else if (!preferences.removeBookmarkedChapters()) {
|
||||
} else if (!preferences.removeBookmarkedChapters().get()) {
|
||||
chapters.filterNot { it.bookmark }
|
||||
} else {
|
||||
chapters
|
||||
|
||||
@@ -104,7 +104,7 @@ internal class DownloadNotifier(private val context: Context) {
|
||||
download.pages!!.size,
|
||||
)
|
||||
|
||||
if (preferences.hideNotificationContent()) {
|
||||
if (preferences.hideNotificationContent().get()) {
|
||||
setContentTitle(downloadingProgressText)
|
||||
setContentText(null)
|
||||
} else {
|
||||
|
||||
@@ -39,7 +39,7 @@ class DownloadProvider(private val context: Context) {
|
||||
}
|
||||
|
||||
init {
|
||||
preferences.downloadsDirectory().asFlow()
|
||||
preferences.downloadsDirectory().changes()
|
||||
.onEach { downloadsDir = UniFile.fromUri(context, it.toUri()) }
|
||||
.launchIn(scope)
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ class DownloadService : Service() {
|
||||
*/
|
||||
private fun onNetworkStateChanged() {
|
||||
if (isOnline()) {
|
||||
if (preferences.downloadOnlyOverWifi() && !isConnectedToWifi()) {
|
||||
if (preferences.downloadOnlyOverWifi().get() && !isConnectedToWifi()) {
|
||||
stopDownloads(R.string.download_notifier_text_only_wifi)
|
||||
} else {
|
||||
val started = downloadManager.startDownloads()
|
||||
|
||||
Reference in New Issue
Block a user