Skip to content

Commit

Permalink
Add @BlocksSchemaUpgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
dae committed Jul 21, 2022
1 parent 4cf1698 commit e432986
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion AnkiDroid/src/main/java/com/ichi2/anki/BackendUndo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion AnkiDroid/src/main/java/com/ichi2/anki/ModelBrowser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.displayKeyboard
import com.ichi2.widget.WidgetStatus.update
Expand Down Expand Up @@ -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
}
Expand Down
13 changes: 13 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/utils/KotlinCleanup.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,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)

0 comments on commit e432986

Please sign in to comment.