Methods Summary |
---|
public SpellCheckerInfo | getCurrentSpellChecker()
try {
// Passing null as a locale for ICS
return sService.getCurrentSpellChecker(null);
} catch (RemoteException e) {
return null;
}
|
public SpellCheckerSubtype | getCurrentSpellCheckerSubtype(boolean allowImplicitlySelectedSubtype)
try {
if (sService == null) {
// TODO: This is a workaround. Needs to investigate why sService could be null
// here.
Log.e(TAG, "sService is null.");
return null;
}
// Passing null as a locale until we support multiple enabled spell checker subtypes.
return sService.getCurrentSpellCheckerSubtype(null, allowImplicitlySelectedSubtype);
} catch (RemoteException e) {
Log.e(TAG, "Error in getCurrentSpellCheckerSubtype: " + e);
return null;
}
|
public SpellCheckerInfo[] | getEnabledSpellCheckers()
try {
final SpellCheckerInfo[] retval = sService.getEnabledSpellCheckers();
if (DBG) {
Log.d(TAG, "getEnabledSpellCheckers: " + (retval != null ? retval.length : "null"));
}
return retval;
} catch (RemoteException e) {
Log.e(TAG, "Error in getEnabledSpellCheckers: " + e);
return null;
}
|
public static android.view.textservice.TextServicesManager | getInstance()Retrieve the global TextServicesManager instance, creating it if it doesn't already exist.
synchronized (TextServicesManager.class) {
if (sInstance != null) {
return sInstance;
}
sInstance = new TextServicesManager();
}
return sInstance;
|
public boolean | isSpellCheckerEnabled()
try {
return sService.isSpellCheckerEnabled();
} catch (RemoteException e) {
Log.e(TAG, "Error in isSpellCheckerEnabled:" + e);
return false;
}
|
public SpellCheckerSession | newSpellCheckerSession(android.os.Bundle bundle, java.util.Locale locale, android.view.textservice.SpellCheckerSession.SpellCheckerSessionListener listener, boolean referToSpellCheckerLanguageSettings)Get a spell checker session for the specified spell checker
if (listener == null) {
throw new NullPointerException();
}
if (!referToSpellCheckerLanguageSettings && locale == null) {
throw new IllegalArgumentException("Locale should not be null if you don't refer"
+ " settings.");
}
if (referToSpellCheckerLanguageSettings && !isSpellCheckerEnabled()) {
return null;
}
final SpellCheckerInfo sci;
try {
sci = sService.getCurrentSpellChecker(null);
} catch (RemoteException e) {
return null;
}
if (sci == null) {
return null;
}
SpellCheckerSubtype subtypeInUse = null;
if (referToSpellCheckerLanguageSettings) {
subtypeInUse = getCurrentSpellCheckerSubtype(true);
if (subtypeInUse == null) {
return null;
}
if (locale != null) {
final String subtypeLocale = subtypeInUse.getLocale();
final String subtypeLanguage = parseLanguageFromLocaleString(subtypeLocale);
if (subtypeLanguage.length() < 2 || !locale.getLanguage().equals(subtypeLanguage)) {
return null;
}
}
} else {
final String localeStr = locale.toString();
for (int i = 0; i < sci.getSubtypeCount(); ++i) {
final SpellCheckerSubtype subtype = sci.getSubtypeAt(i);
final String tempSubtypeLocale = subtype.getLocale();
final String tempSubtypeLanguage = parseLanguageFromLocaleString(tempSubtypeLocale);
if (tempSubtypeLocale.equals(localeStr)) {
subtypeInUse = subtype;
break;
} else if (tempSubtypeLanguage.length() >= 2 &&
locale.getLanguage().equals(tempSubtypeLanguage)) {
subtypeInUse = subtype;
}
}
}
if (subtypeInUse == null) {
return null;
}
final SpellCheckerSession session = new SpellCheckerSession(
sci, sService, listener, subtypeInUse);
try {
sService.getSpellCheckerService(sci.getId(), subtypeInUse.getLocale(),
session.getTextServicesSessionListener(),
session.getSpellCheckerSessionListener(), bundle);
} catch (RemoteException e) {
return null;
}
return session;
|
private static java.lang.String | parseLanguageFromLocaleString(java.lang.String locale)Returns the language component of a given locale string.
final int idx = locale.indexOf('_");
if (idx < 0) {
return locale;
} else {
return locale.substring(0, idx);
}
|
public void | setCurrentSpellChecker(SpellCheckerInfo sci)
try {
if (sci == null) {
throw new NullPointerException("SpellCheckerInfo is null.");
}
sService.setCurrentSpellChecker(null, sci.getId());
} catch (RemoteException e) {
Log.e(TAG, "Error in setCurrentSpellChecker: " + e);
}
|
public void | setSpellCheckerEnabled(boolean enabled)
try {
sService.setSpellCheckerEnabled(enabled);
} catch (RemoteException e) {
Log.e(TAG, "Error in setSpellCheckerEnabled:" + e);
}
|
public void | setSpellCheckerSubtype(SpellCheckerSubtype subtype)
try {
final int hashCode;
if (subtype == null) {
hashCode = 0;
} else {
hashCode = subtype.hashCode();
}
sService.setCurrentSpellCheckerSubtype(null, hashCode);
} catch (RemoteException e) {
Log.e(TAG, "Error in setSpellCheckerSubtype:" + e);
}
|