Search in sources :

Example 81 with SpellCheckerInfo

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;
    }
}
Also used : SpellCheckerInfo(android.view.textservice.SpellCheckerInfo)

Example 82 with SpellCheckerInfo

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);
    }
}
Also used : Intent(android.content.Intent) SpellCheckerInfo(android.view.textservice.SpellCheckerInfo)

Example 83 with SpellCheckerInfo

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();
}
Also used : SpellCheckerSubtype(android.view.textservice.SpellCheckerSubtype) AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) SpellCheckerInfo(android.view.textservice.SpellCheckerInfo)

Example 84 with SpellCheckerInfo

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;
    }
}
Also used : SpellCheckerInfo(android.view.textservice.SpellCheckerInfo)

Example 85 with SpellCheckerInfo

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);
}
Also used : SpellCheckerInfo(android.view.textservice.SpellCheckerInfo) Test(org.junit.Test)

Aggregations

SpellCheckerInfo (android.view.textservice.SpellCheckerInfo)87 SpellCheckerSubtype (android.view.textservice.SpellCheckerSubtype)19 RemoteException (android.os.RemoteException)16 Intent (android.content.Intent)13 ServiceInfo (android.content.pm.ServiceInfo)11 Locale (java.util.Locale)10 DialogInterface (android.content.DialogInterface)7 Test (org.junit.Test)7 AlertDialog (android.app.AlertDialog)6 ComponentName (android.content.ComponentName)6 ApplicationInfo (android.content.pm.ApplicationInfo)6 PackageManager (android.content.pm.PackageManager)6 ResolveInfo (android.content.pm.ResolveInfo)6 InputMethodInfo (android.view.inputmethod.InputMethodInfo)6 InputMethodManager (android.view.inputmethod.InputMethodManager)6 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)6 ISpellCheckerSession (com.android.internal.textservice.ISpellCheckerSession)6 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6