1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.inputmethod.keyboard.internal; 18 19 import android.util.Log; 20 21 /* package */ final class ShiftKeyState extends ModifierKeyState { 22 private static final int PRESSING_ON_SHIFTED = 3; // both temporary shifted & shift locked 23 private static final int IGNORING = 4; 24 ShiftKeyState(String name)25 public ShiftKeyState(String name) { 26 super(name); 27 } 28 29 @Override onOtherKeyPressed()30 public void onOtherKeyPressed() { 31 int oldState = mState; 32 if (oldState == PRESSING) { 33 mState = CHORDING; 34 } else if (oldState == PRESSING_ON_SHIFTED) { 35 mState = IGNORING; 36 } 37 if (DEBUG) 38 Log.d(TAG, mName + ".onOtherKeyPressed: " + toString(oldState) + " > " + this); 39 } 40 onPressOnShifted()41 public void onPressOnShifted() { 42 int oldState = mState; 43 mState = PRESSING_ON_SHIFTED; 44 if (DEBUG) 45 Log.d(TAG, mName + ".onPressOnShifted: " + toString(oldState) + " > " + this); 46 } 47 isPressingOnShifted()48 public boolean isPressingOnShifted() { 49 return mState == PRESSING_ON_SHIFTED; 50 } 51 isIgnoring()52 public boolean isIgnoring() { 53 return mState == IGNORING; 54 } 55 56 @Override toString()57 public String toString() { 58 return toString(mState); 59 } 60 61 @Override toString(int state)62 protected String toString(int state) { 63 switch (state) { 64 case PRESSING_ON_SHIFTED: return "PRESSING_ON_SHIFTED"; 65 case IGNORING: return "IGNORING"; 66 default: return super.toString(state); 67 } 68 } 69 } 70