diff --git a/app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt similarity index 97% rename from app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt rename to app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt index 446c93f68..d403324fe 100644 --- a/app/src/main/java/io/legado/app/ui/config/WebDavConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt @@ -31,7 +31,7 @@ import kotlinx.coroutines.Dispatchers.IO import org.jetbrains.anko.toast import kotlin.coroutines.CoroutineContext -class WebDavConfigFragment : PreferenceFragmentCompat(), +class BackupConfigFragment : PreferenceFragmentCompat(), Preference.OnPreferenceChangeListener, CoroutineScope { private lateinit var job: Job @@ -46,14 +46,14 @@ class WebDavConfigFragment : PreferenceFragmentCompat(), job = Job() fun bindPreferenceSummaryToValue(preference: Preference?) { preference?.apply { - onPreferenceChangeListener = this@WebDavConfigFragment + onPreferenceChangeListener = this@BackupConfigFragment onPreferenceChange( this, context.getPrefString(key) ) } } - addPreferencesFromResource(R.xml.pref_config_web_dav) + addPreferencesFromResource(R.xml.pref_config_backup) findPreference("web_dav_url")?.let { it.setOnBindEditTextListener { editText -> ATH.setTint(editText, requireContext().accentColor) @@ -74,6 +74,7 @@ class WebDavConfigFragment : PreferenceFragmentCompat(), } bindPreferenceSummaryToValue(it) } + bindPreferenceSummaryToValue(findPreference(PreferKey.backupPath)) } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { @@ -115,6 +116,7 @@ class WebDavConfigFragment : PreferenceFragmentCompat(), override fun onPreferenceTreeClick(preference: Preference?): Boolean { when (preference?.key) { + PreferKey.backupPath -> selectBackupFolder() "web_dav_backup" -> backup() "web_dav_restore" -> restore() "import_old" -> importOldData() @@ -206,7 +208,7 @@ class WebDavConfigFragment : PreferenceFragmentCompat(), alert(title = "导入") { message = "是否导入旧版本数据" yesButton { - PermissionsCompat.Builder(this@WebDavConfigFragment) + PermissionsCompat.Builder(this@BackupConfigFragment) .addPermissions(*Permissions.Group.STORAGE) .rationale(R.string.tip_perm_request_storage) .onGranted { diff --git a/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt b/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt index 838b5c31d..a79e3f6a9 100644 --- a/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt +++ b/app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt @@ -36,9 +36,9 @@ class ConfigActivity : VMBaseActivity(R.layout.activity_config) } ConfigViewModel.TYPE_WEB_DAV_CONFIG -> { title_bar.title = getString(R.string.backup_restore) - val fTag = "webDavFragment" + val fTag = "backupFragment" var configFragment = supportFragmentManager.findFragmentByTag(fTag) - if (configFragment == null) configFragment = WebDavConfigFragment() + if (configFragment == null) configFragment = BackupConfigFragment() supportFragmentManager.beginTransaction() .replace(R.id.configFrameLayout, configFragment, fTag) .commit() diff --git a/app/src/main/res/xml/pref_config_web_dav.xml b/app/src/main/res/xml/pref_config_backup.xml similarity index 89% rename from app/src/main/res/xml/pref_config_web_dav.xml rename to app/src/main/res/xml/pref_config_backup.xml index 0b4a84e09..d70d7145d 100644 --- a/app/src/main/res/xml/pref_config_web_dav.xml +++ b/app/src/main/res/xml/pref_config_backup.xml @@ -28,6 +28,11 @@ + +