bug fixes

This commit is contained in:
Bnyro 2022-09-18 13:03:48 +02:00
parent 9fa7bb9c6d
commit b22611fe21
3 changed files with 27 additions and 8 deletions

View File

@ -11,6 +11,7 @@ import com.github.libretube.R
import com.github.libretube.adapters.BackupOptionsAdapter
import com.github.libretube.databinding.DialogBackupBinding
import com.github.libretube.db.DatabaseHolder
import com.github.libretube.extensions.await
import com.github.libretube.obj.BackupFile
import com.github.libretube.util.BackupHelper
import com.google.android.material.dialog.MaterialAlertDialogBuilder
@ -37,7 +38,7 @@ class BackupDialog() : DialogFragment() {
R.string.watch_positions,
R.string.search_history,
R.string.local_subscriptions,
R.string.customInstance
R.string.backup_customInstances
)
val selected = mutableListOf(false, false, false, false, false)
@ -53,11 +54,28 @@ class BackupDialog() : DialogFragment() {
.setView(binding.root)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.backup) { _, _ ->
if (selected[0]) backupFile.watchHistory = DatabaseHolder.db.watchHistoryDao().getAll()
if (selected[1]) backupFile.watchPositions = DatabaseHolder.db.watchPositionDao().getAll()
if (selected[2]) backupFile.searchHistory = DatabaseHolder.db.searchHistoryDao().getAll()
if (selected[3]) backupFile.localSubscriptions = DatabaseHolder.db.localSubscriptionDao().getAll()
if (selected[4]) backupFile.customInstances = DatabaseHolder.db.customInstanceDao().getAll()
Thread {
if (selected[0]) {
backupFile.watchHistory =
DatabaseHolder.db.watchHistoryDao().getAll()
}
if (selected[1]) {
backupFile.watchPositions =
DatabaseHolder.db.watchPositionDao().getAll()
}
if (selected[2]) {
backupFile.searchHistory =
DatabaseHolder.db.searchHistoryDao().getAll()
}
if (selected[3]) {
backupFile.localSubscriptions =
DatabaseHolder.db.localSubscriptionDao().getAll()
}
if (selected[4]) {
backupFile.customInstances =
DatabaseHolder.db.customInstanceDao().getAll()
}
}.await()
createBackupFile.launch("application/json")
}

View File

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingHorizontal="10dp"
android:paddingHorizontal="30dp"
android:paddingVertical="5dp">
<TextView

View File

@ -326,6 +326,7 @@
<string name="sb_skip_manual_summary">Don\'t skip segments automatically, always prompt before.</string>
<string name="local_subscriptions">Local subscriptions</string>
<string name="preferences">Preferences</string>
<string name="backup_customInstances">Custom Instances</string>
<!-- Notification channel strings -->
<string name="download_channel_name">Download Service</string>