aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/res/values/strings.xml2
-rw-r--r--java/res/xml/kbd_rows_symbols.xml4
-rw-r--r--java/res/xml/kbd_symbols_shift_row4.xml8
-rw-r--r--java/res/xml/prefs.xml102
-rw-r--r--java/src/com/android/inputmethod/latin/Settings.java19
-rw-r--r--java/src/com/android/inputmethod/latin/UserDictionary.java38
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java38
7 files changed, 134 insertions, 77 deletions
diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml
index acc6e5882..2f591fdf0 100644
--- a/java/res/values/strings.xml
+++ b/java/res/values/strings.xml
@@ -82,6 +82,8 @@
<!-- Option to configure dictionaries -->
<string name="configure_dictionaries_title">Add-on dictionaries</string>
+ <!-- Name of the main dictionary, as opposed to auxiliary dictionaries (medical/entertainment/sports...) -->
+ <string name="main_dictionary">Main dictionary</string>
<!-- Option to enable showing suggestions -->
<string name="prefs_show_suggestions">Show correction suggestions</string>
diff --git a/java/res/xml/kbd_rows_symbols.xml b/java/res/xml/kbd_rows_symbols.xml
index e0ede8ba6..2235f4d56 100644
--- a/java/res/xml/kbd_rows_symbols.xml
+++ b/java/res/xml/kbd_rows_symbols.xml
@@ -101,8 +101,8 @@
<Key
latin:keyLabel="!"
latin:moreKeys="¡" />
- <!-- Note: DroidSans doesn't have double-high-reversed-quotation '\u201f' glyph. -->
- <!-- latin:moreKeys="“,”,„,‟,«,»" -->
+ <!-- Note: Neither DroidSans nor Roboto have a glyph for ‟ Double high-reversed-9 quotation mark U+201F. -->
+ <!-- latin:moreKeys="“,”,„,‟,«,»" -->
<Key
latin:keyLabel="&quot;"
latin:moreKeys="“,”,«,»"
diff --git a/java/res/xml/kbd_symbols_shift_row4.xml b/java/res/xml/kbd_symbols_shift_row4.xml
index c8d52932c..99fa80a62 100644
--- a/java/res/xml/kbd_symbols_shift_row4.xml
+++ b/java/res/xml/kbd_symbols_shift_row4.xml
@@ -32,9 +32,11 @@
<Key
latin:keyStyle="toAlphaKeyStyle"
latin:keyWidth="15%p" />
+ <!-- Note: Neither DroidSans nor Roboto have a glyph for ‟ Double high-reversed-9 quotation mark U+201F. -->
+ <!-- latin:keyLabelOption="hasPopupHint" -->
+ <!-- latin:moreKeys="‟" -->
<Key
latin:keyLabel="„"
- latin:moreKeys="“,”,„,‟,«,»,‘,’,‚,‛"
latin:keyStyle="functionalKeyStyle" />
<Key
latin:keyStyle="spaceKeyStyle"
@@ -53,9 +55,11 @@
latin:keyWidth="13.75%p" />
<include
latin:keyboardLayout="@xml/kbd_settings_or_tab" />
+ <!-- Note: Neither DroidSans nor Roboto have a glyph for ‟ Double high-reversed-9 quotation mark U+201F. -->
+ <!-- latin:keyLabelOption="hasPopupHint" -->
+ <!-- latin:moreKeys="‟" -->
<Key
latin:keyLabel="„"
- latin:moreKeys="“,”,„,‟,«,»,‘,’,‚,‛"
latin:keyWidth="9.2%p"
latin:keyStyle="functionalKeyStyle" />
<Key
diff --git a/java/res/xml/prefs.xml b/java/res/xml/prefs.xml
index d02e5d7b6..43bbd6512 100644
--- a/java/res/xml/prefs.xml
+++ b/java/res/xml/prefs.xml
@@ -93,66 +93,46 @@
<PreferenceCategory
android:title="@string/misc_category"
android:key="misc_settings">
- <CheckBoxPreference
- android:key="usability_study_mode"
- android:title="@string/prefs_usability_study_mode"
- android:persistent="true"
- android:defaultValue="false" />
- <CheckBoxPreference
- android:key="enable_logging"
- android:title="@string/prefs_enable_log"
- android:summary="@string/prefs_description_log"
- android:persistent="true"
- android:defaultValue="true" />
- <ListPreference
- android:key="pref_keyboard_layout_20100902"
- android:title="@string/keyboard_layout"
- android:persistent="true"
- android:entryValues="@array/keyboard_layout_modes_values"
- android:entries="@array/keyboard_layout_modes"
- android:defaultValue="@string/config_default_keyboard_theme_id" />
+ <CheckBoxPreference
+ android:key="usability_study_mode"
+ android:title="@string/prefs_usability_study_mode"
+ android:persistent="true"
+ android:defaultValue="false" />
+ <PreferenceScreen
+ android:key="pref_advanced_settings"
+ android:title="@string/advanced_settings"
+ android:summary="@string/advanced_settings_summary">
+ <!-- Values for popup dismiss delay are added programatically -->
+ <ListPreference
+ android:key="pref_key_preview_popup_dismiss_delay"
+ android:title="@string/key_preview_popup_dismiss_delay" />
+ <CheckBoxPreference
+ android:key="pref_key_use_contacts_dict"
+ android:title="@string/use_contacts_dict"
+ android:summary="@string/use_contacts_dict_summary"
+ android:persistent="true"
+ android:defaultValue="true" />
+ <CheckBoxPreference
+ android:key="bigram_suggestion"
+ android:title="@string/bigram_suggestion"
+ android:summary="@string/bigram_suggestion_summary"
+ android:persistent="true"
+ android:defaultValue="true" />
+ <CheckBoxPreference
+ android:key="enable_span_insert"
+ android:title="@string/enable_span_insert"
+ android:summary="@string/enable_span_insert_summary"
+ android:persistent="true"
+ android:defaultValue="true" />
+ <!-- TODO: evaluate results and revive this option. The code
+ already supports it. -->
+ <!-- <CheckBoxPreference -->
+ <!-- android:key="bigram_prediction" -->
+ <!-- android:dependency="bigram_suggestion" -->
+ <!-- android:title="@string/bigram_prediction" -->
+ <!-- android:summary="@string/bigram_prediction_summary" -->
+ <!-- android:persistent="true" -->
+ <!-- android:defaultValue="false" /> -->
+ </PreferenceScreen>
</PreferenceCategory>
- <PreferenceScreen
- android:key="pref_advanced_settings"
- android:title="@string/advanced_settings"
- android:summary="@string/advanced_settings_summary">
- <!-- Values for popup dismiss delay are added programatically -->
- <ListPreference
- android:key="pref_key_preview_popup_dismiss_delay"
- android:title="@string/key_preview_popup_dismiss_delay" />
- <CheckBoxPreference
- android:key="pref_key_use_contacts_dict"
- android:title="@string/use_contacts_dict"
- android:summary="@string/use_contacts_dict_summary"
- android:persistent="true"
- android:defaultValue="true" />
- <CheckBoxPreference
- android:key="bigram_suggestion"
- android:title="@string/bigram_suggestion"
- android:summary="@string/bigram_suggestion_summary"
- android:persistent="true"
- android:defaultValue="true" />
- <CheckBoxPreference
- android:key="enable_span_insert"
- android:title="@string/enable_span_insert"
- android:summary="@string/enable_span_insert_summary"
- android:persistent="true"
- android:defaultValue="true" />
- <!-- TODO: evaluate results and revive this option. The code already supports it. -->
- <!-- <CheckBoxPreference -->
- <!-- android:key="bigram_prediction" -->
- <!-- android:dependency="bigram_suggestion" -->
- <!-- android:title="@string/bigram_prediction" -->
- <!-- android:summary="@string/bigram_prediction_summary" -->
- <!-- android:persistent="true" -->
- <!-- android:defaultValue="false" /> -->
- </PreferenceScreen>
- <!-- <Preference
- android:title="Debug Settings"
- android:key="debug_settings">
- <intent
- android:action="android.intent.action.MAIN"
- android:targetPackage="com.android.inputmethod.latin"
- android:targetClass="com.android.inputmethod.latin.DebugSettings" />
- </Preference>-->
</PreferenceScreen>
diff --git a/java/src/com/android/inputmethod/latin/Settings.java b/java/src/com/android/inputmethod/latin/Settings.java
index e0eae180d..c97f56712 100644
--- a/java/src/com/android/inputmethod/latin/Settings.java
+++ b/java/src/com/android/inputmethod/latin/Settings.java
@@ -55,6 +55,8 @@ public class Settings extends InputMethodSettingsActivity
DialogInterface.OnDismissListener, OnPreferenceClickListener {
private static final String TAG = Settings.class.getSimpleName();
+ public static final boolean ENABLE_EXPERIMENTAL_SETTINGS = false;
+
public static final String PREF_GENERAL_SETTINGS_KEY = "general_settings";
public static final String PREF_VIBRATE_ON = "vibrate_on";
public static final String PREF_SOUND_ON = "sound_on";
@@ -397,6 +399,8 @@ public class Settings extends InputMethodSettingsActivity
(PreferenceGroup) findPreference(PREF_GENERAL_SETTINGS_KEY);
final PreferenceGroup textCorrectionGroup =
(PreferenceGroup) findPreference(PREF_CORRECTION_SETTINGS_KEY);
+ final PreferenceGroup miscSettings =
+ (PreferenceGroup) findPreference(PREF_MISC_SETTINGS_KEY);
if (!Values.isShowSettingsKeyOption(res)) {
generalSettings.removePreference(mShowSettingsKeyPreference);
@@ -437,12 +441,6 @@ public class Settings extends InputMethodSettingsActivity
}
}
- final boolean showUsabilityModeStudyOption = res.getBoolean(
- R.bool.config_enable_usability_study_mode_option);
- if (!showUsabilityModeStudyOption) {
- getPreferenceScreen().removePreference(findPreference(PREF_USABILITY_STUDY_MODE));
- }
-
mKeyPreviewPopupDismissDelay =
(ListPreference)findPreference(PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
final String[] entries = new String[] {
@@ -467,6 +465,15 @@ public class Settings extends InputMethodSettingsActivity
if (0 >= number) {
textCorrectionGroup.removePreference(dictionaryLink);
}
+
+ final boolean showUsabilityModeStudyOption = res.getBoolean(
+ R.bool.config_enable_usability_study_mode_option);
+ if (!showUsabilityModeStudyOption || !ENABLE_EXPERIMENTAL_SETTINGS) {
+ final Preference pref = findPreference(PREF_USABILITY_STUDY_MODE);
+ if (pref != null) {
+ miscSettings.removePreference(pref);
+ }
+ }
}
@SuppressWarnings("unused")
diff --git a/java/src/com/android/inputmethod/latin/UserDictionary.java b/java/src/com/android/inputmethod/latin/UserDictionary.java
index 6608d8268..d696a6158 100644
--- a/java/src/com/android/inputmethod/latin/UserDictionary.java
+++ b/java/src/com/android/inputmethod/latin/UserDictionary.java
@@ -25,16 +25,17 @@ import android.database.Cursor;
import android.net.Uri;
import android.os.RemoteException;
import android.provider.UserDictionary.Words;
+import android.text.TextUtils;
import com.android.inputmethod.keyboard.ProximityInfo;
public class UserDictionary extends ExpandableDictionary {
-
+
private static final String[] PROJECTION_QUERY = {
Words.WORD,
Words.FREQUENCY,
};
-
+
private static final String[] PROJECTION_ADD = {
Words._ID,
Words.FREQUENCY,
@@ -42,10 +43,11 @@ public class UserDictionary extends ExpandableDictionary {
};
private ContentObserver mObserver;
- private String mLocale;
+ final private String mLocale;
public UserDictionary(Context context, String locale) {
super(context, Suggest.DIC_USER);
+ if (null == locale) throw new NullPointerException(); // Catch the error earlier
mLocale = locale;
// Perform a managed query. The Activity will handle closing and re-querying the cursor
// when needed.
@@ -73,9 +75,35 @@ public class UserDictionary extends ExpandableDictionary {
@Override
public void loadDictionaryAsync() {
+ // Split the locale. For example "en" => ["en"], "de_DE" => ["de", "DE"],
+ // "en_US_foo_bar_qux" => ["en", "US", "foo_bar_qux"] because of the limit of 3.
+ // This is correct for locale processing.
+ // For this example, we'll look at the "en_US_POSIX" case.
+ final String[] localeElements =
+ TextUtils.isEmpty(mLocale) ? new String[] {} : mLocale.split("_", 3);
+
+ final StringBuilder request = new StringBuilder("(locale is NULL)");
+ String localeSoFar = "";
+ // At start, localeElements = ["en", "US", "POSIX"] ; localeSoFar = "" ;
+ // and request = "(locale is NULL)"
+ for (int i = 0; i < localeElements.length; ++i) {
+ // i | localeSoFar | localeElements
+ // 0 | "" | ["en", "US", "POSIX"]
+ // 1 | "en_" | ["en", "US", "POSIX"]
+ // 2 | "en_US_" | ["en", "en_US", "POSIX"]
+ localeElements[i] = localeSoFar + localeElements[i];
+ localeSoFar = localeElements[i] + "_";
+ // i | request
+ // 0 | "(locale is NULL)"
+ // 1 | "(locale is NULL) or (locale=?)"
+ // 2 | "(locale is NULL) or (locale=?) or (locale=?)"
+ request.append(" or (locale=?)");
+ }
+ // At the end, localeElements = ["en", "en_US", "en_US_POSIX"]; localeSoFar = en_US_POSIX_"
+ // and request = "(locale is NULL) or (locale=?) or (locale=?) or (locale=?)"
Cursor cursor = getContext().getContentResolver()
- .query(Words.CONTENT_URI, PROJECTION_QUERY, "(locale IS NULL) or (locale=?)",
- new String[] { mLocale }, null);
+ .query(Words.CONTENT_URI, PROJECTION_QUERY, request.toString(),
+ localeElements, null);
addWords(cursor);
}
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
index 3cf8788aa..dfa0abf1b 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -282,6 +282,42 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
mLocale = LocaleUtils.constructLocaleFromString(localeString);
}
+ /**
+ * Finds out whether a particular string should be filtered out of spell checking.
+ *
+ * This will loosely match URLs, numbers, symbols.
+ *
+ * @param text the string to evaluate.
+ * @return true if we should filter this text out, false otherwise
+ */
+ private boolean shouldFilterOut(final String text) {
+ if (TextUtils.isEmpty(text) || text.length() <= 1) return true;
+
+ // TODO: check if an equivalent processing can't be done more quickly with a
+ // compiled regexp.
+ // Filter by first letter
+ final int firstCodePoint = text.codePointAt(0);
+ // Filter out words that don't start with a letter or an apostrophe
+ if (!Character.isLetter(firstCodePoint)
+ && '\'' != firstCodePoint) return true;
+
+ // Filter contents
+ final int length = text.length();
+ int letterCount = 0;
+ for (int i = 0; i < length; ++i) {
+ final int codePoint = text.codePointAt(i);
+ // Any word containing a '@' is probably an e-mail address
+ // Any word containing a '/' is probably either an ad-hoc combination of two
+ // words or a URI - in either case we don't want to spell check that
+ if ('@' == codePoint
+ || '/' == codePoint) return true;
+ if (Character.isLetter(codePoint)) ++letterCount;
+ }
+ // Guestimate heuristic: perform spell checking if at least 3/4 of the characters
+ // in this word are letters
+ return (letterCount * 4 < length * 3);
+ }
+
// Note : this must be reentrant
/**
* Gets a list of suggestions for a specific string. This returns a list of possible
@@ -293,7 +329,7 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
final int suggestionsLimit) {
final String text = textInfo.getText();
- if (TextUtils.isEmpty(text)) return EMPTY_SUGGESTIONS_INFO;
+ if (shouldFilterOut(text)) return EMPTY_SUGGESTIONS_INFO;
final SuggestionsGatherer suggestionsGatherer =
new SuggestionsGatherer(suggestionsLimit);