diff options
-rw-r--r-- | java/res/drawable/btn_keyboard_key.xml | 6 | ||||
-rw-r--r-- | java/res/values-land/dimens.xml | 18 | ||||
-rw-r--r-- | java/res/values/dimens.xml | 18 | ||||
-rw-r--r-- | java/res/xml/kbd_more_keys_keyboard_template.xml | 18 | ||||
-rw-r--r-- | native/jni/src/geometry_utils.h | 21 | ||||
-rw-r--r-- | native/jni/src/proximity_info.cpp | 4 | ||||
-rw-r--r-- | native/jni/src/proximity_info_state.cpp | 4 |
7 files changed, 50 insertions, 39 deletions
diff --git a/java/res/drawable/btn_keyboard_key.xml b/java/res/drawable/btn_keyboard_key.xml index 45578e582..797bc105e 100644 --- a/java/res/drawable/btn_keyboard_key.xml +++ b/java/res/drawable/btn_keyboard_key.xml @@ -17,8 +17,8 @@ <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Toggle keys. Use checkable/checked state. --> - - <item android:state_checkable="true" android:state_checked="true" + + <item android:state_checkable="true" android:state_checked="true" android:state_pressed="true" android:drawable="@drawable/btn_keyboard_key_pressed_on" /> <item android:state_checkable="true" android:state_pressed="true" @@ -34,5 +34,5 @@ android:drawable="@drawable/btn_keyboard_key_pressed" /> <item android:drawable="@drawable/btn_keyboard_key_normal" /> - + </selector> diff --git a/java/res/values-land/dimens.xml b/java/res/values-land/dimens.xml index fdd94347d..c78c25f86 100644 --- a/java/res/values-land/dimens.xml +++ b/java/res/values-land/dimens.xml @@ -1,19 +1,19 @@ <?xml version="1.0" encoding="utf-8"?> <!-- -/* +/* ** ** Copyright 2008, The Android Open Source Project ** -** 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 +** 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 +** 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 +** 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. */ --> diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml index d92a71560..0fb8877a9 100644 --- a/java/res/values/dimens.xml +++ b/java/res/values/dimens.xml @@ -1,19 +1,19 @@ <?xml version="1.0" encoding="utf-8"?> <!-- -/* +/* ** ** Copyright 2008, The Android Open Source Project ** -** 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 +** 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 +** 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 +** 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. */ --> diff --git a/java/res/xml/kbd_more_keys_keyboard_template.xml b/java/res/xml/kbd_more_keys_keyboard_template.xml index 8e977c5ad..537973d03 100644 --- a/java/res/xml/kbd_more_keys_keyboard_template.xml +++ b/java/res/xml/kbd_more_keys_keyboard_template.xml @@ -1,19 +1,19 @@ <?xml version="1.0" encoding="utf-8"?> <!-- -/* +/* ** ** Copyright 2008, The Android Open Source Project ** -** 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 +** 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 +** 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 +** 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. */ --> diff --git a/native/jni/src/geometry_utils.h b/native/jni/src/geometry_utils.h index f30e9fcc0..bad5eda61 100644 --- a/native/jni/src/geometry_utils.h +++ b/native/jni/src/geometry_utils.h @@ -25,14 +25,17 @@ #define M_PI_F 3.14159265f -namespace latinime { +#define ROUND_FLOAT_10000(f) ((f) < 1000.0f && (f) > 0.001f) \ + ? (floorf((f) * 10000.0f) / 10000.0f) : (f) -static inline float squareFloat(float x) { - return x * x; -} +#define SQUARE_FLOAT(x) ((x) * (x)) + +namespace latinime { static inline float getSquaredDistanceFloat(float x1, float y1, float x2, float y2) { - return squareFloat(x1 - x2) + squareFloat(y1 - y2); + const float deltaX = x1 - x2; + const float deltaY = y1 - y2; + return SQUARE_FLOAT(deltaX) + SQUARE_FLOAT(deltaY); } static inline float getDistanceFloat(float x1, float y1, float x2, float y2) { @@ -52,9 +55,11 @@ static inline float getAngle(int x1, int y1, int x2, int y2) { } static inline float getAngleDiff(float a1, float a2) { - const float diff = fabsf(a1 - a2); + const float deltaA = fabsf(a1 - a2); + const float diff = ROUND_FLOAT_10000(deltaA); if (diff > M_PI_F) { - return 2.0f * M_PI_F - diff; + const float normalizedDiff = 2.0f * M_PI_F - diff; + return ROUND_FLOAT_10000(normalizedDiff); } return diff; } @@ -76,7 +81,7 @@ static inline float pointToLineSegSquaredDistanceFloat( const float ray2y = y2 - y1; const float dotProduct = ray1x * ray2x + ray1y * ray2y; - const float lineLengthSqr = squareFloat(ray2x) + squareFloat(ray2y); + const float lineLengthSqr = SQUARE_FLOAT(ray2x) + SQUARE_FLOAT(ray2y); const float projectionLengthSqr = dotProduct / lineLengthSqr; float projectionX; diff --git a/native/jni/src/proximity_info.cpp b/native/jni/src/proximity_info.cpp index 9bb8b29ae..693a9f2b1 100644 --- a/native/jni/src/proximity_info.cpp +++ b/native/jni/src/proximity_info.cpp @@ -141,7 +141,9 @@ bool ProximityInfo::hasSpaceProximity(const int x, const int y) const { static inline float getNormalizedSquaredDistanceFloat(float x1, float y1, float x2, float y2, float scale) { - return squareFloat((x1 - x2) / scale) + squareFloat((y1 - y2) / scale); + const float deltaX = x1 - x2; + const float deltaY = y1 - y2; + return (SQUARE_FLOAT(deltaX) + SQUARE_FLOAT(deltaY)) / SQUARE_FLOAT(scale); } float ProximityInfo::getNormalizedSquaredDistanceFromCenterFloat( diff --git a/native/jni/src/proximity_info_state.cpp b/native/jni/src/proximity_info_state.cpp index 208b69356..7e917a929 100644 --- a/native/jni/src/proximity_info_state.cpp +++ b/native/jni/src/proximity_info_state.cpp @@ -177,6 +177,10 @@ void ProximityInfoState::initInputParams(const int pointerId, const float maxPoi hypotf(mProximityInfo->getKeyboardWidth(), mProximityInfo->getKeyboardHeight()) * READ_FORWORD_LENGTH_SCALE); for (int i = 0; i < mInputSize; ++i) { + if (DEBUG_GEO_FULL) { + AKLOGI("Sampled(%d): x = %d, y = %d, time = %d", i, mInputXs[i], mInputYs[i], + mTimes[i]); + } for (int j = max(i + 1, lastSavedInputSize); j < mInputSize; ++j) { if (mLengthCache[j] - mLengthCache[i] >= readForwordLength) { break; |