From 9ef0283bdcd9534cc09ae37eb2b78771b95247b5 Mon Sep 17 00:00:00 2001 From: satok Date: Thu, 4 Nov 2010 21:17:48 +0900 Subject: Change API for getting InputMethodSubtype's mode from resource id to String Change-Id: I00aa99f8ab9901d40806a6bb336ab718eb857e8b --- .../android/server/InputMethodManagerService.java | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'services/java/com/android/server/InputMethodManagerService.java') diff --git a/services/java/com/android/server/InputMethodManagerService.java b/services/java/com/android/server/InputMethodManagerService.java index 41471d97f774..d035eb586aad 100644 --- a/services/java/com/android/server/InputMethodManagerService.java +++ b/services/java/com/android/server/InputMethodManagerService.java @@ -1622,15 +1622,12 @@ public class InputMethodManagerService extends IInputMethodManager.Stub if (enabledSubtypeSet.contains(String.valueOf(subtype.hashCode()))) { CharSequence title; int nameResId = subtype.getNameResId(); - int modeResId = subtype.getModeResId(); + String mode = subtype.getMode(); if (nameResId != 0) { title = pm.getText(property.getPackageName(), nameResId, property.getServiceInfo().applicationInfo); } else { CharSequence language = subtype.getLocale(); - CharSequence mode = modeResId == 0 ? null - : pm.getText(property.getPackageName(), modeResId, - property.getServiceInfo().applicationInfo); // TODO: Use more friendly Title and UI title = label + "," + (mode == null ? "" : mode) + "," + (language == null ? "" : language); @@ -1869,14 +1866,17 @@ public class InputMethodManagerService extends IInputMethodManager.Stub int applicableSubtypeId = DEFAULT_SUBTYPE_ID; for (int i = 0; i < subtypes.size(); ++i) { final String subtypeLocale = subtypes.get(i).getLocale(); - if (locale.equals(subtypeLocale)) { - // Exact match (e.g. system locale is "en_US" and subtype locale is "en_US") - applicableSubtypeId = i; - break; - } else if (!partialMatchFound && subtypeLocale.startsWith(language)) { - // Partial match (e.g. system locale is "en_US" and subtype locale is "en") - applicableSubtypeId = i; - partialMatchFound = true; + // An applicable subtype should be a keyboard subtype + if (subtypes.get(i).getMode().equalsIgnoreCase("keyboard")) { + if (locale.equals(subtypeLocale)) { + // Exact match (e.g. system locale is "en_US" and subtype locale is "en_US") + applicableSubtypeId = i; + break; + } else if (!partialMatchFound && subtypeLocale.startsWith(language)) { + // Partial match (e.g. system locale is "en_US" and subtype locale is "en") + applicableSubtypeId = i; + partialMatchFound = true; + } } } -- cgit v1.2.3