am 06f66153: Release caps lock by double tap on shift key
* commit '06f66153be6de88fd635ae09647fcd13a4bf04c0': Release caps lock by double tap on shift keymain
commit
e64d182b23
|
@ -496,6 +496,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
|
||||||
} else if (isShiftLocked() && !shiftKeyState.isIgnoring() && !withSliding) {
|
} else if (isShiftLocked() && !shiftKeyState.isIgnoring() && !withSliding) {
|
||||||
// Shift has been pressed without chording while caps lock state.
|
// Shift has been pressed without chording while caps lock state.
|
||||||
toggleCapsLock();
|
toggleCapsLock();
|
||||||
|
// To be able to turn off caps lock by "double tap" on shift key, we should ignore
|
||||||
|
// the second tap of the "double tap" from now for a while because we just have
|
||||||
|
// already turned off caps lock above.
|
||||||
|
mInputView.startIgnoringDoubleTap();
|
||||||
} else if (isShiftedOrShiftLocked() && shiftKeyState.isPressingOnShifted()
|
} else if (isShiftedOrShiftLocked() && shiftKeyState.isPressingOnShifted()
|
||||||
&& !withSliding) {
|
&& !withSliding) {
|
||||||
// Shift has been pressed without chording while shifted state.
|
// Shift has been pressed without chording while shifted state.
|
||||||
|
|
|
@ -16,10 +16,6 @@
|
||||||
|
|
||||||
package com.android.inputmethod.keyboard;
|
package com.android.inputmethod.keyboard;
|
||||||
|
|
||||||
import com.android.inputmethod.latin.LatinImeLogger;
|
|
||||||
import com.android.inputmethod.latin.R;
|
|
||||||
import com.android.inputmethod.latin.SubtypeSwitcher;
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
@ -45,11 +41,16 @@ import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewConfiguration;
|
||||||
import android.view.ViewGroup.LayoutParams;
|
import android.view.ViewGroup.LayoutParams;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.PopupWindow;
|
import android.widget.PopupWindow;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.android.inputmethod.latin.LatinImeLogger;
|
||||||
|
import com.android.inputmethod.latin.R;
|
||||||
|
import com.android.inputmethod.latin.SubtypeSwitcher;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
@ -193,6 +194,7 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
private static final int MSG_REPEAT_KEY = 3;
|
private static final int MSG_REPEAT_KEY = 3;
|
||||||
private static final int MSG_LONGPRESS_KEY = 4;
|
private static final int MSG_LONGPRESS_KEY = 4;
|
||||||
private static final int MSG_LONGPRESS_SHIFT_KEY = 5;
|
private static final int MSG_LONGPRESS_SHIFT_KEY = 5;
|
||||||
|
private static final int MSG_IGNORE_DOUBLE_TAP = 6;
|
||||||
|
|
||||||
private boolean mInKeyRepeat;
|
private boolean mInKeyRepeat;
|
||||||
|
|
||||||
|
@ -284,6 +286,16 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
public void cancelKeyTimers() {
|
public void cancelKeyTimers() {
|
||||||
cancelKeyRepeatTimer();
|
cancelKeyRepeatTimer();
|
||||||
cancelLongPressTimers();
|
cancelLongPressTimers();
|
||||||
|
removeMessages(MSG_IGNORE_DOUBLE_TAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startIgnoringDoubleTap() {
|
||||||
|
sendMessageDelayed(obtainMessage(MSG_IGNORE_DOUBLE_TAP),
|
||||||
|
ViewConfiguration.getDoubleTapTimeout());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIgnoringDoubleTap() {
|
||||||
|
return hasMessages(MSG_IGNORE_DOUBLE_TAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelAllMessages() {
|
public void cancelAllMessages() {
|
||||||
|
@ -453,7 +465,12 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
final PointerTracker tracker = getPointerTracker(id);
|
final PointerTracker tracker = getPointerTracker(id);
|
||||||
// If the second down event is also on shift key.
|
// If the second down event is also on shift key.
|
||||||
if (tracker.isOnShiftKey((int)secondDown.getX(), (int)secondDown.getY())) {
|
if (tracker.isOnShiftKey((int)secondDown.getX(), (int)secondDown.getY())) {
|
||||||
onDoubleTapShiftKey(tracker);
|
// Detected a double tap on shift key. If we are in the ignoring double tap
|
||||||
|
// mode, it means we have already turned off caps lock in
|
||||||
|
// {@link KeyboardSwitcher#onReleaseShift} .
|
||||||
|
final boolean ignoringDoubleTap = mHandler.isIgnoringDoubleTap();
|
||||||
|
if (!ignoringDoubleTap)
|
||||||
|
onDoubleTapShiftKey(tracker);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Otherwise these events should not be handled as double tap.
|
// Otherwise these events should not be handled as double tap.
|
||||||
|
@ -472,6 +489,11 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
|
||||||
mKeyRepeatInterval = res.getInteger(R.integer.config_key_repeat_interval);
|
mKeyRepeatInterval = res.getInteger(R.integer.config_key_repeat_interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void startIgnoringDoubleTap() {
|
||||||
|
if (ENABLE_CAPSLOCK_BY_DOUBLETAP)
|
||||||
|
mHandler.startIgnoringDoubleTap();
|
||||||
|
}
|
||||||
|
|
||||||
public void setOnKeyboardActionListener(KeyboardActionListener listener) {
|
public void setOnKeyboardActionListener(KeyboardActionListener listener) {
|
||||||
mKeyboardActionListener = listener;
|
mKeyboardActionListener = listener;
|
||||||
for (PointerTracker tracker : mPointerTrackers) {
|
for (PointerTracker tracker : mPointerTrackers) {
|
||||||
|
|
Loading…
Reference in New Issue