From d9fec5d317c09da6bcc7a54df4e0190a76d21eae Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Thu, 17 May 2012 16:01:54 -0700 Subject: Add support for grouping keyboard layouts by collection. Bug: 6405203 Change-Id: Id818b27ec09928150795d594a96df186a6e39168 --- core/java/android/hardware/input/InputManager.java | 7 ++++-- .../android/hardware/input/KeyboardLayout.java | 26 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) (limited to 'core/java/android/hardware') 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. *

-     * <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 <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.
      * 

      * <?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 {
     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
-- 
cgit v1.1