summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-07-24 18:47:50 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-07-24 18:47:50 -0700
commit54e677ffb026eb838237b8a5e6581833f616e32a (patch)
treeb250439bc91ed1c16895c087db936324cabf0261
parentc82cc94db08810ca238643b85c75b3593b2d8067 (diff)
parent562ab585f9e413d9696ee250e5ec02f95889a157 (diff)
downloadframeworks_base-54e677ffb026eb838237b8a5e6581833f616e32a.zip
frameworks_base-54e677ffb026eb838237b8a5e6581833f616e32a.tar.gz
frameworks_base-54e677ffb026eb838237b8a5e6581833f616e32a.tar.bz2
Merge "[Step 2] Add apis for spell checker settings"
-rw-r--r--api/current.txt2
-rw-r--r--core/java/android/view/textservice/SpellCheckerInfo.java20
-rw-r--r--core/java/android/view/textservice/TextServicesManager.java23
-rw-r--r--core/java/com/android/internal/textservice/ITextServicesManager.aidl1
-rw-r--r--services/java/com/android/server/TextServicesManagerService.java11
5 files changed, 57 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt
index 2514efd..74d9cc6 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -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;
}
diff --git a/core/java/android/view/textservice/SpellCheckerInfo.java b/core/java/android/view/textservice/SpellCheckerInfo.java
index 1205adf..d88a39f 100644
--- a/core/java/android/view/textservice/SpellCheckerInfo.java
+++ b/core/java/android/view/textservice/SpellCheckerInfo.java
@@ -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;
@@ -103,6 +105,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.
*/
@Override
diff --git a/core/java/android/view/textservice/TextServicesManager.java b/core/java/android/view/textservice/TextServicesManager.java
index 9749416..229b414 100644
--- a/core/java/android/view/textservice/TextServicesManager.java
+++ b/core/java/android/view/textservice/TextServicesManager.java
@@ -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;
+ }
+ }
}
diff --git a/core/java/com/android/internal/textservice/ITextServicesManager.aidl b/core/java/com/android/internal/textservice/ITextServicesManager.aidl
index ad0c1ff..2a045e3 100644
--- a/core/java/com/android/internal/textservice/ITextServicesManager.aidl
+++ b/core/java/com/android/internal/textservice/ITextServicesManager.aidl
@@ -32,4 +32,5 @@ interface ITextServicesManager {
in ITextServicesSessionListener tsListener,
in ISpellCheckerSessionListener scListener);
oneway void finishSpellCheckerService(in ISpellCheckerSessionListener listener);
+ SpellCheckerInfo[] getEnabledSpellCheckers();
}
diff --git a/services/java/com/android/server/TextServicesManagerService.java b/services/java/com/android/server/TextServicesManagerService.java
index 4a0c837..ffdc288 100644
--- a/services/java/com/android/server/TextServicesManagerService.java
+++ b/services/java/com/android/server/TextServicesManagerService.java
@@ -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;
}
@@ -198,6 +201,11 @@ public class TextServicesManagerService extends ITextServicesManager.Stub {
}
@Override
+ public SpellCheckerInfo[] getEnabledSpellCheckers() {
+ return mSpellCheckerList.toArray(new SpellCheckerInfo[mSpellCheckerList.size()]);
+ }
+
+ @Override
public void finishSpellCheckerService(ISpellCheckerSessionListener listener) {
synchronized(mSpellCheckerMap) {
for (SpellCheckerBindGroup group : mSpellCheckerBindGroups.values()) {
@@ -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());