| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.view; |
| 17 |
|
| 18 |
import static com.android.internal.util.Preconditions.checkNotNull; |
| 19 |
|
| 20 |
import android.annotation.NonNull; |
| 21 |
import android.annotation.Nullable; |
| 22 |
import android.annotation.TestApi; |
| 23 |
import android.os.Parcel; |
| 24 |
import android.os.Parcelable; |
| 25 |
|
| 26 |
import java.util.ArrayList; |
| 27 |
import java.util.Collections; |
| 28 |
import java.util.List; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public final class KeyboardShortcutGroup implements Parcelable { |
| 34 |
private final CharSequence mLabel; |
| 35 |
private final List<KeyboardShortcutInfo> mItems; |
| 36 |
|
| 37 |
private boolean mSystemGroup; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public KeyboardShortcutGroup(@Nullable CharSequence label, |
| 44 |
@NonNull List<KeyboardShortcutInfo> items) { |
| 45 |
mLabel = label; |
| 46 |
mItems = new ArrayList<>(checkNotNull(items)); |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
public KeyboardShortcutGroup(@Nullable CharSequence label) { |
| 53 |
this(label, Collections.<KeyboardShortcutInfo>emptyList()); |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
@TestApi |
| 63 |
public KeyboardShortcutGroup(@Nullable CharSequence label, |
| 64 |
@NonNull List<KeyboardShortcutInfo> items, boolean isSystemGroup) { |
| 65 |
mLabel = label; |
| 66 |
mItems = new ArrayList<>(checkNotNull(items)); |
| 67 |
mSystemGroup = isSystemGroup; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
@TestApi |
| 76 |
public KeyboardShortcutGroup(@Nullable CharSequence label, boolean isSystemGroup) { |
| 77 |
this(label, Collections.<KeyboardShortcutInfo>emptyList(), isSystemGroup); |
| 78 |
} |
| 79 |
|
| 80 |
private KeyboardShortcutGroup(Parcel source) { |
| 81 |
mItems = new ArrayList<>(); |
| 82 |
mLabel = source.readCharSequence(); |
| 83 |
source.readTypedList(mItems, KeyboardShortcutInfo.CREATOR); |
| 84 |
mSystemGroup = source.readInt() == 1; |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
public CharSequence getLabel() { |
| 91 |
return mLabel; |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
public List<KeyboardShortcutInfo> getItems() { |
| 98 |
return mItems; |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
@TestApi |
| 103 |
public boolean isSystemGroup() { |
| 104 |
return mSystemGroup; |
| 105 |
} |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
public void addItem(KeyboardShortcutInfo item) { |
| 113 |
mItems.add(item); |
| 114 |
} |
| 115 |
|
| 116 |
@Override |
| 117 |
public int describeContents() { |
| 118 |
return 0; |
| 119 |
} |
| 120 |
|
| 121 |
@Override |
| 122 |
public void writeToParcel(Parcel dest, int flags) { |
| 123 |
dest.writeCharSequence(mLabel); |
| 124 |
dest.writeTypedList(mItems); |
| 125 |
dest.writeInt(mSystemGroup ? 1 : 0); |
| 126 |
} |
| 127 |
|
| 128 |
public static final @android.annotation.NonNull Creator<KeyboardShortcutGroup> CREATOR = |
| 129 |
new Creator<KeyboardShortcutGroup>() { |
| 130 |
public KeyboardShortcutGroup createFromParcel(Parcel source) { |
| 131 |
return new KeyboardShortcutGroup(source); |
| 132 |
} |
| 133 |
public KeyboardShortcutGroup[] newArray(int size) { |
| 134 |
return new KeyboardShortcutGroup[size]; |
| 135 |
} |
| 136 |
}; |
| 137 |
} |