yoshistabber / anymemo

Automatically exported from code.google.com/p/anymemo
GNU General Public License v2.0
0 stars 0 forks source link

Replace "Skip" with "Move To Back" #306

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The problem with "Skip" is it doesn't give you an easy way to retrieve the 
skipped card. I've implemented a moveToBack function which updates the card's 
ordinal and resets the learning data instead of the next learn date. That way, 
the card is effectively pushed to the very back of the deck instead of being 
skipped forever.

Diff below.

Note, this patch replaces the skip menu item. You might want to add a separate 
"Move to Back" option if you want to keep skip for backwards compatibility.

--- a/src/org/liberty/android/fantastischmemo/dao/CardDao.java
+++ b/src/org/liberty/android/fantastischmemo/dao/CardDao.java
@@ -7,6 +7,7 @@ import org.liberty.android.fantastischmemo.domain.Card;
 import org.liberty.android.fantastischmemo.domain.Category;

 public interface CardDao extends HelperDao<Card, Integer> {
+    int moveToBack(Card c);
     Card queryFirstOrdinal();
     /* c is the filter category */
     Card queryFirstOrdinal(Category c);

diff --git a/src/org/liberty/android/fantastischmemo/dao/CardDaoImpl.java 
b/src/org/liberty/android/fantastischmemo/dao/CardDaoImpl.java
index 8d7babc..638e4e5 100644
--- a/src/org/liberty/android/fantastischmemo/dao/CardDaoImpl.java
+++ b/src/org/liberty/android/fantastischmemo/dao/CardDaoImpl.java
@@ -231,6 +231,33 @@ public class CardDaoImpl extends 
AbstractHelperDaoImpl<Card, Integer> implements
         }
     }

+    public int moveToBack(Card c) {
+        try {
+            int res = 0;
+            Card last = queryLastOrdinal();
+            if (last != null) {
+
+                // move trailing cards forward
+                Integer cardOrdinal = c.getOrdinal();
+                UpdateBuilder<Card, Integer> updateBuilder = updateBuilder();
+                updateBuilder.updateColumnExpression("ordinal", "ordinal - 1");
+                updateBuilder.where().gt("ordinal", cardOrdinal).prepare();
+                res = update(updateBuilder.prepare());
+
+                // move the current card to the back
+                c.setOrdinal(last.getOrdinal());
+                update(c);
+
+                // reset the learning data
+                LearningDataDao learningDataDao = 
getHelper().getLearningDataDao();
+                learningDataDao.resetLearningData(c.getLearningData());
+            }
+            return res;
+        } catch (SQLException e) {
+            throw new RuntimeException(e);
+        }
+    }

diff --git a/src/org/liberty/android/fantastischmemo/ui/StudyActivity.java 
b/src/org/liberty/android/fantastischmemo/ui/StudyActivity.java
index 21590d9..6e8c883 100644
--- a/src/org/liberty/android/fantastischmemo/ui/StudyActivity.java
+++ b/src/org/liberty/android/fantastischmemo/ui/StudyActivity.java
@@ -209,7 +209,7 @@ public class StudyActivity extends QACardActivity {
             }
             case R.id.menu_context_skip:
             {
-                showSkipDialog();
+                skipCurrentCard();
                 return true;
             }
             case R.id.menu_context_gotoprev:
@@ -715,11 +715,9 @@ public class StudyActivity extends QACardActivity {
     }

     private void skipCurrentCard() {
-        if(getCurrentCard() != null) {
-            LearningData ld = getCurrentCard().getLearningData();
-            ld.setNextLearnDate(new Date(Long.MAX_VALUE));
-            ld.setAcqReps(1);
-            getDbOpenHelper().getLearningDataDao().update(ld);
+        Card card = getCurrentCard();
+        if(card != null) {
+            getDbOpenHelper().getCardDao().moveToBack(card);
             // Do not restart this card
             setCurrentCard(null);
             restartActivity();

Original issue reported on code.google.com by rogerkea...@gmail.com on 21 Feb 2014 at 2:33

GoogleCodeExporter commented 8 years ago
I wonder if there are many people need this feature. I will leave this issue 
open to discussion.

From implementation point of view, changing the ordinal of card will not only 
change the learning order, but change the order in the preview/edit and 
listing. So I don't think it is the way to go. 

Original comment by mrlhwlib...@gmail.com on 21 Feb 2014 at 9:22

GoogleCodeExporter commented 8 years ago
You're right. After a while of using this feature I didn't find it useful. 
Instead I created a new deck called "next.db" and moved the cards I wanted to 
skip there using the share function. I know there is a request for a "move card 
to new deck" feature, so I'll just add my vote to that instead.

Cheers.

Original comment by rogerkea...@gmail.com on 21 Mar 2014 at 2:58

GoogleCodeExporter commented 8 years ago
AnyMemo does not have an idea of "back of the queue" outside of learning. With 
review priority function in AnyMemo 10.4, the code in listed by op is not even 
working anymore. So I don't think this issue is doable. Please vote issue 246 
for moving cards.

Original comment by mrlhwlib...@gmail.com on 21 Mar 2014 at 6:51