Merge remote-tracking branch 'goog/master' into mergescriptpackage
commit
27da749a27
|
@ -708,28 +708,45 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
|
|||
}
|
||||
}
|
||||
|
||||
private static final String[] EVENTKEYS_LOG_SEGMENT_START = {
|
||||
"logSegmentStart", "isIncludingPrivateData"
|
||||
};
|
||||
private static final String[] EVENTKEYS_LOG_SEGMENT_END = {
|
||||
"logSegmentEnd"
|
||||
};
|
||||
/* package for test */ void publishLogBuffer(final LogBuffer logBuffer,
|
||||
final ResearchLog researchLog, final boolean isIncludingPrivateData) {
|
||||
final LogUnit openingLogUnit = new LogUnit();
|
||||
final Object[] values = {
|
||||
isIncludingPrivateData
|
||||
};
|
||||
openingLogUnit.addLogStatement(EVENTKEYS_LOG_SEGMENT_START, values,
|
||||
false /* isPotentiallyPrivate */);
|
||||
researchLog.publish(openingLogUnit, true /* isIncludingPrivateData */);
|
||||
LogUnit logUnit;
|
||||
while ((logUnit = logBuffer.shiftOut()) != null) {
|
||||
researchLog.publish(logUnit, isIncludingPrivateData);
|
||||
}
|
||||
final LogUnit closingLogUnit = new LogUnit();
|
||||
closingLogUnit.addLogStatement(EVENTKEYS_LOG_SEGMENT_END, EVENTKEYS_NULLVALUES,
|
||||
false /* isPotentiallyPrivate */);
|
||||
researchLog.publish(closingLogUnit, true /* isIncludingPrivateData */);
|
||||
}
|
||||
|
||||
private boolean hasOnlyLetters(final String word) {
|
||||
private boolean hasLetters(final String word) {
|
||||
final int length = word.length();
|
||||
for (int i = 0; i < length; i = word.offsetByCodePoints(i, 1)) {
|
||||
final int codePoint = word.codePointAt(i);
|
||||
if (!Character.isLetter(codePoint)) {
|
||||
return false;
|
||||
if (Character.isLetter(codePoint)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private void onWordComplete(final String word) {
|
||||
Log.d(TAG, "onWordComplete: " + word);
|
||||
if (word != null && word.length() > 0 && hasOnlyLetters(word)) {
|
||||
if (word != null && word.length() > 0 && hasLetters(word)) {
|
||||
mCurrentLogUnit.setWord(word);
|
||||
mStatistics.recordWordEntered();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue