0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 20:03:05 +02:00

Merge pull request #386 from timrae/preferences-changes

Preferences changes
This commit is contained in:
Nicolas Raoul 2014-06-17 11:32:56 +09:00
commit 8811ba68a5
7 changed files with 181 additions and 182 deletions

View File

@ -69,7 +69,6 @@
</string-array> </string-array>
<!-- Card editor --> <!-- Card editor -->
<string name="about_title">About AnkiDroid</string>
<string name="cardeditor_title_add_note">Add note</string> <string name="cardeditor_title_add_note">Add note</string>
<string name="cardeditor_title_edit_card">Edit note</string> <string name="cardeditor_title_edit_card">Edit note</string>
<!-- <string name="factadder_title">Card adder</string> --> <!-- <string name="factadder_title">Card adder</string> -->
@ -156,7 +155,7 @@
<string name="import_importing">Importing cards…</string> <string name="import_importing">Importing cards…</string>
<string name="import_hint">Place the apkg file in directory %s and press \"OK\" to import cards</string> <string name="import_hint">Place the apkg file in directory %s and press \"OK\" to import cards</string>
<string name="upgrade_import_no_file_found">No importable %1$s file found</string> <string name="upgrade_import_no_file_found">No importable %1$s file found</string>
<string name="study_options">Options</string> <string name="study_options">Deck options</string>
<string name="custom_study">Custom study</string> <string name="custom_study">Custom study</string>
<string name="dyn_deck_desc">This is a special deck for studying outside of the normal schedule. Cards will be automatically returned to their original decks after you review them. Deleting this deck from the deck list will return all remaining cards to their original deck.</string> <string name="dyn_deck_desc">This is a special deck for studying outside of the normal schedule. Cards will be automatically returned to their original decks after you review them. Deleting this deck from the deck list will return all remaining cards to their original deck.</string>
<string name="exit_wizard">Exit Wizard</string> <string name="exit_wizard">Exit Wizard</string>

View File

@ -133,4 +133,7 @@
<string name="lookup_button_content">Look up</string> <string name="lookup_button_content">Look up</string>
<string name="statistics_button_content">Statistics</string> <string name="statistics_button_content">Statistics</string>
<string name="dialog_collection_path_title">Folder does not exit</string>
<string name="dialog_collection_path_text">The folder you specified does not exist, would you like to create it?</string>
</resources> </resources>

View File

@ -22,20 +22,25 @@
<!-- preferences.xml categories--> <!-- preferences.xml categories-->
<string name="pref_cat_general">AnkiDroid</string> <string name="pref_cat_general">AnkiDroid</string>
<string name="pref_cat_general_summ">General settings</string>
<string name="pref_cat_reviewing">Reviewing</string> <string name="pref_cat_reviewing">Reviewing</string>
<string name="pref_cat_reviewing_summ">Non-deck-specific reviewer settings</string>
<string name="pref_cat_reviewer_behaviour">Behavior</string> <string name="pref_cat_reviewer_behaviour">Behavior</string>
<string name="pref_cat_flashcard">Display</string> <string name="pref_cat_flashcard">Display</string>
<string name="pref_cat_whiteboard">Whiteboard</string> <string name="pref_cat_whiteboard">Whiteboard</string>
<string name="pref_cat_automatic_display">Automatic display answer</string> <string name="pref_cat_automatic_display">Automatic display answer</string>
<string name="pref_cat_fonts_formatting">Fonts and style</string> <string name="pref_cat_fonts">Fonts</string>
<string name="pref_cat_fonts">Font selection</string> <string name="pref_cat_fonts_summ">Change default font and size</string>
<string name="pref_cat_fonts_size">Size</string> <string name="pref_cat_gestures">Gestures</string>
<string name="pref_cat_gestures">Touches and swipes</string> <string name="pref_cat_gestures_summ">Use taps and swipes instead of buttons</string>
<string name="pref_cat_actions">Actions</string> <string name="pref_cat_actions">Actions</string>
<string name="pref_cat_advanced">Advanced</string> <string name="pref_cat_advanced">Advanced</string>
<string name="pref_cat_advanced_summ">Optimization and experimental features</string>
<string name="pref_cat_performance">Performance</string> <string name="pref_cat_performance">Performance</string>
<string name="pref_cat_workarounds">Workarounds</string> <string name="pref_cat_workarounds">Workarounds</string>
<string name="pref_cat_plugins">Plugins</string> <string name="pref_cat_plugins">Plugins</string>
<string name="about_title">About AnkiDroid</string>
<string name="about_version">Version: </string>
<!-- preferences.xml entries--> <!-- preferences.xml entries-->
<string name="enable_whiteboard">Enable whiteboard</string> <string name="enable_whiteboard">Enable whiteboard</string>
@ -45,7 +50,7 @@
<string name="whiteboard_black">Black strokes</string> <string name="whiteboard_black">Black strokes</string>
<string name="whiteboard_black_summ">Uses less memory, unless in night mode</string> <string name="whiteboard_black_summ">Uses less memory, unless in night mode</string>
<string name="write_answers_disable">Disable typing in answer</string> <string name="write_answers_disable">Disable typing in answer</string>
<string name="write_answers_disable_summ">Prevents the keyboard from appearing on flashcards containing typed fields</string> <string name="write_answers_disable_summ">Prevents keyboard from appearing on cards containing \'type in the answer\' fields</string>
<string name="text_selection_click">Long press workaround</string> <string name="text_selection_click">Long press workaround</string>
<string name="text_selection_click_summ">Enable this if you are not able to select text with a long press</string> <string name="text_selection_click_summ">Enable this if you are not able to select text with a long press</string>
<string name="dictionary">Lookup dictionary</string> <string name="dictionary">Lookup dictionary</string>
@ -58,16 +63,16 @@
<string name="display_font_size_summ">XXX %</string> <string name="display_font_size_summ">XXX %</string>
<string name="image_size">Reviewer image scaling</string> <string name="image_size">Reviewer image scaling</string>
<string name="image_size_summ">XXX %</string> <string name="image_size_summ">XXX %</string>
<string name="button_size">Reviewer button size</string> <string name="button_size">Answer button size</string>
<string name="button_size_summ">XXX %</string> <string name="button_size_summ">XXX %</string>
<string name="card_browser_font_size">Card browser font scaling</string> <string name="card_browser_font_size">Card browser font scaling</string>
<string name="card_browser_font_size_summ">XXX %</string> <string name="card_browser_font_size_summ">XXX %</string>
<string name="col_path">Collection path</string> <string name="col_path">Collection path</string>
<string name="col_path_summ">XXX</string> <string name="col_path_summ">XXX</string>
<string name="fullscreen_review">Fullscreen mode</string> <string name="fullscreen_review">Fullscreen mode</string>
<string name="fullscreen_review_summ">Use all available screen space</string> <string name="fullscreen_review_summ">Hide the system status bar</string>
<string name="gestures">Enable gestures</string> <string name="gestures">Enable gestures</string>
<string name="gestures_summ">Use swipes and touches to perform actions such as answering and editing cards.</string> <string name="gestures_summ">Assign gestures to actions such as answering and editing cards.</string>
<string name="gestures_swipe_up">Swipe up</string> <string name="gestures_swipe_up">Swipe up</string>
<string name="gestures_swipe_down">Swipe down</string> <string name="gestures_swipe_down">Swipe down</string>
<string name="gestures_swipe_left">Swipe left</string> <string name="gestures_swipe_left">Swipe left</string>
@ -128,7 +133,7 @@
<string name="pref_intent_add_instant">Instant add</string> <string name="pref_intent_add_instant">Instant add</string>
<string name="pref_intent_add_instant_summ">Add new cards from dictionaries without opening AnkiDroid. You find them later under \'saved data\' in card adder.</string> <string name="pref_intent_add_instant_summ">Add new cards from dictionaries without opening AnkiDroid. You find them later under \'saved data\' in card adder.</string>
<string name="show_estimates">Show button time</string> <string name="show_estimates">Show button time</string>
<string name="show_estimates_summ">Show next review time on the answer buttons</string> <string name="show_estimates_summ">Show next review time on answer buttons</string>
<string name="show_progress">Show remaining</string> <string name="show_progress">Show remaining</string>
<string name="show_progress_summ">Show remaining card count</string> <string name="show_progress_summ">Show remaining card count</string>
<string name="use_current">Deck for new cards</string> <string name="use_current">Deck for new cards</string>
@ -171,8 +176,7 @@
<!-- Deck configurations --> <!-- Deck configurations -->
<string name="deck_conf_deck_name">Deck name</string> <string name="deck_conf_deck_name">Deck name</string>
<string name="deck_conf_deck_description">Deck description</string> <string name="deck_conf_deck_description">Deck description</string>
<string name="deck_conf_pref_cat_options">Options</string> <string name="deck_conf_group">Options group</string>
<string name="deck_conf_group">Group</string>
<plurals name="deck_conf_group_summ"> <plurals name="deck_conf_group_summ">
<item quantity="one">%1$s\n1 deck uses this group</item> <item quantity="one">%1$s\n1 deck uses this group</item>
<item quantity="other">%1$s\n%2$d decks use this group</item> <item quantity="other">%1$s\n%2$d decks use this group</item>

View File

@ -17,18 +17,50 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.ichi2.anki" > xmlns:app="http://schemas.android.com/apk/res/com.ichi2.anki" >
<EditTextPreference
android:key="name"
android:title="@string/deck_conf_deck_name" />
<EditTextPreference
android:key="desc"
android:title="@string/deck_conf_deck_description" />
<PreferenceCategory android:title="@string/deck_conf_pref_cat_options" >
<ListPreference <ListPreference
android:key="deckConf" android:key="deckConf"
android:title="@string/deck_conf_group" /> android:title="@string/deck_conf_group" />
<PreferenceScreen android:title="@string/deck_conf_manage" >
<Preference
android:enabled="false"
android:key="currentConf"
android:title="@string/deck_conf_current_group" />
<EditTextPreference
android:key="confAdd"
android:summary="@string/deck_conf_add_summ"
android:title="@string/deck_conf_add" />
<com.ichi2.preferences.CustomDialogPreference
android:dialogIcon="@android:drawable/ic_dialog_alert"
android:dialogMessage="@string/deck_conf_remove_message"
android:dialogTitle="@string/deck_conf_remove_title"
android:key="confRemove"
android:negativeButtonText="@string/dialog_cancel"
android:positiveButtonText="@string/dialog_positive_remove"
android:title="@string/deck_conf_remove" />
<EditTextPreference
android:key="confRename"
android:title="@string/deck_conf_rename" />
<com.ichi2.preferences.CustomDialogPreference
android:dialogIcon="@android:drawable/ic_dialog_alert"
android:dialogMessage="@string/deck_conf_reset_message"
android:dialogTitle="@string/deck_conf_reset_title"
android:key="confRestore"
android:negativeButtonText="@string/dialog_cancel"
android:positiveButtonText="@string/dialog_positive_restore"
android:title="@string/deck_conf_reset_title" />
<com.ichi2.preferences.CustomDialogPreference
android:dialogIcon="@android:drawable/ic_dialog_alert"
android:dialogMessage="@string/deck_conf_set_subdecks_message"
android:dialogTitle="@string/deck_conf_set_subdecks_title"
android:key="confSetSubdecks"
android:negativeButtonText="@string/dialog_cancel"
android:positiveButtonText="@string/dialog_positive_set"
android:title="@string/deck_conf_set_subdecks" />
</PreferenceScreen>
<PreferenceScreen android:title="@string/deck_conf_new_cards" > <PreferenceScreen android:title="@string/deck_conf_new_cards" >
<com.ichi2.preferences.StepsPreference <com.ichi2.preferences.StepsPreference
@ -150,47 +182,7 @@
android:summary="@string/deck_conf_replayq_summ" android:summary="@string/deck_conf_replayq_summ"
android:title="@string/deck_conf_replayq" /> android:title="@string/deck_conf_replayq" />
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen android:title="@string/deck_conf_manage" >
<Preference
android:enabled="false"
android:key="currentConf"
android:title="@string/deck_conf_current_group" />
<EditTextPreference <EditTextPreference
android:key="confAdd" android:key="desc"
android:summary="@string/deck_conf_add_summ" android:title="@string/deck_conf_deck_description" />
android:title="@string/deck_conf_add" />
<com.ichi2.preferences.CustomDialogPreference
android:dialogIcon="@android:drawable/ic_dialog_alert"
android:dialogMessage="@string/deck_conf_remove_message"
android:dialogTitle="@string/deck_conf_remove_title"
android:key="confRemove"
android:negativeButtonText="@string/dialog_cancel"
android:positiveButtonText="@string/dialog_positive_remove"
android:title="@string/deck_conf_remove" />
<EditTextPreference
android:key="confRename"
android:title="@string/deck_conf_rename" />
<com.ichi2.preferences.CustomDialogPreference
android:dialogIcon="@android:drawable/ic_dialog_alert"
android:dialogMessage="@string/deck_conf_reset_message"
android:dialogTitle="@string/deck_conf_reset_title"
android:key="confRestore"
android:negativeButtonText="@string/dialog_cancel"
android:positiveButtonText="@string/dialog_positive_restore"
android:title="@string/deck_conf_reset_title" />
<com.ichi2.preferences.CustomDialogPreference
android:dialogIcon="@android:drawable/ic_dialog_alert"
android:dialogMessage="@string/deck_conf_set_subdecks_message"
android:dialogTitle="@string/deck_conf_set_subdecks_title"
android:key="confSetSubdecks"
android:negativeButtonText="@string/dialog_cancel"
android:positiveButtonText="@string/dialog_positive_set"
android:title="@string/deck_conf_set_subdecks" />
</PreferenceScreen>
</PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@ -23,7 +23,8 @@
<!-- General Preferences --> <!-- General Preferences -->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.ichi2.anki" > xmlns:app="http://schemas.android.com/apk/res/com.ichi2.anki" >
<PreferenceScreen android:title="@string/pref_cat_general" > <PreferenceScreen android:title="@string/pref_cat_general"
android:summary="@string/pref_cat_general_summ" >
<EditTextPreference <EditTextPreference
android:defaultValue="/sdcard/AnkiDroid" android:defaultValue="/sdcard/AnkiDroid"
android:key="deckPath" android:key="deckPath"
@ -82,7 +83,8 @@
</PreferenceScreen> </PreferenceScreen>
<!-- Reviewing Preferences --> <!-- Reviewing Preferences -->
<PreferenceScreen android:title="@string/pref_cat_reviewing" > <PreferenceScreen android:title="@string/pref_cat_reviewing"
android:summary="@string/pref_cat_reviewing_summ" >
<PreferenceCategory android:title="@string/pref_cat_reviewer_behaviour" > <PreferenceCategory android:title="@string/pref_cat_reviewer_behaviour" >
<ListPreference <ListPreference
android:defaultValue="" android:defaultValue=""
@ -136,6 +138,15 @@
android:key="showEstimates" android:key="showEstimates"
android:summary="@string/show_estimates_summ" android:summary="@string/show_estimates_summ"
android:title="@string/show_estimates" /> android:title="@string/show_estimates" />
<com.hlidskialf.android.preference.SeekBarPreference
android:defaultValue="100"
android:key="answerButtonSize"
android:max="170"
android:summary="@string/button_size_summ"
android:text=" %"
android:title="@string/button_size"
app:interval="10"
app:min="100" />
<CheckBoxPreference <CheckBoxPreference
android:key="showProgress" android:key="showProgress"
android:summary="@string/show_progress_summ" android:summary="@string/show_progress_summ"
@ -188,9 +199,9 @@
</PreferenceScreen> </PreferenceScreen>
<!-- Fonts & Style Prefrences --> <!-- Fonts & Style Prefrences -->
<PreferenceScreen android:title="@string/pref_cat_fonts_formatting" <PreferenceScreen android:title="@string/pref_cat_fonts"
android:key="font_preference_group"> android:key="font_preference_group"
<PreferenceCategory android:title="@string/pref_cat_fonts" > android:summary="@string/pref_cat_fonts_summ">
<ListPreference <ListPreference
android:defaultValue="" android:defaultValue=""
android:key="defaultFont" android:key="defaultFont"
@ -209,8 +220,6 @@
android:key="browserEditorFont" android:key="browserEditorFont"
android:summary="@string/pref_browser_editor_font_summ" android:summary="@string/pref_browser_editor_font_summ"
android:title="@string/pref_browser_editor_font" /> android:title="@string/pref_browser_editor_font" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_cat_fonts_size" >
<com.hlidskialf.android.preference.SeekBarPreference <com.hlidskialf.android.preference.SeekBarPreference
android:defaultValue="100" android:defaultValue="100"
android:key="relativeDisplayFontSize" android:key="relativeDisplayFontSize"
@ -229,15 +238,6 @@
android:title="@string/image_size" android:title="@string/image_size"
app:interval="10" app:interval="10"
app:min="50" /> app:min="50" />
<com.hlidskialf.android.preference.SeekBarPreference
android:defaultValue="100"
android:key="answerButtonSize"
android:max="170"
android:summary="@string/button_size_summ"
android:text=" %"
android:title="@string/button_size"
app:interval="10"
app:min="100" />
<com.hlidskialf.android.preference.SeekBarPreference <com.hlidskialf.android.preference.SeekBarPreference
android:defaultValue="100" android:defaultValue="100"
android:key="relativeCardBrowserFontSize" android:key="relativeCardBrowserFontSize"
@ -247,11 +247,11 @@
android:title="@string/card_browser_font_size" android:title="@string/card_browser_font_size"
app:interval="10" app:interval="10"
app:min="10" /> app:min="10" />
</PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>
<!-- Navigation Prefrences --> <!-- Navigation Prefrences -->
<PreferenceScreen android:title="@string/pref_cat_gestures" > <PreferenceScreen android:title="@string/pref_cat_gestures"
android:summary="@string/pref_cat_gestures_summ" >
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false" android:defaultValue="false"
android:disableDependentsState="false" android:disableDependentsState="false"
@ -354,7 +354,8 @@
</PreferenceScreen> </PreferenceScreen>
<!-- Advanced Preferences --> <!-- Advanced Preferences -->
<PreferenceScreen android:title="@string/pref_cat_advanced" > <PreferenceScreen android:title="@string/pref_cat_advanced"
android:summary="@string/pref_cat_advanced_summ" >
<PreferenceCategory android:title="@string/pref_cat_performance" > <PreferenceCategory android:title="@string/pref_cat_performance" >
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false" android:defaultValue="false"

View File

@ -139,10 +139,8 @@ public class DeckPicker extends NavigationDrawerActivity {
*/ */
private static final int CONTEXT_MENU_COLLAPSE_DECK = 0; private static final int CONTEXT_MENU_COLLAPSE_DECK = 0;
private static final int CONTEXT_MENU_RENAME_DECK = 1; private static final int CONTEXT_MENU_RENAME_DECK = 1;
private static final int CONTEXT_MENU_DELETE_DECK = 2; private static final int CONTEXT_MENU_DECK_OPTIONS = 2;
private static final int CONTEXT_MENU_DECK_SUMMARY = 3; private static final int CONTEXT_MENU_DELETE_DECK = 3;
private static final int CONTEXT_MENU_CUSTOM_DICTIONARY = 4;
private static final int CONTEXT_MENU_RESET_LANGUAGE = 5;
public static final String EXTRA_START = "start"; public static final String EXTRA_START = "start";
public static final String EXTRA_DECK_ID = "deckId"; public static final String EXTRA_DECK_ID = "deckId";
@ -247,37 +245,20 @@ public class DeckPicker extends NavigationDrawerActivity {
case CONTEXT_MENU_DELETE_DECK: case CONTEXT_MENU_DELETE_DECK:
showDialog(DIALOG_DELETE_DECK); showDialog(DIALOG_DELETE_DECK);
return; return;
case CONTEXT_MENU_RESET_LANGUAGE:
// resetDeckLanguages(data.get("filepath")); case CONTEXT_MENU_DECK_OPTIONS:
return; if (AnkiDroidApp.getCol().getDecks().isDyn(mCurrentDid)){
case CONTEXT_MENU_CUSTOM_DICTIONARY: // open cram options if filtered deck
// String[] dicts = res.getStringArray(R.array.dictionary_labels); Intent i = new Intent(DeckPicker.this, CramDeckOptions.class);
// String[] vals = res.getStringArray(R.array.dictionary_values); i.putExtra("cramInitialConfig", (String) null);
// int currentSet = MetaDB.getLookupDictionary(DeckPicker.this, data.get("filepath")); startActivityWithAnimation(i, ActivityTransitionAnimation.FADE);
// } else {
// mCurrentDeckPath = data.get("filepath"); // otherwise open regular options
// String[] labels = new String[dicts.length + 1]; Intent i = new Intent(DeckPicker.this, DeckOptions.class);
// mDictValues = new int[dicts.length + 1]; startActivityWithAnimation(i, ActivityTransitionAnimation.FADE);
// int currentChoice = 0; }
// labels[0] = res.getString(R.string.deckpicker_select_dictionary_default);
// mDictValues[0] = -1;
// for (int i = 1; i < labels.length; i++) {
// labels[i] = dicts[i-1];
// mDictValues[i] = Integer.parseInt(vals[i-1]);
// if (currentSet == mDictValues[i]) {
// currentChoice = i;
// }
// }
// StyledDialog.Builder builder = new StyledDialog.Builder(DeckPicker.this);
// builder.setTitle(res.getString(R.string.deckpicker_select_dictionary_title));
// builder.setSingleChoiceItems(labels, currentChoice, new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int item) {
// MetaDB.storeLookupDictionary(DeckPicker.this, mCurrentDeckPath, mDictValues[item]);
// }
// });
// StyledDialog alert = builder.create();
// alert.show();
return; return;
case CONTEXT_MENU_RENAME_DECK: case CONTEXT_MENU_RENAME_DECK:
StyledDialog.Builder builder2 = new StyledDialog.Builder(DeckPicker.this); StyledDialog.Builder builder2 = new StyledDialog.Builder(DeckPicker.this);
builder2.setTitle(res.getString(R.string.contextmenu_deckpicker_rename_deck)); builder2.setTitle(res.getString(R.string.contextmenu_deckpicker_rename_deck));
@ -318,11 +299,7 @@ public class DeckPicker extends NavigationDrawerActivity {
builder2.setNegativeButton(res.getString(R.string.dialog_cancel), null); builder2.setNegativeButton(res.getString(R.string.dialog_cancel), null);
builder2.create().show(); builder2.create().show();
return; return;
case CONTEXT_MENU_DECK_SUMMARY:
// mStatisticType = 0;
// DeckTask.launchDeckTask(DeckTask.TASK_TYPE_LOAD_STATISTICS, mLoadStatisticsHandler, new
// DeckTask.TaskData(DeckPicker.this, new String[]{data.get("filepath")}, mStatisticType, 0));
return;
} }
} }
}; };
@ -1640,15 +1617,10 @@ public class DeckPicker extends NavigationDrawerActivity {
break; break;
case DIALOG_CONTEXT_MENU: case DIALOG_CONTEXT_MENU:
String[] entries = new String[3]; String[] entries = new String[4];
// entries[CONTEXT_MENU_DECK_SUMMARY] =
// "XXXsum";//res.getStringArray(R.array.statistics_type_labels)[0];
// entries[CONTEXT_MENU_CUSTOM_DICTIONARY] =
// res.getString(R.string.contextmenu_deckpicker_set_custom_dictionary);
// entries[CONTEXT_MENU_RESET_LANGUAGE] =
// res.getString(R.string.contextmenu_deckpicker_reset_language_assignments);
entries[CONTEXT_MENU_COLLAPSE_DECK] = res.getString(R.string.contextmenu_deckpicker_collapse_deck); entries[CONTEXT_MENU_COLLAPSE_DECK] = res.getString(R.string.contextmenu_deckpicker_collapse_deck);
entries[CONTEXT_MENU_RENAME_DECK] = res.getString(R.string.contextmenu_deckpicker_rename_deck); entries[CONTEXT_MENU_RENAME_DECK] = res.getString(R.string.contextmenu_deckpicker_rename_deck);
entries[CONTEXT_MENU_DECK_OPTIONS] = res.getString(R.string.study_options);
entries[CONTEXT_MENU_DELETE_DECK] = res.getString(R.string.contextmenu_deckpicker_delete_deck); entries[CONTEXT_MENU_DELETE_DECK] = res.getString(R.string.contextmenu_deckpicker_delete_deck);
builder.setTitle("Context Menu"); builder.setTitle("Context Menu");
builder.setIcon(R.drawable.ic_menu_manage); builder.setIcon(R.drawable.ic_menu_manage);

View File

@ -19,6 +19,7 @@
package com.ichi2.anki; package com.ichi2.anki;
import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnClickListener;
@ -32,6 +33,7 @@ import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference; import android.preference.EditTextPreference;
import android.preference.ListPreference; import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener; import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory; import android.preference.PreferenceCategory;
@ -84,14 +86,13 @@ public class Preferences extends PreferenceActivity implements OnSharedPreferenc
private PreferenceManager mPrefMan; private PreferenceManager mPrefMan;
private CheckBoxPreference keepScreenOnCheckBoxPreference; private CheckBoxPreference keepScreenOnCheckBoxPreference;
private CheckBoxPreference showAnswerCheckBoxPreference; private CheckBoxPreference showAnswerCheckBoxPreference;
private CheckBoxPreference swipeCheckboxPreference;
private CheckBoxPreference useBackupPreference; private CheckBoxPreference useBackupPreference;
private CheckBoxPreference safeDisplayPreference;
private CheckBoxPreference convertFenText; private CheckBoxPreference convertFenText;
private CheckBoxPreference inputWorkaround; private CheckBoxPreference inputWorkaround;
private CheckBoxPreference longclickWorkaround; private CheckBoxPreference longclickWorkaround;
private CheckBoxPreference fixHebrewText; private CheckBoxPreference fixHebrewText;
private CheckBoxPreference fixArabicText; private CheckBoxPreference fixArabicText;
private EditTextPreference collectionPathPreference;
private Preference syncAccount; private Preference syncAccount;
private static String[] sShowValueInSummList = { LANGUAGE, "dictionary", "reportErrorMode", private static String[] sShowValueInSummList = { LANGUAGE, "dictionary", "reportErrorMode",
"minimumCardsDueForNotification", "gestureSwipeUp", "gestureSwipeDown", "gestureSwipeLeft", "minimumCardsDueForNotification", "gestureSwipeUp", "gestureSwipeDown", "gestureSwipeLeft",
@ -135,11 +136,10 @@ public class Preferences extends PreferenceActivity implements OnSharedPreferenc
addPreferencesFromResource(R.xml.preferences); addPreferencesFromResource(R.xml.preferences);
swipeCheckboxPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("gestures"); collectionPathPreference = (EditTextPreference) getPreferenceScreen().findPreference("deckPath");
keepScreenOnCheckBoxPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("keepScreenOn"); keepScreenOnCheckBoxPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("keepScreenOn");
showAnswerCheckBoxPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("timeoutAnswer"); showAnswerCheckBoxPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("timeoutAnswer");
useBackupPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("useBackup"); useBackupPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("useBackup");
safeDisplayPreference = (CheckBoxPreference) getPreferenceScreen().findPreference("safeDisplay");
convertFenText = (CheckBoxPreference) getPreferenceScreen().findPreference("convertFenText"); convertFenText = (CheckBoxPreference) getPreferenceScreen().findPreference("convertFenText");
syncAccount = (Preference) getPreferenceScreen().findPreference("syncAccount"); syncAccount = (Preference) getPreferenceScreen().findPreference("syncAccount");
showEstimates = (CheckBoxPreference) getPreferenceScreen().findPreference("showEstimates"); showEstimates = (CheckBoxPreference) getPreferenceScreen().findPreference("showEstimates");
@ -180,6 +180,34 @@ public class Preferences extends PreferenceActivity implements OnSharedPreferenc
} }
}); });
// Check that input is valid when changing the collection path
collectionPathPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, final Object newValue) {
File collectionDirectory = new File((String) newValue);
if (!collectionDirectory.exists()) {
Dialog pathCheckDialog = new AlertDialog.Builder(Preferences.this)
.setTitle(R.string.dialog_collection_path_title)
.setMessage(R.string.dialog_collection_path_text)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
AnkiDroidApp.getSharedPrefs(getBaseContext()).edit().putString("deckPath", (String) newValue).commit();
updateEditTextPreference("deckPath");
}
})
.create();
pathCheckDialog.show();
return false;
} else {
return true;
}
}
});
// About dialog // About dialog
Preference dialogPreference = (Preference) getPreferenceScreen().findPreference("about_dialog_preference"); Preference dialogPreference = (Preference) getPreferenceScreen().findPreference("about_dialog_preference");
dialogPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() { dialogPreference.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@ -188,6 +216,7 @@ public class Preferences extends PreferenceActivity implements OnSharedPreferenc
return true; return true;
} }
}); });
dialogPreference.setSummary(getResources().getString(R.string.about_version) + " " + AnkiDroidApp.getPkgVersionName());
if (mCol != null) { if (mCol != null) {
// For collection preferences, we need to fetch the correct values from the collection // For collection preferences, we need to fetch the correct values from the collection
@ -615,5 +644,4 @@ public class Preferences extends PreferenceActivity implements OnSharedPreferenc
} }
}; };
} }