[Step 2] Add apis for spell checker settings

Bug: 5057977

Change-Id: I4617b7f1487349c5de385e7392dbc39c69fa2ebc
This commit is contained in:
satok
2011-07-25 10:12:21 +09:00
parent 1bedd99761
commit 562ab585f9
5 changed files with 57 additions and 0 deletions

View File

@@ -24055,6 +24055,8 @@ package android.view.textservice {
method public android.content.ComponentName getComponent();
method public java.lang.String getId();
method public java.lang.String getPackageName();
method public android.graphics.drawable.Drawable loadIcon(android.content.pm.PackageManager);
method public java.lang.CharSequence loadLabel(android.content.pm.PackageManager);
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator CREATOR;
}

View File

@@ -18,8 +18,10 @@ package android.view.textservice;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
@@ -102,6 +104,24 @@ public final class SpellCheckerInfo implements Parcelable {
}
};
/**
* Load the user-displayed label for this spell checker.
*
* @param pm Supply a PackageManager used to load the spell checker's resources.
*/
public CharSequence loadLabel(PackageManager pm) {
return mService.loadLabel(pm);
}
/**
* Load the user-displayed icon for this spell checker.
*
* @param pm Supply a PackageManager used to load the spell checker's resources.
*/
public Drawable loadIcon(PackageManager pm) {
return mService.loadIcon(pm);
}
/**
* Used to make this class parcelable.
*/

View File

@@ -97,4 +97,27 @@ public final class TextServicesManager {
}
return session;
}
/**
* @hide
*/
public SpellCheckerInfo[] getEnabledSpellCheckers() {
try {
return sService.getEnabledSpellCheckers();
} catch (RemoteException e) {
return null;
}
}
/**
* @hide
*/
public SpellCheckerInfo getCurrentSpellChecker() {
try {
// Passing null as a locale for ICS
return sService.getCurrentSpellChecker(null);
} catch (RemoteException e) {
return null;
}
}
}

View File

@@ -32,4 +32,5 @@ interface ITextServicesManager {
in ITextServicesSessionListener tsListener,
in ISpellCheckerSessionListener scListener);
oneway void finishSpellCheckerService(in ISpellCheckerSessionListener listener);
SpellCheckerInfo[] getEnabledSpellCheckers();
}

View File

@@ -156,6 +156,9 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
final String curSpellCheckerId =
Settings.Secure.getString(mContext.getContentResolver(),
Settings.Secure.SPELL_CHECKER_SERVICE);
if (DBG) {
Slog.w(TAG, "getCurrentSpellChecker: " + curSpellCheckerId);
}
if (TextUtils.isEmpty(curSpellCheckerId)) {
return null;
}
@@ -197,6 +200,11 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
return;
}
@Override
public SpellCheckerInfo[] getEnabledSpellCheckers() {
return mSpellCheckerList.toArray(new SpellCheckerInfo[mSpellCheckerList.size()]);
}
@Override
public void finishSpellCheckerService(ISpellCheckerSessionListener listener) {
synchronized(mSpellCheckerMap) {
@@ -208,6 +216,9 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
}
private void setCurrentSpellChecker(SpellCheckerInfo sci) {
if (DBG) {
Slog.w(TAG, "setCurrentSpellChecker: " + sci.getId());
}
if (sci == null || mSpellCheckerMap.containsKey(sci.getId())) return;
Settings.Secure.putString(mContext.getContentResolver(),
Settings.Secure.SPELL_CHECKER_SERVICE, sci == null ? "" : sci.getId());