use of android.view.textservice.SpellCheckerInfo in project platform_frameworks_base by android.
the class TextServicesManagerService method setCurrentSpellCheckerLocked.
private void setCurrentSpellCheckerLocked(String sciId) {
if (DBG) {
Slog.w(TAG, "setCurrentSpellChecker: " + sciId);
}
if (TextUtils.isEmpty(sciId) || !mSpellCheckerMap.containsKey(sciId))
return;
final SpellCheckerInfo currentSci = getCurrentSpellChecker(null);
if (currentSci != null && currentSci.getId().equals(sciId)) {
// Do nothing if the current spell checker is same as new spell checker.
return;
}
final long ident = Binder.clearCallingIdentity();
try {
mSettings.putSelectedSpellChecker(sciId);
setCurrentSpellCheckerSubtypeLocked(0);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
use of android.view.textservice.SpellCheckerInfo in project platform_frameworks_base by android.
the class TextServicesManagerService method resetInternalState.
private void resetInternalState(@UserIdInt int userId) {
final boolean useCopyOnWriteSettings = !mSystemReady || !mUserManager.isUserUnlockingOrUnlocked(userId);
mSettings.switchCurrentUser(userId, useCopyOnWriteSettings);
updateCurrentProfileIds();
unbindServiceLocked();
buildSpellCheckerMapLocked(mContext, mSpellCheckerList, mSpellCheckerMap, mSettings);
SpellCheckerInfo sci = getCurrentSpellChecker(null);
if (sci == null) {
sci = findAvailSpellCheckerLocked(null);
if (sci != null) {
// Set the current spell checker if there is one or more spell checkers
// available. In this case, "sci" is the first one in the available spell
// checkers.
setCurrentSpellCheckerLocked(sci.getId());
}
}
}
use of android.view.textservice.SpellCheckerInfo in project android_frameworks_base by DirtyUnicorns.
the class TextServicesManagerService method setCurrentSpellCheckerLocked.
private void setCurrentSpellCheckerLocked(String sciId) {
if (DBG) {
Slog.w(TAG, "setCurrentSpellChecker: " + sciId);
}
if (TextUtils.isEmpty(sciId) || !mSpellCheckerMap.containsKey(sciId))
return;
final SpellCheckerInfo currentSci = getCurrentSpellChecker(null);
if (currentSci != null && currentSci.getId().equals(sciId)) {
// Do nothing if the current spell checker is same as new spell checker.
return;
}
final long ident = Binder.clearCallingIdentity();
try {
mSettings.putSelectedSpellChecker(sciId);
setCurrentSpellCheckerSubtypeLocked(0);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
use of android.view.textservice.SpellCheckerInfo in project android_frameworks_base by DirtyUnicorns.
the class TextServicesManagerService method setCurrentSpellCheckerSubtypeLocked.
private void setCurrentSpellCheckerSubtypeLocked(int hashCode) {
if (DBG) {
Slog.w(TAG, "setCurrentSpellCheckerSubtype: " + hashCode);
}
final SpellCheckerInfo sci = getCurrentSpellChecker(null);
int tempHashCode = 0;
for (int i = 0; sci != null && i < sci.getSubtypeCount(); ++i) {
if (sci.getSubtypeAt(i).hashCode() == hashCode) {
tempHashCode = hashCode;
break;
}
}
final long ident = Binder.clearCallingIdentity();
try {
mSettings.putSelectedSpellCheckerSubtype(tempHashCode);
} finally {
Binder.restoreCallingIdentity(ident);
}
}
use of android.view.textservice.SpellCheckerInfo in project android_frameworks_base by DirtyUnicorns.
the class TextServicesManagerService method findAvailSpellCheckerLocked.
private SpellCheckerInfo findAvailSpellCheckerLocked(String prefPackage) {
final int spellCheckersCount = mSpellCheckerList.size();
if (spellCheckersCount == 0) {
Slog.w(TAG, "no available spell checker services found");
return null;
}
if (prefPackage != null) {
for (int i = 0; i < spellCheckersCount; ++i) {
final SpellCheckerInfo sci = mSpellCheckerList.get(i);
if (prefPackage.equals(sci.getPackageName())) {
if (DBG) {
Slog.d(TAG, "findAvailSpellCheckerLocked: " + sci.getPackageName());
}
return sci;
}
}
}
// Look up a spell checker based on the system locale.
// TODO: Still there is a room to improve in the following logic: e.g., check if the package
// is pre-installed or not.
final Locale systemLocal = mContext.getResources().getConfiguration().locale;
final ArrayList<Locale> suitableLocales = InputMethodUtils.getSuitableLocalesForSpellChecker(systemLocal);
if (DBG) {
Slog.w(TAG, "findAvailSpellCheckerLocked suitableLocales=" + Arrays.toString(suitableLocales.toArray(new Locale[suitableLocales.size()])));
}
final int localeCount = suitableLocales.size();
for (int localeIndex = 0; localeIndex < localeCount; ++localeIndex) {
final Locale locale = suitableLocales.get(localeIndex);
for (int spellCheckersIndex = 0; spellCheckersIndex < spellCheckersCount; ++spellCheckersIndex) {
final SpellCheckerInfo info = mSpellCheckerList.get(spellCheckersIndex);
final int subtypeCount = info.getSubtypeCount();
for (int subtypeIndex = 0; subtypeIndex < subtypeCount; ++subtypeIndex) {
final SpellCheckerSubtype subtype = info.getSubtypeAt(subtypeIndex);
final Locale subtypeLocale = InputMethodUtils.constructLocaleFromString(subtype.getLocale());
if (locale.equals(subtypeLocale)) {
// returning the first found one.
return info;
}
}
}
}
if (spellCheckersCount > 1) {
Slog.w(TAG, "more than one spell checker service found, picking first");
}
return mSpellCheckerList.get(0);
}
Aggregations