2010-11-16 09:47:39 +00:00
|
|
|
/*
|
2011-05-20 03:09:57 +00:00
|
|
|
* Copyright (C) 2010 The Android Open Source Project
|
2010-11-16 09:47:39 +00:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
|
|
* use this file except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations under
|
|
|
|
* the License.
|
|
|
|
*/
|
|
|
|
|
2011-06-22 02:53:02 +00:00
|
|
|
package com.android.inputmethod.keyboard.internal;
|
2010-11-16 09:47:39 +00:00
|
|
|
|
2010-11-13 08:16:34 +00:00
|
|
|
import android.util.Log;
|
|
|
|
|
2010-11-16 09:47:39 +00:00
|
|
|
public class ShiftKeyState extends ModifierKeyState {
|
|
|
|
private static final int PRESSING_ON_SHIFTED = 3; // both temporary shifted & shift locked
|
|
|
|
private static final int IGNORING = 4;
|
|
|
|
|
2010-11-13 08:16:34 +00:00
|
|
|
public ShiftKeyState(String name) {
|
|
|
|
super(name);
|
|
|
|
}
|
|
|
|
|
2010-11-16 09:47:39 +00:00
|
|
|
@Override
|
|
|
|
public void onOtherKeyPressed() {
|
2010-11-13 08:16:34 +00:00
|
|
|
int oldState = mState;
|
2010-11-19 21:52:58 +00:00
|
|
|
if (oldState == PRESSING) {
|
2010-11-16 09:47:39 +00:00
|
|
|
mState = MOMENTARY;
|
2010-11-19 21:52:58 +00:00
|
|
|
} else if (oldState == PRESSING_ON_SHIFTED) {
|
2010-11-16 09:47:39 +00:00
|
|
|
mState = IGNORING;
|
|
|
|
}
|
2010-11-13 08:16:34 +00:00
|
|
|
if (DEBUG)
|
|
|
|
Log.d(TAG, mName + ".onOtherKeyPressed: " + toString(oldState) + " > " + this);
|
2010-11-16 09:47:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onPressOnShifted() {
|
2010-11-13 08:16:34 +00:00
|
|
|
int oldState = mState;
|
2010-11-16 09:47:39 +00:00
|
|
|
mState = PRESSING_ON_SHIFTED;
|
2010-11-13 08:16:34 +00:00
|
|
|
if (DEBUG)
|
|
|
|
Log.d(TAG, mName + ".onPressOnShifted: " + toString(oldState) + " > " + this);
|
2010-11-16 09:47:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isPressingOnShifted() {
|
|
|
|
return mState == PRESSING_ON_SHIFTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isIgnoring() {
|
|
|
|
return mState == IGNORING;
|
|
|
|
}
|
2010-11-13 08:16:34 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return toString(mState);
|
|
|
|
}
|
|
|
|
|
2010-11-19 21:52:58 +00:00
|
|
|
@Override
|
|
|
|
protected String toString(int state) {
|
2010-11-13 08:16:34 +00:00
|
|
|
switch (state) {
|
|
|
|
case PRESSING_ON_SHIFTED: return "PRESSING_ON_SHIFTED";
|
|
|
|
case IGNORING: return "IGNORING";
|
2010-11-19 21:52:58 +00:00
|
|
|
default: return super.toString(state);
|
2010-11-13 08:16:34 +00:00
|
|
|
}
|
|
|
|
}
|
2010-11-16 09:47:39 +00:00
|
|
|
}
|