From 2085d43daf44752deae1b6b00a14cb0f517d69cb Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Wed, 1 Sep 2010 23:18:39 +0900 Subject: Make abstract KeyDetector class The KeyDetector abstracts key detection algorithm. The ProximityKeyDetector is one of its concrete implementations. Another one that might be called XAxisKeyDetector will follow to realize the pop-up mini-keyboard behavior described in bug#2959169. Bug: 2959169 Change-Id: Idd3fc53282e6b721ec7a4ce500af8aba21ce07a3 --- .../inputmethod/latin/ProximityKeyDetector.java | 30 +++------------------- 1 file changed, 3 insertions(+), 27 deletions(-) (limited to 'java/src/com/android/inputmethod/latin/ProximityKeyDetector.java') diff --git a/java/src/com/android/inputmethod/latin/ProximityKeyDetector.java b/java/src/com/android/inputmethod/latin/ProximityKeyDetector.java index eae2d7f08..6ee005510 100644 --- a/java/src/com/android/inputmethod/latin/ProximityKeyDetector.java +++ b/java/src/com/android/inputmethod/latin/ProximityKeyDetector.java @@ -16,48 +16,24 @@ package com.android.inputmethod.latin; -import android.inputmethodservice.Keyboard; import android.inputmethodservice.Keyboard.Key; import java.util.Arrays; -class ProximityKeyDetector { +class ProximityKeyDetector extends KeyDetector { private static final int MAX_NEARBY_KEYS = 12; - private Keyboard mKeyboard; - private Key[] mKeys; - - private boolean mProximityCorrectOn; - private int mProximityThresholdSquare; - // working area private int[] mDistances = new int[MAX_NEARBY_KEYS]; - public void setKeyboard(Keyboard keyboard, Key[] keys) { - if (keyboard == null || keys == null) - throw new NullPointerException(); - mKeyboard = keyboard; - mKeys = keys; - } - - public void setProximityCorrectionEnabled(boolean enabled) { - mProximityCorrectOn = enabled; - } - - public boolean isProximityCorrectionEnabled() { - return mProximityCorrectOn; - } - - public void setProximityThreshold(int threshold) { - mProximityThresholdSquare = threshold * threshold; - } - + @Override public int[] newCodeArray() { int[] codes = new int[MAX_NEARBY_KEYS]; Arrays.fill(codes, LatinKeyboardBaseView.NOT_A_KEY); return codes; } + @Override public int getKeyIndexAndNearbyCodes(int x, int y, int[] allKeys) { final Key[] keys = mKeys; if (keys == null) -- cgit v1.2.3-83-g751a