pull/78/head
kunfei 5 years ago
parent 985f484b29
commit 6423f91798
  1. 10
      app/src/main/java/io/legado/app/ui/config/BackupConfigFragment.kt
  2. 4
      app/src/main/java/io/legado/app/ui/config/ConfigActivity.kt
  3. 5
      app/src/main/res/xml/pref_config_backup.xml

@ -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<EditTextPreference>("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 {

@ -36,9 +36,9 @@ class ConfigActivity : VMBaseActivity<ConfigViewModel>(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()

@ -28,6 +28,11 @@
<io.legado.app.lib.theme.prefs.ATEPreferenceCategory app:iconSpaceReserved="false">
<androidx.preference.Preference
android:key="backupUri"
android:title="备份路径"
app:iconSpaceReserved="false" />
<androidx.preference.Preference
android:key="web_dav_backup"
android:title="备份"
Loading…
Cancel
Save