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)
|
val themeToggle = findPreference<ListPreference>(PreferenceKeys.THEME_MODE)
|
||||||
themeToggle?.setOnPreferenceChangeListener { _, _ ->
|
themeToggle?.setOnPreferenceChangeListener { _, _ ->
|
||||||
val restartDialog = RequireRestartDialog()
|
RequireRestartDialog().show(childFragmentManager, RequireRestartDialog::class.java.name)
|
||||||
restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
val pureTheme = findPreference<SwitchPreferenceCompat>(PreferenceKeys.PURE_THEME)
|
val pureTheme = findPreference<SwitchPreferenceCompat>(PreferenceKeys.PURE_THEME)
|
||||||
pureTheme?.setOnPreferenceChangeListener { _, _ ->
|
pureTheme?.setOnPreferenceChangeListener { _, _ ->
|
||||||
val restartDialog = RequireRestartDialog()
|
RequireRestartDialog().show(childFragmentManager, RequireRestartDialog::class.java.name)
|
||||||
restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
val accentColor = findPreference<ListPreference>(PreferenceKeys.ACCENT_COLOR)
|
val accentColor = findPreference<ListPreference>(PreferenceKeys.ACCENT_COLOR)
|
||||||
updateAccentColorValues(accentColor!!)
|
updateAccentColorValues(accentColor!!)
|
||||||
accentColor.setOnPreferenceChangeListener { _, _ ->
|
accentColor.setOnPreferenceChangeListener { _, _ ->
|
||||||
val restartDialog = RequireRestartDialog()
|
RequireRestartDialog().show(childFragmentManager, RequireRestartDialog::class.java.name)
|
||||||
restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,8 +53,7 @@ class AppearanceSettings : BasePreferenceFragment() {
|
|||||||
|
|
||||||
val labelVisibilityMode = findPreference<ListPreference>(PreferenceKeys.LABEL_VISIBILITY)
|
val labelVisibilityMode = findPreference<ListPreference>(PreferenceKeys.LABEL_VISIBILITY)
|
||||||
labelVisibilityMode?.setOnPreferenceChangeListener { _, _ ->
|
labelVisibilityMode?.setOnPreferenceChangeListener { _, _ ->
|
||||||
val restartDialog = RequireRestartDialog()
|
RequireRestartDialog().show(childFragmentManager, RequireRestartDialog::class.java.name)
|
||||||
restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,12 +13,14 @@ import com.github.libretube.helpers.ImportHelper
|
|||||||
import com.github.libretube.obj.BackupFile
|
import com.github.libretube.obj.BackupFile
|
||||||
import com.github.libretube.ui.base.BasePreferenceFragment
|
import com.github.libretube.ui.base.BasePreferenceFragment
|
||||||
import com.github.libretube.ui.dialogs.BackupDialog
|
import com.github.libretube.ui.dialogs.BackupDialog
|
||||||
|
import com.github.libretube.ui.dialogs.RequireRestartDialog
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
class BackupRestoreSettings : BasePreferenceFragment() {
|
class BackupRestoreSettings : BasePreferenceFragment() {
|
||||||
private val backupDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH:mm:ss")
|
private val backupDateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH:mm:ss")
|
||||||
@ -50,6 +52,12 @@ class BackupRestoreSettings : BasePreferenceFragment() {
|
|||||||
it?.let {
|
it?.let {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
BackupHelper.restoreAdvancedBackup(requireContext(), it)
|
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
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
val advancesBackup = findPreference<Preference>("backup")
|
val advancedBackup = findPreference<Preference>("backup")
|
||||||
advancesBackup?.setOnPreferenceClickListener {
|
advancedBackup?.setOnPreferenceClickListener {
|
||||||
BackupDialog {
|
BackupDialog {
|
||||||
backupFile = it
|
backupFile = it
|
||||||
val timestamp = backupDateTimeFormatter.format(LocalDateTime.now())
|
val timestamp = backupDateTimeFormatter.format(LocalDateTime.now())
|
||||||
|
@ -20,8 +20,7 @@ class GeneralSettings : BasePreferenceFragment() {
|
|||||||
|
|
||||||
val language = findPreference<ListPreference>("language")
|
val language = findPreference<ListPreference>("language")
|
||||||
language?.setOnPreferenceChangeListener { _, _ ->
|
language?.setOnPreferenceChangeListener { _, _ ->
|
||||||
val restartDialog = RequireRestartDialog()
|
RequireRestartDialog().show(childFragmentManager, RequireRestartDialog::class.java.name)
|
||||||
restartDialog.show(childFragmentManager, RequireRestartDialog::class.java.name)
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user