diff options
Diffstat (limited to 'java')
39 files changed, 419 insertions, 119 deletions
diff --git a/java/res/drawable-hdpi/unbundled_check_01.png b/java/res/drawable-hdpi/unbundled_check_01.png Binary files differnew file mode 100644 index 000000000..8234399d5 --- /dev/null +++ b/java/res/drawable-hdpi/unbundled_check_01.png diff --git a/java/res/drawable-hdpi/unbundled_check_02.png b/java/res/drawable-hdpi/unbundled_check_02.png Binary files differnew file mode 100644 index 000000000..6ccd07b55 --- /dev/null +++ b/java/res/drawable-hdpi/unbundled_check_02.png diff --git a/java/res/drawable-hdpi/unbundled_earth_01.png b/java/res/drawable-hdpi/unbundled_earth_01.png Binary files differnew file mode 100644 index 000000000..3d22f3bfc --- /dev/null +++ b/java/res/drawable-hdpi/unbundled_earth_01.png diff --git a/java/res/drawable-hdpi/unbundled_earth_02.png b/java/res/drawable-hdpi/unbundled_earth_02.png Binary files differnew file mode 100644 index 000000000..1998aea56 --- /dev/null +++ b/java/res/drawable-hdpi/unbundled_earth_02.png diff --git a/java/res/drawable-hdpi/unbundled_key_01.png b/java/res/drawable-hdpi/unbundled_key_01.png Binary files differnew file mode 100644 index 000000000..84591ecb7 --- /dev/null +++ b/java/res/drawable-hdpi/unbundled_key_01.png diff --git a/java/res/drawable-hdpi/unbundled_key_02.png b/java/res/drawable-hdpi/unbundled_key_02.png Binary files differnew file mode 100644 index 000000000..f366e524c --- /dev/null +++ b/java/res/drawable-hdpi/unbundled_key_02.png diff --git a/java/res/drawable-hdpi/unbundled_select_01.png b/java/res/drawable-hdpi/unbundled_select_01.png Binary files differnew file mode 100644 index 000000000..3887fe491 --- /dev/null +++ b/java/res/drawable-hdpi/unbundled_select_01.png diff --git a/java/res/drawable-hdpi/unbundled_select_02.png b/java/res/drawable-hdpi/unbundled_select_02.png Binary files differnew file mode 100644 index 000000000..6a99b6b09 --- /dev/null +++ b/java/res/drawable-hdpi/unbundled_select_02.png diff --git a/java/res/drawable/ic_setup_step1.xml b/java/res/drawable/ic_setup_step1.xml new file mode 100644 index 000000000..e26afb3ca --- /dev/null +++ b/java/res/drawable/ic_setup_step1.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2013, 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 +** +** 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. +*/ +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:state_focused="true" + android:drawable="@drawable/unbundled_key_01" /> + <item + android:state_pressed="true" + android:drawable="@drawable/unbundled_key_01" /> + <item + android:drawable="@drawable/unbundled_key_02" /> +</selector> diff --git a/java/res/drawable/ic_setup_step2.xml b/java/res/drawable/ic_setup_step2.xml new file mode 100644 index 000000000..46db29306 --- /dev/null +++ b/java/res/drawable/ic_setup_step2.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2013, 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 +** +** 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. +*/ +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:state_focused="true" + android:drawable="@drawable/unbundled_select_01" /> + <item + android:state_pressed="true" + android:drawable="@drawable/unbundled_select_01" /> + <item + android:drawable="@drawable/unbundled_select_02" /> +</selector> diff --git a/java/res/drawable/ic_setup_step3.xml b/java/res/drawable/ic_setup_step3.xml new file mode 100644 index 000000000..4ff9fd933 --- /dev/null +++ b/java/res/drawable/ic_setup_step3.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2013, 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 +** +** 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. +*/ +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:state_focused="true" + android:drawable="@drawable/unbundled_earth_01" /> + <item + android:state_pressed="true" + android:drawable="@drawable/unbundled_earth_01" /> + <item + android:drawable="@drawable/unbundled_earth_02" /> +</selector> diff --git a/java/res/drawable/ic_setup_step3_finish.xml b/java/res/drawable/ic_setup_step3_finish.xml new file mode 100644 index 000000000..8ac8a86d1 --- /dev/null +++ b/java/res/drawable/ic_setup_step3_finish.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2013, 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 +** +** 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. +*/ +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:state_focused="true" + android:drawable="@drawable/unbundled_check_01" /> + <item + android:state_pressed="true" + android:drawable="@drawable/unbundled_check_01" /> + <item + android:drawable="@drawable/unbundled_check_02" /> +</selector> diff --git a/java/res/drawable/setup_step_action_background.xml b/java/res/drawable/setup_step_action_background.xml new file mode 100644 index 000000000..25738e3a4 --- /dev/null +++ b/java/res/drawable/setup_step_action_background.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2013, 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 +** +** 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. +*/ +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:state_focused="true" + android:drawable="@color/setup_text_action" /> + <item + android:state_pressed="true" + android:drawable="@color/setup_text_action" /> + <item + android:drawable="@color/setup_step_background" /> +</selector> diff --git a/java/res/drawable/setup_step_action_color.xml b/java/res/drawable/setup_step_action_color.xml new file mode 100644 index 000000000..c53e026d5 --- /dev/null +++ b/java/res/drawable/setup_step_action_color.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** +** Copyright 2013, 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 +** +** 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. +*/ +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:state_focused="true" + android:color="@color/setup_step_background" /> + <item + android:state_pressed="true" + android:color="@color/setup_step_background" /> + <item + android:color="@color/setup_text_action" /> +</selector> diff --git a/java/res/layout/setup_step.xml b/java/res/layout/setup_step.xml index 26d7fe799..c15d07bad 100644 --- a/java/res/layout/setup_step.xml +++ b/java/res/layout/setup_step.xml @@ -42,7 +42,7 @@ <View android:layout_width="match_parent" android:layout_height="2dp" /> - <TextView + <Button android:id="@+id/setup_step_action_label" style="@style/setupStepActionLabelStyle" android:gravity="center_vertical" diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index 3a7b39e3a..a71e7cc11 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -85,6 +85,8 @@ <attr name="slidingKeyInputEnable" format="boolean" /> <attr name="slidingKeyInputPreviewColor" format="color" /> <attr name="slidingKeyInputPreviewWidth" format="dimension" /> + <attr name="slidingKeyInputPreviewBodyRatio" format="integer" /> + <attr name="slidingKeyInputPreviewShadowRatio" format="integer" /> <!-- Key repeat start timeout --> <attr name="keyRepeatStartTimeout" format="integer" /> <!-- Key repeat interval in millisecond. --> @@ -115,6 +117,8 @@ <attr name="gesturePreviewTrailColor" format="color" /> <attr name="gesturePreviewTrailStartWidth" format="dimension" /> <attr name="gesturePreviewTrailEndWidth" format="dimension" /> + <attr name="gesturePreviewTrailBodyRatio" format="integer" /> + <attr name="gesturePreviewTrailShadowRatio" format="integer" /> <!-- Delay after gesture input and gesture floating preview text dismissing in millisecond --> <attr name="gestureFloatingPreviewTextLingerTimeout" format="integer" /> <!-- Attributes for GestureFloatingPreviewText --> diff --git a/java/res/values/config.xml b/java/res/values/config.xml index a90ba8014..d4fff620c 100644 --- a/java/res/values/config.xml +++ b/java/res/values/config.xml @@ -58,6 +58,9 @@ <bool name="config_sliding_key_input_enabled">true</bool> <!-- Sliding key input preview parameters --> <dimen name="config_sliding_key_input_preview_width">8.0dp</dimen> + <!-- Percentages of sliding key input preview body and shadow, in proportion to the width. --> + <integer name="config_sliding_key_input_preview_body_ratio">80</integer> + <integer name="config_sliding_key_input_preview_shadow_ratio">50</integer> <integer name="config_key_repeat_start_timeout">400</integer> <integer name="config_key_repeat_interval">50</integer> <integer name="config_default_longpress_key_timeout">300</integer> <!-- milliseconds --> diff --git a/java/res/values/dimens.xml b/java/res/values/dimens.xml index dd42acf3c..db33ad812 100644 --- a/java/res/values/dimens.xml +++ b/java/res/values/dimens.xml @@ -103,6 +103,9 @@ <!-- Gesture preview trail parameters --> <dimen name="gesture_preview_trail_start_width">10.0dp</dimen> <dimen name="gesture_preview_trail_end_width">2.5dp</dimen> + <!-- Percentages of gesture preview taril body and shadow, in proportion to the trail width. --> + <integer name="gesture_preview_trail_body_ratio">80</integer> + <integer name="gesture_preview_trail_shadow_ratio">50</integer> <!-- Gesture floating preview text parameters --> <dimen name="gesture_floating_preview_text_size">24dp</dimen> <dimen name="gesture_floating_preview_text_offset">73dp</dimen> diff --git a/java/res/values/setup-styles.xml b/java/res/values/setup-styles.xml index cfc689a78..420adcbb7 100644 --- a/java/res/values/setup-styles.xml +++ b/java/res/values/setup-styles.xml @@ -38,8 +38,8 @@ <item name="android:textSize">14sp</item> </style> <style name="setupStepActionLabelStyle"> - <item name="android:background">@color/setup_step_background</item> - <item name="android:textColor">@color/setup_text_action</item> + <item name="android:background">@drawable/setup_step_action_background</item> + <item name="android:textColor">@drawable/setup_step_action_color</item> <item name="android:textSize">18sp</item> </style> </resources> diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index dbadfabb8..3d283de23 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -442,31 +442,40 @@ <!-- Title of the button to revert to the default value of the device in the settings dialog [CHAR LIMIT=15] --> <string name="button_default">Default</string> - <!-- TODO: Remove translatable="false" once wordings are finalized. --> + <!-- Title of the setup wizard welcome screen. [CHAR LIMT=40] --> + <string name="setup_welcome_title">"Welcome to <xliff:g id="application_name">%s</xliff:g>"</string> + <!-- Additional title of the setup wizard welcome screen, just below the setup_welcome_title. [CHAR_LIMIT=64] --> + <string name="setup_welcome_additional_description">with Gesture Typing</string> + <!-- The label of the button that starts the setup wizard. [CHAR_LIMIT=64] --> + <string name="setup_start_action">Get started</string> <!-- Title of the setup wizard. [CHAR LIMT=40] --> - <string name="setup_title" translatable="false">"Installing <xliff:g id="application_name">%s</xliff:g>"</string> + <string name="setup_steps_title">"Setting up <xliff:g id="application_name">%s</xliff:g>"</string> <!-- Ordinal number of the 1st step in the setup wizard. [CHAR LIMIT=5] --> <string name="setup_step1_bullet" translatable="false">1</string> <!-- Title of the 1st step in the setup wizard. [CHAR LIMIT=64] --> - <string name="setup_step1_title" translatable="false">"Enable <xliff:g id="application_name">%s</xliff:g> in settings."</string> + <string name="setup_step1_title">"Enable <xliff:g id="application_name">%s</xliff:g>"</string> <!-- Detailed instruction of the 1st step in the setup wizard. [CHAR LIMIT=80] --> - <string name="setup_step1_instruction" translatable="false">"For security, please check \"<xliff:g id="application_name">%s</xliff:g>\""</string> + <string name="setup_step1_instruction">"Please check \"<xliff:g id="application_name">%s</xliff:g>\" in your Language & input settings. This will authorize it to run on your device."</string> + <!-- Title of the Language & input settings. This should be aligned with msgid="5292716747264442359" --> + <string name="setup_step1_action">Language & input</string> <!-- Ordinal number of the 2nd step in the setup wizard. [CHAR LIMIT=5] --> <string name="setup_step2_bullet" translatable="false">2</string> <!-- Title of the 2nd step in the setup wizard. [CHAR LIMIT=64] --> - <string name="setup_step2_title" translatable="false">"Switch to <xliff:g id="application_name">%s</xliff:g>."</string> + <string name="setup_step2_title">"Switch to <xliff:g id="application_name">%s</xliff:g>"</string> <!-- Detailed instruction of the 2nd step in the setup wizard. [CHAR LIMIT=80] --> - <string name="setup_step2_instruction" translatable="false">"Now that you've enabled <xliff:g id="application_name">%s</xliff:g>, you can switch to it."</string> + <string name="setup_step2_instruction">"Now that it's enabled, select \"<xliff:g id="application_name">%s</xliff:g>\", one more time to activate it."</string> + <!-- Title of the Input method picker. This should be aligned with msgid="4653387336791222978" --> + <string name="setup_step2_action">Choose input method</string> <!-- Ordinal number of the 3rd step in the setup wizard. [CHAR LIMIT=5] --> <string name="setup_step3_bullet" translatable="false">3</string> <!-- Title of the 3rd step in the setup wizard. [CHAR LIMIT=64] --> - <string name="setup_step3_title" translatable="false">"Congratulations, you're all set!"</string> + <string name="setup_step3_title">"Congratulations, you're all set!"</string> <!-- Detailed instruction of the 3rd step in the setup wizard. [CHAR LIMIT=80] --> - <string name="setup_step3_instruction" translatable="false">Configure additional languages</string> - <!-- Title of the Language & input settings. This should be aligned with msgid="5292716747264442359" --> - <string name="language_settings">Language & input</string> - <!-- Title of the Input method picker. This should be aligned with msgid="4653387336791222978" --> - <string name="select_input_method">Choose input method</string> + <string name="setup_step3_instruction">Now you can type in all your favorite apps with <xliff:g id="application_name">%s</xliff:g>.</string> + <!-- The label of the button that triggers the screen for configuaring additional languages of the keyboard. [CHAR_LIMIT=64] --> + <string name="setup_step3_action">Configure additional languages</string> + <!-- The label of the button that finishes the setup wizard. [CHAR_LIMIT=64] --> + <string name="setup_finish_action">Finished</string> <!-- Option to show setup wizard icon. [CHAR LIMIT=30]--> <string name="show_setup_wizard_icon" translatable="false">Show setup wizard icon</string> @@ -498,9 +507,9 @@ <!-- Message about some dictionary indicating the file is installed, but the dictionary is disabled --> <string name="dictionary_disabled">Installed, disabled</string> - <!-- Message to display in the dictionaries setting screen when some error prevented us to list installed dictionaries [CHAR LIMIT=50] --> + <!-- Message to display in the dictionaries setting screen when some error prevented us to list installed dictionaries [CHAR LIMIT=20] --> <string name="cannot_connect_to_dict_service">Problem connecting to dictionary service</string> - <!-- Message to display in the dictionaries setting screen when we found that no dictionaries are available [CHAR LIMIT=50]--> + <!-- Message to display in the dictionaries setting screen when we found that no dictionaries are available [CHAR LIMIT=20]--> <string name="no_dictionaries_available">No dictionaries available</string> <!-- Title of the options to press to refresh the list (as in, check for updates now) [CHAR_LIMIT=50] --> diff --git a/java/res/values/styles.xml b/java/res/values/styles.xml index fb59c745f..436e080f7 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -70,6 +70,8 @@ <item name="gesturePreviewTrailColor">@color/highlight_color_default</item> <item name="gesturePreviewTrailStartWidth">@dimen/gesture_preview_trail_start_width</item> <item name="gesturePreviewTrailEndWidth">@dimen/gesture_preview_trail_end_width</item> + <item name="gesturePreviewTrailBodyRatio">@integer/gesture_preview_trail_body_ratio</item> + <item name="gesturePreviewTrailShadowRatio">@integer/gesture_preview_trail_shadow_ratio</item> <!-- Common attributes of MainKeyboardView --> <item name="keyHysteresisDistance">@dimen/config_key_hysteresis_distance</item> <item name="keyHysteresisDistanceForSlidingModifier">@dimen/config_key_hysteresis_distance_for_sliding_modifier</item> @@ -78,6 +80,8 @@ <item name="slidingKeyInputEnable">@bool/config_sliding_key_input_enabled</item> <item name="slidingKeyInputPreviewColor">@color/highlight_translucent_color_default</item> <item name="slidingKeyInputPreviewWidth">@dimen/config_sliding_key_input_preview_width</item> + <item name="slidingKeyInputPreviewBodyRatio">@integer/config_sliding_key_input_preview_body_ratio</item> + <item name="slidingKeyInputPreviewShadowRatio">@integer/config_sliding_key_input_preview_shadow_ratio</item> <item name="keyRepeatStartTimeout">@integer/config_key_repeat_start_timeout</item> <item name="keyRepeatInterval">@integer/config_key_repeat_interval</item> <item name="longPressShiftLockTimeout">@integer/config_longpress_shift_lock_timeout</item> diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index ba78d014a..d74644d9e 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -1189,10 +1189,12 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack if (ENABLE_USABILITY_STUDY_LOG) { writeUsabilityStudyLog(me, action, eventTime, i, pointerId, px, py); } - if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { - ResearchLogger.mainKeyboardView_processMotionEvent( - me, action, eventTime, i, pointerId, px, py); - } + // TODO: This seems to be no longer necessary, and confusing because it leads to + // duplicate MotionEvents being recorded. + // if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { + // ResearchLogger.mainKeyboardView_processMotionEvent( + // me, action, eventTime, i, pointerId, px, py); + // } } } else { final PointerTracker tracker = PointerTracker.getPointerTracker(id, this); diff --git a/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java b/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java index f682b518f..7fd1bedcb 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java +++ b/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java @@ -51,6 +51,9 @@ final class GesturePreviewTrail { public final int mTrailColor; public final float mTrailStartWidth; public final float mTrailEndWidth; + public final float mTrailBodyRatio; + public boolean mTrailShadowEnabled; + public final float mTrailShadowRatio; public final int mFadeoutStartDelay; public final int mFadeoutDuration; public final int mUpdateInterval; @@ -64,6 +67,14 @@ final class GesturePreviewTrail { R.styleable.MainKeyboardView_gesturePreviewTrailStartWidth, 0.0f); mTrailEndWidth = mainKeyboardViewAttr.getDimension( R.styleable.MainKeyboardView_gesturePreviewTrailEndWidth, 0.0f); + final int PERCENTAGE_INT = 100; + mTrailBodyRatio = (float)mainKeyboardViewAttr.getInt( + R.styleable.MainKeyboardView_gesturePreviewTrailBodyRatio, PERCENTAGE_INT) + / (float)PERCENTAGE_INT; + final int trailShadowRatioInt = mainKeyboardViewAttr.getInt( + R.styleable.MainKeyboardView_gesturePreviewTrailShadowRatio, 0); + mTrailShadowEnabled = (trailShadowRatioInt > 0); + mTrailShadowRatio = (float)trailShadowRatioInt / (float)PERCENTAGE_INT; mFadeoutStartDelay = mainKeyboardViewAttr.getInt( R.styleable.MainKeyboardView_gesturePreviewTrailFadeoutStartDelay, 0); mFadeoutDuration = mainKeyboardViewAttr.getInt( @@ -97,7 +108,7 @@ final class GesturePreviewTrail { } private void addStrokeLocked(final GestureStrokeWithPreviewPoints stroke, final long downTime) { - final int trailSize = mEventTimes.getLength(); + final int trailSize = mEventTimes.getLength(); stroke.appendPreviewStroke(mEventTimes, mXCoordinates, mYCoordinates); if (mEventTimes.getLength() == trailSize) { return; @@ -219,14 +230,22 @@ final class GesturePreviewTrail { final float r2 = getWidth(elapsedTime, params) / 2.0f; // Draw trail line only when the current point isn't a down point. if (!isDownEventXCoord(xCoords[i])) { - final Path path = roundedLine.makePath(p1x, p1y, r1, p2x, p2y, r2); + final float body1 = r1 * params.mTrailBodyRatio; + final float body2 = r2 * params.mTrailBodyRatio; + final Path path = roundedLine.makePath(p1x, p1y, body1, p2x, p2y, body2); if (path != null) { + roundedLine.getBounds(mRoundedLineBounds); + if (params.mTrailShadowEnabled) { + final float shadow2 = r2 * params.mTrailShadowRatio; + paint.setShadowLayer(shadow2, 0.0f, 0.0f, params.mTrailColor); + final int shadowInset = -(int)Math.ceil(shadow2); + mRoundedLineBounds.inset(shadowInset, shadowInset); + } + // Take union for the bounds. + outBoundsRect.union(mRoundedLineBounds); final int alpha = getAlpha(elapsedTime, params); paint.setAlpha(alpha); canvas.drawPath(path, paint); - // Take union for the bounds. - roundedLine.getBounds(mRoundedLineBounds); - outBoundsRect.union(mRoundedLineBounds); } } p1x = p2x; @@ -242,14 +261,14 @@ final class GesturePreviewTrail { System.arraycopy(eventTimes, startIndex, eventTimes, 0, newSize); System.arraycopy(xCoords, startIndex, xCoords, 0, newSize); System.arraycopy(yCoords, startIndex, yCoords, 0, newSize); - // The start index of the last segment of the stroke - // {@link mLastInterpolatedDrawIndex} should also be updated because all array - // elements have just been shifted for compaction. - mLastInterpolatedDrawIndex = Math.max(mLastInterpolatedDrawIndex - startIndex, 0); } mEventTimes.setLength(newSize); mXCoordinates.setLength(newSize); mYCoordinates.setLength(newSize); + // The start index of the last segment of the stroke + // {@link mLastInterpolatedDrawIndex} should also be updated because all array + // elements have just been shifted for compaction or been zeroed. + mLastInterpolatedDrawIndex = Math.max(mLastInterpolatedDrawIndex - startIndex, 0); } return newSize > 0; } diff --git a/java/src/com/android/inputmethod/keyboard/internal/SlidingKeyInputPreview.java b/java/src/com/android/inputmethod/keyboard/internal/SlidingKeyInputPreview.java index 37f4e3582..33dbbafa3 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/SlidingKeyInputPreview.java +++ b/java/src/com/android/inputmethod/keyboard/internal/SlidingKeyInputPreview.java @@ -30,7 +30,7 @@ import com.android.inputmethod.latin.R; * Draw rubber band preview graphics during sliding key input. */ public final class SlidingKeyInputPreview extends AbstractDrawingPreview { - private final int mPreviewWidth; + private final float mPreviewBodyRadius; private boolean mShowSlidingKeyInputPreview; private final int[] mPreviewFrom = CoordinateUtils.newInstance(); @@ -44,8 +44,20 @@ public final class SlidingKeyInputPreview extends AbstractDrawingPreview { super(drawingView); final int previewColor = mainKeyboardViewAttr.getColor( R.styleable.MainKeyboardView_slidingKeyInputPreviewColor, 0); - mPreviewWidth = mainKeyboardViewAttr.getDimensionPixelSize( - R.styleable.MainKeyboardView_slidingKeyInputPreviewWidth, 0); + final float previewRadius = mainKeyboardViewAttr.getDimension( + R.styleable.MainKeyboardView_slidingKeyInputPreviewWidth, 0) / 2.0f; + final int PERCENTAGE_INT = 100; + final float previewBodyRatio = (float)mainKeyboardViewAttr.getInt( + R.styleable.MainKeyboardView_slidingKeyInputPreviewBodyRatio, PERCENTAGE_INT) + / (float)PERCENTAGE_INT; + mPreviewBodyRadius = previewRadius * previewBodyRatio; + final int previewShadowRatioInt = mainKeyboardViewAttr.getInt( + R.styleable.MainKeyboardView_slidingKeyInputPreviewShadowRatio, 0); + if (previewShadowRatioInt > 0) { + final float previewShadowRatio = (float)previewShadowRatioInt / (float)PERCENTAGE_INT; + final float shadowRadius = previewRadius * previewShadowRatio; + mPaint.setShadowLayer(shadowRadius, 0.0f, 0.0f, previewColor); + } mPaint.setColor(previewColor); } @@ -65,7 +77,7 @@ public final class SlidingKeyInputPreview extends AbstractDrawingPreview { } // TODO: Finalize the rubber band preview implementation. - final int radius = mPreviewWidth / 2; + final float radius = mPreviewBodyRadius; final Path path = mRoundedLine.makePath( CoordinateUtils.x(mPreviewFrom), CoordinateUtils.y(mPreviewFrom), radius, CoordinateUtils.x(mPreviewTo), CoordinateUtils.y(mPreviewTo), radius); diff --git a/java/src/com/android/inputmethod/latin/Constants.java b/java/src/com/android/inputmethod/latin/Constants.java index 50e50233e..86bb25562 100644 --- a/java/src/com/android/inputmethod/latin/Constants.java +++ b/java/src/com/android/inputmethod/latin/Constants.java @@ -160,6 +160,8 @@ public final class Constants { public static final int CODE_DOUBLE_QUOTE = '"'; public static final int CODE_QUESTION_MARK = '?'; public static final int CODE_EXCLAMATION_MARK = '!'; + public static final int CODE_SLASH = '/'; + public static final int CODE_COMMERCIAL_AT = '@'; // TODO: Check how this should work for right-to-left languages. It seems to stand // that for rtl languages, a closing parenthesis is a left parenthesis. Is this // managed by the font? Or is it a different char? diff --git a/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java b/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java index 22d189987..75c2cf2c8 100644 --- a/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java +++ b/java/src/com/android/inputmethod/latin/ContactsBinaryDictionary.java @@ -252,7 +252,7 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary { } private static boolean isValidName(final String name) { - if (name != null && -1 == name.indexOf('@')) { + if (name != null && -1 == name.indexOf(Constants.CODE_COMMERCIAL_AT)) { return true; } return false; diff --git a/java/src/com/android/inputmethod/latin/InputTypeUtils.java b/java/src/com/android/inputmethod/latin/InputTypeUtils.java index ecb20144b..46194f6e4 100644 --- a/java/src/com/android/inputmethod/latin/InputTypeUtils.java +++ b/java/src/com/android/inputmethod/latin/InputTypeUtils.java @@ -33,7 +33,6 @@ public final class InputTypeUtils implements InputType { private static final int[] SUPPRESSING_AUTO_SPACES_FIELD_VARIATION = { InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS, InputType.TYPE_TEXT_VARIATION_PASSWORD, - InputType.TYPE_TEXT_VARIATION_URI, InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD, InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD }; public static final int IME_ACTION_CUSTOM_LABEL = EditorInfo.IME_MASK_ACTION + 1; diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 0a6f2ab00..0e1c4dc31 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -2559,7 +2559,8 @@ public final class LatinIME extends InputMethodService implements KeyboardAction // This essentially inserts a space, and that's it. public void promotePhantomSpace() { - if (mSettings.getCurrent().shouldInsertSpacesAutomatically()) { + if (mSettings.getCurrent().shouldInsertSpacesAutomatically() + && !mConnection.textBeforeCursorLooksLikeURL()) { sendKeyCodePoint(Constants.CODE_SPACE); if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { ResearchLogger.latinIME_promotePhantomSpace(); diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java index e17846618..8ed7ab264 100644 --- a/java/src/com/android/inputmethod/latin/RichInputConnection.java +++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java @@ -19,7 +19,6 @@ package com.android.inputmethod.latin; import android.inputmethodservice.InputMethodService; import android.text.SpannableString; import android.text.TextUtils; -import android.text.style.SuggestionSpan; import android.util.Log; import android.view.KeyEvent; import android.view.inputmethod.CompletionInfo; @@ -721,4 +720,15 @@ public final class RichInputConnection { // position and the expected position, then it must be a belated update. return (newSelStart - oldSelStart) * (mCurrentCursorPosition - newSelStart) >= 0; } + + /** + * Looks at the text just before the cursor to find out if it looks like a URL. + * + * The weakest point here is, if we don't have enough text bufferized, we may fail to realize + * we are in URL situation, but other places in this class have the same limitation and it + * does not matter too much in the practice. + */ + public boolean textBeforeCursorLooksLikeURL() { + return StringUtils.lastPartLooksLikeURL(mCommittedTextBeforeComposingText); + } } diff --git a/java/src/com/android/inputmethod/latin/SettingsFragment.java b/java/src/com/android/inputmethod/latin/SettingsFragment.java index a96c997c8..79036c276 100644 --- a/java/src/com/android/inputmethod/latin/SettingsFragment.java +++ b/java/src/com/android/inputmethod/latin/SettingsFragment.java @@ -77,10 +77,13 @@ public final class SettingsFragment extends InputMethodSettingsFragment final Resources res = getResources(); final Context context = getActivity(); - // When we are called from the Settings application but we are not already running, the - // {@link SubtypeLocale} class may not have been initialized. It is safe to call - // {@link SubtypeLocale#init(Context)} multiple times. + // When we are called from the Settings application but we are not already running, some + // singleton and utility classes may not have been initialized. We have to call + // initialization method of these classes here. See {@link LatinIME#onCreate()}. + SubtypeSwitcher.init(context); SubtypeLocale.init(context); + AudioAndHapticFeedbackManager.init(context); + mVoicePreference = (ListPreference) findPreference(Settings.PREF_VOICE_MODE); mShowCorrectionSuggestionsPreference = (ListPreference) findPreference(Settings.PREF_SHOW_SUGGESTIONS_SETTING); diff --git a/java/src/com/android/inputmethod/latin/StringUtils.java b/java/src/com/android/inputmethod/latin/StringUtils.java index 7f1e7c619..d5ee58a63 100644 --- a/java/src/com/android/inputmethod/latin/StringUtils.java +++ b/java/src/com/android/inputmethod/latin/StringUtils.java @@ -282,4 +282,69 @@ public final class StringUtils { } return builder.toString(); } + + /** + * Approximates whether the text before the cursor looks like a URL. + * + * This is not foolproof, but it should work well in the practice. + * Essentially it walks backward from the cursor until it finds something that's not a letter, + * digit, or common URL symbol like underscore. If it hasn't found a period yet, then it + * does not look like a URL. + * If the text: + * - starts with www and contains a period + * - starts with a slash preceded by either a slash, whitespace, or start-of-string + * Then it looks like a URL and we return true. Otherwise, we return false. + * + * Note: this method is called quite often, and should be fast. + * + * TODO: This will return that "abc./def" and ".abc/def" look like URLs to keep down the + * code complexity, but ideally it should not. It's acceptable for now. + */ + public static boolean lastPartLooksLikeURL(final CharSequence text) { + int i = text.length(); + if (0 == i) return false; + int wCount = 0; + int slashCount = 0; + boolean hasSlash = false; + boolean hasPeriod = false; + int codePoint = 0; + while (i > 0) { + codePoint = Character.codePointBefore(text, i); + if (codePoint < Constants.CODE_PERIOD || codePoint > 'z') { + // Handwavy heuristic to see if that's a URL character. Anything between period + // and z. This includes all lower- and upper-case ascii letters, period, + // underscore, arrobase, question mark, equal sign. It excludes spaces, exclamation + // marks, double quotes... + // Anything that's not a URL-like character causes us to break from here and + // evaluate normally. + break; + } + if (Constants.CODE_PERIOD == codePoint) { + hasPeriod = true; + } + if (Constants.CODE_SLASH == codePoint) { + hasSlash = true; + if (2 == ++slashCount) { + return true; + } + } else { + slashCount = 0; + } + if ('w' == codePoint) { + ++wCount; + } else { + wCount = 0; + } + i = Character.offsetByCodePoints(text, i, -1); + } + // End of the text run. + // If it starts with www and includes a period, then it looks like a URL. + if (wCount >= 3 && hasPeriod) return true; + // If it starts with a slash, and the code point before is whitespace, it looks like an URL. + if (1 == slashCount && (0 == i || Character.isWhitespace(codePoint))) return true; + // If it has both a period and a slash, it looks like an URL. + if (hasPeriod && hasSlash) return true; + // Otherwise, it doesn't look like an URL. + return false; + } } diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index 2f9e34ff1..bef8a3cf1 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -80,6 +80,7 @@ public final class SubtypeSwitcher { public static void init(final Context context) { SubtypeLocale.init(context); + RichInputMethodManager.init(context); sInstance.initialize(context); } @@ -87,10 +88,13 @@ public final class SubtypeSwitcher { // Intentional empty constructor for singleton. } - private void initialize(final Context service) { - mResources = service.getResources(); + private void initialize(final Context context) { + if (mResources != null) { + return; + } + mResources = context.getResources(); mRichImm = RichInputMethodManager.getInstance(); - mConnectivityManager = (ConnectivityManager) service.getSystemService( + mConnectivityManager = (ConnectivityManager) context.getSystemService( Context.CONNECTIVITY_SERVICE); mNoLanguageSubtype = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( SubtypeLocale.NO_LANGUAGE, SubtypeLocale.QWERTY); diff --git a/java/src/com/android/inputmethod/latin/setup/SetupActivity.java b/java/src/com/android/inputmethod/latin/setup/SetupActivity.java index 15d0bac37..099169aa9 100644 --- a/java/src/com/android/inputmethod/latin/setup/SetupActivity.java +++ b/java/src/com/android/inputmethod/latin/setup/SetupActivity.java @@ -20,7 +20,6 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.res.Resources; -import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Message; @@ -113,13 +112,13 @@ public final class SetupActivity extends Activity { // the SDK version. final TextView titleView = (TextView)findViewById(R.id.setup_title); final int appName = getApplicationInfo().labelRes; - titleView.setText(getString(R.string.setup_title, getString(appName))); + titleView.setText(getString(R.string.setup_steps_title, getString(appName))); mStepIndicatorView = (SetupStepIndicatorView)findViewById(R.id.setup_step_indicator); final SetupStep step1 = new SetupStep(findViewById(R.id.setup_step1), appName, R.string.setup_step1_title, R.string.setup_step1_instruction, - R.drawable.ic_settings_language, R.string.language_settings); + R.drawable.ic_setup_step1, R.string.setup_step1_action); step1.setAction(new Runnable() { @Override public void run() { @@ -131,7 +130,7 @@ public final class SetupActivity extends Activity { final SetupStep step2 = new SetupStep(findViewById(R.id.setup_step2), appName, R.string.setup_step2_title, R.string.setup_step2_instruction, - 0 /* actionIcon */, R.string.select_input_method); + R.drawable.ic_setup_step2, R.string.setup_step2_action); step2.setAction(new Runnable() { @Override public void run() { @@ -143,8 +142,8 @@ public final class SetupActivity extends Activity { mSetupSteps.addStep(STEP_2, step2); final SetupStep step3 = new SetupStep(findViewById(R.id.setup_step3), - appName, R.string.setup_step3_title, 0 /* instruction */, - R.drawable.sym_keyboard_language_switch, R.string.setup_step3_instruction); + appName, R.string.setup_step3_title, R.string.setup_step3_instruction, + R.drawable.ic_setup_step3, R.string.setup_step3_action); step3.setAction(new Runnable() { @Override public void run() { @@ -314,9 +313,7 @@ public final class SetupActivity extends Activity { final int paddingEnd = ViewCompatUtils.getPaddingEnd(mActionLabel); ViewCompatUtils.setPaddingRelative(mActionLabel, paddingEnd, 0, paddingEnd, 0); } else { - final int overrideColor = res.getColor(R.color.setup_text_action); final Drawable icon = res.getDrawable(actionIcon); - icon.setColorFilter(overrideColor, PorterDuff.Mode.MULTIPLY); icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight()); TextViewCompatUtils.setCompoundDrawablesRelative( mActionLabel, icon, null, null, null); diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java index 96b2c818d..da8657201 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java @@ -189,10 +189,12 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session { int letterCount = 0; for (int i = 0; i < length; i = text.offsetByCodePoints(i, 1)) { final int codePoint = text.codePointAt(i); - // Any word containing a '@' is probably an e-mail address - // Any word containing a '/' is probably either an ad-hoc combination of two + // Any word containing a COMMERCIAL_AT is probably an e-mail address + // Any word containing a SLASH is probably either an ad-hoc combination of two // words or a URI - in either case we don't want to spell check that - if ('@' == codePoint || '/' == codePoint) return true; + if (Constants.CODE_COMMERCIAL_AT == codePoint || Constants.CODE_SLASH == codePoint) { + return true; + } if (isLetterCheckableByLanguage(codePoint, script)) ++letterCount; } // Guestimate heuristic: perform spell checking if at least 3/4 of the characters diff --git a/java/src/com/android/inputmethod/research/FeedbackFragment.java b/java/src/com/android/inputmethod/research/FeedbackFragment.java index 39f9c87a0..a0738292e 100644 --- a/java/src/com/android/inputmethod/research/FeedbackFragment.java +++ b/java/src/com/android/inputmethod/research/FeedbackFragment.java @@ -65,12 +65,10 @@ public class FeedbackFragment extends Fragment implements OnClickListener { mCancelButton.setOnClickListener(this); if (savedInstanceState != null) { - Log.d(TAG, "restoring from savedInstanceState"); restoreState(savedInstanceState); } else { final Bundle bundle = getActivity().getIntent().getExtras(); if (bundle != null) { - Log.d(TAG, "restoring from getArguments()"); restoreState(bundle); } } @@ -81,10 +79,7 @@ public class FeedbackFragment extends Fragment implements OnClickListener { public void onClick(final View view) { final ResearchLogger researchLogger = ResearchLogger.getInstance(); if (view == mIncludingUserRecordingCheckBox) { - if (hasUserRecording()) { - // Remove the recording - setHasUserRecording(false); - } else { + if (mIncludingUserRecordingCheckBox.isChecked()) { final Bundle bundle = new Bundle(); onSaveInstanceState(bundle); @@ -103,9 +98,9 @@ public class FeedbackFragment extends Fragment implements OnClickListener { R.string.research_feedback_empty_feedback_error_message, Toast.LENGTH_LONG).show(); } else { - final boolean isIncludingAccountName = isIncludingAccountName(); - researchLogger.sendFeedback(feedbackContents, - false /* isIncludingHistory */, isIncludingAccountName, hasUserRecording()); + final boolean isIncludingAccountName = mIncludingAccountNameCheckBox.isChecked(); + researchLogger.sendFeedback(feedbackContents, false /* isIncludingHistory */, + isIncludingAccountName, mIncludingUserRecordingCheckBox.isChecked()); getActivity().finish(); researchLogger.setFeedbackDialogBundle(null); researchLogger.onLeavingSendFeedbackDialog(); @@ -125,29 +120,13 @@ public class FeedbackFragment extends Fragment implements OnClickListener { final String savedFeedbackString = mEditText.getText().toString(); bundle.putString(KEY_FEEDBACK_STRING, savedFeedbackString); - bundle.putBoolean(KEY_INCLUDE_ACCOUNT_NAME, isIncludingAccountName()); - bundle.putBoolean(KEY_HAS_USER_RECORDING, hasUserRecording()); + bundle.putBoolean(KEY_INCLUDE_ACCOUNT_NAME, mIncludingAccountNameCheckBox.isChecked()); + bundle.putBoolean(KEY_HAS_USER_RECORDING, mIncludingUserRecordingCheckBox.isChecked()); } - public void restoreState(final Bundle bundle) { + private void restoreState(final Bundle bundle) { mEditText.setText(bundle.getString(KEY_FEEDBACK_STRING)); - setIsIncludingAccountName(bundle.getBoolean(KEY_INCLUDE_ACCOUNT_NAME)); - setHasUserRecording(bundle.getBoolean(KEY_HAS_USER_RECORDING)); - } - - private boolean hasUserRecording() { - return mIncludingUserRecordingCheckBox.isChecked(); - } - - private void setHasUserRecording(final boolean hasRecording) { - mIncludingUserRecordingCheckBox.setChecked(hasRecording); - } - - private boolean isIncludingAccountName() { - return mIncludingAccountNameCheckBox.isChecked(); - } - - private void setIsIncludingAccountName(final boolean isIncludingAccountName) { - mIncludingAccountNameCheckBox.setChecked(isIncludingAccountName); + mIncludingAccountNameCheckBox.setChecked(bundle.getBoolean(KEY_INCLUDE_ACCOUNT_NAME)); + mIncludingUserRecordingCheckBox.setChecked(bundle.getBoolean(KEY_HAS_USER_RECORDING)); } } diff --git a/java/src/com/android/inputmethod/research/ResearchLog.java b/java/src/com/android/inputmethod/research/ResearchLog.java index 35a491f2c..18bf7ba54 100644 --- a/java/src/com/android/inputmethod/research/ResearchLog.java +++ b/java/src/com/android/inputmethod/research/ResearchLog.java @@ -108,10 +108,14 @@ public class ResearchLog { @Override public Object call() throws Exception { try { - if (mHasWrittenData) { - mJsonWriter.endArray(); - mHasWrittenData = false; + // TODO: This is necessary to avoid an exception. Better would be to not even + // open the JsonWriter if the file is not even opened unless there is valid data + // to write. + if (!mHasWrittenData) { + mJsonWriter.beginArray(); } + mJsonWriter.endArray(); + mHasWrittenData = false; mJsonWriter.flush(); mJsonWriter.close(); if (DEBUG) { @@ -159,6 +163,12 @@ public class ResearchLog { public Object call() throws Exception { try { if (mHasWrittenData) { + // TODO: This is necessary to avoid an exception. Better would be to not + // even open the JsonWriter if the file is not even opened unless there is + // valid data to write. + if (!mHasWrittenData) { + mJsonWriter.beginArray(); + } mJsonWriter.endArray(); mJsonWriter.close(); mHasWrittenData = false; diff --git a/java/src/com/android/inputmethod/research/ResearchLogDirectory.java b/java/src/com/android/inputmethod/research/ResearchLogDirectory.java index 291dea5d0..d156068d6 100644 --- a/java/src/com/android/inputmethod/research/ResearchLogDirectory.java +++ b/java/src/com/android/inputmethod/research/ResearchLogDirectory.java @@ -97,15 +97,17 @@ public class ResearchLogDirectory { } } - public File getLogFilePath(final long time) { - return new File(mFilesDir, getUniqueFilename(LOG_FILENAME_PREFIX, time)); + public File getLogFilePath(final long time, final long nanoTime) { + return new File(mFilesDir, getUniqueFilename(LOG_FILENAME_PREFIX, time, nanoTime)); } - public File getUserRecordingFilePath(final long time) { - return new File(mFilesDir, getUniqueFilename(USER_RECORDING_FILENAME_PREFIX, time)); + public File getUserRecordingFilePath(final long time, final long nanoTime) { + return new File(mFilesDir, getUniqueFilename(USER_RECORDING_FILENAME_PREFIX, time, + nanoTime)); } - private static String getUniqueFilename(final String prefix, final long time) { - return prefix + "-" + time + FILENAME_SUFFIX; + private static String getUniqueFilename(final String prefix, final long time, + final long nanoTime) { + return prefix + "-" + time + "-" + nanoTime + FILENAME_SUFFIX; } } diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java index 7a23ddb05..cd18e3de6 100644 --- a/java/src/com/android/inputmethod/research/ResearchLogger.java +++ b/java/src/com/android/inputmethod/research/ResearchLogger.java @@ -389,7 +389,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang } if (mMainLogBuffer == null) { mMainResearchLog = new ResearchLog(mResearchLogDirectory.getLogFilePath( - System.currentTimeMillis()), mLatinIME); + System.currentTimeMillis(), System.nanoTime()), mLatinIME); final int numWordsToIgnore = new Random().nextInt(NUMBER_OF_WORDS_BETWEEN_SAMPLES + 1); mMainLogBuffer = new MainLogBuffer(NUMBER_OF_WORDS_BETWEEN_SAMPLES, numWordsToIgnore, mSuggest) { @@ -420,7 +420,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang private void resetFeedbackLogging() { mFeedbackLog = new ResearchLog(mResearchLogDirectory.getLogFilePath( - System.currentTimeMillis()), mLatinIME); + System.currentTimeMillis(), System.nanoTime()), mLatinIME); mFeedbackLogBuffer = new FixedLogBuffer(FEEDBACK_WORD_BUFFER_SIZE); } @@ -545,7 +545,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang mUserRecordingLog.blockingAbort(RESEARCHLOG_ABORT_TIMEOUT_IN_MS); } mUserRecordingFile = mResearchLogDirectory.getUserRecordingFilePath( - System.currentTimeMillis()); + System.currentTimeMillis(), System.nanoTime()); mUserRecordingLog = new ResearchLog(mUserRecordingFile, mLatinIME); mUserRecordingLogBuffer = new LogBuffer(); resetRecordingTimer(); @@ -813,7 +813,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang // enabled. The dot is actually a zero-width, zero-height rectangle, placed at the // lower-right corner of the canvas, painted with a non-zero border width. paint.setStrokeWidth(3); - canvas.drawRect(width, height, width, height, paint); + canvas.drawRect(width - 1, height - 1, width, height, paint); } paint.setColor(savedColor); paint.setStyle(savedStyle); @@ -894,7 +894,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang // Check that expected word matches. if (oldLogUnit != null) { final String oldLogUnitWord = oldLogUnit.getWord(); - if (!oldLogUnitWord.equals(expectedWord)) { + if (oldLogUnitWord != null && !oldLogUnitWord.equals(expectedWord)) { return; } } @@ -1107,7 +1107,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang packageInfo = mLatinIME.getPackageManager().getPackageInfo(mLatinIME.getPackageName(), 0); final String versionName = packageInfo.versionName; - return !(developerBuildRegex.matcher(versionName).find()); + return developerBuildRegex.matcher(versionName).find(); } catch (final NameNotFoundException e) { Log.e(TAG, "Could not determine package name", e); return false; @@ -1826,6 +1826,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang public static void latinIME_onEndBatchInput(final CharSequence enteredText, final int enteredWordPos, final SuggestedWords suggestedWords) { final ResearchLogger researchLogger = getInstance(); + if (!TextUtils.isEmpty(enteredText) && hasLetters(enteredText.toString())) { + researchLogger.mCurrentLogUnit.setWord(enteredText.toString()); + } researchLogger.enqueueEvent(LOGSTATEMENT_LATINIME_ONENDBATCHINPUT, enteredText, enteredWordPos); researchLogger.mCurrentLogUnit.initializeSuggestions(suggestedWords); diff --git a/java/src/com/android/inputmethod/research/UploaderService.java b/java/src/com/android/inputmethod/research/UploaderService.java index 6a9717b7c..d2db34927 100644 --- a/java/src/com/android/inputmethod/research/UploaderService.java +++ b/java/src/com/android/inputmethod/research/UploaderService.java @@ -22,6 +22,7 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.os.SystemClock; import com.android.inputmethod.latin.define.ProductionFlag; @@ -79,28 +80,14 @@ public final class UploaderService extends IntentService { */ public static void cancelAndRescheduleUploadingService(final Context context, final boolean needsRescheduling) { - final PendingIntent pendingIntent = getPendingIntentForService(context); + final Intent intent = new Intent(context, UploaderService.class); + final PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, 0); final AlarmManager alarmManager = (AlarmManager) context.getSystemService( Context.ALARM_SERVICE); - cancelAnyScheduledServiceAlarm(alarmManager, pendingIntent); + alarmManager.cancel(pendingIntent); if (needsRescheduling) { - scheduleServiceAlarm(alarmManager, pendingIntent); + alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + + UploaderService.RUN_INTERVAL, pendingIntent); } } - - private static PendingIntent getPendingIntentForService(final Context context) { - final Intent intent = new Intent(context, UploaderService.class); - return PendingIntent.getService(context, 0, intent, 0); - } - - private static void cancelAnyScheduledServiceAlarm(final AlarmManager alarmManager, - final PendingIntent pendingIntent) { - alarmManager.cancel(pendingIntent); - } - - private static void scheduleServiceAlarm(final AlarmManager alarmManager, - final PendingIntent pendingIntent) { - alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, UploaderService.RUN_INTERVAL, - pendingIntent); - } } |