Skip to content

Commit

Permalink
Remove estimated time (ankidroid#14613)
Browse files Browse the repository at this point in the history
* remove ETA from study options
* remove ETA from picker
  • Loading branch information
RobozinhoD authored Oct 31, 2023
1 parent cd992c0 commit 7d15caa
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 224 deletions.
11 changes: 2 additions & 9 deletions AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ import com.ichi2.anki.snackbar.showSnackbar
import com.ichi2.anki.ui.dialogs.storageMigrationFailedDialogIsShownOrPending
import com.ichi2.anki.ui.windows.permissions.PermissionsActivity
import com.ichi2.anki.utils.SECONDS_PER_DAY
import com.ichi2.anki.utils.timeQuantityTopDeckPicker
import com.ichi2.anki.widgets.DeckAdapter
import com.ichi2.annotations.NeedsTest
import com.ichi2.async.*
Expand Down Expand Up @@ -1890,23 +1889,17 @@ open class DeckPicker :
}
mDeckListAdapter.buildDeckList(tree, currentFilter)

// Set the "x due in y minutes" subtitle
// Set the "x due" subtitle
try {
val eta = mDeckListAdapter.eta()
val due = mDeckListAdapter.due
val res = resources

val time: String = if (eta != -1 && eta != null) {
timeQuantityTopDeckPicker(this, (eta * 60).toLong())
} else {
"-"
}
if (due != null && supportActionBar != null) {
val cardCount = withCol { cardCount() }
val subTitle: String = if (due == 0) {
res.getQuantityString(R.plurals.deckpicker_title_zero_due, cardCount, cardCount)
} else {
res.getQuantityString(R.plurals.deckpicker_title, due, due, time)
res.getQuantityString(R.plurals.widget_cards_due, due, due)
}
supportActionBar!!.subtitle = subTitle
}
Expand Down
14 changes: 1 addition & 13 deletions AnkiDroid/src/main/java/com/ichi2/anki/StudyOptionsFragment.kt
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 textETA: TextView
private lateinit var textCongratsMessage: TextView
private var mToolbar: Toolbar? = null

Expand Down Expand Up @@ -215,7 +214,6 @@ class StudyOptionsFragment : Fragment(), Toolbar.OnMenuItemClickListener {
textTodayRev = studyOptionsView.findViewById(R.id.studyoptions_rev)
textNewTotal = studyOptionsView.findViewById(R.id.studyoptions_total_new)
textTotal = studyOptionsView.findViewById(R.id.studyoptions_total)
textETA = studyOptionsView.findViewById(R.id.studyoptions_eta)
buttonStart.setOnClickListener(mButtonClickListener)
}

Expand Down Expand Up @@ -483,11 +481,7 @@ class StudyOptionsFragment : Fragment(), Toolbar.OnMenuItemClickListener {
/**
* Number of cards in this decks and its subdecks.
*/
val numberOfCardsInDeck: Int,
/**
* Expected time spent today to review all due cards in this deck.
*/
val eta: Int
val numberOfCardsInDeck: Int
)

/** Open cram deck option if deck is opened for the first time
Expand Down Expand Up @@ -646,12 +640,6 @@ class StudyOptionsFragment : Fragment(), Toolbar.OnMenuItemClickListener {

// Set total number of cards
textTotal.text = result.numberOfCardsInDeck.toString()
// Set estimated time remaining
if (result.eta != -1) {
textETA.text = result.eta.toString()
} else {
textETA.text = "-"
}
// Rebuild the options menu
configureToolbar()
}
Expand Down
81 changes: 0 additions & 81 deletions AnkiDroid/src/main/java/com/ichi2/anki/utils/Time.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import com.ichi2.libanki.utils.Time
import java.text.SimpleDateFormat
import java.util.Locale
import kotlin.math.abs
import kotlin.math.floor
import kotlin.math.max
import kotlin.math.roundToInt

Expand All @@ -40,86 +39,6 @@ private const val TIME_DAY = 24.0 * TIME_HOUR
private const val TIME_MONTH = 30.0 * TIME_DAY
private const val TIME_YEAR = 12.0 * TIME_MONTH

/**
* Return a string representing a time quantity
*
* Equivalent to Anki's anki/utils.py's shortTimeFmt, applied to a number.
* I.e. equivalent to Anki's anki/utils.py's fmtTimeSpan, with the parameter short=True.
*
* @param context The application's environment.
* @param time_s The time to format, in seconds
* @return The time quantity string. Something like "3 s" or "1.7
* yr". Only months and year have a number after the decimal.
*/
fun timeQuantityTopDeckPicker(context: Context, time_s: Long): String {
val res = context.resources
// N.B.: the integer s, min, h, d and (one decimal, rounded by format) double for month, year is
// hard-coded. See also 01-core.xml
return if (abs(time_s) < TIME_MINUTE) {
res.getString(R.string.time_quantity_seconds, time_s)
} else if (abs(time_s) < TIME_HOUR) {
res.getString(
R.string.time_quantity_minutes,
(time_s / TIME_MINUTE).roundToInt()
)
} else if (abs(time_s) < TIME_DAY) {
res.getString(
R.string.time_quantity_hours_minutes,
floor(time_s / TIME_HOUR).toInt(),
(time_s % TIME_HOUR / TIME_MINUTE).roundToInt()
)
} else if (abs(time_s) < TIME_MONTH) {
res.getString(
R.string.time_quantity_days_hours,
floor(time_s / TIME_DAY).toInt(),
(time_s % TIME_DAY / TIME_HOUR).roundToInt()
)
} else if (abs(time_s) < TIME_YEAR) {
res.getString(R.string.time_quantity_months, time_s / TIME_MONTH)
} else {
res.getString(R.string.time_quantity_years, time_s / TIME_YEAR)
}
}

/**
* Return a string representing a time quantity
*
* Equivalent to Anki's anki/utils.py's shortTimeFmt, applied to a number.
* I.e. equivalent to Anki's anki/utils.py's fmtTimeSpan, with the parameter short=True.
*
* @param context The application's environment.
* @param time_s The time to format, in seconds
* @return The time quantity string. Something like "3 s" or "1.7
* yr". Only months and year have a number after the decimal.
*/
fun timeQuantityNextIvl(context: Context, time_s: Long): String {
val res = context.resources
// N.B.: the integer s, min, h, d and (one decimal, rounded by format) double for month, year is
// hard-coded. See also 01-core.xml
return if (abs(time_s) < TIME_MINUTE) {
res.getString(R.string.time_quantity_seconds, time_s)
} else if (abs(time_s) < TIME_HOUR) {
res.getString(
R.string.time_quantity_minutes,
(time_s / TIME_MINUTE).roundToInt()
)
} else if (abs(time_s) < TIME_DAY) {
res.getString(
R.string.time_quantity_hours,
(time_s / TIME_HOUR).roundToInt()
)
} else if (abs(time_s) < TIME_MONTH) {
res.getString(
R.string.time_quantity_days,
(time_s / TIME_DAY).roundToInt()
)
} else if (abs(time_s) < TIME_YEAR) {
res.getString(R.string.time_quantity_months, time_s / TIME_MONTH)
} else {
res.getString(R.string.time_quantity_years, time_s / TIME_YEAR)
}
}

/**
* Return a string representing how much time remains
*
Expand Down
7 changes: 0 additions & 7 deletions AnkiDroid/src/main/java/com/ichi2/anki/widgets/DeckAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import androidx.recyclerview.widget.RecyclerView
import com.ichi2.anki.CollectionManager.withCol
import com.ichi2.anki.R
import com.ichi2.libanki.DeckId
import com.ichi2.libanki.sched.Counts
import com.ichi2.libanki.sched.DeckNode
import com.ichi2.utils.KotlinCleanup
import kotlinx.coroutines.runBlocking
Expand Down Expand Up @@ -273,12 +272,6 @@ class DeckAdapter(private val layoutInflater: LayoutInflater, context: Context)
return findDeckPosition(parent.did)
}

suspend fun eta(): Int? = if (mNumbersComputed) {
withCol { sched.eta(Counts(mNew, mLrn, mRev)) }
} else {
null
}

val due: Int?
get() = if (mNumbersComputed) {
mNew + mLrn + mRev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ fun updateValuesFromDeck(
counts.lrn,
counts.rev,
totalNewCount,
totalCount,
sched.eta(counts)
totalCount
)
} catch (e: RuntimeException) {
Timber.e(e, "doInBackgroundUpdateValuesFromDeck - an error occurred")
Expand Down
16 changes: 0 additions & 16 deletions AnkiDroid/src/main/res/layout/studyoptions_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,6 @@
android:layout_height="wrap_content"
android:gravity="end" />
</TableRow>

<TableRow>

<com.ichi2.ui.FixedTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="0dip"
android:paddingEnd="5dip"
android:text="@string/studyoptions_eta" />

<com.ichi2.ui.FixedTextView
android:id="@+id/studyoptions_eta"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end" />
</TableRow>
</TableLayout>
<com.ichi2.ui.FixedTextView
android:id="@+id/studyoptions_deck_description"
Expand Down
20 changes: 0 additions & 20 deletions AnkiDroid/src/main/res/values/01-core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,12 @@
<string name="studyoptions_due_today">Due today:</string>
<string name="studyoptions_new_total">Total new cards:</string>
<string name="studyoptions_total_cards">Total cards:</string>
<string name="studyoptions_eta">Estimated time (min):</string>
<string name="studyoptions_start">Study</string>

<!-- DeckPicker.kt -->
<string name="expand">Expand</string>
<string name="collapse">Collapse</string>
<string name="study_more">Study more</string>
<plurals name="deckpicker_title">
<item quantity="one">%1$d card due (%2$s)</item>
<item quantity="other">%1$d cards due (%2$s)</item>
</plurals>
<plurals name="reviewer_window_title">
<item quantity="one">%d minute left</item>
<item quantity="other">%d minutes left</item>
Expand Down Expand Up @@ -111,21 +106,6 @@
grant AnkiDroid the 'Storage' permission. This needs to be a fairly generic message as implementations
of the permissions/app info screen will differ between devices. -->
<string name="startup_no_storage_permission">Please grant AnkiDroid the ‘Storage’ permission to continue</string>
<!--
The time_quantities are units of time. They are used without
plurals or dots.
s, min, h, d, are standard (ISO 31-1) units and should usually
not be translated, at least not for languages using the Latin
alphabet.
-->
<string name="time_quantity_seconds">%d s</string>
<string name="time_quantity_minutes">%d min</string>
<string name="time_quantity_hours_minutes">%1$d h %2$d m</string>
<string name="time_quantity_hours">%d h</string>
<string name="time_quantity_days">%d d</string>
<string name="time_quantity_days_hours">%1$d d %2$d h</string>
<string name="time_quantity_months">%.1f mo</string>
<string name="time_quantity_years">%.1f yr</string><!-- or "%.1f a" -->
<string name="rebuild_filtered_deck">Rebuilding filtered deck…</string>
<string name="rebuild_cram_label">Rebuild</string>
<string name="empty_cram_label">Empty</string>
Expand Down
76 changes: 0 additions & 76 deletions AnkiDroid/src/test/java/com/ichi2/utils/UtilsIntegrationTest.kt

This file was deleted.

0 comments on commit 7d15caa

Please sign in to comment.