diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/AnkiActivity.kt b/AnkiDroid/src/main/java/com/ichi2/anki/AnkiActivity.kt index 34cd6993e231..233ba7eaa125 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/AnkiActivity.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/AnkiActivity.kt @@ -546,6 +546,12 @@ open class AnkiActivity : AppCompatActivity, SimpleMessageDialogListener { window.navigationBarColor = ThemeUtils.getThemeAttrColor(this, attr) } + fun closeCollectionAndFinish() { + Timber.i("closeCollectionAndFinish()") + CollectionHelper.instance.closeCollection("AnkiActivity:closeCollectionAndFinish()") + finish() + } + companion object { const val DIALOG_FRAGMENT_TAG = "dialog" diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt b/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt index ee21425ba539..be6fc00121bc 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt @@ -732,7 +732,7 @@ open class DeckPicker : ) ) positiveButton(R.string.close) { - exit() + closeCollectionAndFinish() } cancelable(false) } @@ -1656,12 +1656,6 @@ open class DeckPicker : } } - fun exit() { - Timber.i("exit()") - CollectionHelper.instance.closeCollection("DeckPicker:exit()") - finish() - } - open fun handleDbError() { Timber.i("Displaying Database Error") showDatabaseErrorDialog(DatabaseErrorDialogType.DIALOG_LOAD_FAILED) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/DatabaseErrorDialog.kt b/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/DatabaseErrorDialog.kt index da9b4ef08d95..7c875c308532 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/DatabaseErrorDialog.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/DatabaseErrorDialog.kt @@ -83,7 +83,7 @@ class DatabaseErrorDialog : AsyncDialogFragment() { ?.showDatabaseErrorDialog(DIALOG_ERROR_HANDLING) } negativeButton(R.string.close) { - exit() + closeCollectionAndFinish() } } } @@ -103,7 +103,7 @@ class DatabaseErrorDialog : AsyncDialogFragment() { dismissAllDialogFragments() } neutralButton(R.string.close) { - exit() + closeCollectionAndFinish() } setActionButtonEnabled(WhichButton.NEGATIVE, (activity as DeckPicker).hasErrorFiles()) } @@ -304,7 +304,7 @@ class DatabaseErrorDialog : AsyncDialogFragment() { dialog.show { contentNullable(message) positiveButton(R.string.close) { - exit() + closeCollectionAndFinish() } cancelable(false) } @@ -323,7 +323,7 @@ class DatabaseErrorDialog : AsyncDialogFragment() { contentNullable(message) icon(R.drawable.ic_warning) positiveButton(R.string.close) { - exit() + closeCollectionAndFinish() } listItems(items = options, waitForPositiveButton = false) { _: MaterialDialog, index: Int, _: CharSequence -> when (values[index]) { @@ -341,7 +341,7 @@ class DatabaseErrorDialog : AsyncDialogFragment() { dialog.show { contentNullable(message) positiveButton(R.string.close) { - exit() + closeCollectionAndFinish() } } } @@ -439,7 +439,7 @@ class DatabaseErrorDialog : AsyncDialogFragment() { val ch = CollectionHelper.instance ch.closeCollection("DatabaseErrorDialog: Before Create New Collection") CollectionHelper.resetAnkiDroidDirectory(context) - context.exit() + context.closeCollectionAndFinish() } negativeButton(R.string.dialog_cancel) cancelable(false) @@ -455,8 +455,8 @@ class DatabaseErrorDialog : AsyncDialogFragment() { } } - private fun exit() { - (activity as DeckPicker).exit() + private fun closeCollectionAndFinish() { + (activity as AnkiActivity).closeCollectionAndFinish() } // Generic message shown when a libanki task failed // The sqlite database has been corrupted (DatabaseErrorHandler.onCorrupt() was called)