Search in sources :

Example 76 with SpellCheckerInfo

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

Example 77 with SpellCheckerInfo

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

Example 78 with SpellCheckerInfo

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

Example 79 with SpellCheckerInfo

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

Example 80 with SpellCheckerInfo

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

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