Loading core/java/android/hardware/input/InputManager.java +5 −2 Original line number Diff line number Diff line Loading @@ -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. * <pre><code> * <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> Loading @@ -90,7 +91,9 @@ public final class InputManager { * an XML resource whose root element is <code><keyboard-layouts></code> that * contains zero or more <code><keyboard-layout></code> elements. * Each <code><keyboard-layout></code> 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. * <pre></code> * <?xml version="1.0" encoding="utf-8"?> * <keyboard-layouts xmlns:android="http://schemas.android.com/apk/res/android"> Loading core/java/android/hardware/input/KeyboardLayout.java +23 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ public final class KeyboardLayout implements Parcelable, Comparable<KeyboardLayout> { private final String mDescriptor; private final String mLabel; private final String mCollection; public static final Parcelable.Creator<KeyboardLayout> CREATOR = new Parcelable.Creator<KeyboardLayout>() { Loading @@ -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(); } /** Loading @@ -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; Loading @@ -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() { if (mCollection.isEmpty()) { return mLabel; } return mLabel + " - " + mCollection; } } No newline at end of file packages/InputDevices/AndroidManifest.xml +2 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,8 @@ android:label="@string/app_label" android:process="system"> <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> Loading packages/InputDevices/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,9 @@ <!-- Name of the application. [CHAR LIMIT=35] --> <string name="app_label">Input Devices</string> <!-- Keyboard layouts label, used to describe the set of all built-in layouts in the UI. [CHAR LIMIT=35] --> <string name="keyboard_layouts_label">Android keyboard</string> <!-- US English keyboard layout label. [CHAR LIMIT=35] --> <string name="keyboard_layout_english_us_label">English (US)</string> Loading services/java/com/android/server/input/InputManagerService.java +10 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()]); Loading @@ -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) { Loading Loading @@ -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); Loading Loading @@ -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 { Loading Loading @@ -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( Loading Loading @@ -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 { Loading Loading
core/java/android/hardware/input/InputManager.java +5 −2 Original line number Diff line number Diff line Loading @@ -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. * <pre><code> * <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> Loading @@ -90,7 +91,9 @@ public final class InputManager { * an XML resource whose root element is <code><keyboard-layouts></code> that * contains zero or more <code><keyboard-layout></code> elements. * Each <code><keyboard-layout></code> 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. * <pre></code> * <?xml version="1.0" encoding="utf-8"?> * <keyboard-layouts xmlns:android="http://schemas.android.com/apk/res/android"> Loading
core/java/android/hardware/input/KeyboardLayout.java +23 −3 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ public final class KeyboardLayout implements Parcelable, Comparable<KeyboardLayout> { private final String mDescriptor; private final String mLabel; private final String mCollection; public static final Parcelable.Creator<KeyboardLayout> CREATOR = new Parcelable.Creator<KeyboardLayout>() { Loading @@ -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(); } /** Loading @@ -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; Loading @@ -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() { if (mCollection.isEmpty()) { return mLabel; } return mLabel + " - " + mCollection; } } No newline at end of file
packages/InputDevices/AndroidManifest.xml +2 −1 Original line number Diff line number Diff line Loading @@ -8,7 +8,8 @@ android:label="@string/app_label" android:process="system"> <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> Loading
packages/InputDevices/res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,9 @@ <!-- Name of the application. [CHAR LIMIT=35] --> <string name="app_label">Input Devices</string> <!-- Keyboard layouts label, used to describe the set of all built-in layouts in the UI. [CHAR LIMIT=35] --> <string name="keyboard_layouts_label">Android keyboard</string> <!-- US English keyboard layout label. [CHAR LIMIT=35] --> <string name="keyboard_layout_english_us_label">English (US)</string> Loading
services/java/com/android/server/input/InputManagerService.java +10 −8 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()]); Loading @@ -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) { Loading Loading @@ -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); Loading Loading @@ -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 { Loading Loading @@ -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( Loading Loading @@ -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 { Loading