Skip to content

Commit

Permalink
Update DatabaseErrorDialog.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
neeldoshii committed May 2, 2024
1 parent 1856ee1 commit 255543e
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class DatabaseErrorDialog : AsyncDialogFragment() {
val res = res()
val alertDialog = AlertDialog.Builder(requireActivity())
val isLoggedIn = isLoggedIn()
alertDialog.cancelable(true)
.title(text = title)
var sqliteInstalled = false
try {
sqliteInstalled = Runtime.getRuntime().exec("sqlite3 --version").waitFor() == 0
Expand Down Expand Up @@ -351,6 +353,7 @@ class DatabaseErrorDialog : AsyncDialogFragment() {
val listItems = UninstallListItem.createList()
alertDialog.show {
title(R.string.directory_inaccessible_after_uninstall)
message(text = message)
listItemsAndMessage(message = message, items = listItems.map { getString(it.stringRes) }) { _, index: Int ->
val listItem = listItems[index]
listItem.onClick(activity as DeckPicker)
Expand Down Expand Up @@ -507,6 +510,23 @@ class DatabaseErrorDialog : AsyncDialogFragment() {
else -> requireArguments().getString("dialogMessage")
}

private val title: String
get() = when (requireDialogType()) {
DIALOG_LOAD_FAILED -> res().getString(R.string.open_collection_failed_title)
DIALOG_ERROR_HANDLING -> res().getString(R.string.error_handling_title)
DIALOG_REPAIR_COLLECTION -> res().getString(R.string.dialog_positive_repair)
DIALOG_RESTORE_BACKUP -> res().getString(R.string.backup_restore)
DIALOG_NEW_COLLECTION -> res().getString(R.string.backup_new_collection)
DIALOG_CONFIRM_DATABASE_CHECK -> res().getString(R.string.check_db_title)
DIALOG_CONFIRM_RESTORE_BACKUP -> res().getString(R.string.restore_backup_title)
DIALOG_ONE_WAY_SYNC_FROM_SERVER -> res().getString(R.string.backup_one_way_sync_from_server)
DIALOG_DB_LOCKED -> res().getString(R.string.database_locked_title)
INCOMPATIBLE_DB_VERSION -> res().getString(R.string.incompatible_database_version_title)
DIALOG_DB_ERROR -> res().getString(R.string.answering_error_title)
DIALOG_DISK_FULL -> res().getString(R.string.storage_full_title)
DIALOG_STORAGE_UNAVAILABLE_AFTER_UNINSTALL -> res().getString(R.string.directory_inaccessible_after_uninstall)
}

override val notificationMessage: String? get() = message
override val notificationTitle: String get() = res().getString(R.string.answering_error_title)

Expand Down

0 comments on commit 255543e

Please sign in to comment.