Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4bc554b3 authored by satok's avatar satok Committed by Android (Google) Code Review
Browse files

Merge "Fix setCurrentSpellCheckerSubtype"

parents 3efc794f 3cb5b39a
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -146,10 +146,11 @@ public final class TextServicesManager {
    /**
     * @hide
     */
    public SpellCheckerSubtype getCurrentSpellCheckerSubtype() {
    public SpellCheckerSubtype getCurrentSpellCheckerSubtype(
            boolean allowImplicitlySelectedSubtype) {
        try {
            // Passing null as a locale for ICS
            return sService.getCurrentSpellCheckerSubtype(null);
            return sService.getCurrentSpellCheckerSubtype(null, allowImplicitlySelectedSubtype);
        } catch (RemoteException e) {
            Log.e(TAG, "Error in getCurrentSpellCheckerSubtype: " + e);
            return null;
+2 −1
Original line number Diff line number Diff line
@@ -30,7 +30,8 @@ import android.view.textservice.SpellCheckerSubtype;
 */
interface ITextServicesManager {
    SpellCheckerInfo getCurrentSpellChecker(String locale);
    SpellCheckerSubtype getCurrentSpellCheckerSubtype(String locale);
    SpellCheckerSubtype getCurrentSpellCheckerSubtype(
            String locale, boolean allowImplicitlySelectedSubtype);
    oneway void getSpellCheckerService(String sciId, in String locale,
            in ITextServicesSessionListener tsListener,
            in ISpellCheckerSessionListener scListener, in Bundle bundle);
+10 −4
Original line number Diff line number Diff line
@@ -131,6 +131,11 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
            if (DBG) Slog.d(TAG, "Add: " + compName);
            try {
                final SpellCheckerInfo sci = new SpellCheckerInfo(context, ri);
                if (sci.getSubtypeCount() <= 0) {
                    Slog.w(TAG, "Skipping text service " + compName
                            + ": it does not contain subtypes.");
                    continue;
                }
                list.add(sci);
                map.put(sci.getId(), sci);
            } catch (XmlPullParserException e) {
@@ -186,9 +191,11 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
        }
    }

    // TODO: Respect allowImplicitlySelectedSubtype
    // TODO: Save SpellCheckerSubtype by supported languages.
    @Override
    public SpellCheckerSubtype getCurrentSpellCheckerSubtype(String locale) {
    public SpellCheckerSubtype getCurrentSpellCheckerSubtype(
            String locale, boolean allowImplicitlySelectedSubtype) {
        synchronized (mSpellCheckerMap) {
            final String subtypeHashCodeStr =
                    Settings.Secure.getString(mContext.getContentResolver(),
@@ -207,8 +214,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
                if (DBG) {
                    Slog.w(TAG, "Return first subtype in " + sci.getId());
                }
                // Return the first Subtype if there is no settings for the current subtype.
                return sci.getSubtypeAt(0);
                return null;
            }
            final int hashCode = Integer.valueOf(subtypeHashCodeStr);
            for (int i = 0; i < sci.getSubtypeCount(); ++i) {
@@ -223,7 +229,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
            if (DBG) {
                Slog.w(TAG, "Return first subtype in " + sci.getId());
            }
            return sci.getSubtypeAt(0);
            return null;
        }
    }