Merge "Remove MainLogBuffer#setSuggest()"
commit
788dc55662
|
@ -428,7 +428,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
||||||
initSuggest();
|
initSuggest();
|
||||||
|
|
||||||
if (ProductionFlag.IS_EXPERIMENTAL) {
|
if (ProductionFlag.IS_EXPERIMENTAL) {
|
||||||
ResearchLogger.getInstance().init(this, mKeyboardSwitcher);
|
ResearchLogger.getInstance().init(this, mKeyboardSwitcher, mSuggest);
|
||||||
}
|
}
|
||||||
mDisplayOrientation = getResources().getConfiguration().orientation;
|
mDisplayOrientation = getResources().getConfiguration().orientation;
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
|
||||||
|
|
||||||
// TODO: Remove dependence on Suggest, and pass in Dictionary as a parameter to an appropriate
|
// TODO: Remove dependence on Suggest, and pass in Dictionary as a parameter to an appropriate
|
||||||
// method.
|
// method.
|
||||||
private Suggest mSuggest;
|
private final Suggest mSuggest;
|
||||||
@UsedForTesting
|
@UsedForTesting
|
||||||
private Dictionary mDictionaryForTesting;
|
private Dictionary mDictionaryForTesting;
|
||||||
private boolean mIsStopping = false;
|
private boolean mIsStopping = false;
|
||||||
|
@ -78,13 +78,11 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
|
||||||
// after a sample is taken.
|
// after a sample is taken.
|
||||||
/* package for test */ int mNumWordsUntilSafeToSample;
|
/* package for test */ int mNumWordsUntilSafeToSample;
|
||||||
|
|
||||||
public MainLogBuffer(final int wordsBetweenSamples, final int numInitialWordsToIgnore) {
|
public MainLogBuffer(final int wordsBetweenSamples, final int numInitialWordsToIgnore,
|
||||||
|
final Suggest suggest) {
|
||||||
super(N_GRAM_SIZE + wordsBetweenSamples);
|
super(N_GRAM_SIZE + wordsBetweenSamples);
|
||||||
mNumWordsBetweenNGrams = wordsBetweenSamples;
|
mNumWordsBetweenNGrams = wordsBetweenSamples;
|
||||||
mNumWordsUntilSafeToSample = DEBUG ? 0 : numInitialWordsToIgnore;
|
mNumWordsUntilSafeToSample = DEBUG ? 0 : numInitialWordsToIgnore;
|
||||||
}
|
|
||||||
|
|
||||||
public void setSuggest(final Suggest suggest) {
|
|
||||||
mSuggest = suggest;
|
mSuggest = suggest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,8 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
return sInstance;
|
return sInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(final LatinIME latinIME, final KeyboardSwitcher keyboardSwitcher) {
|
public void init(final LatinIME latinIME, final KeyboardSwitcher keyboardSwitcher,
|
||||||
|
final Suggest suggest) {
|
||||||
assert latinIME != null;
|
assert latinIME != null;
|
||||||
if (latinIME == null) {
|
if (latinIME == null) {
|
||||||
Log.w(TAG, "IMS is null; logging is off");
|
Log.w(TAG, "IMS is null; logging is off");
|
||||||
|
@ -245,6 +246,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
Log.w(TAG, "IME storage directory does not exist.");
|
Log.w(TAG, "IME storage directory does not exist.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mSuggest = suggest;
|
||||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(latinIME);
|
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(latinIME);
|
||||||
if (prefs != null) {
|
if (prefs != null) {
|
||||||
if (!prefs.contains(PREF_USABILITY_STUDY_MODE)) {
|
if (!prefs.contains(PREF_USABILITY_STUDY_MODE)) {
|
||||||
|
@ -479,7 +481,8 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
if (mMainLogBuffer == null) {
|
if (mMainLogBuffer == null) {
|
||||||
mMainResearchLog = new ResearchLog(createLogFile(mFilesDir), mLatinIME);
|
mMainResearchLog = new ResearchLog(createLogFile(mFilesDir), mLatinIME);
|
||||||
final int numWordsToIgnore = new Random().nextInt(NUMBER_OF_WORDS_BETWEEN_SAMPLES + 1);
|
final int numWordsToIgnore = new Random().nextInt(NUMBER_OF_WORDS_BETWEEN_SAMPLES + 1);
|
||||||
mMainLogBuffer = new MainLogBuffer(NUMBER_OF_WORDS_BETWEEN_SAMPLES, numWordsToIgnore) {
|
mMainLogBuffer = new MainLogBuffer(NUMBER_OF_WORDS_BETWEEN_SAMPLES, numWordsToIgnore,
|
||||||
|
mSuggest) {
|
||||||
@Override
|
@Override
|
||||||
protected void publish(final ArrayList<LogUnit> logUnits,
|
protected void publish(final ArrayList<LogUnit> logUnits,
|
||||||
boolean canIncludePrivateData) {
|
boolean canIncludePrivateData) {
|
||||||
|
@ -502,7 +505,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
mMainLogBuffer.setSuggest(mSuggest);
|
|
||||||
}
|
}
|
||||||
if (mFeedbackLogBuffer == null) {
|
if (mFeedbackLogBuffer == null) {
|
||||||
resetFeedbackLogging();
|
resetFeedbackLogging();
|
||||||
|
@ -850,10 +852,13 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
||||||
mInFeedbackDialog = false;
|
mInFeedbackDialog = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initSuggest(Suggest suggest) {
|
public void initSuggest(final Suggest suggest) {
|
||||||
mSuggest = suggest;
|
mSuggest = suggest;
|
||||||
|
// MainLogBuffer has out-of-date Suggest object. Need to close it down and create a new
|
||||||
|
// one.
|
||||||
if (mMainLogBuffer != null) {
|
if (mMainLogBuffer != null) {
|
||||||
mMainLogBuffer.setSuggest(mSuggest);
|
stop();
|
||||||
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue