FileDocCategorySizeDatePackage
SoftKey.javaAPI DocAndroid 1.5 API6315Wed May 06 22:42:48 BST 2009com.android.inputmethod.pinyin

SoftKey

public class SoftKey extends Object
Class for soft keys which defined in the keyboard xml file. A soft key can be a basic key or a toggling key.
see
com.android.inputmethod.pinyin.SoftKeyToggle

Fields Summary
protected static final int
KEYMASK_REPEAT
protected static final int
KEYMASK_BALLOON
public static final int
MAX_MOVE_TOLERANCE_X
For a finger touch device, after user presses a key, there will be some consequent moving events because of the changing in touching pressure. If the moving distance in x is within this threshold, the moving events will be ignored.
public static final int
MAX_MOVE_TOLERANCE_Y
For a finger touch device, after user presses a key, there will be some consequent moving events because of the changing in touching pressure. If the moving distance in y is within this threshold, the moving events will be ignored.
protected int
mKeyMask
Used to indicate the type and attributes of this key. the lowest 8 bits should be reserved for SoftkeyToggle.
protected SoftKeyType
mKeyType
protected android.graphics.drawable.Drawable
mKeyIcon
protected android.graphics.drawable.Drawable
mKeyIconPopup
protected String
mKeyLabel
protected int
mKeyCode
public int
mPopupSkbId
If this value is not 0, this key can be used to popup a sub soft keyboard when user presses it for some time.
public float
mLeftF
public float
mRightF
public float
mTopF
public float
mBottomF
public int
mLeft
public int
mRight
public int
mTop
public int
mBottom
Constructors Summary
Methods Summary
public voidchangeCase(boolean upperCase)

        if (null != mKeyLabel) {
            if (upperCase)
                mKeyLabel = mKeyLabel.toUpperCase();
            else
                mKeyLabel = mKeyLabel.toLowerCase();
        }
    
public intgetColor()

        return mKeyType.mColor;
    
public intgetColorBalloon()

        return mKeyType.mColorBalloon;
    
public intgetColorHl()

        return mKeyType.mColorHl;
    
public android.graphics.drawable.DrawablegetKeyBg()

        return mKeyType.mKeyBg;
    
public intgetKeyCode()

        return mKeyCode;
    
public android.graphics.drawable.DrawablegetKeyHlBg()

        return mKeyType.mKeyHlBg;
    
public android.graphics.drawable.DrawablegetKeyIcon()

        return mKeyIcon;
    
public android.graphics.drawable.DrawablegetKeyIconPopup()

        if (null != mKeyIconPopup) {
            return mKeyIconPopup;
        }
        return mKeyIcon;
    
public java.lang.StringgetKeyLabel()

        return mKeyLabel;
    
public intgetPopupResId()

        return mPopupSkbId;
    
public intheight()

        return mBottom - mTop;
    
public booleanisKeyCodeKey()

        if (mKeyCode > 0) return true;
        return false;
    
public booleanisUniStrKey()

        if (null != mKeyLabel && mKeyCode == 0) return true;
        return false;
    
public booleanisUserDefKey()

        if (mKeyCode < 0) return true;
        return false;
    
public booleanmoveWithinKey(int x, int y)

        if (mLeft - MAX_MOVE_TOLERANCE_X <= x
                && mTop - MAX_MOVE_TOLERANCE_Y <= y
                && mRight + MAX_MOVE_TOLERANCE_X > x
                && mBottom + MAX_MOVE_TOLERANCE_Y > y) {
            return true;
        }
        return false;
    
public booleanneedBalloon()

        return (mKeyMask & KEYMASK_BALLOON) != 0;
    
public booleanrepeatable()

        return (mKeyMask & KEYMASK_REPEAT) != 0;
    
public voidsetKeyAttribute(int keyCode, java.lang.String label, boolean repeat, boolean balloon)

        mKeyCode = keyCode;
        mKeyLabel = label;

        if (repeat) {
            mKeyMask |= KEYMASK_REPEAT;
        } else {
            mKeyMask &= (~KEYMASK_REPEAT);
        }

        if (balloon) {
            mKeyMask |= KEYMASK_BALLOON;
        } else {
            mKeyMask &= (~KEYMASK_BALLOON);
        }
    
public voidsetKeyDimensions(float left, float top, float right, float bottom)

        mLeftF = left;
        mTopF = top;
        mRightF = right;
        mBottomF = bottom;
    
public voidsetKeyType(SoftKeyType keyType, android.graphics.drawable.Drawable keyIcon, android.graphics.drawable.Drawable keyIconPopup)


         
              
        mKeyType = keyType;
        mKeyIcon = keyIcon;
        mKeyIconPopup = keyIconPopup;
    
public voidsetPopupSkbId(int popupSkbId)

        mPopupSkbId = popupSkbId;
    
public voidsetSkbCoreSize(int skbWidth, int skbHeight)

        mLeft = (int) (mLeftF * skbWidth);
        mRight = (int) (mRightF * skbWidth);
        mTop = (int) (mTopF * skbHeight);
        mBottom = (int) (mBottomF * skbHeight);
    
public java.lang.StringtoString()

        String str = "\n";
        str += "  keyCode: " + String.valueOf(mKeyCode) + "\n";
        str += "  keyMask: " + String.valueOf(mKeyMask) + "\n";
        str += "  keyLabel: " + (mKeyLabel == null ? "null" : mKeyLabel) + "\n";
        str += "  popupResId: " + String.valueOf(mPopupSkbId) + "\n";
        str += "  Position: " + String.valueOf(mLeftF) + ", "
                + String.valueOf(mTopF) + ", " + String.valueOf(mRightF) + ", "
                + String.valueOf(mBottomF) + "\n";
        return str;
    
public intwidth()

        return mRight - mLeft;