Skip to content

Commit

Permalink
refactor: remove unused congrats stuff in Study Options Fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
BrayanDSO authored and mikehardy committed Dec 9, 2023
1 parent 3193cc2 commit 7fb5056
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
}
Expand Down
40 changes: 0 additions & 40 deletions AnkiDroid/src/main/java/com/ichi2/libanki/sched/Scheduler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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())
}
Expand Down
10 changes: 0 additions & 10 deletions AnkiDroid/src/main/res/layout/studyoptions_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,6 @@
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="vertical">
<com.ichi2.ui.FixedTextView
android:id="@+id/studyoptions_congrats_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minLines="2"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:paddingBottom="8dp"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/studyoptions_start"
android:layout_width="wrap_content"
Expand Down
1 change: 0 additions & 1 deletion AnkiDroid/src/main/res/values/01-core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
<string name="search_deck" comment="Deck search for selecting it">Deck Search</string>
<string name="search_for_download_deck" comment="Deck search value for downloading deck">Deck Search</string>
<string name="invalid_deck_name">Invalid deck name</string>
<string name="studyoptions_empty">This deck is empty. Press the + button to add new content.</string>
<string name="studyoptions_no_cards_due">No cards are due yet</string>

<string name="sd_card_not_mounted">Device storage not mounted</string>
Expand Down
41 changes: 0 additions & 41 deletions AnkiDroid/src/test/java/com/ichi2/libanki/SchedulerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 7fb5056

Please sign in to comment.