From e4eb8050abdb52ea095269bcc0c9b0bf0a791f4c Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 30 Jun 2022 16:07:15 +1000 Subject: [PATCH] Add `@BlocksSchemaUpgrade` --- .../src/main/java/com/ichi2/anki/BackendUndo.kt | 3 ++- .../src/main/java/com/ichi2/anki/ModelBrowser.kt | 3 ++- .../src/main/java/com/ichi2/utils/KotlinCleanup.kt | 13 +++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/BackendUndo.kt b/AnkiDroid/src/main/java/com/ichi2/anki/BackendUndo.kt index 1698db1edca5..ee302b20221b 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/BackendUndo.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/BackendUndo.kt @@ -20,6 +20,7 @@ import com.ichi2.anki.UIUtils.showSimpleSnackbar import com.ichi2.libanki.CollectionV16 import com.ichi2.libanki.undoNew import com.ichi2.libanki.undoableOp +import com.ichi2.utils.BlocksSchemaUpgrade import net.ankiweb.rsdroid.BackendException suspend fun AnkiActivity.backendUndoAndShowPopup(col: CollectionV16): Boolean { @@ -36,7 +37,7 @@ suspend fun AnkiActivity.backendUndoAndShowPopup(col: CollectionV16): Boolean { ) true } catch (exc: BackendException) { - // FIXME: -Backend module should export this as a separate Exception + @BlocksSchemaUpgrade("Backend module should export this as a separate Exception") if (exc.localizedMessage == "UndoEmpty") { // backend undo queue empty false diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/ModelBrowser.kt b/AnkiDroid/src/main/java/com/ichi2/anki/ModelBrowser.kt index 7206726b0666..ea759fbbd92f 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/ModelBrowser.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/ModelBrowser.kt @@ -47,6 +47,7 @@ import com.ichi2.libanki.StdModels import com.ichi2.libanki.Utils import com.ichi2.libanki.utils.TimeManager import com.ichi2.ui.FixedEditText +import com.ichi2.utils.BlocksSchemaUpgrade import com.ichi2.utils.KotlinCleanup import com.ichi2.utils.showWithKeyboard import com.ichi2.widget.WidgetStatus.update @@ -427,7 +428,7 @@ class ModelBrowser : AnkiActivity() { */ private fun openTemplateEditor() { if (!BackendFactory.defaultLegacySchema) { - // this screen needs rewriting for the new backend + @BlocksSchemaUpgrade("this screen needs rewriting for the new backend") AlertDialog.Builder(this).setTitle("Not yet supported on new backend").show() return } diff --git a/AnkiDroid/src/main/java/com/ichi2/utils/KotlinCleanup.kt b/AnkiDroid/src/main/java/com/ichi2/utils/KotlinCleanup.kt index 95af660c03b1..65e0da4a08ad 100644 --- a/AnkiDroid/src/main/java/com/ichi2/utils/KotlinCleanup.kt +++ b/AnkiDroid/src/main/java/com/ichi2/utils/KotlinCleanup.kt @@ -26,3 +26,16 @@ package com.ichi2.utils @Repeatable @MustBeDocumented annotation class KotlinCleanup(val value: String) + +/** This must be fixed/implemented before AnkiDroid can switch to using the new backend code + * by default. + */ +@Target( + AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, + AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION, + AnnotationTarget.FIELD, AnnotationTarget.PROPERTY, AnnotationTarget.LOCAL_VARIABLE +) +@Retention(AnnotationRetention.SOURCE) +@Repeatable +@MustBeDocumented +annotation class BlocksSchemaUpgrade(val value: String)