Merge "Fix setCurrentSpellCheckerSubtype"

This commit is contained in:
satok
2011-08-25 21:34:44 -07:00
committed by Android (Google) Code Review
3 changed files with 15 additions and 7 deletions

View File

@@ -146,10 +146,11 @@ public final class TextServicesManager {
/** /**
* @hide * @hide
*/ */
public SpellCheckerSubtype getCurrentSpellCheckerSubtype() { public SpellCheckerSubtype getCurrentSpellCheckerSubtype(
boolean allowImplicitlySelectedSubtype) {
try { try {
// Passing null as a locale for ICS // Passing null as a locale for ICS
return sService.getCurrentSpellCheckerSubtype(null); return sService.getCurrentSpellCheckerSubtype(null, allowImplicitlySelectedSubtype);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error in getCurrentSpellCheckerSubtype: " + e); Log.e(TAG, "Error in getCurrentSpellCheckerSubtype: " + e);
return null; return null;

View File

@@ -30,7 +30,8 @@ import android.view.textservice.SpellCheckerSubtype;
*/ */
interface ITextServicesManager { interface ITextServicesManager {
SpellCheckerInfo getCurrentSpellChecker(String locale); SpellCheckerInfo getCurrentSpellChecker(String locale);
SpellCheckerSubtype getCurrentSpellCheckerSubtype(String locale); SpellCheckerSubtype getCurrentSpellCheckerSubtype(
String locale, boolean allowImplicitlySelectedSubtype);
oneway void getSpellCheckerService(String sciId, in String locale, oneway void getSpellCheckerService(String sciId, in String locale,
in ITextServicesSessionListener tsListener, in ITextServicesSessionListener tsListener,
in ISpellCheckerSessionListener scListener, in Bundle bundle); in ISpellCheckerSessionListener scListener, in Bundle bundle);

View File

@@ -131,6 +131,11 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
if (DBG) Slog.d(TAG, "Add: " + compName); if (DBG) Slog.d(TAG, "Add: " + compName);
try { try {
final SpellCheckerInfo sci = new SpellCheckerInfo(context, ri); 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); list.add(sci);
map.put(sci.getId(), sci); map.put(sci.getId(), sci);
} catch (XmlPullParserException e) { } catch (XmlPullParserException e) {
@@ -186,9 +191,11 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
} }
} }
// TODO: Respect allowImplicitlySelectedSubtype
// TODO: Save SpellCheckerSubtype by supported languages. // TODO: Save SpellCheckerSubtype by supported languages.
@Override @Override
public SpellCheckerSubtype getCurrentSpellCheckerSubtype(String locale) { public SpellCheckerSubtype getCurrentSpellCheckerSubtype(
String locale, boolean allowImplicitlySelectedSubtype) {
synchronized (mSpellCheckerMap) { synchronized (mSpellCheckerMap) {
final String subtypeHashCodeStr = final String subtypeHashCodeStr =
Settings.Secure.getString(mContext.getContentResolver(), Settings.Secure.getString(mContext.getContentResolver(),
@@ -207,8 +214,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
if (DBG) { if (DBG) {
Slog.w(TAG, "Return first subtype in " + sci.getId()); Slog.w(TAG, "Return first subtype in " + sci.getId());
} }
// Return the first Subtype if there is no settings for the current subtype. return null;
return sci.getSubtypeAt(0);
} }
final int hashCode = Integer.valueOf(subtypeHashCodeStr); final int hashCode = Integer.valueOf(subtypeHashCodeStr);
for (int i = 0; i < sci.getSubtypeCount(); ++i) { for (int i = 0; i < sci.getSubtypeCount(); ++i) {
@@ -223,7 +229,7 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
if (DBG) { if (DBG) {
Slog.w(TAG, "Return first subtype in " + sci.getId()); Slog.w(TAG, "Return first subtype in " + sci.getId());
} }
return sci.getSubtypeAt(0); return null;
} }
} }