From 01b9cdb5201b79b73f157bfba8f5da24416017d4 Mon Sep 17 00:00:00 2001 From: David Allison <62114487+david-allison@users.noreply.github.com> Date: Fri, 3 Jan 2025 20:56:19 +0000 Subject: [PATCH] refactor(custom-study): rename 'STUDY_NEW/REV' to 'EXTEND_X' --- .../dialogs/customstudy/CustomStudyDialog.kt | 42 +++++++++---------- .../anki/dialogs/CustomStudyDialogTest.kt | 4 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/customstudy/CustomStudyDialog.kt b/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/customstudy/CustomStudyDialog.kt index 32b1dd1cfbca..2ff99014b7cc 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/customstudy/CustomStudyDialog.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/customstudy/CustomStudyDialog.kt @@ -42,11 +42,11 @@ import com.ichi2.anki.CollectionManager.withCol import com.ichi2.anki.R import com.ichi2.anki.analytics.AnalyticsDialogFragment import com.ichi2.anki.dialogs.customstudy.CustomStudyDialog.ContextMenuOption +import com.ichi2.anki.dialogs.customstudy.CustomStudyDialog.ContextMenuOption.EXTEND_NEW +import com.ichi2.anki.dialogs.customstudy.CustomStudyDialog.ContextMenuOption.EXTEND_REV import com.ichi2.anki.dialogs.customstudy.CustomStudyDialog.ContextMenuOption.STUDY_AHEAD import com.ichi2.anki.dialogs.customstudy.CustomStudyDialog.ContextMenuOption.STUDY_FORGOT -import com.ichi2.anki.dialogs.customstudy.CustomStudyDialog.ContextMenuOption.STUDY_NEW import com.ichi2.anki.dialogs.customstudy.CustomStudyDialog.ContextMenuOption.STUDY_PREVIEW -import com.ichi2.anki.dialogs.customstudy.CustomStudyDialog.ContextMenuOption.STUDY_REV import com.ichi2.anki.dialogs.customstudy.CustomStudyDialog.ContextMenuOption.STUDY_TAGS import com.ichi2.anki.dialogs.customstudy.CustomStudyDialog.CustomStudyDefaults.Companion.toDomainModel import com.ichi2.anki.dialogs.tags.TagsDialog @@ -194,8 +194,8 @@ class CustomStudyDialog( ) requireActivity().showDialogFragment(dialogFragment) } - STUDY_NEW, - STUDY_REV, + EXTEND_NEW, + EXTEND_REV, STUDY_FORGOT, STUDY_AHEAD, STUDY_PREVIEW, @@ -295,7 +295,7 @@ class CustomStudyDialog( setSelectAllOnFocus(true) requestFocus() // a user may enter a negative value when extending limits - if (contextMenuOption == STUDY_NEW || contextMenuOption == STUDY_REV) { + if (contextMenuOption == EXTEND_NEW || contextMenuOption == EXTEND_REV) { inputType = EditorInfo.TYPE_CLASS_NUMBER or EditorInfo.TYPE_NUMBER_FLAG_SIGNED } } @@ -335,8 +335,8 @@ class CustomStudyDialog( customStudyRequest { deckId = dialogDeckId when (contextMenuOption) { - STUDY_NEW -> newLimitDelta = userEntry - STUDY_REV -> reviewLimitDelta = userEntry + EXTEND_NEW -> newLimitDelta = userEntry + EXTEND_REV -> reviewLimitDelta = userEntry STUDY_FORGOT -> forgotDays = userEntry STUDY_AHEAD -> reviewAheadDays = userEntry STUDY_PREVIEW -> previewDays = userEntry @@ -349,7 +349,7 @@ class CustomStudyDialog( collection.sched.customStudy(request) } when (contextMenuOption) { - STUDY_NEW, STUDY_REV -> + EXTEND_NEW, EXTEND_REV -> customStudyListener?.onExtendStudyLimits() STUDY_FORGOT, STUDY_AHEAD, STUDY_PREVIEW -> customStudyListener?.onCreateCustomStudySession() STUDY_TAGS -> TODO("This branch has not been covered before") @@ -363,7 +363,7 @@ class CustomStudyDialog( STUDY_FORGOT -> sharedPrefs().edit { putInt("forgottenDays", userEntry) } STUDY_AHEAD -> sharedPrefs().edit { putInt("aheadDays", userEntry) } STUDY_PREVIEW -> sharedPrefs().edit { putInt("previewDays", userEntry) } - STUDY_NEW, STUDY_REV -> { + EXTEND_NEW, EXTEND_REV -> { // Nothing to do in ankidroid. The default value is provided by the backend. } STUDY_TAGS -> TODO("This branch has not been covered before") @@ -402,11 +402,11 @@ class CustomStudyDialog( * @see ContextMenuData */ private fun buildMenuItems(): List = - mutableListOf(STUDY_NEW, STUDY_REV, STUDY_FORGOT, STUDY_AHEAD, STUDY_PREVIEW, STUDY_TAGS).map { option -> + mutableListOf(EXTEND_NEW, EXTEND_REV, STUDY_FORGOT, STUDY_AHEAD, STUDY_PREVIEW, STUDY_TAGS).map { option -> val enabled = when (option) { - STUDY_NEW -> defaults.extendNew.isUsable - STUDY_REV -> defaults.extendReview.isUsable + EXTEND_NEW -> defaults.extendNew.isUsable + EXTEND_REV -> defaults.extendReview.isUsable else -> true } ContextMenuData(option, enabled) @@ -416,8 +416,8 @@ class CustomStudyDialog( private val text1: String get() = when (selectedSubDialog) { - STUDY_NEW -> defaults.labelForNewQueueAvailable() - STUDY_REV -> defaults.labelForReviewQueueAvailable() + EXTEND_NEW -> defaults.labelForNewQueueAvailable() + EXTEND_REV -> defaults.labelForReviewQueueAvailable() STUDY_FORGOT, STUDY_AHEAD, STUDY_PREVIEW, @@ -431,8 +431,8 @@ class CustomStudyDialog( get() { val res = resources return when (selectedSubDialog) { - STUDY_NEW -> res.getString(R.string.custom_study_new_extend) - STUDY_REV -> res.getString(R.string.custom_study_rev_extend) + EXTEND_NEW -> res.getString(R.string.custom_study_new_extend) + EXTEND_REV -> res.getString(R.string.custom_study_rev_extend) STUDY_FORGOT -> res.getString(R.string.custom_study_forgotten) STUDY_AHEAD -> res.getString(R.string.custom_study_ahead) STUDY_PREVIEW -> res.getString(R.string.custom_study_preview) @@ -447,8 +447,8 @@ class CustomStudyDialog( get() { val prefs = requireActivity().sharedPrefs() return when (selectedSubDialog) { - STUDY_NEW -> defaults.extendNew.initialValue.toString() - STUDY_REV -> defaults.extendReview.initialValue.toString() + EXTEND_NEW -> defaults.extendNew.initialValue.toString() + EXTEND_REV -> defaults.extendReview.initialValue.toString() STUDY_FORGOT -> prefs.getInt("forgottenDays", 1).toString() STUDY_AHEAD -> prefs.getInt("aheadDays", 1).toString() STUDY_PREVIEW -> prefs.getInt("previewDays", 1).toString() @@ -521,7 +521,7 @@ class CustomStudyDialog( /** * A [context menu item][ContextMenuOption], and whether it is usable. - * Example: [STUDY_NEW] would be unusable if there are no new cards + * Example: [EXTEND_NEW] would be unusable if there are no new cards */ data class ContextMenuData( val item: ContextMenuOption, @@ -536,10 +536,10 @@ class CustomStudyDialog( val getTitle: Resources.() -> String, ) { /** Increase today's new card limit */ - STUDY_NEW({ TR.customStudyIncreaseTodaysNewCardLimit() }), + EXTEND_NEW({ TR.customStudyIncreaseTodaysNewCardLimit() }), /** Increase today's review card limit */ - STUDY_REV({ TR.customStudyIncreaseTodaysReviewCardLimit() }), + EXTEND_REV({ TR.customStudyIncreaseTodaysReviewCardLimit() }), /** Review forgotten cards */ STUDY_FORGOT({ TR.customStudyReviewForgottenCards() }), diff --git a/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt b/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt index 60d0d5a35511..3e30f4c7872e 100644 --- a/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt +++ b/AnkiDroid/src/test/java/com/ichi2/anki/dialogs/CustomStudyDialogTest.kt @@ -136,7 +136,7 @@ class CustomStudyDialogTest : RobolectricTest() { // extend limits with a value of '1' withCustomStudyFragment( - args = argumentsDisplayingSubscreen(ContextMenuOption.STUDY_NEW), + args = argumentsDisplayingSubscreen(ContextMenuOption.EXTEND_NEW), ) { dialogFragment: CustomStudyDialog -> onSubscreenEditText() @@ -154,7 +154,7 @@ class CustomStudyDialogTest : RobolectricTest() { // ensure 'newExtendByValue' is used by our UI withCustomStudyFragment( - args = argumentsDisplayingSubscreen(ContextMenuOption.STUDY_NEW), + args = argumentsDisplayingSubscreen(ContextMenuOption.EXTEND_NEW), ) { dialogFragment: CustomStudyDialog -> onSubscreenEditText() .check(matches(withText(newExtendByValue.toString())))