diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/sched/BaseSched.kt b/AnkiDroid/src/main/java/com/ichi2/libanki/sched/BaseSched.kt index 9c6673841ebd..f17279452801 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/sched/BaseSched.kt +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/sched/BaseSched.kt @@ -23,6 +23,7 @@ import android.graphics.Typeface import android.text.SpannableStringBuilder import android.text.style.StyleSpan import androidx.annotation.VisibleForTesting +import anki.ankidroid.schedTimingTodayLegacyRequest import anki.decks.DeckTreeNode import anki.scheduler.* import com.ichi2.anki.R @@ -478,13 +479,17 @@ abstract class BaseSched(val col: Collection) { fun _timingToday(): SchedTimingTodayResponse { return if (true) { // (BackendFactory.defaultLegacySchema) { @Suppress("useless_cast") - return col.backend.schedTimingTodayLegacy( - col.crt, - col.get_config("creationOffset", 0 as Int)!!, - time.intTime(), - _current_timezone_offset(), - _rolloverHour() - ) + val request = schedTimingTodayLegacyRequest { + createdSecs = col.crt + val minsWest = col.get_config("creationOffset", null as Int?) + if (minsWest != null) { + createdMinsWest = minsWest + } + nowSecs = time.intTime() + nowMinsWest = _current_timezone_offset() + rolloverHour = _rolloverHour() + } + return col.backend.schedTimingTodayLegacy(request) } else { // this currently breaks a bunch of unit tests that assume a mocked time, // as it uses the real time to calculate daysElapsed diff --git a/AnkiDroid/src/main/java/com/ichi2/libanki/sched/SchedV2.java b/AnkiDroid/src/main/java/com/ichi2/libanki/sched/SchedV2.java index 5ec2494d49a1..1259137b2801 100644 --- a/AnkiDroid/src/main/java/com/ichi2/libanki/sched/SchedV2.java +++ b/AnkiDroid/src/main/java/com/ichi2/libanki/sched/SchedV2.java @@ -2127,13 +2127,8 @@ public void _updateCutoff() { SchedTimingTodayResponse timing = _timingToday(); - if (_new_timezone_enabled()) { - mToday = timing.getDaysElapsed(); - mDayCutoff = timing.getNextDayAt(); - } else { - mToday = _daysSinceCreation(); - mDayCutoff = _dayCutoff(); - } + mToday = timing.getDaysElapsed(); + mDayCutoff = timing.getNextDayAt(); if (oldToday != mToday) { getCol().log(mToday, mDayCutoff); @@ -2151,36 +2146,6 @@ public void _updateCutoff() { } } - - private long _dayCutoff() { - int rolloverTime = getCol().get_config("rollover", 4); - if (rolloverTime < 0) { - rolloverTime = 24 + rolloverTime; - } - Calendar date = getTime().calendar(); - date.set(Calendar.HOUR_OF_DAY, rolloverTime); - date.set(Calendar.MINUTE, 0); - date.set(Calendar.SECOND, 0); - date.set(Calendar.MILLISECOND, 0); - Calendar today = getTime().calendar(); - if (date.before(today)) { - date.add(Calendar.DAY_OF_MONTH, 1); - } - - return date.getTimeInMillis() / 1000; - } - - - private int _daysSinceCreation() { - Calendar c = getCol().crtCalendar(); - c.set(Calendar.HOUR, _rolloverHour()); - c.set(Calendar.MINUTE, 0); - c.set(Calendar.SECOND, 0); - c.set(Calendar.MILLISECOND, 0); - - return (int) (((getTime().intTimeMS() - c.getTimeInMillis()) / 1000) / SECONDS_PER_DAY); - } - protected void update(@NonNull Deck g) { for (String t : new String[] { "new", "rev", "lrn", "time" }) { String key = t + "Today"; diff --git a/build.gradle b/build.gradle index 60d7d0d9cb2f..f5c443945074 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { ext.kotlin_version = '1.7.0' ext.lint_version = '30.2.1' ext.acra_version = '5.7.0' - ext.ankidroid_backend_version = '0.1.14-anki2.1.54' + ext.ankidroid_backend_version = '0.1.15-anki2.1.54' ext.hamcrest_version = '2.2' ext.junit_version = '5.8.2' ext.coroutines_version = '1.6.2'