Merge "Remove MainLogBuffer#setSuggest()"
commit
788dc55662
|
@ -428,7 +428,7 @@ public final class LatinIME extends InputMethodService implements KeyboardAction
|
|||
initSuggest();
|
||||
|
||||
if (ProductionFlag.IS_EXPERIMENTAL) {
|
||||
ResearchLogger.getInstance().init(this, mKeyboardSwitcher);
|
||||
ResearchLogger.getInstance().init(this, mKeyboardSwitcher, mSuggest);
|
||||
}
|
||||
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
|
||||
// method.
|
||||
private Suggest mSuggest;
|
||||
private final Suggest mSuggest;
|
||||
@UsedForTesting
|
||||
private Dictionary mDictionaryForTesting;
|
||||
private boolean mIsStopping = false;
|
||||
|
@ -78,13 +78,11 @@ public abstract class MainLogBuffer extends FixedLogBuffer {
|
|||
// after a sample is taken.
|
||||
/* 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);
|
||||
mNumWordsBetweenNGrams = wordsBetweenSamples;
|
||||
mNumWordsUntilSafeToSample = DEBUG ? 0 : numInitialWordsToIgnore;
|
||||
}
|
||||
|
||||
public void setSuggest(final Suggest suggest) {
|
||||
mSuggest = suggest;
|
||||
}
|
||||
|
||||
|
|
|
@ -235,7 +235,8 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
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;
|
||||
if (latinIME == null) {
|
||||
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.");
|
||||
}
|
||||
}
|
||||
mSuggest = suggest;
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(latinIME);
|
||||
if (prefs != null) {
|
||||
if (!prefs.contains(PREF_USABILITY_STUDY_MODE)) {
|
||||
|
@ -479,7 +481,8 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
if (mMainLogBuffer == null) {
|
||||
mMainResearchLog = new ResearchLog(createLogFile(mFilesDir), mLatinIME);
|
||||
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
|
||||
protected void publish(final ArrayList<LogUnit> logUnits,
|
||||
boolean canIncludePrivateData) {
|
||||
|
@ -502,7 +505,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
}
|
||||
}
|
||||
};
|
||||
mMainLogBuffer.setSuggest(mSuggest);
|
||||
}
|
||||
if (mFeedbackLogBuffer == null) {
|
||||
resetFeedbackLogging();
|
||||
|
@ -850,10 +852,13 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
mInFeedbackDialog = false;
|
||||
}
|
||||
|
||||
public void initSuggest(Suggest suggest) {
|
||||
public void initSuggest(final Suggest suggest) {
|
||||
mSuggest = suggest;
|
||||
// MainLogBuffer has out-of-date Suggest object. Need to close it down and create a new
|
||||
// one.
|
||||
if (mMainLogBuffer != null) {
|
||||
mMainLogBuffer.setSuggest(mSuggest);
|
||||
stop();
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue