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

SoftKeyToggle

public class SoftKeyToggle extends SoftKey
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.SoftKey

Fields Summary
private static final int
KEYMASK_TOGGLE_STATE
The current state number is stored in the lowest 8 bits of mKeyMask, this mask is used to get the state number. If the current state is 0, the normal state is enabled; if the current state is more than 0, a toggle state in the toggle state chain will be enabled.
private ToggleState
mToggleState
Constructors Summary
Methods Summary
public voidchangeCase(boolean lowerCase)

        ToggleState state = getToggleState();
        if (null != state && null != state.mKeyLabel) {
            if (lowerCase)
                state.mKeyLabel = state.mKeyLabel.toLowerCase();
            else
                state.mKeyLabel = state.mKeyLabel.toUpperCase();
        }
    
public com.android.inputmethod.pinyin.SoftKeyToggle$ToggleStatecreateToggleState()

        return new ToggleState();
    
public booleandisableAllToggleStates()

        int oldStateId = (mKeyMask & KEYMASK_TOGGLE_STATE);
        mKeyMask &= (~KEYMASK_TOGGLE_STATE);
        return oldStateId != 0;
    
public booleandisableToggleState(int stateId, boolean resetIfNotFound)

        int oldStateId = (mKeyMask & KEYMASK_TOGGLE_STATE);
        if (oldStateId == stateId) {
            mKeyMask &= (~KEYMASK_TOGGLE_STATE);
            return stateId != 0;
        }

        if (resetIfNotFound) {
            mKeyMask &= (~KEYMASK_TOGGLE_STATE);
            return oldStateId != 0;
        }
        return false;
    
public booleanenableToggleState(int stateId, boolean resetIfNotFound)

        int oldStateId = (mKeyMask & KEYMASK_TOGGLE_STATE);
        if (oldStateId == stateId) return false;

        mKeyMask &= (~KEYMASK_TOGGLE_STATE);
        if (stateId > 0) {
            mKeyMask |= (KEYMASK_TOGGLE_STATE & stateId);
            if (getToggleState() == null) {
                mKeyMask &= (~KEYMASK_TOGGLE_STATE);
                if (!resetIfNotFound && oldStateId > 0) {
                    mKeyMask |= (KEYMASK_TOGGLE_STATE & oldStateId);
                }
                return resetIfNotFound;
            } else {
                return true;
            }
        } else {
            return true;
        }
    
public intgetColor()

        ToggleState state = getToggleState();
        if (null != state && null != state.mKeyType) {
            return state.mKeyType.mColor;
        }
        return mKeyType.mColor;
    
public intgetColorBalloon()

        ToggleState state = getToggleState();
        if (null != state && null != state.mKeyType) {
            return state.mKeyType.mColorBalloon;
        }
        return mKeyType.mColorBalloon;
    
public intgetColorHl()

        ToggleState state = getToggleState();
        if (null != state && null != state.mKeyType) {
            return state.mKeyType.mColorHl;
        }
        return mKeyType.mColorHl;
    
public android.graphics.drawable.DrawablegetKeyBg()

        ToggleState state = getToggleState();
        if (null != state && null != state.mKeyType) {
            return state.mKeyType.mKeyBg;
        }
        return mKeyType.mKeyBg;
    
public intgetKeyCode()

        ToggleState state = getToggleState();
        if (null != state) return state.mKeyCode;
        return mKeyCode;
    
public android.graphics.drawable.DrawablegetKeyHlBg()

        ToggleState state = getToggleState();
        if (null != state && null != state.mKeyType) {
            return state.mKeyType.mKeyHlBg;
        }
        return mKeyType.mKeyHlBg;
    
public android.graphics.drawable.DrawablegetKeyIcon()

        ToggleState state = getToggleState();
        if (null != state) return state.mKeyIcon;
        return super.getKeyIcon();
    
public android.graphics.drawable.DrawablegetKeyIconPopup()

        ToggleState state = getToggleState();
        if (null != state) {
            if (null != state.mKeyIconPopup) {
                return state.mKeyIconPopup;
            } else {
                return state.mKeyIcon;
            }
        }
        return super.getKeyIconPopup();
    
public java.lang.StringgetKeyLabel()

        ToggleState state = getToggleState();
        if (null != state) return state.mKeyLabel;
        return mKeyLabel;
    
private com.android.inputmethod.pinyin.SoftKeyToggle$ToggleStategetToggleState()

        int stateId = (mKeyMask & KEYMASK_TOGGLE_STATE);
        if (0 == stateId) return null;

        ToggleState state = mToggleState;
        while ((null != state)
                && (state.mIdAndFlags & KEYMASK_TOGGLE_STATE) != stateId) {
            state = state.mNextState;
        }
        return state;
    
public intgetToggleStateId()


       
        return (mKeyMask & KEYMASK_TOGGLE_STATE);
    
public booleanisKeyCodeKey()

        ToggleState state = getToggleState();
        if (null != state) {
            if (state.mKeyCode > 0) return true;
            return false;
        }
        return super.isKeyCodeKey();
    
public booleanisUniStrKey()

        ToggleState state = getToggleState();
        if (null != state) {
            if (null != state.mKeyLabel && state.mKeyCode == 0) {
                return true;
            }
            return false;
        }
        return super.isUniStrKey();
    
public booleanisUserDefKey()

        ToggleState state = getToggleState();
        if (null != state) {
            if (state.mKeyCode < 0) return true;
            return false;
        }
        return super.isUserDefKey();
    
public booleanneedBalloon()

        ToggleState state = getToggleState();
        if (null != state) {
            return (state.mIdAndFlags & KEYMASK_BALLOON) != 0;
        }
        return super.needBalloon();
    
public booleanrepeatable()

        ToggleState state = getToggleState();
        if (null != state) {
            return (state.mIdAndFlags & KEYMASK_REPEAT) != 0;
        }
        return super.repeatable();
    
public booleansetToggleStates(com.android.inputmethod.pinyin.SoftKeyToggle$ToggleState rootState)

        if (null == rootState) return false;
        mToggleState = rootState;
        return true;