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

Commit 64da12ab authored by Jeff Brown's avatar Jeff Brown
Browse files

Add dispatch key shortcut window callback.

Enables Activities and Dialogs to implement key shortcut behavior.
Useful for global key shortcuts that are not bound to the focused
view or to a menu.

Change-Id: If377d20b227ee1c5cac84c47c9630b2d77f67e2c
parent f31161a0
Loading
Loading
Loading
Loading
+134 −8
Original line number Diff line number Diff line
@@ -22724,6 +22724,19 @@
<parameter name="event" type="android.view.KeyEvent">
</parameter>
</method>
<method name="dispatchKeyShortcutEvent"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="event" type="android.view.KeyEvent">
</parameter>
</method>
<method name="dispatchPopulateAccessibilityEvent"
 return="boolean"
 abstract="false"
@@ -23601,6 +23614,21 @@
<parameter name="event" type="android.view.KeyEvent">
</parameter>
</method>
<method name="onKeyShortcut"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="keyCode" type="int">
</parameter>
<parameter name="event" type="android.view.KeyEvent">
</parameter>
</method>
<method name="onKeyUp"
 return="boolean"
 abstract="false"
@@ -27475,6 +27503,19 @@
<parameter name="event" type="android.view.KeyEvent">
</parameter>
</method>
<method name="dispatchKeyShortcutEvent"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="event" type="android.view.KeyEvent">
</parameter>
</method>
<method name="dispatchPopulateAccessibilityEvent"
 return="boolean"
 abstract="false"
@@ -27851,6 +27892,21 @@
<parameter name="event" type="android.view.KeyEvent">
</parameter>
</method>
<method name="onKeyShortcut"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="keyCode" type="int">
</parameter>
<parameter name="event" type="android.view.KeyEvent">
</parameter>
</method>
<method name="onKeyUp"
 return="boolean"
 abstract="false"
@@ -207218,6 +207274,17 @@
 visibility="public"
>
</field>
<field name="META_ALT_MASK"
 type="int"
 transient="false"
 volatile="false"
 value="50"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="META_ALT_ON"
 type="int"
 transient="false"
@@ -207262,6 +207329,17 @@
 visibility="public"
>
</field>
<field name="META_CTRL_MASK"
 type="int"
 transient="false"
 volatile="false"
 value="28672"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="META_CTRL_ON"
 type="int"
 transient="false"
@@ -207306,6 +207384,17 @@
 visibility="public"
>
</field>
<field name="META_META_MASK"
 type="int"
 transient="false"
 volatile="false"
 value="458752"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="META_META_ON"
 type="int"
 transient="false"
@@ -207361,6 +207450,17 @@
 visibility="public"
>
</field>
<field name="META_SHIFT_MASK"
 type="int"
 transient="false"
 volatile="false"
 value="193"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="META_SHIFT_ON"
 type="int"
 transient="false"
@@ -221457,6 +221557,19 @@
<parameter name="event" type="android.view.KeyEvent">
</parameter>
</method>
<method name="superDispatchKeyShortcutEvent"
 return="boolean"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="event" type="android.view.KeyEvent">
</parameter>
</method>
<method name="superDispatchTouchEvent"
 return="boolean"
 abstract="true"
@@ -221789,6 +221902,19 @@
<parameter name="event" type="android.view.KeyEvent">
</parameter>
</method>
<method name="dispatchKeyShortcutEvent"
 return="boolean"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="event" type="android.view.KeyEvent">
</parameter>
</method>
<method name="dispatchPopulateAccessibilityEvent"
 return="boolean"
 abstract="true"
@@ -257785,7 +257911,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="t" type="T">
<parameter name="arg0" type="T">
</parameter>
</method>
</interface>
@@ -262244,7 +262370,7 @@
 return="void"
 abstract="false"
 native="false"
 synchronized="true"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
@@ -262259,7 +262385,7 @@
 return="void"
 abstract="false"
 native="false"
 synchronized="true"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
@@ -262393,7 +262519,7 @@
 return="java.beans.PropertyChangeListener[]"
 abstract="false"
 native="false"
 synchronized="true"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
@@ -262406,7 +262532,7 @@
 return="java.beans.PropertyChangeListener[]"
 abstract="false"
 native="false"
 synchronized="true"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
@@ -262417,7 +262543,7 @@
 return="boolean"
 abstract="false"
 native="false"
 synchronized="true"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
@@ -262430,7 +262556,7 @@
 return="void"
 abstract="false"
 native="false"
 synchronized="true"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
@@ -262445,7 +262571,7 @@
 return="void"
 abstract="false"
 native="false"
 synchronized="true"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
+32 −1
Original line number Diff line number Diff line
@@ -2072,6 +2072,20 @@ public class Activity extends ContextThemeWrapper
        }
    }

    /**
     * Called when a key shortcut event is not handled by any of the views in the Activity.
     * Override this method to implement global key shortcuts for the Activity.
     * Key shortcuts can also be implemented by setting the
     * {@link MenuItem#setShortcut(char, char) shortcut} property of menu items.
     *
     * @param keyCode The value in event.getKeyCode().
     * @param event Description of the key event.
     * @return True if the key shortcut was handled.
     */
    public boolean onKeyShortcut(int keyCode, KeyEvent event) {
        return false;
    }

    /**
     * Called when a touch screen event was not handled by any of the views
     * under it.  This is most useful to process touch events that happen
@@ -2231,6 +2245,23 @@ public class Activity extends ContextThemeWrapper
                ? decor.getKeyDispatcherState() : null, this);
    }

    /**
     * Called to process a key shortcut event.
     * You can override this to intercept all key shortcut events before they are
     * dispatched to the window.  Be sure to call this implementation for key shortcut
     * events that should be handled normally.
     *
     * @param event The key shortcut event.
     * @return True if this event was consumed.
     */
    public boolean dispatchKeyShortcutEvent(KeyEvent event) {
        onUserInteraction();
        if (getWindow().superDispatchKeyShortcutEvent(event)) {
            return true;
        }
        return onKeyShortcut(event.getKeyCode(), event);
    }

    /**
     * Called to process touch screen events.  You can override this to
     * intercept all touch screen events before they are dispatched to the
+31 −1
Original line number Diff line number Diff line
@@ -572,6 +572,20 @@ public class Dialog implements DialogInterface, Window.Callback,
        }
    }

    /**
     * Called when an key shortcut event is not handled by any of the views in the Dialog.
     * Override this method to implement global key shortcuts for the Dialog.
     * Key shortcuts can also be implemented by setting the
     * {@link MenuItem#setShortcut(char, char) shortcut} property of menu items.
     *
     * @param keyCode The value in event.getKeyCode().
     * @param event Description of the key event.
     * @return True if the key shortcut was handled.
     */
    public boolean onKeyShortcut(int keyCode, KeyEvent event) {
        return false;
    }

    /**
     * Called when a touch screen event was not handled by any of the views
     * under it. This is most useful to process touch events that happen outside
@@ -658,6 +672,22 @@ public class Dialog implements DialogInterface, Window.Callback,
                ? mDecor.getKeyDispatcherState() : null, this);
    }

    /**
     * Called to process a key shortcut event.
     * You can override this to intercept all key shortcut events before they are
     * dispatched to the window.  Be sure to call this implementation for key shortcut
     * events that should be handled normally.
     *
     * @param event The key shortcut event.
     * @return True if this event was consumed.
     */
    public boolean dispatchKeyShortcutEvent(KeyEvent event) {
        if (mWindow.superDispatchKeyShortcutEvent(event)) {
            return true;
        }
        return onKeyShortcut(event.getKeyCode(), event);
    }

    /**
     * Called to process touch screen events.  You can override this to
     * intercept all touch screen events before they are dispatched to the
+17 −5
Original line number Diff line number Diff line
@@ -990,20 +990,32 @@ public class KeyEvent extends InputEvent implements Parcelable {
     */
    public static final int META_SCROLL_LOCK_ON = 0x400000;

    /** {@hide} */
    /**
     * This mask is a combination of {@link #META_SHIFT_ON}, {@link #META_SHIFT_LEFT_ON}
     * and {@link #META_SHIFT_RIGHT_ON}.
     */
    public static final int META_SHIFT_MASK = META_SHIFT_ON
            | META_SHIFT_LEFT_ON | META_SHIFT_RIGHT_ON;

    /** {@hide} */
    /**
     * This mask is a combination of {@link #META_ALT_ON}, {@link #META_ALT_LEFT_ON}
     * and {@link #META_ALT_RIGHT_ON}.
     */
    public static final int META_ALT_MASK = META_ALT_ON
            | META_ALT_LEFT_ON | META_ALT_RIGHT_ON;

    /** {@hide} */
    /**
     * This mask is a combination of {@link #META_CTRL_ON}, {@link #META_CTRL_LEFT_ON}
     * and {@link #META_CTRL_RIGHT_ON}.
     */
    public static final int META_CTRL_MASK = META_CTRL_ON
            | META_CTRL_LEFT_ON | META_CTRL_RIGHT_ON;

    /** {@hide} */
    public static final int META_META_MASK = META_ALT_ON
    /**
     * This mask is a combination of {@link #META_META_ON}, {@link #META_META_LEFT_ON}
     * and {@link #META_META_RIGHT_ON}.
     */
    public static final int META_META_MASK = META_META_ON
            | META_META_LEFT_ON | META_META_RIGHT_ON;

    /**
+4 −1
Original line number Diff line number Diff line
@@ -4768,7 +4768,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
    }

    /**
     * Called when an unhandled key shortcut event occurs.
     * Called on the focused view when a key shortcut event is not handled.
     * Override this method to implement local key shortcuts for the View.
     * Key shortcuts can also be implemented by setting the
     * {@link MenuItem#setShortcut(char, char) shortcut} property of menu items.
     *
     * @param keyCode The value in event.getKeyCode().
     * @param event Description of the key event.
Loading