Example usage for android.view KeyEvent isSystem

List of usage examples for android.view KeyEvent isSystem

Introduction

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

Prototype

public final boolean isSystem() 

Source Link

Document

Is this a system key?

Usage

From source file:info.guardianproject.otr.app.im.app.ContactListActivity.java

private static boolean isReadable(int keyCode, KeyEvent event) {
    if (KeyEvent.isModifierKey(keyCode) || event.isSystem()) {
        return false;
    }/*from ww  w . java 2  s .co m*/

    switch (keyCode) {
    case KeyEvent.KEYCODE_DPAD_CENTER:
    case KeyEvent.KEYCODE_DPAD_DOWN:
    case KeyEvent.KEYCODE_DPAD_LEFT:
    case KeyEvent.KEYCODE_DPAD_RIGHT:
    case KeyEvent.KEYCODE_DPAD_UP:
    case KeyEvent.KEYCODE_ENTER:
        return false;
    }

    return true;
}

From source file:com.duy.pascal.ui.view.console.ConsoleView.java

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (event.isSystem()) {
        return super.onKeyUp(keyCode, event);
    }/*www.  j a v a2  s  .  c  o m*/
    return super.onKeyUp(keyCode, event);
}

From source file:com.duy.pascal.ui.view.console.ConsoleView.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (event.isSystem()) {
        return super.onKeyDown(keyCode, event);
    }/*from   w  ww  .  jav  a2  s. co  m*/
    mKeyBuffer.push((char) event.getUnicodeChar()); //scan code

    if (keyCode == KeyEvent.KEYCODE_DEL) {
        putString(THE_DELETE_COMMAND);
        return true;
    }
    String c = event.getCharacters();
    if (c == null) {
        c = Character.valueOf((char) event.getUnicodeChar()).toString();
    }
    putString(c);
    return true;
}

From source file:android.support.v7.app.AppCompatDelegateImplV7.java

private boolean performPanelShortcut(PanelFeatureState st, int keyCode, KeyEvent event, int flags) {
    if (event.isSystem()) {
        return false;
    }/*  w ww .j  av a 2  s.  co  m*/

    boolean handled = false;

    // Only try to perform menu shortcuts if preparePanel returned true (possible false
    // return value from application not wanting to show the menu).
    if ((st.isPrepared || preparePanel(st, event)) && st.menu != null) {
        // The menu is prepared now, perform the shortcut on it
        handled = st.menu.performShortcut(keyCode, event, flags);
    }

    if (handled) {
        // Only close down the menu if we don't have an action bar keeping it open.
        if ((flags & Menu.FLAG_PERFORM_NO_CLOSE) == 0 && mDecorContentParent == null) {
            closePanel(st, true);
        }
    }

    return handled;
}

From source file:android.app.Activity.java

/**
 * Called when a key was pressed down and not handled by any of the views
 * inside of the activity. So, for example, key presses while the cursor 
 * is inside a TextView will not trigger the event (unless it is a navigation
 * to another object) because TextView handles its own key presses.
 * /*from  ww  w. java  2s  .co  m*/
 * <p>If the focused view didn't want this event, this method is called.
 *
 * <p>The default implementation takes care of {@link KeyEvent#KEYCODE_BACK}
 * by calling {@link #onBackPressed()}, though the behavior varies based
 * on the application compatibility mode: for
 * {@link android.os.Build.VERSION_CODES#ECLAIR} or later applications,
 * it will set up the dispatch to call {@link #onKeyUp} where the action
 * will be performed; for earlier applications, it will perform the
 * action immediately in on-down, as those versions of the platform
 * behaved.
 * 
 * <p>Other additional default key handling may be performed
 * if configured with {@link #setDefaultKeyMode}.
 * 
 * @return Return <code>true</code> to prevent this event from being propagated
 * further, or <code>false</code> to indicate that you have not handled 
 * this event and it should continue to be propagated.
 * @see #onKeyUp
 * @see android.view.KeyEvent
 */
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.ECLAIR) {
            event.startTracking();
        } else {
            onBackPressed();
        }
        return true;
    }

    if (mDefaultKeyMode == DEFAULT_KEYS_DISABLE) {
        return false;
    } else if (mDefaultKeyMode == DEFAULT_KEYS_SHORTCUT) {
        if (getWindow().performPanelShortcut(Window.FEATURE_OPTIONS_PANEL, keyCode, event,
                Menu.FLAG_ALWAYS_PERFORM_CLOSE)) {
            return true;
        }
        return false;
    } else {
        // Common code for DEFAULT_KEYS_DIALER & DEFAULT_KEYS_SEARCH_*
        boolean clearSpannable = false;
        boolean handled;
        if ((event.getRepeatCount() != 0) || event.isSystem()) {
            clearSpannable = true;
            handled = false;
        } else {
            handled = TextKeyListener.getInstance().onKeyDown(null, mDefaultKeySsb, keyCode, event);
            if (handled && mDefaultKeySsb.length() > 0) {
                // something useable has been typed - dispatch it now.

                final String str = mDefaultKeySsb.toString();
                clearSpannable = true;

                switch (mDefaultKeyMode) {
                case DEFAULT_KEYS_DIALER:
                    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + str));
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);
                    break;
                case DEFAULT_KEYS_SEARCH_LOCAL:
                    startSearch(str, false, null, false);
                    break;
                case DEFAULT_KEYS_SEARCH_GLOBAL:
                    startSearch(str, false, null, true);
                    break;
                }
            }
        }
        if (clearSpannable) {
            mDefaultKeySsb.clear();
            mDefaultKeySsb.clearSpans();
            Selection.setSelection(mDefaultKeySsb, 0);
        }
        return handled;
    }
}