diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java index 6448b55c6653a..dfd35e1e78776 100755 --- a/core/java/android/hardware/input/InputManager.java +++ b/core/java/android/hardware/input/InputManager.java @@ -77,7 +77,8 @@ public final class InputManager { * The meta-data specifies a resource that contains a description of each keyboard * layout that is provided by the application. *
- * <receiver android:name=".InputDeviceReceiver"> + * <receiver android:name=".InputDeviceReceiver" + * android:label="@string/keyboard_layouts_label"> * <intent-filter> * <action android:name="android.hardware.input.action.QUERY_KEYBOARD_LAYOUTS" /> * </intent-filter> @@ -90,7 +91,9 @@ public final class InputManager { * an XML resource whose root element is* <?xml version="1.0" encoding="utf-8"?> * <keyboard-layouts xmlns:android="http://schemas.android.com/apk/res/android"> diff --git a/core/java/android/hardware/input/KeyboardLayout.java b/core/java/android/hardware/input/KeyboardLayout.java index e75a6dcfdfef2..5402e75a42c72 100644 --- a/core/java/android/hardware/input/KeyboardLayout.java +++ b/core/java/android/hardware/input/KeyboardLayout.java @@ -28,6 +28,7 @@ public final class KeyboardLayout implements Parcelable, Comparable<keyboard-layouts>that * contains zero or more<keyboard-layout>elements. * Each<keyboard-layout>element specifies the name, label, and location - * of a key character map for a particular keyboard layout. + * of a key character map for a particular keyboard layout. The label on the receiver + * is used to name the collection of keyboard layouts provided by this receiver in the + * keyboard layout settings. *{ private final String mDescriptor; private final String mLabel; + private final String mCollection; public static final Parcelable.Creator CREATOR = new Parcelable.Creator () { @@ -39,14 +40,16 @@ public final class KeyboardLayout implements Parcelable, } }; - public KeyboardLayout(String descriptor, String label) { + public KeyboardLayout(String descriptor, String label, String collection) { mDescriptor = descriptor; mLabel = label; + mCollection = collection; } private KeyboardLayout(Parcel source) { mDescriptor = source.readString(); mLabel = source.readString(); + mCollection = source.readString(); } /** @@ -68,6 +71,15 @@ public final class KeyboardLayout implements Parcelable, return mLabel; } + /** + * Gets the name of the collection to which the keyboard layout belongs. This is + * the label of the broadcast receiver or application that provided the keyboard layout. + * @return The keyboard layout collection name. + */ + public String getCollection() { + return mCollection; + } + @Override public int describeContents() { return 0; @@ -77,15 +89,23 @@ public final class KeyboardLayout implements Parcelable, public void writeToParcel(Parcel dest, int flags) { dest.writeString(mDescriptor); dest.writeString(mLabel); + dest.writeString(mCollection); } @Override public int compareTo(KeyboardLayout another) { - return mLabel.compareToIgnoreCase(another.mLabel); + int result = mLabel.compareToIgnoreCase(another.mLabel); + if (result == 0) { + result = mCollection.compareToIgnoreCase(another.mCollection); + } + return result; } @Override public String toString() { - return mLabel; + if (mCollection.isEmpty()) { + return mLabel; + } + return mLabel + " - " + mCollection; } } \ No newline at end of file diff --git a/packages/InputDevices/AndroidManifest.xml b/packages/InputDevices/AndroidManifest.xml index 6831a74b6d10a..f0e4abcb58bf1 100644 --- a/packages/InputDevices/AndroidManifest.xml +++ b/packages/InputDevices/AndroidManifest.xml @@ -8,7 +8,8 @@ android:label="@string/app_label" android:process="system"> - + diff --git a/packages/InputDevices/res/values/strings.xml b/packages/InputDevices/res/values/strings.xml index 140c7d4243a24..c13e606f816bf 100644 --- a/packages/InputDevices/res/values/strings.xml +++ b/packages/InputDevices/res/values/strings.xml @@ -3,6 +3,9 @@ Input Devices + +Android keyboard +English (US) diff --git a/services/java/com/android/server/input/InputManagerService.java b/services/java/com/android/server/input/InputManagerService.java index 9e94b52fbaf55..4f1f76fbea033 100644 --- a/services/java/com/android/server/input/InputManagerService.java +++ b/services/java/com/android/server/input/InputManagerService.java @@ -37,7 +37,6 @@ import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.PackageManager.NameNotFoundException; -import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.Resources.NotFoundException; import android.content.res.TypedArray; @@ -597,8 +596,8 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog. visitAllKeyboardLayouts(new KeyboardLayoutVisitor() { @Override public void visitKeyboardLayout(Resources resources, - String descriptor, String label, int keyboardLayoutResId) { - list.add(new KeyboardLayout(descriptor, label)); + String descriptor, String label, String collection, int keyboardLayoutResId) { + list.add(new KeyboardLayout(descriptor, label, collection)); } }); return list.toArray(new KeyboardLayout[list.size()]); @@ -614,8 +613,8 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog. visitKeyboardLayout(keyboardLayoutDescriptor, new KeyboardLayoutVisitor() { @Override public void visitKeyboardLayout(Resources resources, - String descriptor, String label, int keyboardLayoutResId) { - result[0] = new KeyboardLayout(descriptor, label); + String descriptor, String label, String collection, int keyboardLayoutResId) { + result[0] = new KeyboardLayout(descriptor, label, collection); } }); if (result[0] == null) { @@ -663,6 +662,9 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog. return; } + CharSequence receiverLabel = receiver.loadLabel(pm); + String collection = receiverLabel != null ? receiverLabel.toString() : ""; + try { Resources resources = pm.getResourcesForApplication(receiver.applicationInfo); XmlResourceParser parser = resources.getXml(configResId); @@ -696,7 +698,7 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog. receiver.packageName, receiver.name, name); if (keyboardName == null || name.equals(keyboardName)) { visitor.visitKeyboardLayout(resources, descriptor, - label, keyboardLayoutResId); + label, collection, keyboardLayoutResId); } } } finally { @@ -1139,7 +1141,7 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog. visitKeyboardLayout(keyboardLayoutDescriptor, new KeyboardLayoutVisitor() { @Override public void visitKeyboardLayout(Resources resources, - String descriptor, String label, int keyboardLayoutResId) { + String descriptor, String label, String collection, int keyboardLayoutResId) { try { result[0] = descriptor; result[1] = Streams.readFully(new InputStreamReader( @@ -1262,7 +1264,7 @@ public class InputManagerService extends IInputManager.Stub implements Watchdog. private interface KeyboardLayoutVisitor { void visitKeyboardLayout(Resources resources, - String descriptor, String label, int keyboardLayoutResId); + String descriptor, String label, String collection, int keyboardLayoutResId); } private final class InputDevicesChangedListenerRecord implements DeathRecipient {