diff options
3 files changed, 35 insertions, 1 deletions
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 6aed1aaf787a..25bc656db4ba 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -410,7 +410,7 @@ <!-- QuickSettings: Brightness [CHAR LIMIT=NONE] --> <string name="quick_settings_brightness_label">Brightness</string> <!-- QuickSettings: IME [CHAR LIMIT=NONE] --> - <string name="quick_settings_ime_label">IME</string> + <string name="quick_settings_ime_label">Input Method</string> <!-- QuickSettings: Location [CHAR LIMIT=NONE] --> <string name="quick_settings_location_label">Location in use</string> <!-- QuickSettings: Media device [CHAR LIMIT=NONE] --> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java index 39e142980483..c34e012e9847 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java @@ -411,6 +411,10 @@ class QuickSettings { mModel.addImeTile(imeTile, new QuickSettingsModel.RefreshCallback() { @Override public void refreshView(QuickSettingsTileView view, State state) { + TextView tv = (TextView) view.findViewById(R.id.ime_textview); + if (state.label != null) { + tv.setText(state.label); + } view.setVisibility(state.enabled ? View.VISIBLE : View.GONE); } }); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java index ab3e66e31e02..a0a528233420 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettingsModel.java @@ -29,13 +29,19 @@ import android.database.ContentObserver; import android.hardware.display.WifiDisplayStatus; import android.os.Handler; import android.provider.Settings; +import android.text.TextUtils; import android.view.View; +import android.view.inputmethod.InputMethodInfo; +import android.view.inputmethod.InputMethodManager; +import android.view.inputmethod.InputMethodSubtype; import com.android.systemui.R; import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback; import com.android.systemui.statusbar.policy.LocationController.LocationGpsStateChangeCallback; import com.android.systemui.statusbar.policy.NetworkController.NetworkSignalChangedCallback; +import java.util.List; + class QuickSettingsModel implements BluetoothStateChangeCallback, NetworkSignalChangedCallback, @@ -338,8 +344,32 @@ class QuickSettingsModel implements BluetoothStateChangeCallback, mImeCallback.refreshView(mImeTile, mImeState); } void onImeWindowStatusChanged(boolean visible) { + InputMethodManager imm = + (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE); + List<InputMethodInfo> imis = imm.getInputMethodList(); + mImeState.enabled = visible; + mImeState.label = getCurrentInputMethodName(mContext, mContext.getContentResolver(), + imm, imis, mContext.getPackageManager()); mImeCallback.refreshView(mImeTile, mImeState); } + private static String getCurrentInputMethodName(Context context, ContentResolver resolver, + InputMethodManager imm, List<InputMethodInfo> imis, PackageManager pm) { + if (resolver == null || imis == null) return null; + final String currentInputMethodId = Settings.Secure.getString(resolver, + Settings.Secure.DEFAULT_INPUT_METHOD); + if (TextUtils.isEmpty(currentInputMethodId)) return null; + for (InputMethodInfo imi : imis) { + if (currentInputMethodId.equals(imi.getId())) { + final InputMethodSubtype subtype = imm.getCurrentInputMethodSubtype(); + final CharSequence summary = subtype != null + ? subtype.getDisplayName(context, imi.getPackageName(), + imi.getServiceInfo().applicationInfo) + : context.getString(R.string.quick_settings_ime_label); + return summary.toString(); + } + } + return null; + } }
\ No newline at end of file |