当前位置: 首页>>代码示例>>Java>>正文


Java KeyEvent.getUnicodeChar方法代码示例

本文整理汇总了Java中android.view.KeyEvent.getUnicodeChar方法的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.getUnicodeChar方法的具体用法?Java KeyEvent.getUnicodeChar怎么用?Java KeyEvent.getUnicodeChar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.getUnicodeChar方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dispatchKeyEvent

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    // Determine if the key event was actual text, if so, focus the search bar and then dispatch
    // the key normally so that it can process this key event
    if (!mSearchBarController.isSearchFieldFocused() &&
            event.getAction() == KeyEvent.ACTION_DOWN) {
        final int unicodeChar = event.getUnicodeChar();
        final boolean isKeyNotWhitespace = unicodeChar > 0 &&
                !Character.isWhitespace(unicodeChar) && !Character.isSpaceChar(unicodeChar);
        if (isKeyNotWhitespace) {
            boolean gotKey = TextKeyListener.getInstance().onKeyDown(this, mSearchQueryBuilder,
                    event.getKeyCode(), event);
            if (gotKey && mSearchQueryBuilder.length() > 0) {
                mSearchBarController.focusSearchField();
            }
        }
    }

    return super.dispatchKeyEvent(event);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:21,代码来源:AllAppsContainerView.java

示例2: onKeyDown

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    final int uniChar = event.getUnicodeChar();
    final boolean handled = super.onKeyDown(keyCode, event);
    final boolean isKeyNotWhitespace = uniChar > 0 && !Character.isWhitespace(uniChar);
    if (!handled && acceptFilter() && isKeyNotWhitespace) {
        boolean gotKey = TextKeyListener.getInstance().onKeyDown(mWorkspace, mDefaultKeySsb,
                keyCode, event);
        if (gotKey && mDefaultKeySsb != null && mDefaultKeySsb.length() > 0) {
            // something usable has been typed - start a search
            // the typed text will be retrieved and cleared by
            // showSearchDialog()
            // If there are multiple keystrokes before the search dialog takes focus,
            // onSearchRequested() will be called for every keystroke,
            // but it is idempotent, so it's fine.
            return onSearchRequested();
        }
    }

    // Eat the long press event so the keyboard doesn't come up.
    if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) {
        return true;
    }

    return handled;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:27,代码来源:Launcher.java

示例3: dispatchKeyEvent

import android.view.KeyEvent; //导入方法依赖的package包/类
/**
 * @brief Captures the keys of the keyboard
 * @param event The event
 * @details Capture the keys of the keyboard. If the character has to be pressed with a combination of the shift key 
 * and other key then adds 100 to the modKeyCount attribute to applies the offset
 */
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
	if(event.getAction() == KeyEvent.ACTION_DOWN || event.getAction() == KeyEvent.ACTION_UP|| event.getAction() == KeyEvent.ACTION_MULTIPLE){
		int keyunicode = event.getUnicodeChar(event.getMetaState() );
	    char character = (char) keyunicode;
	    int key = event.getKeyCode();
	    if(key == 59){
	    	if(modKeyCount == 0){
	    		modKeyCount = 100;
	    	}
	    	else{
	    		modKeyCount = 0;
	    	}
	    }
	    else if(key >= 7){
	    	boolean down = event.getAction() == KeyEvent.ACTION_DOWN;
	    	vnc.sendKey(modKeyCount+key,down);
	    	
	    }
	   
	    
	    Log.e(DEBUG_TAG,String.valueOf( event.getKeyCode()));
	}
    return super.dispatchKeyEvent(event);
}
 
开发者ID:CodyyAndroid,项目名称:LibVNCAndroid,代码行数:32,代码来源:CanvasActivity.java

示例4: onKey

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
    int action = keyEvent.getAction();

    // Work-around for spurious key event from IME, bug #1639445
    if(action == KeyEvent.ACTION_MULTIPLE && keyCode == KeyEvent.KEYCODE_UNKNOWN) {
        return true; // eat it
    }

    if(keyEvent.getUnicodeChar() == '=') {
        if(action == KeyEvent.ACTION_UP) {
            mHandler.onEnter();
        }
        return true;
    }

    if(keyCode != KeyEvent.KEYCODE_DPAD_CENTER && keyCode != KeyEvent.KEYCODE_DPAD_UP && keyCode != KeyEvent.KEYCODE_DPAD_DOWN
            && keyCode != KeyEvent.KEYCODE_ENTER) {
        if(keyEvent.isPrintingKey() && action == KeyEvent.ACTION_UP) {
            // Tell the handler that text was updated.
            mHandler.onTextChanged();
        }
        return false;
    }

    /*
     * We should act on KeyEvent.ACTION_DOWN, but strangely sometimes the
     * DOWN event isn't received, only the UP. So the workaround is to act
     * on UP... http://b/issue?id=1022478
     */

    if(action == KeyEvent.ACTION_UP) {
        switch(keyCode) {
        case KeyEvent.KEYCODE_ENTER:
        case KeyEvent.KEYCODE_DPAD_CENTER:
            mHandler.onEnter();
            break;

        case KeyEvent.KEYCODE_DPAD_UP:
            mHandler.onUp();
            break;

        case KeyEvent.KEYCODE_DPAD_DOWN:
            mHandler.onDown();
            break;
        }
    }
    return true;
}
 
开发者ID:gigabytedevelopers,项目名称:CalcMate,代码行数:50,代码来源:EventListener.java

示例5: dispatchKeyEvent

import android.view.KeyEvent; //导入方法依赖的package包/类
/**
 * Called to process key events.  You can override this to intercept all
 * key events before they are dispatched to the window.  Be sure to call
 * this implementation for key events that should be handled normally.
 *
 * @param event The key event.
 *
 * @return boolean Return true if this event was consumed.
 */
public boolean dispatchKeyEvent(KeyEvent event) {
    onUserInteraction();

    // Let action bars open menus in response to the menu key prioritized over
    // the window handling it
    final int keyCode = event.getKeyCode();
    if (keyCode == KeyEvent.KEYCODE_MENU &&
            mActionBar != null && mActionBar.onMenuKeyEvent(event)) {
        return true;
    } else if (event.isCtrlPressed() &&
            event.getUnicodeChar(event.getMetaState() & ~KeyEvent.META_CTRL_MASK) == '<') {
        // Capture the Control-< and send focus to the ActionBar
        final int action = event.getAction();
        if (action == KeyEvent.ACTION_DOWN) {
            final ActionBar actionBar = getActionBar();
            if (actionBar != null && actionBar.isShowing() && actionBar.requestFocus()) {
                mEatKeyUpEvent = true;
                return true;
            }
        } else if (action == KeyEvent.ACTION_UP && mEatKeyUpEvent) {
            mEatKeyUpEvent = false;
            return true;
        }
    }

    Window win = getWindow();
    if (win.superDispatchKeyEvent(event)) {
        return true;
    }
    View decor = mDecor;
    if (decor == null) decor = win.getDecorView();
    return event.dispatch(this, decor != null
            ? decor.getKeyDispatcherState() : null, this);
}
 
开发者ID:JessYanCoding,项目名称:ProgressManager,代码行数:44,代码来源:a.java

示例6: onKeyUp

import android.view.KeyEvent; //导入方法依赖的package包/类
/**
 * Manages the interaction with the keyboard.
 * adds the letter pressed to the message currentyped
 * takes one letter out if the key delete is pressed
 * saves the message if the key enter is pressed
 * @param keycode
 * @param keyEvent
 * @author Paul Best
 * @return
 */

@Override
public boolean onKeyUp(int keycode, KeyEvent keyEvent) {

    switch (keyEvent.getUnicodeChar()){
        case 0 :
            if(currentmessage.length()>0){
                currentmessage=currentmessage.subSequence(0,currentmessage.length()-1).toString();
            }
            currenttyped.setMmessage(currentmessage);

            break;
        case 10:
            if(currentmessage!=""){
                save();
            }

            currenttyped=null;
            ((InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(this.getWindowToken(), 0);
            currentmessage="";
            break;

        default:
            currentmessage+=(char)keyEvent.getUnicodeChar();
            currenttyped.setMmessage(currentmessage);

    }

    postInvalidate();

    return false;
}
 
开发者ID:jkobject,项目名称:PiPle,代码行数:43,代码来源:Window.java

示例7: onKeyUp

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {

    if(event.getUnicodeChar()!=0)
        new SendMessage().execute("key-"+event.getUnicodeChar());
    return super.onKeyUp(keyCode, event);
}
 
开发者ID:imRishabhGupta,项目名称:PC-Handler,代码行数:8,代码来源:MainActivity.java

示例8: translateKeyDown

import android.view.KeyEvent; //导入方法依赖的package包/类
/**
 * This translates incoming hard key events in to edit operations on an
 * InputConnection.  It is only needed when using the
 * PROCESS_HARD_KEYS option.
 */
private boolean translateKeyDown(int keyCode, KeyEvent event) {
    mMetaState = MetaKeyKeyListener.handleKeyDown(mMetaState,
            keyCode, event);
    int c = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(mMetaState));
    mMetaState = MetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState);
    InputConnection ic = getCurrentInputConnection();
    if (c == 0 || ic == null) {
        return false;
    }

    boolean dead = false;

    if ((c & KeyCharacterMap.COMBINING_ACCENT) != 0) {
        dead = true;
        c = c & KeyCharacterMap.COMBINING_ACCENT_MASK;
    }

    if (mComposing.length() > 0) {
        char accent = mComposing.charAt(mComposing.length() -1 );
        int composed = KeyEvent.getDeadChar(accent, c);

        if (composed != 0) {
            c = composed;
            mComposing.setLength(mComposing.length()-1);
        }
    }

    onKey(c, null);

    return true;
}
 
开发者ID:VladThodo,项目名称:behe-keyboard,代码行数:37,代码来源:PCKeyboard.java

示例9: dispatchKeyEvent

import android.view.KeyEvent; //导入方法依赖的package包/类
public boolean dispatchKeyEvent(KeyEvent keyEvent) {
    f.b("SecureWebView", "-->dispatchKeyEvent, is device support: " + a);
    if (!a) {
        return super.dispatchKeyEvent(keyEvent);
    }
    if (keyEvent.getAction() != 0) {
        return super.dispatchKeyEvent(keyEvent);
    }
    switch (keyEvent.getKeyCode()) {
        case 4:
            return super.dispatchKeyEvent(keyEvent);
        case 66:
            return super.dispatchKeyEvent(keyEvent);
        case 67:
            a.b = true;
            return super.dispatchKeyEvent(keyEvent);
        default:
            if (keyEvent.getUnicodeChar() == 0) {
                return super.dispatchKeyEvent(keyEvent);
            }
            if (SecureJsInterface.isPWDEdit) {
                int unicodeChar = keyEvent.getUnicodeChar();
                if ((unicodeChar >= 33 && unicodeChar <= 95) || (unicodeChar >= 97 && unicodeChar <= 125)) {
                    this.b = new KeyEvent(0, 17);
                    return super.dispatchKeyEvent(this.b);
                }
            }
            return super.dispatchKeyEvent(keyEvent);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:31,代码来源:c.java

示例10: onKeyDown

import android.view.KeyEvent; //导入方法依赖的package包/类
public boolean onKeyDown(int i, KeyEvent keyEvent) {
    f.b("SecureWebView", "-->onKeyDown, is device support: " + a);
    if (!a) {
        return super.onKeyDown(i, keyEvent);
    }
    if (keyEvent.getAction() != 0) {
        return super.onKeyDown(i, keyEvent);
    }
    switch (keyEvent.getKeyCode()) {
        case 4:
            return super.onKeyDown(i, keyEvent);
        case 66:
            return super.onKeyDown(i, keyEvent);
        case 67:
            a.b = true;
            return super.onKeyDown(i, keyEvent);
        default:
            if (keyEvent.getUnicodeChar() == 0) {
                return super.onKeyDown(i, keyEvent);
            }
            if (SecureJsInterface.isPWDEdit) {
                int unicodeChar = keyEvent.getUnicodeChar();
                if ((unicodeChar >= 33 && unicodeChar <= 95) || (unicodeChar >= 97 && unicodeChar <= 125)) {
                    this.b = new KeyEvent(0, 17);
                    return super.onKeyDown(this.b.getKeyCode(), this.b);
                }
            }
            return super.onKeyDown(i, keyEvent);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:31,代码来源:c.java

示例11: decodeHardwareKey

import android.view.KeyEvent; //导入方法依赖的package包/类
@Override
public Event decodeHardwareKey(final KeyEvent keyEvent) {
    // KeyEvent#getUnicodeChar() does not exactly returns a unicode char, but rather a value
    // that includes both the unicode char in the lower 21 bits and flags in the upper bits,
    // hence the name "codePointAndFlags". {@see KeyEvent#getUnicodeChar()} for more info.
    final int codePointAndFlags = keyEvent.getUnicodeChar();
    // The keyCode is the abstraction used by the KeyEvent to represent different keys that
    // do not necessarily map to a unicode character. This represents a physical key, like
    // the key for 'A' or Space, but also Backspace or Ctrl or Caps Lock.
    final int keyCode = keyEvent.getKeyCode();
    final boolean isKeyRepeat = (0 != keyEvent.getRepeatCount());
    if (KeyEvent.KEYCODE_DEL == keyCode) {
        return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT, Constants.CODE_DELETE,
                null /* next */, isKeyRepeat);
    }
    if (keyEvent.isPrintingKey() || KeyEvent.KEYCODE_SPACE == keyCode
            || KeyEvent.KEYCODE_ENTER == keyCode) {
        if (0 != (codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT)) {
            // A dead key.
            return Event.createDeadEvent(
                    codePointAndFlags & KeyCharacterMap.COMBINING_ACCENT_MASK, keyCode,
                    null /* next */);
        }
        if (KeyEvent.KEYCODE_ENTER == keyCode) {
            // The Enter key. If the Shift key is not being pressed, this should send a
            // CODE_ENTER to trigger the action if any, or a carriage return otherwise. If the
            // Shift key is being pressed, this should send a CODE_SHIFT_ENTER and let
            // Latin IME decide what to do with it.
            if (keyEvent.isShiftPressed()) {
                return Event.createHardwareKeypressEvent(Event.NOT_A_CODE_POINT,
                        Constants.CODE_SHIFT_ENTER, null /* next */, isKeyRepeat);
            }
            return Event.createHardwareKeypressEvent(Constants.CODE_ENTER, keyCode,
                    null /* next */, isKeyRepeat);
        }
        // If not Enter, then this is just a regular keypress event for a normal character
        // that can be committed right away, taking into account the current state.
        return Event.createHardwareKeypressEvent(codePointAndFlags, keyCode, null /* next */,
                isKeyRepeat);
    }
    return Event.createNotHandledEvent();
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:43,代码来源:HardwareKeyboardEventDecoder.java


注:本文中的android.view.KeyEvent.getUnicodeChar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。