• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * 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, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */
16 
17 package com.android.inputmethod.keyboard.internal;
18 
19 import android.util.Log;
20 
21 /* package */ 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