Merge "[Step 2] Add apis for spell checker settings"
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,4 +32,5 @@ interface ITextServicesManager {
|
||||
in ITextServicesSessionListener tsListener,
|
||||
in ISpellCheckerSessionListener scListener);
|
||||
oneway void finishSpellCheckerService(in ISpellCheckerSessionListener listener);
|
||||
SpellCheckerInfo[] getEnabledSpellCheckers();
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user