Example usage for android.view KeyEvent KEYCODE_I

List of usage examples for android.view KeyEvent KEYCODE_I

Introduction

In this page you can find the example usage for android.view KeyEvent KEYCODE_I.

Prototype

int KEYCODE_I

To view the source code for android.view KeyEvent KEYCODE_I.

Click Source Link

Document

Key code constant: 'I' key.

Usage

From source file:com.bernard.beaconportal.activities.activity.MessageList.java

/**
 * Handle hotkeys//ww w  . j  a  va 2  s  . co  m
 * 
 * <p>
 * This method is called by {@link #dispatchKeyEvent(KeyEvent)} before any
 * view had the chance to consume this key event.
 * </p>
 * 
 * @param keyCode
 *            The value in {@code event.getKeyCode()}.
 * @param event
 *            Description of the key event.
 * 
 * @return {@code true} if this event was consumed.
 */
public boolean onCustomKeyDown(final int keyCode, final KeyEvent event) {
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP: {
        if (mMessageViewFragment != null && mDisplayMode != DisplayMode.MESSAGE_LIST
                && K9.useVolumeKeysForNavigationEnabled()) {
            showPreviousMessage();
            return true;
        } else if (mDisplayMode != DisplayMode.MESSAGE_VIEW && K9.useVolumeKeysForListNavigationEnabled()) {
            mMessageListFragment.onMoveUp();
            return true;
        }

        break;
    }
    case KeyEvent.KEYCODE_VOLUME_DOWN: {
        if (mMessageViewFragment != null && mDisplayMode != DisplayMode.MESSAGE_LIST
                && K9.useVolumeKeysForNavigationEnabled()) {
            showNextMessage();
            return true;
        } else if (mDisplayMode != DisplayMode.MESSAGE_VIEW && K9.useVolumeKeysForListNavigationEnabled()) {
            mMessageListFragment.onMoveDown();
            return true;
        }

        break;
    }
    case KeyEvent.KEYCODE_C: {
        mMessageListFragment.onCompose();
        return true;
    }
    case KeyEvent.KEYCODE_Q: {
        if (mMessageListFragment != null && mMessageListFragment.isSingleAccountMode()) {
            onShowFolderList();
        }
        return true;
    }
    case KeyEvent.KEYCODE_O: {
        mMessageListFragment.onCycleSort();
        return true;
    }
    case KeyEvent.KEYCODE_I: {
        mMessageListFragment.onReverseSort();
        return true;
    }
    case KeyEvent.KEYCODE_DEL:
    case KeyEvent.KEYCODE_D: {
        if (mDisplayMode == DisplayMode.MESSAGE_LIST) {
            mMessageListFragment.onDelete();
        } else if (mMessageViewFragment != null) {
            mMessageViewFragment.onDelete();
        }
        return true;
    }
    case KeyEvent.KEYCODE_S: {
        mMessageListFragment.toggleMessageSelect();
        return true;
    }
    case KeyEvent.KEYCODE_G: {
        if (mDisplayMode == DisplayMode.MESSAGE_LIST) {
            mMessageListFragment.onToggleFlagged();
        } else if (mMessageViewFragment != null) {
            mMessageViewFragment.onToggleFlagged();
        }
        return true;
    }
    case KeyEvent.KEYCODE_M: {
        if (mDisplayMode == DisplayMode.MESSAGE_LIST) {
            mMessageListFragment.onMove();
        } else if (mMessageViewFragment != null) {
            mMessageViewFragment.onMove();
        }
        return true;
    }
    case KeyEvent.KEYCODE_V: {
        if (mDisplayMode == DisplayMode.MESSAGE_LIST) {
            mMessageListFragment.onArchive();
        } else if (mMessageViewFragment != null) {
            mMessageViewFragment.onArchive();
        }
        return true;
    }
    case KeyEvent.KEYCODE_Y: {
        if (mDisplayMode == DisplayMode.MESSAGE_LIST) {
            mMessageListFragment.onCopy();
        } else if (mMessageViewFragment != null) {
            mMessageViewFragment.onCopy();
        }
        return true;
    }
    case KeyEvent.KEYCODE_Z: {
        if (mDisplayMode == DisplayMode.MESSAGE_LIST) {
            mMessageListFragment.onToggleRead();
        } else if (mMessageViewFragment != null) {
            mMessageViewFragment.onToggleRead();
        }
        return true;
    }
    case KeyEvent.KEYCODE_F: {
        if (mMessageViewFragment != null) {
            mMessageViewFragment.onForward();
        }
        return true;
    }
    case KeyEvent.KEYCODE_A: {
        if (mMessageViewFragment != null) {
            mMessageViewFragment.onReplyAll();
        }
        return true;
    }
    case KeyEvent.KEYCODE_R: {
        if (mMessageViewFragment != null) {
            mMessageViewFragment.onReply();
        }
        return true;
    }
    case KeyEvent.KEYCODE_J:
    case KeyEvent.KEYCODE_P: {
        if (mMessageViewFragment != null) {
            showPreviousMessage();
        }
        return true;
    }
    case KeyEvent.KEYCODE_N:
    case KeyEvent.KEYCODE_K: {
        if (mMessageViewFragment != null) {
            showNextMessage();
        }
        return true;
    }
    /*
     * FIXME case KeyEvent.KEYCODE_Z: { mMessageViewFragment.zoom(event);
     * return true; }
     */
    case KeyEvent.KEYCODE_H: {
        Toast toast = Toast.makeText(this, R.string.message_list_help_key, Toast.LENGTH_LONG);
        toast.show();
        return true;
    }

    }

    return false;
}