From 8e6e147a8abf69d6a83517c955e4e5e9cb9c7c24 Mon Sep 17 00:00:00 2001 From: Brayan Oliveira <69634269+brayandso@users.noreply.github.com> Date: Sat, 9 Dec 2023 09:20:38 -0300 Subject: [PATCH] refactor: remove unused congrats stuff in Study Options Fragment --- .../com/ichi2/anki/StudyOptionsFragment.kt | 7 ---- .../java/com/ichi2/libanki/sched/Scheduler.kt | 40 ------------------ .../main/res/layout/studyoptions_fragment.xml | 10 ----- AnkiDroid/src/main/res/values/01-core.xml | 1 - .../java/com/ichi2/libanki/SchedulerTest.kt | 41 ------------------- 5 files changed, 99 deletions(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/StudyOptionsFragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/StudyOptionsFragment.kt index a3e27f61c0eb..a6b4da2e6e2d 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/StudyOptionsFragment.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/StudyOptionsFragment.kt @@ -77,7 +77,6 @@ class StudyOptionsFragment : Fragment(), Toolbar.OnMenuItemClickListener { private lateinit var textTodayRev: TextView private lateinit var textNewTotal: TextView private lateinit var textTotal: TextView - private lateinit var textCongratsMessage: TextView private var mToolbar: Toolbar? = null // Flag to indicate if the fragment should load the deck options immediately after it loads @@ -207,7 +206,6 @@ class StudyOptionsFragment : Fragment(), Toolbar.OnMenuItemClickListener { // make links clickable textDeckDescription.movementMethod = LinkMovementMethod.getInstance() buttonStart = studyOptionsView.findViewById(R.id.studyoptions_start) - textCongratsMessage = studyOptionsView.findViewById(R.id.studyoptions_congrats_message) // Code common to both fragmented and non-fragmented view textTodayNew = studyOptionsView.findViewById(R.id.studyoptions_new) textTodayLrn = studyOptionsView.findViewById(R.id.studyoptions_lrn) @@ -570,8 +568,6 @@ class StudyOptionsFragment : Fragment(), Toolbar.OnMenuItemClickListener { if (result.numberOfCardsInDeck == 0 && !isDynamic) { mCurrentContentView = CONTENT_EMPTY deckInfoLayout.visibility = View.VISIBLE - textCongratsMessage.visibility = View.VISIBLE - textCongratsMessage.setText(R.string.studyoptions_empty) buttonStart.visibility = View.GONE } else if (result.newCardsToday + result.lrnCardsToday + result.revCardsToday == 0) { mCurrentContentView = CONTENT_CONGRATS @@ -582,12 +578,9 @@ class StudyOptionsFragment : Fragment(), Toolbar.OnMenuItemClickListener { } else { buttonStart.visibility = View.GONE } - textCongratsMessage.visibility = View.VISIBLE - textCongratsMessage.text = col.sched.finishedMsg() } else { mCurrentContentView = CONTENT_STUDY_OPTIONS deckInfoLayout.visibility = View.VISIBLE - textCongratsMessage.visibility = View.GONE buttonStart.visibility = View.VISIBLE buttonStart.setText(R.string.studyoptions_start) } diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/sched/Scheduler.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/sched/Scheduler.kt index 26b27cf7a85e..9cfdcb5598d2 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/sched/Scheduler.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/sched/Scheduler.kt @@ -17,9 +17,6 @@ package com.ichi2.libanki.sched import android.app.Activity -import android.graphics.Typeface -import android.text.SpannableStringBuilder -import android.text.style.StyleSpan import androidx.annotation.VisibleForTesting import androidx.annotation.WorkerThread import anki.ankidroid.schedTimingTodayLegacyRequest @@ -42,7 +39,6 @@ import com.ichi2.libanki.DeckId import com.ichi2.libanki.NoteId import com.ichi2.libanki.Utils import com.ichi2.libanki.utils.TimeManager.time -import net.ankiweb.rsdroid.RustCleanup import timber.log.Timber data class CurrentQueueState( @@ -425,42 +421,6 @@ open class Scheduler(val col: Collection) { return DeckNode(col.backend.deckTree(now = if (includeCounts) time.intTime() else 0), "") } - /** - * @param context Some Context to access the lang - * @return A message to show to user when they reviewed the last card. Let them know if they can see learning card later today - * or if they could see more card today by extending review. - */ - @RustCleanup("remove once new congrats screen is the default") - fun finishedMsg(): CharSequence { - val sb = SpannableStringBuilder() - sb.append(col.tr.schedulingCongratulationsFinished()) - val boldSpan = StyleSpan(Typeface.BOLD) - sb.setSpan(boldSpan, 0, sb.length, 0) - sb.append(nextDueMsg()) - return sb - } - - fun nextDueMsg(): String { - val sb = StringBuilder() - if (revDue()) { - sb.append("\n\n") - sb.append(col.tr.schedulingTodayReviewLimitReached()) - } - if (newDue()) { - sb.append("\n\n") - sb.append(col.tr.schedulingTodayNewLimitReached()) - } - if (haveBuriedInCurrentDeck()) { - sb.append("\n\n") - sb.append(col.tr.schedulingBuriedCardsFound(col.tr.schedulingUnburyThem())) - } - if (col.decks.current().isNormal) { - sb.append("\n\n") - sb.append(col.tr.schedulingHowToCustomStudy(col.tr.schedulingCustomStudy())) - } - return sb.toString() - } - fun deckLimit(): String { return Utils.ids2str(col.decks.active()) } diff --git a/AnkiDroid/src/main/res/layout/studyoptions_fragment.xml b/AnkiDroid/src/main/res/layout/studyoptions_fragment.xml index eb313f546fe2..e280b92adc44 100644 --- a/AnkiDroid/src/main/res/layout/studyoptions_fragment.xml +++ b/AnkiDroid/src/main/res/layout/studyoptions_fragment.xml @@ -161,16 +161,6 @@ android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:orientation="vertical"> - Deck Search Deck Search Invalid deck name - This deck is empty. Press the + button to add new content. No cards are due yet Device storage not mounted diff --git a/AnkiDroid/src/test/java/com/ichi2/libanki/SchedulerTest.kt b/AnkiDroid/src/test/java/com/ichi2/libanki/SchedulerTest.kt index d1e29cd8a998..8d1e2adb98ca 100644 --- a/AnkiDroid/src/test/java/com/ichi2/libanki/SchedulerTest.kt +++ b/AnkiDroid/src/test/java/com/ichi2/libanki/SchedulerTest.kt @@ -616,47 +616,6 @@ open class SchedulerTest : JvmTest() { */ } - @Test - @Throws(Exception::class) - fun test_finishedV2() { - val col = col - // nothing due - MatcherAssert.assertThat( - col.sched.finishedMsg().toString(), - Matchers.containsString("Congratulations") - ) - MatcherAssert.assertThat( - col.sched.finishedMsg().toString(), - Matchers.not( - Matchers.containsString("limit") - ) - ) - val note = col.newNote() - note.setItem("Front", "one") - note.setItem("Back", "two") - col.addNote(note) - // have a new card - MatcherAssert.assertThat( - col.sched.finishedMsg().toString(), - Matchers.containsString("new cards available") - ) - // turn it into a review - val c = note.cards()[0] - c.startTimer() - col.sched.answerCard(c, BUTTON_THREE) - // nothing should be due tomorrow, as it's due in a week - MatcherAssert.assertThat( - col.sched.finishedMsg().toString(), - Matchers.containsString("Congratulations") - ) - MatcherAssert.assertThat( - col.sched.finishedMsg().toString(), - Matchers.not( - Matchers.containsString("limit") - ) - ) - } - @Test @Throws(Exception::class) fun test_nextIvlV2() {