summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsatok <satok@google.com>2011-09-12 16:55:28 +0900
committersatok <satok@google.com>2011-09-12 18:21:18 +0900
commitf3320979f6d3b63686f15cedae65bba144643e25 (patch)
tree49db7f74d12d18d8aa64bfd796820955f1ae5cbb
parent9ce9a5482a8bcf542c5e81f50d385f707e7085d1 (diff)
downloadinputmethodcommon-ics-mr1-release.tar.gz
Bug: 5069983 Change-Id: I96002ec726ba2c6c8962bdb02ce63ecf295df90f
-rw-r--r--Android.mk3
-rw-r--r--java/com/android/inputmethodcommon/InputMethodSettingsActivity.java21
-rw-r--r--java/com/android/inputmethodcommon/InputMethodSettingsFragment.java21
-rw-r--r--java/com/android/inputmethodcommon/InputMethodSettingsImpl.java61
-rw-r--r--java/com/android/inputmethodcommon/InputMethodSettingsInterface.java14
5 files changed, 44 insertions, 76 deletions
diff --git a/Android.mk b/Android.mk
index 7e4d14d..4aebc01 100644
--- a/Android.mk
+++ b/Android.mk
@@ -16,8 +16,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := inputmethod-common
-# TODO: Change a sdk version to 14 once the framework gets ready
-LOCAL_SDK_VERSION := 13
+LOCAL_SDK_VERSION := current
LOCAL_SRC_FILES := \
$(call all-java-files-under, java)
include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/java/com/android/inputmethodcommon/InputMethodSettingsActivity.java b/java/com/android/inputmethodcommon/InputMethodSettingsActivity.java
index f7d00e1..6e868c9 100644
--- a/java/com/android/inputmethodcommon/InputMethodSettingsActivity.java
+++ b/java/com/android/inputmethodcommon/InputMethodSettingsActivity.java
@@ -71,31 +71,24 @@ public abstract class InputMethodSettingsActivity extends PreferenceActivity
* {@inheritDoc}
*/
@Override
- public void setSubtypeEnablerSummary(int resId) {
- mSettings.setSubtypeEnablerSummary(resId);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setSubtypeEnablerSummary(CharSequence summary) {
- mSettings.setSubtypeEnablerSummary(summary);
+ public void setSubtypeEnablerIcon(int resId) {
+ mSettings.setSubtypeEnablerIcon(resId);
}
/**
* {@inheritDoc}
*/
@Override
- public void setSubtypeEnablerIcon(int resId) {
- mSettings.setSubtypeEnablerIcon(resId);
+ public void setSubtypeEnablerIcon(Drawable drawable) {
+ mSettings.setSubtypeEnablerIcon(drawable);
}
/**
* {@inheritDoc}
*/
@Override
- public void setSubtypeEnablerIcon(Drawable drawable) {
- mSettings.setSubtypeEnablerIcon(drawable);
+ public void onResume() {
+ super.onResume();
+ mSettings.updateSubtypeEnabler();
}
}
diff --git a/java/com/android/inputmethodcommon/InputMethodSettingsFragment.java b/java/com/android/inputmethodcommon/InputMethodSettingsFragment.java
index 7b5c793..49f0b87 100644
--- a/java/com/android/inputmethodcommon/InputMethodSettingsFragment.java
+++ b/java/com/android/inputmethodcommon/InputMethodSettingsFragment.java
@@ -72,31 +72,24 @@ public abstract class InputMethodSettingsFragment extends PreferenceFragment
* {@inheritDoc}
*/
@Override
- public void setSubtypeEnablerSummary(int resId) {
- mSettings.setSubtypeEnablerSummary(resId);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setSubtypeEnablerSummary(CharSequence summary) {
- mSettings.setSubtypeEnablerSummary(summary);
+ public void setSubtypeEnablerIcon(int resId) {
+ mSettings.setSubtypeEnablerIcon(resId);
}
/**
* {@inheritDoc}
*/
@Override
- public void setSubtypeEnablerIcon(int resId) {
- mSettings.setSubtypeEnablerIcon(resId);
+ public void setSubtypeEnablerIcon(Drawable drawable) {
+ mSettings.setSubtypeEnablerIcon(drawable);
}
/**
* {@inheritDoc}
*/
@Override
- public void setSubtypeEnablerIcon(Drawable drawable) {
- mSettings.setSubtypeEnablerIcon(drawable);
+ public void onResume() {
+ super.onResume();
+ mSettings.updateSubtypeEnabler();
}
}
diff --git a/java/com/android/inputmethodcommon/InputMethodSettingsImpl.java b/java/com/android/inputmethodcommon/InputMethodSettingsImpl.java
index 5d11205..8c209d7 100644
--- a/java/com/android/inputmethodcommon/InputMethodSettingsImpl.java
+++ b/java/com/android/inputmethodcommon/InputMethodSettingsImpl.java
@@ -21,12 +21,12 @@ import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
-import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;
import android.provider.Settings;
import android.text.TextUtils;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodManager;
+import android.view.inputmethod.InputMethodSubtype;
import java.util.List;
@@ -36,10 +36,11 @@ import java.util.List;
private CharSequence mInputMethodSettingsCategoryTitle;
private int mSubtypeEnablerTitleRes;
private CharSequence mSubtypeEnablerTitle;
- private int mSubtypeEnablerSummaryRes;
- private CharSequence mSubtypeEnablerSummary;
private int mSubtypeEnablerIconRes;
private Drawable mSubtypeEnablerIcon;
+ private InputMethodManager mImm;
+ private InputMethodInfo mImi;
+ private Context mContext;
/**
* Initialize internal states of this object.
@@ -48,10 +49,10 @@ import java.util.List;
* @return true if this application is an IME and has two or more subtypes, false otherwise.
*/
public boolean init(final Context context, final PreferenceScreen prefScreen) {
- final InputMethodManager imm =
- (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
- final InputMethodInfo imi = getMyImi(context, imm);
- if (imi == null || imi.getSubtypeCount() <= 1) {
+ mContext = context;
+ mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
+ mImi = getMyImi(context, mImm);
+ if (mImi == null || mImi.getSubtypeCount() <= 1) {
return false;
}
mSubtypeEnablerPreference = new Preference(context);
@@ -62,7 +63,7 @@ import java.util.List;
final CharSequence title = getSubtypeEnablerTitle(context);
final Intent intent =
new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS);
- intent.putExtra(Settings.EXTRA_INPUT_METHOD_ID, imi.getId());
+ intent.putExtra(Settings.EXTRA_INPUT_METHOD_ID, mImi.getId());
if (!TextUtils.isEmpty(title)) {
intent.putExtra(Intent.EXTRA_TITLE, title);
}
@@ -89,6 +90,22 @@ import java.util.List;
return null;
}
+ private static String getEnabledSubtypesLabel(
+ Context context, InputMethodManager imm, InputMethodInfo imi) {
+ if (context == null || imm == null || imi == null) return null;
+ final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true);
+ final StringBuilder sb = new StringBuilder();
+ final int N = subtypes.size();
+ for (int i = 0; i < N; ++i) {
+ final InputMethodSubtype subtype = subtypes.get(i);
+ if (sb.length() > 0) {
+ sb.append(", ");
+ }
+ sb.append(subtype.getDisplayName(context, imi.getPackageName(),
+ imi.getServiceInfo().applicationInfo));
+ }
+ return sb.toString();
+ }
/**
* {@inheritDoc}
*/
@@ -131,25 +148,6 @@ import java.util.List;
* {@inheritDoc}
*/
@Override
- public void setSubtypeEnablerSummary(int resId) {
- mSubtypeEnablerSummaryRes = resId;
- updateSubtypeEnabler();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setSubtypeEnablerSummary(CharSequence summary) {
- mSubtypeEnablerSummaryRes = 0;
- mSubtypeEnablerSummary = summary;
- updateSubtypeEnabler();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
public void setSubtypeEnablerIcon(int resId) {
mSubtypeEnablerIconRes = resId;
updateSubtypeEnabler();
@@ -173,17 +171,16 @@ import java.util.List;
}
}
- private void updateSubtypeEnabler() {
+ public void updateSubtypeEnabler() {
if (mSubtypeEnablerPreference != null) {
if (mSubtypeEnablerTitleRes != 0) {
mSubtypeEnablerPreference.setTitle(mSubtypeEnablerTitleRes);
} else if (!TextUtils.isEmpty(mSubtypeEnablerTitle)) {
mSubtypeEnablerPreference.setTitle(mSubtypeEnablerTitle);
}
- if (mSubtypeEnablerSummaryRes != 0) {
- mSubtypeEnablerPreference.setSummary(mSubtypeEnablerSummaryRes);
- } else if (!TextUtils.isEmpty(mSubtypeEnablerSummary)) {
- mSubtypeEnablerPreference.setSummary(mSubtypeEnablerSummary);
+ final String summary = getEnabledSubtypesLabel(mContext, mImm, mImi);
+ if (!TextUtils.isEmpty(summary)) {
+ mSubtypeEnablerPreference.setSummary(summary);
}
if (mSubtypeEnablerIconRes != 0) {
mSubtypeEnablerPreference.setIcon(mSubtypeEnablerIconRes);
diff --git a/java/com/android/inputmethodcommon/InputMethodSettingsInterface.java b/java/com/android/inputmethodcommon/InputMethodSettingsInterface.java
index 8e0f027..6e97fae 100644
--- a/java/com/android/inputmethodcommon/InputMethodSettingsInterface.java
+++ b/java/com/android/inputmethodcommon/InputMethodSettingsInterface.java
@@ -50,20 +50,6 @@ public interface InputMethodSettingsInterface {
public void setSubtypeEnablerTitle(CharSequence title);
/**
- * Sets the summary for the inputmethod enabler preference for launching subtype enabler with a
- * resource ID.
- * @param resId The resource id of the summary for the preference.
- */
- public void setSubtypeEnablerSummary(int resId);
-
- /**
- * Sets the summary for the inputmethod enabler preference for launching subtype enabler with a
- * CharSequence.
- * @param summary The summary of the preference.
- */
- public void setSubtypeEnablerSummary(CharSequence summary);
-
- /**
* Sets the icon for the preference for launching subtype enabler with a resource ID.
* @param resId The resource id of an optional icon for the preference.
*/