-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sched: Enable New Timezone Handling Code
Copied from Anki at commit 131d37dca52c29033432e0149052093ab1c79461 Except one line in Collection which accepts data if server == true. https://github.com/ankitects/anki/blob/131d37dca52c29033432e0149052093ab1c79461/pylib/anki/collection.py https://github.com/ankitects/anki/blob/131d37dca52c29033432e0149052093ab1c79461/pylib/anki/schedv2.py * Bumps SYNC_VERSION to 10 if using Rust * Add local_minutes_west and sched_timing_today to Backend * Add "New timezone handling" preference * Set "localOffset" preference if using SchedV2 under Rust * Fix SchedV2:_updateCutoff to better handle timezones We will calculate this information in the Rust in V2 of the Rust Conversion We can't do this yet as we're still on V11 of the database schema Fixes 5805
- Loading branch information
1 parent
7459828
commit c12a438
Showing
15 changed files
with
323 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...Droid/src/main/java/com/ichi2/libanki/backend/exception/BackendNotSupportedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2021 David Allison <[email protected]> | ||
* | ||
* 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.ichi2.libanki.backend.exception; | ||
|
||
import net.ankiweb.rsdroid.RustCleanup; | ||
|
||
@RustCleanup("All of these should be removed when JavaBackend is removed") | ||
public class BackendNotSupportedException extends Exception { | ||
public RuntimeException alreadyUsingRustBackend() { | ||
return new RuntimeException("A BackendNotSupportedException should not occur when using Rust backend", this); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
AnkiDroid/src/main/java/com/ichi2/libanki/backend/model/SchedTimingToday.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2021 David Allison <[email protected]> | ||
* | ||
* 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.ichi2.libanki.backend.model; | ||
|
||
public interface SchedTimingToday { | ||
/** The number of days that have passed since the collection was created.<br/> | ||
* uint32 upstream */ | ||
int days_elapsed(); | ||
/** | ||
* Timestamp of the next day rollover.<br/> | ||
* int64 upstream */ | ||
long next_day_at(); | ||
} | ||
|
43 changes: 43 additions & 0 deletions
43
AnkiDroid/src/main/java/com/ichi2/libanki/backend/model/SchedTimingTodayProto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2021 David Allison <[email protected]> | ||
* | ||
* 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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.ichi2.libanki.backend.model; | ||
|
||
import BackendProto.AdBackend; | ||
|
||
/** | ||
* Adapter for SchedTimingTodayOut2 result from Rust | ||
*/ | ||
public class SchedTimingTodayProto implements SchedTimingToday { | ||
|
||
private final AdBackend.SchedTimingTodayOut2 mData; | ||
|
||
public SchedTimingTodayProto(AdBackend.SchedTimingTodayOut2 data) { | ||
mData = data; | ||
} | ||
|
||
|
||
@Override | ||
public int days_elapsed() { | ||
return mData.getDaysElapsed(); | ||
} | ||
|
||
|
||
@Override | ||
public long next_day_at() { | ||
return mData.getNextDayAt(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.