From 7d15caaa4acc16a2ace7adcfb54d0158eef20c0b Mon Sep 17 00:00:00 2001
From: Robozinho <65715921+RobozinhoD@users.noreply.github.com>
Date: Tue, 31 Oct 2023 17:35:36 -0300
Subject: [PATCH] Remove estimated time (#14613)
* remove ETA from study options
* remove ETA from picker
---
.../main/java/com/ichi2/anki/DeckPicker.kt | 11 +--
.../com/ichi2/anki/StudyOptionsFragment.kt | 14 +---
.../main/java/com/ichi2/anki/utils/Time.kt | 81 -------------------
.../com/ichi2/anki/widgets/DeckAdapter.kt | 7 --
.../com/ichi2/async/CollectionOperations.kt | 3 +-
.../main/res/layout/studyoptions_fragment.xml | 16 ----
AnkiDroid/src/main/res/values/01-core.xml | 20 -----
.../com/ichi2/utils/UtilsIntegrationTest.kt | 76 -----------------
8 files changed, 4 insertions(+), 224 deletions(-)
delete mode 100644 AnkiDroid/src/test/java/com/ichi2/utils/UtilsIntegrationTest.kt
diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt b/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt
index 1da06b91e5ba..91fa1cc410a3 100644
--- a/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt
@@ -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.*
@@ -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
}
diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/StudyOptionsFragment.kt b/AnkiDroid/src/main/java/com/ichi2/anki/StudyOptionsFragment.kt
index 0fd49707204f..a3e27f61c0eb 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 textETA: TextView
private lateinit var textCongratsMessage: TextView
private var mToolbar: Toolbar? = null
@@ -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)
}
@@ -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
@@ -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()
}
diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/utils/Time.kt b/AnkiDroid/src/main/java/com/ichi2/anki/utils/Time.kt
index bcfa37bf21ac..a8447c0c81fd 100644
--- a/AnkiDroid/src/main/java/com/ichi2/anki/utils/Time.kt
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/utils/Time.kt
@@ -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
@@ -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
*
diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/widgets/DeckAdapter.kt b/AnkiDroid/src/main/java/com/ichi2/anki/widgets/DeckAdapter.kt
index ad0fcf70f6f0..50c0445d89e7 100644
--- a/AnkiDroid/src/main/java/com/ichi2/anki/widgets/DeckAdapter.kt
+++ b/AnkiDroid/src/main/java/com/ichi2/anki/widgets/DeckAdapter.kt
@@ -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
@@ -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
diff --git a/AnkiDroid/src/main/java/com/ichi2/async/CollectionOperations.kt b/AnkiDroid/src/main/java/com/ichi2/async/CollectionOperations.kt
index f8bd12b6e3f6..a6f1ae6a43bd 100644
--- a/AnkiDroid/src/main/java/com/ichi2/async/CollectionOperations.kt
+++ b/AnkiDroid/src/main/java/com/ichi2/async/CollectionOperations.kt
@@ -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")
diff --git a/AnkiDroid/src/main/res/layout/studyoptions_fragment.xml b/AnkiDroid/src/main/res/layout/studyoptions_fragment.xml
index 179a4495f21e..80bc8091c636 100644
--- a/AnkiDroid/src/main/res/layout/studyoptions_fragment.xml
+++ b/AnkiDroid/src/main/res/layout/studyoptions_fragment.xml
@@ -145,22 +145,6 @@
android:layout_height="wrap_content"
android:gravity="end" />
-
-
-
-
-
-
-
Due today:
Total new cards:
Total cards:
- Estimated time (min):
Study
Expand
Collapse
Study more
-
- - %1$d card due (%2$s)
- - %1$d cards due (%2$s)
-
- %d minute left
- %d minutes left
@@ -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. -->
Please grant AnkiDroid the ‘Storage’ permission to continue
-
- %d s
- %d min
- %1$d h %2$d m
- %d h
- %d d
- %1$d d %2$d h
- %.1f mo
- %.1f yr
Rebuilding filtered deck…
Rebuild
Empty
diff --git a/AnkiDroid/src/test/java/com/ichi2/utils/UtilsIntegrationTest.kt b/AnkiDroid/src/test/java/com/ichi2/utils/UtilsIntegrationTest.kt
deleted file mode 100644
index 4f7db2f71535..000000000000
--- a/AnkiDroid/src/test/java/com/ichi2/utils/UtilsIntegrationTest.kt
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2020 David Allison
- *
- * This program is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 3 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see .
- */
-package com.ichi2.utils
-
-import androidx.annotation.CheckResult
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import com.ichi2.anki.RobolectricTest
-import com.ichi2.anki.utils.timeQuantityNextIvl
-import com.ichi2.anki.utils.timeQuantityTopDeckPicker
-import com.ichi2.testutils.EmptyApplication
-import org.hamcrest.MatcherAssert
-import org.hamcrest.Matchers
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.robolectric.annotation.Config
-
-@RunWith(AndroidJUnit4::class)
-@Config(application = EmptyApplication::class, qualifiers = "en")
-class UtilsIntegrationTest : RobolectricTest() {
- @Test
- fun deckPickerTimeOneAndHalfHours() {
- val oneAndAHalfHours = 60 * 90
- val actual = deckPickerTime(oneAndAHalfHours.toLong())
- MatcherAssert.assertThat(actual, Matchers.equalTo("1 h 30 m"))
- }
-
- @Test
- fun deckPickerTimeOneHour() {
- val oneAndAHalfHours = 60 * 60
- val actual = deckPickerTime(oneAndAHalfHours.toLong())
- MatcherAssert.assertThat(actual, Matchers.equalTo("1 h 0 m"))
- }
-
- @Test
- fun deckPickerTime60Seconds() {
- val oneAndAHalfHours = 60
- val actual = deckPickerTime(oneAndAHalfHours.toLong())
- MatcherAssert.assertThat(actual, Matchers.equalTo("1 min"))
- }
-
- @Test
- fun deckPickerTimeOneAndAHalfDays() {
- val oneAndAHalfHours = 60 * 60 * 36
- val actual = deckPickerTime(oneAndAHalfHours.toLong())
- MatcherAssert.assertThat(actual, Matchers.equalTo("1 d 12 h"))
- }
-
- @Test
- @Config(qualifiers = "en")
- fun timeQuantityMonths() {
- // Anki Desktop 2.1.30: '\u206810.8\u2069 months'
- MatcherAssert.assertThat(timeQuantityNextInterval(28080000), Matchers.equalTo("10.8 mo"))
- }
-
- private fun timeQuantityNextInterval(time_s: Int): String {
- return timeQuantityNextIvl(targetContext, time_s.toLong())
- }
-
- @CheckResult
- private fun deckPickerTime(time: Long): String {
- return timeQuantityTopDeckPicker(targetContext, time)
- }
-}