diff options
| author | Amith Yamasani <> | 2009-03-25 17:39:37 -0700 | 
|---|---|---|
| committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-25 17:39:37 -0700 | 
| commit | f0138614acd239a43a0b6cb97b0ea845f82925f4 (patch) | |
| tree | a052fe45fbf1d75a86e9ec10ac9662ea7b33ec18 /core/java/android/text | |
| parent | 2ad63a9d773ba987e85ee6a23b0a0724d86d4b0e (diff) | |
| download | frameworks_base-f0138614acd239a43a0b6cb97b0ea845f82925f4.zip frameworks_base-f0138614acd239a43a0b6cb97b0ea845f82925f4.tar.gz frameworks_base-f0138614acd239a43a0b6cb97b0ea845f82925f4.tar.bz2 | |
Automated import from //branches/donutburger/...@142787,142787
Diffstat (limited to 'core/java/android/text')
| -rw-r--r-- | core/java/android/text/AutoText.java | 45 | 
1 files changed, 38 insertions, 7 deletions
| diff --git a/core/java/android/text/AutoText.java b/core/java/android/text/AutoText.java index 508d740..2fc906a 100644 --- a/core/java/android/text/AutoText.java +++ b/core/java/android/text/AutoText.java @@ -69,6 +69,7 @@ public class AutoText {      private char mTrieUsed;      private String mText;      private Locale mLocale; +    private int mSize;      private AutoText(Resources resources) {          mLocale = resources.getConfiguration().locale; @@ -76,12 +77,12 @@ public class AutoText {      }      /** -     * Retrieves a possible spelling correction for the specified range -     * of text.  Returns null if no correction can be found. -     * The View is used to get the current Locale and Resources. +     * Returns the instance of AutoText. If the locale has changed, it will create a new +     * instance of AutoText for the locale. +     * @param view to get the resources from +     * @return the single instance of AutoText       */ -    public static String get(CharSequence src, final int start, final int end, -                             View view) { +    private static AutoText getInstance(View view) {          Resources res = view.getContext().getResources();          Locale locale = res.getConfiguration().locale;          AutoText instance; @@ -94,8 +95,36 @@ public class AutoText {                  sInstance = instance;              }          } +         +        return instance; +    } +     +    /** +     * Retrieves a possible spelling correction for the specified range +     * of text.  Returns null if no correction can be found. +     * The View is used to get the current Locale and Resources. +     */ +    public static String get(CharSequence src, final int start, final int end, +                             View view) { +        return getInstance(view).lookup(src, start, end); +    } + +    /** +     * Returns the size of the auto text dictionary. The return value can be zero if there is +     * no auto correction data available for the current locale. +     * @param view used to retrieve the current Locale and Resources. +     * @return the number of entries in the auto text dictionary +     */ +    public static int getSize(View view) { -        return instance.lookup(src, start, end); +        return getInstance(view).getSize();  +    } + +    /** +     * Returns the size of the dictionary. +     */ +    private int getSize() { +        return mSize;      }      private String lookup(CharSequence src, final int start, final int end) { @@ -181,7 +210,9 @@ public class AutoText {      private void add(String src, char off) {          int slen = src.length();          int herep = TRIE_ROOT; - +        // Keep track of the size of the dictionary +        mSize++; +                  for (int i = 0; i < slen; i++) {              char c = src.charAt(i);              boolean found = false; | 
