This adds dictionary-based spell checking to the keyboard. The keyboard looks at the word being typed and matches it against a dictionary to either complete the rest of the word or find alternative spellings. The core of this feature is implemented in cdict, which is included as a submodule in vendor/cidct. Cdict is developped at https://github.com/Julow/cdict The dictionaries are hosted at https://github.com/Julow/Unexpected-Keyboard-dictionaries/ The wordlists used to build the dictionaries are the same ones used by HeliBoard from https://codeberg.org/Helium314/aosp-dictionaries - Add an activity accessible from the launcher app that lists available dictionaries with a download button. The DictionaryListView view shows the list of available dictionaries and handles downloading and installing them. - The Dictionaries class manages installed dictionaries. Dictionaries are installed as individual files into the app's private directory. - Available dictionaries are listed in dictionaries.xml, which is generated when building Unexpected-Keyboard-dictionaries. method.xml mentions the dictionary name for each locales.
34 lines
927 B
Java
34 lines
927 B
Java
package juloo.keyboard2.dict;
|
|
|
|
import android.content.res.Resources;
|
|
import java.util.Arrays;
|
|
import juloo.keyboard2.R;
|
|
|
|
/** Access arrays in [dictionaries.xml]. */
|
|
public class SupportedDictionaries
|
|
{
|
|
public String[] locales;
|
|
public String[] names;
|
|
public int[] sizes;
|
|
|
|
public SupportedDictionaries(Resources res)
|
|
{
|
|
locales = res.getStringArray(R.array.dictionaries_locale);
|
|
names = res.getStringArray(R.array.dictionaries_name);
|
|
sizes = res.getIntArray(R.array.dictionaries_size);
|
|
}
|
|
|
|
/** Find the index for a given dictionary name. Return [-1] if not found. */
|
|
public int find(String dict_name)
|
|
{
|
|
int i = Arrays.binarySearch(locales, dict_name);
|
|
return (i < 0) ? -1 : i;
|
|
}
|
|
|
|
public int length() { return locales.length; }
|
|
|
|
public String dict_name(int i) { return locales[i]; }
|
|
public String display_name(int i) { return names[i]; }
|
|
public int size(int i) { return sizes[i]; }
|
|
}
|