diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-05-17 16:01:54 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2012-05-17 16:01:54 -0700 |
commit | d9fec5d317c09da6bcc7a54df4e0190a76d21eae (patch) | |
tree | 0eae74e8e946ea2d7715e31c3bd58a8f48befa2a /core/java/android/hardware/input | |
parent | ab624c2fd4f0fad6ba7f422a960942e5a7035cea (diff) | |
download | frameworks_base-d9fec5d317c09da6bcc7a54df4e0190a76d21eae.zip frameworks_base-d9fec5d317c09da6bcc7a54df4e0190a76d21eae.tar.gz frameworks_base-d9fec5d317c09da6bcc7a54df4e0190a76d21eae.tar.bz2 |
Add support for grouping keyboard layouts by collection.
Bug: 6405203
Change-Id: Id818b27ec09928150795d594a96df186a6e39168
Diffstat (limited to 'core/java/android/hardware/input')
-rwxr-xr-x | core/java/android/hardware/input/InputManager.java | 7 | ||||
-rw-r--r-- | core/java/android/hardware/input/KeyboardLayout.java | 26 |
2 files changed, 28 insertions, 5 deletions
diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java index 6448b55..dfd35e1 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. * <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> @@ -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"> diff --git a/core/java/android/hardware/input/KeyboardLayout.java b/core/java/android/hardware/input/KeyboardLayout.java index e75a6dc..5402e75 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<KeyboardLayout> { private final String mDescriptor; private final String mLabel; + private final String mCollection; public static final Parcelable.Creator<KeyboardLayout> CREATOR = new Parcelable.Creator<KeyboardLayout>() { @@ -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 |