diff --git a/res/layout/preferences.xml b/res/layout/preferences.xml index b4a9b8253b..01be9e8614 100644 --- a/res/layout/preferences.xml +++ b/res/layout/preferences.xml @@ -17,26 +17,57 @@ ~ this program. If not, see . --> - - - - + + + + + + + + + + + + + + + + + - diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 4c4cac4748..443aa2698c 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -15,59 +15,89 @@ ~ this program. If not, see . --> - - - - Random order - Order added - Reverse order added - - - 0 - 1 - 2 - - - - Spread out through reviews - After reviews - Before reviews - - - - 0 - 1 - 2 - - - - Largest interval first - Smallest interval first - Order due - Random order - - - - 0 - 1 - 2 - 3 - - - - Show failed cards soon - Show failed cards at end - Show failed cards in 10 minutes - Show failed cards in 8 hours - Show failed cards in 3 days - - - - 0 - 1 - 2 - 3 - 4 - + + + + Random order + Order added + Reverse order added + + + 0 + 1 + 2 + + + + Spread out through reviews + After reviews + Before reviews + + + 0 + 1 + 2 + + + + Largest interval first + Smallest interval first + Order due + Random order + + + 0 + 1 + 2 + 3 + + + + Show failed cards soon + Show failed cards at end + Show failed cards in 10 minutes + Show failed cards in 8 hours + Show failed cards in 3 days + + + 0 + 1 + 2 + 3 + 4 + + + + + Relative + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + 0 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index eaf923ef65..3ab664210e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -20,8 +20,8 @@ Cancel Save - - + + AnkiDroid Yes @@ -87,6 +87,9 @@ +Decks +Study options +Question and answer display Show timer / whiteboard Lets you write on the screen Sample deck @@ -95,6 +98,12 @@ Vibrate on error, that will teach you Write answers Lets you write the answer and compare it with the correct one +Provide ruby annotation support +If the characters '[' and ']' are found, then the enclosed text is handled as a ruby annotation +Font size +Default font size. Using 'Relative' changes the font dynamically based on space +Show question in answer +Shows the question also when displaying the answer unless user entered answer. Deck path Path to where the your decks are stored diff --git a/src/com/ichi2/anki/AnkiDroid.java b/src/com/ichi2/anki/AnkiDroid.java index 6e85629c5c..a03b78f6e1 100644 --- a/src/com/ichi2/anki/AnkiDroid.java +++ b/src/com/ichi2/anki/AnkiDroid.java @@ -75,11 +75,14 @@ public class AnkiDroid extends Activity */ private static final String TAG = "AnkiDroid"; - /** - * Max and min size of the font of the questions and answers - */ - private static final int MAX_FONT_SIZE = 14; - private static final int MIN_FONT_SIZE = 3; + /** Max size of the font of the questions and answers for relative calculation */ + private static final int MAX_QA_FONT_SIZE = 14; + + /** Min size of the font of the questions and answers for relative calculation */ + private static final int MIN_QA_FONT_SIZE = 3; + + /** The font size specified in shared preferences. If 0 then font is calculated with MAX/MIN_FONT_SIZE */ + private int qaFontSize = 0; /** * Menus @@ -94,7 +97,7 @@ public class AnkiDroid extends Activity public static final int MENU_SUSPEND = 4; - private static final int MENU_EDIT = 5; + private static final int MENU_EDIT = 5; /** * Possible outputs trying to load a deck @@ -112,9 +115,7 @@ public class AnkiDroid extends Activity public static final int PREFERENCES_UPDATE = 1; - public static final int EDIT_CURRENT_CARD = 2; - - + public static final int EDIT_CURRENT_CARD = 2; /** * Variables to hold the state @@ -123,7 +124,7 @@ public class AnkiDroid extends Activity private AlertDialog updateDialog; - private BroadcastReceiver mUnmountReceiver = null; + private BroadcastReceiver mUnmountReceiver = null; /** * Name of the last deck loaded @@ -150,6 +151,12 @@ public class AnkiDroid extends Activity private boolean timerAndWhiteboard; private boolean writeAnswers; + + /** Preference: parse for ruby annotations */ + private boolean useRubySupport; + + /** Preference: show the question when showing the answer */ + private boolean showQuestionAnswer; private boolean updateNotifications; // TODO use Veecheck only if this is true @@ -773,17 +780,25 @@ public class AnkiDroid extends Activity // We want to modify the font size depending on how long is the content // Replace each
with 15 spaces, then remove all html tags and spaces String realContent = content.replaceAll("\\", " "); + //TODO: replacement for
in case of showQuestionAnswer = true realContent = realContent.replaceAll("\\<.*?\\>", ""); realContent = realContent.replaceAll(" ", " "); // Calculate the size of the font depending on the length of the content - int size = Math.max(MIN_FONT_SIZE, MAX_FONT_SIZE - (int)(realContent.length()/5)); - mCard.getSettings().setDefaultFontSize(size); + if (0 == qaFontSize) { + int size = Math.max(MIN_QA_FONT_SIZE, MAX_QA_FONT_SIZE - (int)(realContent.length()/5)); + mCard.getSettings().setDefaultFontSize(size); + } else { + mCard.getSettings().setDefaultFontSize(qaFontSize); + } // In order to display the bold style correctly, we have to change font-weight to 700 content = content.replaceAll("font-weight:600;", "font-weight:700;"); - content = RubyParser.ankiRubyToMarkup(content); + // If ruby annotation support is activated, then parse and add markup + if (useRubySupport) { + content = RubyParser.ankiRubyToMarkup(content); + } Log.i(TAG, "content card = \n" + content); String card = cardTemplate.replace("::content::", content); @@ -834,7 +849,15 @@ public class AnkiDroid extends Activity } else { - updateCard(currentCard.answer); + if (true == showQuestionAnswer) { + StringBuffer sb = new StringBuffer(); + sb.append(currentCard.question); + sb.append("
"); + sb.append(currentCard.answer); + updateCard(sb.toString()); + } else { + updateCard(currentCard.answer); + } } } @@ -874,6 +897,11 @@ public class AnkiDroid extends Activity timerAndWhiteboard = preferences.getBoolean("timerAndWhiteboard", true); Log.i(TAG, "restorePreferences - timerAndWhiteboard: " + timerAndWhiteboard); writeAnswers = preferences.getBoolean("writeAnswers", false); + useRubySupport = preferences.getBoolean("useRubySupport", false); + //A little hack to get int values from ListPreference. there should be an easier way ... + String qaFontSizeString = preferences.getString("qaFontSize", "0"); + qaFontSize = Integer.parseInt(qaFontSizeString); + showQuestionAnswer = preferences.getBoolean("showQuestionAnswer", false); updateNotifications = preferences.getBoolean("enabled", true); return preferences;