use of android.view.textservice.SpellCheckerInfo in project android_frameworks_base by crdroidandroid.
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 crdroidandroid.
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_packages_apps_Settings by omnirom.
the class SpellCheckersSettings method onPreferenceChange.
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final SpellCheckerInfo sci = (SpellCheckerInfo) newValue;
final boolean isSystemApp = (sci.getServiceInfo().applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
if (isSystemApp) {
changeCurrentSpellChecker(sci);
return true;
} else {
showSecurityWarnDialog(sci);
return false;
}
}
use of android.view.textservice.SpellCheckerInfo in project android_packages_apps_Settings by DirtyUnicorns.
the class SpellCheckerPreferenceControllerTest method updateState_hasSpellerChecker_shouldSetSummaryToAppName.
@Test
public void updateState_hasSpellerChecker_shouldSetSummaryToAppName() {
final String spellCheckerAppLabel = "test";
final SpellCheckerInfo sci = mock(SpellCheckerInfo.class);
when(mTextServicesManager.isSpellCheckerEnabled()).thenReturn(true);
when(mTextServicesManager.getCurrentSpellChecker()).thenReturn(sci);
when(sci.loadLabel(mContext.getPackageManager())).thenReturn(spellCheckerAppLabel);
mController.updateState(mPreference);
assertThat(mPreference.getSummary()).isEqualTo(spellCheckerAppLabel);
}
use of android.view.textservice.SpellCheckerInfo in project android_packages_apps_Settings by DirtyUnicorns.
the class SpellCheckersSettings method showChooseLanguageDialog.
private void showChooseLanguageDialog() {
if (mDialog != null && mDialog.isShowing()) {
mDialog.dismiss();
}
final SpellCheckerInfo currentSci = mTsm.getCurrentSpellChecker();
if (currentSci == null) {
// spell checker belongs to was uninstalled or being in background.
return;
}
final SpellCheckerSubtype currentScs = mTsm.getCurrentSpellCheckerSubtype(false);
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.phone_language);
final int subtypeCount = currentSci.getSubtypeCount();
final CharSequence[] items = new CharSequence[subtypeCount + 1];
items[ITEM_ID_USE_SYSTEM_LANGUAGE] = getSpellCheckerSubtypeLabel(currentSci, null);
int checkedItemId = ITEM_ID_USE_SYSTEM_LANGUAGE;
for (int index = 0; index < subtypeCount; ++index) {
final SpellCheckerSubtype subtype = currentSci.getSubtypeAt(index);
final int itemId = convertSubtypeIndexToDialogItemId(index);
items[itemId] = getSpellCheckerSubtypeLabel(currentSci, subtype);
if (subtype.equals(currentScs)) {
checkedItemId = itemId;
}
}
builder.setSingleChoiceItems(items, checkedItemId, new AlertDialog.OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int item) {
final int subtypeId;
if (item == ITEM_ID_USE_SYSTEM_LANGUAGE) {
subtypeId = SpellCheckerSubtype.SUBTYPE_ID_NONE;
} else {
final int index = convertDialogItemIdToSubtypeIndex(item);
subtypeId = currentSci.getSubtypeAt(index).hashCode();
}
Settings.Secure.putInt(getContentResolver(), Settings.Secure.SELECTED_SPELL_CHECKER_SUBTYPE, subtypeId);
if (DBG) {
final SpellCheckerSubtype subtype = mTsm.getCurrentSpellCheckerSubtype(true);
Log.d(TAG, "Current spell check locale is " + subtype == null ? "null" : subtype.getLocale());
}
dialog.dismiss();
updatePreferenceScreen();
}
});
mDialog = builder.create();
mDialog.show();
}
Aggregations