mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-16 05:57:29 +01:00
More FlowPreference migration
This commit is contained in:
@@ -22,7 +22,6 @@ import eu.kanade.tachiyomi.data.backup.BackupCreatorJob
|
||||
import eu.kanade.tachiyomi.data.backup.BackupRestoreService
|
||||
import eu.kanade.tachiyomi.data.backup.models.Backup
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.requestPermissionsSafe
|
||||
import eu.kanade.tachiyomi.ui.setting.backup.BackupNotifier
|
||||
@@ -125,7 +124,7 @@ class SettingsBackupController : SettingsController() {
|
||||
titleRes = R.string.pref_backup_directory
|
||||
|
||||
onClick {
|
||||
val currentDir = preferences.backupsDirectory().getOrDefault()
|
||||
val currentDir = preferences.backupsDirectory().get()
|
||||
try {
|
||||
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
|
||||
startActivityForResult(intent, CODE_BACKUP_DIR)
|
||||
@@ -135,11 +134,12 @@ class SettingsBackupController : SettingsController() {
|
||||
}
|
||||
}
|
||||
|
||||
preferences.backupsDirectory().asObservable()
|
||||
.subscribeUntilDestroy { path ->
|
||||
val dir = UniFile.fromUri(context, Uri.parse(path))
|
||||
summary = dir.filePath + "/automatic"
|
||||
}
|
||||
preferences.backupsDirectory().asFlow()
|
||||
.onEach { path ->
|
||||
val dir = UniFile.fromUri(context, Uri.parse(path))
|
||||
summary = dir.filePath + "/automatic"
|
||||
}
|
||||
.launchIn(scope)
|
||||
}
|
||||
val backupNumber = intListPreference {
|
||||
key = Keys.numberOfBackups
|
||||
@@ -210,7 +210,7 @@ class SettingsBackupController : SettingsController() {
|
||||
backupFlags = flags
|
||||
|
||||
// Get dirs
|
||||
val currentDir = preferences.backupsDirectory().getOrDefault()
|
||||
val currentDir = preferences.backupsDirectory().get()
|
||||
|
||||
try {
|
||||
// Use Android's built-in file creator
|
||||
|
||||
@@ -17,7 +17,6 @@ import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
import eu.kanade.tachiyomi.data.database.models.Category
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||
@@ -52,11 +51,12 @@ class SettingsDownloadController : SettingsController() {
|
||||
ctrl.showDialog(router)
|
||||
}
|
||||
|
||||
preferences.downloadsDirectory().asObservable()
|
||||
.subscribeUntilDestroy { path ->
|
||||
val dir = UniFile.fromUri(context, Uri.parse(path))
|
||||
summary = dir.filePath ?: path
|
||||
}
|
||||
preferences.downloadsDirectory().asFlow()
|
||||
.onEach { path ->
|
||||
val dir = UniFile.fromUri(context, Uri.parse(path))
|
||||
summary = dir.filePath ?: path
|
||||
}
|
||||
.launchIn(scope)
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.downloadOnlyOverWifi
|
||||
@@ -159,7 +159,7 @@ class SettingsDownloadController : SettingsController() {
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
val activity = activity!!
|
||||
val currentDir = preferences.downloadsDirectory().getOrDefault()
|
||||
val currentDir = preferences.downloadsDirectory().get()
|
||||
val externalDirs = (getExternalDirs() + File(activity.getString(R.string.custom_dir))).map(File::toString)
|
||||
val selectedIndex = externalDirs.indexOfFirst { it in currentDir }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user