當前位置: 首頁>>代碼示例>>Java>>正文


Java Keyboard.Key方法代碼示例

本文整理匯總了Java中android.inputmethodservice.Keyboard.Key方法的典型用法代碼示例。如果您正苦於以下問題:Java Keyboard.Key方法的具體用法?Java Keyboard.Key怎麽用?Java Keyboard.Key使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.inputmethodservice.Keyboard的用法示例。


在下文中一共展示了Keyboard.Key方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: invalidateAllKeys

import android.inputmethodservice.Keyboard; //導入方法依賴的package包/類
@Override
public void invalidateAllKeys() {
    if (getKeyboard() != null) {
        boolean isDark = ColorUtils.isColorDark(color);
        for (Keyboard.Key key : getKeyboard().getKeys()) {
            if (key.label != null) {
                key.icon = new TextDrawable(getContext(), getShiftedLabel(key.label.toString()), isDark ? Color.WHITE : Color.BLACK);
                key.label = null;
            } else if (key.icon != null) {
                if (key.icon instanceof TextDrawable) {
                    key.icon = new TextDrawable(getContext(), getShiftedLabel(((TextDrawable) key.icon).getText()), isDark ? Color.WHITE : Color.BLACK);
                } else {
                    DrawableCompat.setTint(key.icon, isDark ? Color.WHITE : Color.BLACK);
                    if (key.icon instanceof AnimatedVectorDrawableCompat)
                        ((AnimatedVectorDrawableCompat) key.icon).start();
                }
            }
        }
    }

    super.invalidateAllKeys();
}
 
開發者ID:DoubleDotLabs,項目名稱:Butterboard,代碼行數:23,代碼來源:ButteryKeyboardView.java

示例2: shiftEnglish

import android.inputmethodservice.Keyboard; //導入方法依賴的package包/類
/**
 * 英文鍵盤大小寫切換
 */
private void shiftEnglish() {
    List<Keyboard.Key> keyList = keyboardEnglish.getKeys();
    for (Keyboard.Key key : keyList) {
        if (key.label != null && isKey(key.label.toString())) {
            if (isCapital) {
                key.label = key.label.toString().toLowerCase();
                key.codes[0] = key.codes[0] + 32;
            } else {
                key.label = key.label.toString().toUpperCase();
                key.codes[0] = key.codes[0] - 32;
            }
        }
    }
    isCapital = !isCapital;
}
 
開發者ID:GitPhoenix,項目名稱:KeyboardView,代碼行數:19,代碼來源:EditView.java

示例3: drawKeyboardEnglish

import android.inputmethodservice.Keyboard; //導入方法依賴的package包/類
/**
 * 繪製英文鍵盤
 *
 * @param keys
 * @param canvas
 */
private void drawKeyboardEnglish(List<Keyboard.Key> keys, Canvas canvas) {
    for (Keyboard.Key key : keys) {
        if (key.codes[0] == -5) {//刪除鍵
            drawKeyBackground(R.drawable.img_edit_clear, canvas, key);
        }
        if (key.codes[0] == -1) {//大小寫切換
            drawKeyBackground(R.drawable.img_edit_clear, canvas, key);
        }
        if (key.codes[0] == 32) {//space

        }
        if (key.codes[0] == -4) {//完成

        }
    }
}
 
開發者ID:GitPhoenix,項目名稱:KeyboardView,代碼行數:23,代碼來源:SKeyboardView.java

示例4: onDraw

import android.inputmethodservice.Keyboard; //導入方法依賴的package包/類
@Override
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    // 遍曆所有的按鍵
    List<Keyboard.Key> keys = getKeyboard().getKeys();
    for (Keyboard.Key key : keys) {
        // 如果是左下角空白的按鍵,重畫按鍵的背景
        if (key.codes[0] == KEYCODE_EMPTY) {
            drawKeyBackground(key, canvas, mDeleteBackgroundColor);
        }
        // 如果是右下角的刪除按鍵,重畫按鍵的背景,並且繪製刪除圖標
        else if (key.codes[0] == Keyboard.KEYCODE_DELETE) {
            drawKeyBackground(key, canvas, mDeleteBackgroundColor);
            drawDeleteButton(key, canvas);
        }
    }
}
 
開發者ID:wuzhendev,項目名稱:android-xnumberkeyboard,代碼行數:19,代碼來源:XNumberKeyboardView.java

示例5: shuffleKeyboard

import android.inputmethodservice.Keyboard; //導入方法依賴的package包/類
/**
 * 隨機打亂數字鍵盤上鍵位的排列順序。
 */
public void shuffleKeyboard() {
    Keyboard keyboard = getKeyboard();
    if (keyboard != null && keyboard.getKeys() != null && keyboard.getKeys().size() > 0) {

        Collections.shuffle(keyCodes); // 隨機排序數字

        // 遍曆所有的按鍵
        List<Keyboard.Key> keys = getKeyboard().getKeys();
        int index = 0;
        for (Keyboard.Key key : keys) {
            // 如果按鍵是數字
            if (key.codes[0] != KEYCODE_EMPTY && key.codes[0] != Keyboard.KEYCODE_DELETE) {
                char code = keyCodes.get(index++);
                key.codes[0] = code;
                key.label = Character.toString(code);
            }
        }
        setKeyboard(keyboard);
    }
}
 
開發者ID:wuzhendev,項目名稱:android-xnumberkeyboard,代碼行數:24,代碼來源:XNumberKeyboardView.java

示例6: initType

import android.inputmethodservice.Keyboard; //導入方法依賴的package包/類
/**
 * 判斷為何種鍵盤, 通過某一個按鍵的code值
 * TODO 注意,這種方法有弊端:如果xml中的最上麵一排的按鍵數目發生變化,這裏應該改變
 *
 * @param keys
 */
private void initType(List<Keyboard.Key> keys) {
    switch (keys.get(5).codes[0]) {
        case 113:
            currentType = TYPE_ABC;
            break;
        case 81:
            currentType = TYPE_ABC_SHIFT;
            break;
        case 49:
            currentType = TYPE_SYMBOL;
            break;
        case 126:
            currentType = TYPE_SYMBOL_MORE;
            break;
    }
}
 
開發者ID:PuffOpenSource,項目名稱:Puff-Android,代碼行數:23,代碼來源:PuffKeyboardView.java

示例7: controlKeyToggle

import android.inputmethodservice.Keyboard; //導入方法依賴的package包/類
public void controlKeyToggle() {
    keyboard = kv.getKeyboard();
    int i;
    List<Keyboard.Key> keys = keyboard.getKeys();
    for (i = 0; i < keys.size(); i++) {
        if (ctrl) {
            if (keys.get(i).label != null && keys.get(i).label.equals("Ctrl")) {
                keys.get(i).label = "CTRL";
                break;
            }
        } else {
            if (keys.get(i).label != null && keys.get(i).label.equals("CTRL")) {
                keys.get(i).label = "Ctrl";
                break;
            }
        }
    }
    kv.invalidateKey(i);
}
 
開發者ID:gazlaws-dev,項目名稱:codeboard,代碼行數:20,代碼來源:CodeBoardIME.java

示例8: shiftKeyToggle

import android.inputmethodservice.Keyboard; //導入方法依賴的package包/類
public void shiftKeyToggle() {

        keyboard = kv.getKeyboard();
        List<Keyboard.Key> keys = keyboard.getKeys();
        for (int i = 0; i < keys.size(); i++) {
            if (shift) {
                if (keys.get(i).label != null && keys.get(i).label.equals("Shft")) {
                    keys.get(i).label = "SHFT";
                    break;
                }
            } else {
                if (keys.get(i).label != null && keys.get(i).label.equals("SHFT")) {
                    keys.get(i).label = "Shft";
                    break;
                }
            }
        }
        keyboard.setShifted(shift);
        kv.invalidateAllKeys();
    }
 
開發者ID:gazlaws-dev,項目名稱:codeboard,代碼行數:21,代碼來源:CodeBoardIME.java

示例9: onInitializeInterface

import android.inputmethodservice.Keyboard; //導入方法依賴的package包/類
@Override
public void onInitializeInterface() {
	// TODO Auto-generated method stub
	super.onInitializeInterface();
	this.setupUtilityKeyboard();
	dotDashKeyboard = new DotDashKeyboard(this, R.xml.dotdash);
	dotDashKeyboard.setupDotDashKeys(this.prefs.getBoolean(DotDashPrefs.DASHKEYONLEFT, false));
	
	spaceKey = dotDashKeyboard.spaceKey;
	capsLockKey = dotDashKeyboard.capsLockKey;
	List<Keyboard.Key> keys = dotDashKeyboard.getKeys();
	spaceKeyIndex = keys.indexOf(spaceKey);
	capsLockKeyIndex = keys.indexOf(capsLockKey);
	if (isAudio()) {
		loadSoundPool();
	}
}
 
開發者ID:agwells,項目名稱:dotdash-keyboard-android,代碼行數:18,代碼來源:DotDashIMEService.java

示例10: createKeyFromXml

import android.inputmethodservice.Keyboard; //導入方法依賴的package包/類
@Override
protected Keyboard.Key createKeyFromXml(Resources res, Keyboard.Row parent, int x, int y,
                                        XmlResourceParser parser) {
    LatinKey key = new LatinKey(res, parent, x, y, parser);
    final int code = key.codes[0];
    if (code >= 0 && code != '\n' && (code < 32 || code > 127)) {
        key.label = " ";
        key.setEnabled(false);
    }
    switch (key.codes[0]) {
        case KEYCODE_ENTER:
            mEnterKey = key;
            break;
    }
    return key;
}
 
開發者ID:bither,項目名稱:bither-android,代碼行數:17,代碼來源:EntryKeyboard.java

示例11: syncStateKeys

import android.inputmethodservice.Keyboard; //導入方法依賴的package包/類
private void syncStateKeys(Keyboard k) {
    for (Keyboard.Key key : k.getKeys()) {
        if (key.sticky) {
            switch (key.codes[0]) {
                case VirtualKeyCode.ALT:
                    key.on = altState;
                    break;
                case VirtualKeyCode.CAPS:
                    key.on = capsState;
                    break;
                case VirtualKeyCode.CTRL:
                    key.on = ctrlState;
                    break;
                case VirtualKeyCode.WIN:
                    key.on = winState;
                    break;
                case VirtualKeyCode.MAC_COMMAND:
                    key.on = commandState;
                    break;
            }
        }
    }
}
 
開發者ID:devbury,項目名稱:mkRemote,代碼行數:24,代碼來源:Main.java

示例12: swapKeys

import android.inputmethodservice.Keyboard; //導入方法依賴的package包/類
private void swapKeys(Keyboard.Key k1, Keyboard.Key k2) {
    int[] codes = k1.codes;
    Drawable icon = k1.icon;
    Drawable iconPreview = k1.iconPreview;
    CharSequence label = k1.label;
    boolean modifier = k1.modifier;
    boolean on = k1.on;
    CharSequence popupCharacters = k1.popupCharacters;
    int popupResId = k1.popupResId;
    boolean pressed = k1.pressed;
    boolean repeatable = k1.repeatable;
    boolean sticky = k1.sticky;
    CharSequence text = k1.text;

    k1.codes = k2.codes;
    k1.icon = k2.icon;
    k1.iconPreview = k2.iconPreview;
    k1.label = k2.label;
    k1.modifier = k2.modifier;
    k1.on = k2.on;
    k1.popupCharacters = k2.popupCharacters;
    k1.popupResId = k2.popupResId;
    k1.pressed = k2.pressed;
    k1.repeatable = k2.repeatable;
    k1.sticky = k2.sticky;
    k1.text = k2.text;

    k2.codes = codes;
    k2.icon = icon;
    k2.iconPreview = iconPreview;
    k2.label = label;
    k2.modifier = modifier;
    k2.on = on;
    k2.popupCharacters = popupCharacters;
    k2.popupResId = popupResId;
    k2.pressed = pressed;
    k2.repeatable = repeatable;
    k2.sticky = sticky;
    k2.text = text;
}
 
開發者ID:rollforbugs,項目名稱:lokey,代碼行數:41,代碼來源:IME.java

示例13: shuffleKeyboard

import android.inputmethodservice.Keyboard; //導入方法依賴的package包/類
private void shuffleKeyboard(Keyboard keyboard) {
    List<Keyboard.Key> keys = keyboard.getKeys();
    int nKeys = keys.size();
    int swappiness = Integer.parseInt(prefs.getString("pref_swap_swappiness", "1"));
    for (int i = 0; i < swappiness; i++) {
        Keyboard.Key k1 = keys.get(rand.nextInt(nKeys));
        Keyboard.Key k2 = keys.get(rand.nextInt(nKeys));
        swapKeys(k1, k2);
    }
    kv.invalidateAllKeys();
}
 
開發者ID:rollforbugs,項目名稱:lokey,代碼行數:12,代碼來源:IME.java

示例14: changeKeyHeight

import android.inputmethodservice.Keyboard; //導入方法依賴的package包/類
public void changeKeyHeight(double height_modifier){
    int height = 0;
    for(Keyboard.Key key : getKeys()) {
        key.height *= height_modifier;
        key.y *= height_modifier;
        height = key.height;
    }
    setKeyHeight(height);
    getNearestKeys(0, 0); //somehow adding this fixed a weird bug where bottom row keys could not be pressed if keyboard height is too tall.. from the Keyboard source code seems like calling this will recalculate some values used in keypress detection calculation
}
 
開發者ID:VladThodo,項目名稱:behe-keyboard,代碼行數:11,代碼來源:LatinKeyboard.java

示例15: drawKeyboardNumber

import android.inputmethodservice.Keyboard; //導入方法依賴的package包/類
/**
 * 繪製數字鍵盤
 *
 * @param keys
 * @param canvas
 */
private void drawKeyboardNumber(List<Keyboard.Key> keys, Canvas canvas) {
    for (Keyboard.Key key : keys) {
        if (key.codes[0] == -5) {//刪除鍵
            drawKeyBackground(R.drawable.img_edit_clear, canvas, key);
        }
    }
}
 
開發者ID:GitPhoenix,項目名稱:KeyboardView,代碼行數:14,代碼來源:SKeyboardView.java


注:本文中的android.inputmethodservice.Keyboard.Key方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。