Permalink
Browse files

start of catch up on recent libanki changes

  • Loading branch information...
1 parent 93ee98d commit 6449d60937b4b494e1fae106da1f85fe78cbda0d @nobnago committed Mar 14, 2012
View
@@ -101,4 +101,15 @@
<string name="delete_deck">Deleting deck...\nPlease wait.</string>
+ <string-array name="dynOrderLabels">
+ <item>Oldest seen first</item>
+ <item>Random</item>
+ <item>Increasing intervals</item>
+ <item>Decreasing intervals</item>
+ <item>Most lapses</item>
+ <item>Failed today</item>
+ <item>Order added</item>
+ <item>Order due</item>
+ </string-array>
+
</resources>
View
@@ -98,9 +98,4 @@
<item>New cards in random order</item>
<item>New cards in order added</item>
</string-array>
- <string-array name="rev_order_labels">
- <item>Sort by due date</item>
- <item>Sort by decreasing interval (slower)</item>
- <item>Sort by increasing interval (slower)</item>
- </string-array>
-</resources>
+ </resources>
@@ -532,7 +532,7 @@ public void onClick(View v) {
if (changedDid) {
mCurrentEditedCard.setDid(mCurrentDid);
if (mMoveNoteTooToggle.isChecked()) {
- mEditorNote.setDid(mCurrentDid);
+// TODO: mEditorNote.setDid(mCurrentDid);
}
}
mChanged = true;
@@ -992,7 +992,7 @@ public void onClick(DialogInterface dialog, int item) {
if (mCurrentDid != newId) {
if (mAddNote) {
try {
- mEditorNote.setDid(newId);
+// TODO: mEditorNote.setDid(newId);
mEditorNote.model().put("did", newId);
mCol.getModels().setChanged();
} catch (JSONException e) {
@@ -1022,7 +1022,7 @@ public void onClick(DialogInterface dialog, int item) {
origButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- mCurrentDid = mEditorNote.getDid();
+// TODO: mCurrentDid = mEditorNote.getDid();
updateDeck();
mDeckSelectDialog.dismiss();
}
@@ -1406,7 +1406,7 @@ private void setNote(Note note) {
if (note == null) {
boolean firstCard = mEditorNote == null;
mEditorNote = mCol.newNote();
- mCurrentDid = mEditorNote.getDid();
+// TODO: mCurrentDid = mEditorNote.getDid();
if (firstCard && mCaller == CALLER_STUDYOPTIONS && mCurrentDid != mCol.getDecks().current().getLong("id")) {
mCurrentDid = mCol.getDecks().current().getLong("id");
// if called from studyoptions, try to set the decks model
@@ -776,7 +776,6 @@ private TaskData doInBackgroundLoadTutorial(TaskData... params) {
}
note.values()[0] = (i < len) ? questions[i] : sampleQuestions[i - len];
note.values()[1] = (i < len) ? answers[i] : sampleAnswers[i - len];
- note.setDid(did);
col.addNote(note);
}
// deck.setSessionTimeLimit(0);
@@ -67,7 +67,8 @@
private int mLeft = 0;
private int mUsn = 0;
private int mFlags = 0;
- private long mEDue = 0;
+ private long mODue = 0;
+ private long mODid = 0;
private String mData = "";
// END SQL table entries
@@ -109,7 +110,7 @@ public Card(Collection col, long id) {
mReps = 0;
mLapses = 0;
mLeft = 0;
- mEDue = 0;
+ mODue = 0;
mFlags = 0;
mData = "";
}
@@ -139,9 +140,10 @@ public void load() {
mReps = cursor.getInt(11);
mLapses = cursor.getInt(12);
mLeft = cursor.getInt(13);
- mEDue = cursor.getInt(14);
- mFlags = cursor.getInt(15);
- mData = cursor.getString(16);
+ mODue = cursor.getInt(14);
+ mODid = cursor.getInt(15);
+ mFlags = cursor.getInt(16);
+ mData = cursor.getString(17);
} finally {
if (cursor != null) {
cursor.close();
@@ -170,7 +172,8 @@ public void flush() {
sb.append(mReps).append(", ");
sb.append(mLapses).append(", ");
sb.append(mLeft).append(", ");
- sb.append(mEDue).append(", ");
+ sb.append(mODue).append(", ");
+ sb.append(mODid).append(", ");
sb.append(mFlags).append(", ");
sb.append("\"").append(mData).append("\")");
mCol.getDb().execute(sb.toString());
@@ -190,7 +193,8 @@ public void flushSched() {
values.put("reps", mReps);
values.put("lapses", mLapses);
values.put("left", mLeft);
- values.put("edue", mEDue);
+ values.put("odue", mODue);
+ values.put("odid", mODid);
mCol.getDb().update("cards", values, "id = " + mId, null);
}
@@ -258,10 +262,6 @@ public JSONObject model() {
return mCol.getModels().get(note().getMid());
}
- public JSONObject deckConf() {
- return mCol.getDecks().confForDid(mDid);
- }
-
public JSONObject template() {
try {
return model().getJSONArray("tmpls").getJSONObject(mOrd);
@@ -294,15 +294,21 @@ public void setTimer(double time) {
/**
* Time taken to answer card, in integer MS.
*/
- public int timeTaken() {
+ public int timeLimit() {
+ JSONObject conf = mCol.getDecks().confForDid(mODid == 0 ? mDid : mODid);
int total = (int) ((Utils.now() - mTimerStarted) * 1000);
try {
- return Math.min(total, deckConf().getInt("maxTaken") * 1000);
+ return conf.getInt("maxTaken") * 1000;
} catch (JSONException e) {
throw new RuntimeException(e);
}
}
+ public int timeTaken() {
+ int total = (int) ((Utils.now() - mTimerStarted) * 1000);
+ return Math.min(total, timeLimit());
+ }
+
/**
* The cardModel defines a field typeAnswer. If it is empty, then no answer
* should be typed. Otherwise a typed answer should be compared to the value
@@ -548,12 +554,20 @@ public void setQueue(int queue) {
mQueue = queue;
}
- public long getEDue() {
- return mEDue;
+ public long getODue() {
+ return mODue;
+ }
+
+ public void setODid(long odid) {
+ mODid = odid;
+ }
+
+ public long getODid() {
+ return mODid;
}
- public void setEDue(long edue) {
- mEDue = edue;
+ public void setODue(long odue) {
+ mODue = odue;
}
public long getDue() {
@@ -54,7 +54,6 @@
private Models mModels;
private Tags mTags;
- private Sched mStdSched;
private Sched mSched;
private int mSessionStartReps;
@@ -123,8 +122,7 @@ public Collection(AnkiDb db, String path, boolean server) {
mSessionStartReps = 0;
mSessionStartTime = 0;
mLastSessionStart = 0;
- mStdSched = new Sched(this);
- mSched = mStdSched;
+ mSched = new Sched(this);
// check for improper shutdown
cleanup();
}
@@ -327,7 +325,7 @@ public void setDirty() {
*/
private void cleanup() {
if (mDty) {
- mStdSched.onClose();
+ mSched.onClose();
mDty = false;
}
}
@@ -543,7 +541,7 @@ public void _remNotes(long[] ids) {
try {
cur = mDb.getDatabase()
.rawQuery(
- "SELECT id, mid, did, flds FROM notes WHERE id IN "
+ "SELECT id, mid, flds FROM notes WHERE id IN "
+ snids, null);
while (cur.moveToNext()) {
JSONObject model = mModels.get(cur.getLong(1));
@@ -563,9 +561,7 @@ public void _remNotes(long[] ids) {
}
// if missing ord and is available, generate
if (!doHave && avail.contains(tord)) {
- long did = t.getLong("did");
- data.add(new Object[] { ts, nid,
- did != 0 ? did : cur.getLong(2), tord, now,
+ data.add(new Object[] { ts, nid, cur.getLong(2), tord, now,
usn, cur.getLong(0) });
ts += 1;
}
@@ -579,7 +575,7 @@ public void _remNotes(long[] ids) {
}
}
// bulk update
- mDb.executeMany("INSERT INTO cards VALUES (?, ?, ?, ?, ?, ?, 0, 0, ?, 0, 0, 0, 0, 0, 0, 0)", data);
+ mDb.executeMany("INSERT INTO cards VALUES (?, ?, ?, ?, ?, ?, 0, 0, ?, 0, 0, 0, 0, 0, 0)", data);
return rem;
}
@@ -606,7 +602,11 @@ private Card _newCard(Note note, JSONObject template, int due, boolean flush) {
} catch (JSONException e) {
did = 0;
}
- card.setDid(did != 0 ? did : note.getDid());
+ try {
+ card.setDid(did != 0 ? did : note.model().getLong("did"));
+ } catch (JSONException e) {
+ throw new RuntimeException(e);
+ }
card.setDue(_dueForDid(card.getDid(), due));
if (flush) {
card.flush();
@@ -916,35 +916,6 @@ public boolean timeboxReached() {
}
/**
- * Schedulers and cramming
- * **************************************************
- * *********************************************
- */
-
- /**
- * True if scheduler changed.
- */
- public boolean stdSched() {
- if (!mSched.getName().equals("std")) {
- cleanup();
- mSched = mStdSched;
- return true;
- } else {
- return false;
- }
- }
-
- public void cramDecks() {
- cramDecks("mod DESC", 0, 0);
- }
-
- public void cramDecks(String order, int min, int max) {
- stdSched();
- // TODO
- // mSched = new CramScheduler(this, order, min, max);
- }
-
- /**
* Undo
* *********************************************************************
* **************************
Oops, something went wrong.

0 comments on commit 6449d60

Please sign in to comment.