use of android.view.textservice.SpellCheckerInfo in project android_packages_apps_Settings by SudaMod.
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 platform_packages_apps_Settings by BlissRoms.
the class SpellCheckerPreference method setValue.
@Override
public void setValue(String value) {
super.setValue(value);
int index = value != null ? Integer.parseInt(value) : -1;
if (index == -1) {
mIntent = null;
return;
}
SpellCheckerInfo sci = mScis[index];
final String settingsActivity = sci.getSettingsActivity();
if (TextUtils.isEmpty(settingsActivity)) {
mIntent = null;
} else {
mIntent = new Intent(Intent.ACTION_MAIN);
mIntent.setClassName(sci.getPackageName(), settingsActivity);
}
}
use of android.view.textservice.SpellCheckerInfo in project platform_packages_apps_Settings by BlissRoms.
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();
}
use of android.view.textservice.SpellCheckerInfo in project platform_packages_apps_Settings by BlissRoms.
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 platform_packages_apps_Settings by BlissRoms.
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);
}
Aggregations