| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.hardware.input; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.os.LocaleList; |
| 21 |
import android.os.Parcel; |
| 22 |
import android.os.Parcelable; |
| 23 |
|
| 24 |
import java.util.Locale; |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
public final class KeyboardLayout implements Parcelable, |
| 32 |
Comparable<KeyboardLayout> { |
| 33 |
private final String mDescriptor; |
| 34 |
private final String mLabel; |
| 35 |
private final String mCollection; |
| 36 |
private final int mPriority; |
| 37 |
@NonNull |
| 38 |
private final LocaleList mLocales; |
| 39 |
private final int mVendorId; |
| 40 |
private final int mProductId; |
| 41 |
|
| 42 |
public static final @android.annotation.NonNull Parcelable.Creator<KeyboardLayout> CREATOR = |
| 43 |
new Parcelable.Creator<KeyboardLayout>() { |
| 44 |
public KeyboardLayout createFromParcel(Parcel source) { |
| 45 |
return new KeyboardLayout(source); |
| 46 |
} |
| 47 |
public KeyboardLayout[] newArray(int size) { |
| 48 |
return new KeyboardLayout[size]; |
| 49 |
} |
| 50 |
}; |
| 51 |
|
| 52 |
public KeyboardLayout(String descriptor, String label, String collection, int priority, |
| 53 |
LocaleList locales, int vid, int pid) { |
| 54 |
mDescriptor = descriptor; |
| 55 |
mLabel = label; |
| 56 |
mCollection = collection; |
| 57 |
mPriority = priority; |
| 58 |
mLocales = locales; |
| 59 |
mVendorId = vid; |
| 60 |
mProductId = pid; |
| 61 |
} |
| 62 |
|
| 63 |
private KeyboardLayout(Parcel source) { |
| 64 |
mDescriptor = source.readString(); |
| 65 |
mLabel = source.readString(); |
| 66 |
mCollection = source.readString(); |
| 67 |
mPriority = source.readInt(); |
| 68 |
mLocales = LocaleList.CREATOR.createFromParcel(source); |
| 69 |
mVendorId = source.readInt(); |
| 70 |
mProductId = source.readInt(); |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
public String getDescriptor() { |
| 81 |
return mDescriptor; |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
public String getLabel() { |
| 89 |
return mLabel; |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
public String getCollection() { |
| 98 |
return mCollection; |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
public LocaleList getLocales() { |
| 107 |
return mLocales; |
| 108 |
} |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
public int getVendorId() { |
| 116 |
return mVendorId; |
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
public int getProductId() { |
| 125 |
return mProductId; |
| 126 |
} |
| 127 |
|
| 128 |
@Override |
| 129 |
public int describeContents() { |
| 130 |
return 0; |
| 131 |
} |
| 132 |
|
| 133 |
@Override |
| 134 |
public void writeToParcel(Parcel dest, int flags) { |
| 135 |
dest.writeString(mDescriptor); |
| 136 |
dest.writeString(mLabel); |
| 137 |
dest.writeString(mCollection); |
| 138 |
dest.writeInt(mPriority); |
| 139 |
mLocales.writeToParcel(dest, 0); |
| 140 |
dest.writeInt(mVendorId); |
| 141 |
dest.writeInt(mProductId); |
| 142 |
} |
| 143 |
|
| 144 |
@Override |
| 145 |
public int compareTo(KeyboardLayout another) { |
| 146 |
|
| 147 |
|
| 148 |
int result = Integer.compare(another.mPriority, mPriority); |
| 149 |
if (result == 0) { |
| 150 |
result = mLabel.compareToIgnoreCase(another.mLabel); |
| 151 |
} |
| 152 |
if (result == 0) { |
| 153 |
result = mCollection.compareToIgnoreCase(another.mCollection); |
| 154 |
} |
| 155 |
return result; |
| 156 |
} |
| 157 |
|
| 158 |
@Override |
| 159 |
public String toString() { |
| 160 |
if (mCollection.isEmpty()) { |
| 161 |
return mLabel; |
| 162 |
} |
| 163 |
return mLabel + " - " + mCollection; |
| 164 |
} |
| 165 |
} |