Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bfd996f5 authored by Clara Bayarri's avatar Clara Bayarri Committed by Android (Google) Code Review
Browse files

Merge "Keyboard Shortcuts: Add Keycodes for shortcut representation" into nyc-dev

parents 50c8d49d 4e850ffa
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -41649,9 +41649,11 @@ package android.view {
  }
  public final class KeyboardShortcutInfo implements android.os.Parcelable {
    ctor public KeyboardShortcutInfo(java.lang.CharSequence, int, int);
    ctor public KeyboardShortcutInfo(java.lang.CharSequence, char, int);
    method public int describeContents();
    method public char getBaseCharacter();
    method public int getKeycode();
    method public java.lang.CharSequence getLabel();
    method public int getModifiers();
    method public void writeToParcel(android.os.Parcel, int);
+2 −0
Original line number Diff line number Diff line
@@ -44375,9 +44375,11 @@ package android.view {
  }
  public final class KeyboardShortcutInfo implements android.os.Parcelable {
    ctor public KeyboardShortcutInfo(java.lang.CharSequence, int, int);
    ctor public KeyboardShortcutInfo(java.lang.CharSequence, char, int);
    method public int describeContents();
    method public char getBaseCharacter();
    method public int getKeycode();
    method public java.lang.CharSequence getLabel();
    method public int getModifiers();
    method public void writeToParcel(android.os.Parcel, int);
+2 −0
Original line number Diff line number Diff line
@@ -41722,9 +41722,11 @@ package android.view {
  }
  public final class KeyboardShortcutInfo implements android.os.Parcelable {
    ctor public KeyboardShortcutInfo(java.lang.CharSequence, int, int);
    ctor public KeyboardShortcutInfo(java.lang.CharSequence, char, int);
    method public int describeContents();
    method public char getBaseCharacter();
    method public int getKeycode();
    method public java.lang.CharSequence getLabel();
    method public int getModifiers();
    method public void writeToParcel(android.os.Parcel, int);
+37 −10
Original line number Diff line number Diff line
@@ -30,31 +30,46 @@ public final class KeyboardShortcutInfo implements Parcelable {
    private final CharSequence mLabel;
    private final Icon mIcon;
    private final char mBaseCharacter;
    private final int mKeycode;
    private final int mModifiers;

    /**
     * @param label The label that identifies the action performed by this shortcut.
     * @param icon An icon that identifies the action performed by this shortcut.
     * @param baseCharacter The character that triggers the shortcut.
     * @param keycode The keycode that triggers the shortcut. This should be a valid constant
     *     defined in {@link KeyEvent}.
     * @param modifiers The set of modifiers that, combined with the key, trigger the shortcut.
     *     These should be a combination of {@link KeyEvent#META_CTRL_ON},
     *     {@link KeyEvent#META_SHIFT_ON}, {@link KeyEvent#META_META_ON} and
     *     {@link KeyEvent#META_ALT_ON}.
     *     {@link KeyEvent#META_SHIFT_ON}, {@link KeyEvent#META_META_ON},
     *     {@link KeyEvent#META_ALT_ON}, {@link KeyEvent#META_FUNCTION_ON} and
     *     {@link KeyEvent#META_SYM_ON}.
     *
     * @hide
     */
    public KeyboardShortcutInfo(
            @Nullable CharSequence label, @Nullable Icon icon, char baseCharacter, int modifiers) {
            @Nullable CharSequence label, @Nullable Icon icon, int keycode, int modifiers) {
        mLabel = label;
        mIcon = icon;
        checkArgument(baseCharacter != MIN_VALUE);
        mBaseCharacter = baseCharacter;
        mBaseCharacter = MIN_VALUE;
        checkArgument(keycode > KeyEvent.KEYCODE_UNKNOWN && keycode <= KeyEvent.getMaxKeyCode());
        mKeycode = keycode;
        mModifiers = modifiers;
    }

    /**
     * Convenience constructor for shortcuts with a label and no icon.
     *
     * @param label The label that identifies the action performed by this shortcut.
     * @param keycode The keycode that triggers the shortcut. This should be a valid constant
     *     defined in {@link KeyEvent}.
     * @param modifiers The set of modifiers that, combined with the key, trigger the shortcut.
     *     These should be a combination of {@link KeyEvent#META_CTRL_ON},
     *     {@link KeyEvent#META_SHIFT_ON}, {@link KeyEvent#META_META_ON} and
     *     {@link KeyEvent#META_ALT_ON}.
     */
    public KeyboardShortcutInfo(CharSequence label, int keycode, int modifiers) {
        this(label, null, keycode, modifiers);
    }

    /**
     * @param label The label that identifies the action performed by this shortcut.
     * @param baseCharacter The character that triggers the shortcut.
     * @param modifiers The set of modifiers that, combined with the key, trigger the shortcut.
@@ -66,14 +81,16 @@ public final class KeyboardShortcutInfo implements Parcelable {
        mLabel = label;
        checkArgument(baseCharacter != MIN_VALUE);
        mBaseCharacter = baseCharacter;
        mKeycode = KeyEvent.KEYCODE_UNKNOWN;
        mModifiers = modifiers;
        mIcon = null;
    }

    private KeyboardShortcutInfo(Parcel source) {
        mLabel = source.readCharSequence();
        mIcon = (Icon) source.readParcelable(null);
        mIcon = source.readParcelable(null);
        mBaseCharacter = (char) source.readInt();
        mKeycode = source.readInt();
        mModifiers = source.readInt();
    }

@@ -96,7 +113,16 @@ public final class KeyboardShortcutInfo implements Parcelable {
    }

    /**
     * Returns the base character that, combined with the modifiers, triggers this shortcut.
     * Returns the base keycode that, combined with the modifiers, triggers this shortcut. If the
     * base character was set instead, returns {@link KeyEvent#KEYCODE_UNKNOWN}.
     */
    public int getKeycode() {
        return mKeycode;
    }

    /**
     * Returns the base character that, combined with the modifiers, triggers this shortcut. If the
     * keycode was set instead, returns {@link Character#MIN_VALUE}.
     */
    public char getBaseCharacter() {
        return mBaseCharacter;
@@ -119,6 +145,7 @@ public final class KeyboardShortcutInfo implements Parcelable {
        dest.writeCharSequence(mLabel);
        dest.writeParcelable(mIcon, 0);
        dest.writeInt(mBaseCharacter);
        dest.writeInt(mKeycode);
        dest.writeInt(mModifiers);
    }

+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ oneway interface IStatusBar
    void cancelPreloadRecentApps();
    void showScreenPinningRequest();

    void toggleKeyboardShortcutsMenu();
    void toggleKeyboardShortcutsMenu(int deviceId);

    /**
     * Notifies the status bar that an app transition is pending to delay applying some flags with
Loading