aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java10
-rw-r--r--java/src/com/android/inputmethod/latin/SettingsFragment.java9
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeSwitcher.java10
-rw-r--r--java/src/com/android/inputmethod/latin/setup/SetupActivity.java13
-rw-r--r--java/src/com/android/inputmethod/research/FeedbackFragment.java2
-rw-r--r--java/src/com/android/inputmethod/research/ResearchLog.java16
-rw-r--r--java/src/com/android/inputmethod/research/ResearchLogDirectory.java14
-rw-r--r--java/src/com/android/inputmethod/research/ResearchLogger.java12
8 files changed, 50 insertions, 36 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java b/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java
index 0c050610d..7fd1bedcb 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/GesturePreviewTrail.java
@@ -108,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;
@@ -261,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/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/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/research/FeedbackFragment.java b/java/src/com/android/inputmethod/research/FeedbackFragment.java
index 39f9c87a0..8ee2d8e71 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);
}
}
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 f6dc47b0d..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;