mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 06:40:30 +05:30
Merge pull request #3954 from Bnyro/master
Show restart dialog after restoring backup
This commit is contained in:
commit
b047c3c1a9
@ -21,23 +21,20 @@ class AppearanceSettings : BasePreferenceFragment() {
|
||||
|
||||
val themeToggle = findPreference<ListPreference>(PreferenceKeys.THEME_MODE)
|
||||
themeToggle?.setOnPreferenceChangeListener { _, _ ->
|
||||
val restartDialog = RequireRestartDialog()
|
||||
restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
|
||||
RequireRestartDialog().show(childFragmentManager, RequireRestartDialog::class.java.name)
|
||||
true
|
||||
}
|
||||
|
||||
val pureTheme = findPreference<SwitchPreferenceCompat>(PreferenceKeys.PURE_THEME)
|
||||
pureTheme?.setOnPreferenceChangeListener { _, _ ->
|
||||
val restartDialog = RequireRestartDialog()
|
||||
restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
|
||||
RequireRestartDialog().show(childFragmentManager, RequireRestartDialog::class.java.name)
|
||||
true
|
||||
}
|
||||
|
||||
val accentColor = findPreference<ListPreference>(PreferenceKeys.ACCENT_COLOR)
|
||||
updateAccentColorValues(accentColor!!)
|
||||
accentColor.setOnPreferenceChangeListener { _, _ ->
|
||||
val restartDialog = RequireRestartDialog()
|
||||
restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
|
||||
RequireRestartDialog().show(childFragmentManager, RequireRestartDialog::class.java.name)
|
||||
true
|
||||
}
|
||||
|
||||
@ -56,8 +53,7 @@ class AppearanceSettings : BasePreferenceFragment() {
|
||||
|
||||
val labelVisibilityMode = findPreference<ListPreference>(PreferenceKeys.LABEL_VISIBILITY)
|
||||
labelVisibilityMode?.setOnPreferenceChangeListener { _, _ ->
|
||||
val restartDialog = RequireRestartDialog()
|
||||
restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
|
||||
RequireRestartDialog().show(childFragmentManager, RequireRestartDialog::class.java.name)
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -13,12 +13,14 @@ import com.github.libretube.helpers.ImportHelper
|
||||
import com.github.libretube.obj.BackupFile
|
||||
import com.github.libretube.ui.base.BasePreferenceFragment
|
||||
import com.github.libretube.ui.dialogs.BackupDialog
|
||||
import com.github.libretube.ui.dialogs.RequireRestartDialog
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class BackupRestoreSettings : BasePreferenceFragment() {
|
||||
private val backupDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH:mm:ss")
|
||||
@ -50,6 +52,12 @@ class BackupRestoreSettings : BasePreferenceFragment() {
|
||||
it?.let {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
BackupHelper.restoreAdvancedBackup(requireContext(), it)
|
||||
withContext(Dispatchers.Main) {
|
||||
// could fail if fragment is already closed
|
||||
runCatching {
|
||||
RequireRestartDialog().show(childFragmentManager, this::class.java.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -162,8 +170,8 @@ class BackupRestoreSettings : BasePreferenceFragment() {
|
||||
true
|
||||
}
|
||||
|
||||
val advancesBackup = findPreference<Preference>("backup")
|
||||
advancesBackup?.setOnPreferenceClickListener {
|
||||
val advancedBackup = findPreference<Preference>("backup")
|
||||
advancedBackup?.setOnPreferenceClickListener {
|
||||
BackupDialog {
|
||||
backupFile = it
|
||||
val timestamp = backupDateTimeFormatter.format(LocalDateTime.now())
|
||||
|
@ -20,8 +20,7 @@ class GeneralSettings : BasePreferenceFragment() {
|
||||
|
||||
val language = findPreference<ListPreference>("language")
|
||||
language?.setOnPreferenceChangeListener { _, _ ->
|
||||
val restartDialog = RequireRestartDialog()
|
||||
restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
|
||||
RequireRestartDialog().show(childFragmentManager, RequireRestartDialog::class.java.name)
|
||||
true
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user