Remove MainLogBuffer#setSuggest()
multi-project commit with Ia98b1406fc2ee11a96893c77ea58d800fece7624 Change-Id: I8bc3d07b83dbe7d8fc56a618de07dade7f510b13main
parent
578e71e28b
commit
b094372bd6
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -237,7 +237,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");
|
||||
|
@ -247,6 +248,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) {
|
||||
mUUIDString = getUUID(prefs);
|
||||
|
@ -480,7 +482,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) {
|
||||
|
@ -503,7 +506,6 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
}
|
||||
}
|
||||
};
|
||||
mMainLogBuffer.setSuggest(mSuggest);
|
||||
}
|
||||
if (mFeedbackLogBuffer == null) {
|
||||
resetFeedbackLogging();
|
||||
|
@ -851,10 +853,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