|
|
@ -9,6 +9,7 @@ import android.view.MenuInflater |
|
|
|
import android.view.MenuItem |
|
|
|
import android.view.MenuItem |
|
|
|
import android.view.View |
|
|
|
import android.view.View |
|
|
|
import androidx.documentfile.provider.DocumentFile |
|
|
|
import androidx.documentfile.provider.DocumentFile |
|
|
|
|
|
|
|
import androidx.fragment.app.activityViewModels |
|
|
|
import androidx.lifecycle.lifecycleScope |
|
|
|
import androidx.lifecycle.lifecycleScope |
|
|
|
import androidx.preference.EditTextPreference |
|
|
|
import androidx.preference.EditTextPreference |
|
|
|
import androidx.preference.ListPreference |
|
|
|
import androidx.preference.ListPreference |
|
|
@ -36,6 +37,8 @@ import splitties.init.appCtx |
|
|
|
class BackupConfigFragment : BasePreferenceFragment(), |
|
|
|
class BackupConfigFragment : BasePreferenceFragment(), |
|
|
|
SharedPreferences.OnSharedPreferenceChangeListener { |
|
|
|
SharedPreferences.OnSharedPreferenceChangeListener { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val viewModel by activityViewModels<ConfigViewModel>() |
|
|
|
|
|
|
|
|
|
|
|
private val selectBackupPath = registerForActivityResult(HandleFileContract()) { |
|
|
|
private val selectBackupPath = registerForActivityResult(HandleFileContract()) { |
|
|
|
it.uri?.let { uri -> |
|
|
|
it.uri?.let { uri -> |
|
|
|
if (uri.isContentScheme()) { |
|
|
|
if (uri.isContentScheme()) { |
|
|
@ -101,7 +104,6 @@ class BackupConfigFragment : BasePreferenceFragment(), |
|
|
|
it.setOnBindEditTextListener { editText -> |
|
|
|
it.setOnBindEditTextListener { editText -> |
|
|
|
editText.applyTint(requireContext().accentColor) |
|
|
|
editText.applyTint(requireContext().accentColor) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
findPreference<EditTextPreference>(PreferKey.webDavAccount)?.let { |
|
|
|
findPreference<EditTextPreference>(PreferKey.webDavAccount)?.let { |
|
|
|
it.setOnBindEditTextListener { editText -> |
|
|
|
it.setOnBindEditTextListener { editText -> |
|
|
@ -115,6 +117,11 @@ class BackupConfigFragment : BasePreferenceFragment(), |
|
|
|
InputType.TYPE_TEXT_VARIATION_PASSWORD or InputType.TYPE_CLASS_TEXT |
|
|
|
InputType.TYPE_TEXT_VARIATION_PASSWORD or InputType.TYPE_CLASS_TEXT |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
findPreference<EditTextPreference>(PreferKey.webDavDir)?.let { |
|
|
|
|
|
|
|
it.setOnBindEditTextListener { editText -> |
|
|
|
|
|
|
|
editText.applyTint(requireContext().accentColor) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
upPreferenceSummary(PreferKey.webDavUrl, getPrefString(PreferKey.webDavUrl)) |
|
|
|
upPreferenceSummary(PreferKey.webDavUrl, getPrefString(PreferKey.webDavUrl)) |
|
|
|
upPreferenceSummary(PreferKey.webDavAccount, getPrefString(PreferKey.webDavAccount)) |
|
|
|
upPreferenceSummary(PreferKey.webDavAccount, getPrefString(PreferKey.webDavAccount)) |
|
|
|
upPreferenceSummary(PreferKey.webDavPassword, getPrefString(PreferKey.webDavPassword)) |
|
|
|
upPreferenceSummary(PreferKey.webDavPassword, getPrefString(PreferKey.webDavPassword)) |
|
|
@ -160,13 +167,14 @@ class BackupConfigFragment : BasePreferenceFragment(), |
|
|
|
|
|
|
|
|
|
|
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { |
|
|
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { |
|
|
|
when (key) { |
|
|
|
when (key) { |
|
|
|
|
|
|
|
PreferKey.backupPath -> upPreferenceSummary(key, getPrefString(key)) |
|
|
|
PreferKey.webDavUrl, |
|
|
|
PreferKey.webDavUrl, |
|
|
|
PreferKey.webDavAccount, |
|
|
|
PreferKey.webDavAccount, |
|
|
|
PreferKey.webDavPassword, |
|
|
|
PreferKey.webDavPassword, |
|
|
|
PreferKey.backupPath -> { |
|
|
|
PreferKey.webDavDir -> listView.post { |
|
|
|
upPreferenceSummary(key, getPrefString(key)) |
|
|
|
upPreferenceSummary(key, getPrefString(key)) |
|
|
|
|
|
|
|
viewModel.upWebDavConfig() |
|
|
|
} |
|
|
|
} |
|
|
|
PreferKey.webDavDir -> upPreferenceSummary(key, AppConfig.webDavDir) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -191,10 +199,9 @@ class BackupConfigFragment : BasePreferenceFragment(), |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
preference.summary = "*".repeat(value.toString().length) |
|
|
|
preference.summary = "*".repeat(value.toString().length) |
|
|
|
} |
|
|
|
} |
|
|
|
PreferKey.webDavDir -> if (value.isNullOrBlank()) { |
|
|
|
PreferKey.webDavDir -> preference.summary = when (value) { |
|
|
|
preference.summary = "null" |
|
|
|
null -> "legado" |
|
|
|
} else { |
|
|
|
else -> value |
|
|
|
preference.summary = value |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else -> { |
|
|
|
else -> { |
|
|
|
if (preference is ListPreference) { |
|
|
|
if (preference is ListPreference) { |
|
|
|