Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show restart dialog after restoring backup #3954

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}
}
}
}
}
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down