Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
763fd9d5
Commit
763fd9d5
authored
11 years ago
by
Kurt Partridge
Committed by
Android (Google) Code Review
11 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Fix revert of committed words"
parents
156d3930
94ef5432
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/src/com/android/inputmethod/research/ResearchLogger.java
+33
-13
33 additions, 13 deletions
.../src/com/android/inputmethod/research/ResearchLogger.java
with
33 additions
and
13 deletions
java/src/com/android/inputmethod/research/ResearchLogger.java
+
33
−
13
View file @
763fd9d5
...
...
@@ -83,6 +83,8 @@ import java.util.List;
import
java.util.Random
;
import
java.util.regex.Pattern
;
// TODO: Add a unit test for every "logging" method (i.e. that is called from the IME and calls
// enqueueEvent to record a LogStatement).
/**
* Logs the use of the LatinIME keyboard.
*
...
...
@@ -1463,21 +1465,39 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
public
static
void
latinIME_revertCommit
(
final
String
committedWord
,
final
String
originallyTypedWord
,
final
boolean
isBatchMode
,
final
String
separatorString
)
{
// TODO: Prioritize adding a unit test for this method (as it is especially complex)
// TODO: Update the UserRecording LogBuffer as well as the MainLogBuffer
final
ResearchLogger
researchLogger
=
getInstance
();
// TODO: Verify that mCurrentLogUnit has been restored and contains the reverted word.
final
LogUnit
logUnit
;
logUnit
=
researchLogger
.
mMainLogBuffer
.
peekLastLogUnit
();
if
(
originallyTypedWord
.
length
()
>
0
&&
hasLetters
(
originallyTypedWord
))
{
if
(
logUnit
!=
null
)
{
logUnit
.
setWords
(
originallyTypedWord
);
}
}
researchLogger
.
enqueueEvent
(
logUnit
!=
null
?
logUnit
:
researchLogger
.
mCurrentLogUnit
,
LOGSTATEMENT_LATINIME_REVERTCOMMIT
,
committedWord
,
originallyTypedWord
,
separatorString
);
if
(
logUnit
!=
null
)
{
logUnit
.
setContainsUserDeletions
();
//
// 1. Remove separator LogUnit
final
LogUnit
lastLogUnit
=
researchLogger
.
mMainLogBuffer
.
peekLastLogUnit
();
// Check that we're not at the beginning of input
if
(
lastLogUnit
==
null
)
return
;
// Check that we're after a separator
if
(
lastLogUnit
.
getWordsAsString
()
!=
null
)
return
;
// Remove separator
final
LogUnit
separatorLogUnit
=
researchLogger
.
mMainLogBuffer
.
unshiftIn
();
// 2. Add revert LogStatement
final
LogUnit
revertedLogUnit
=
researchLogger
.
mMainLogBuffer
.
peekLastLogUnit
();
if
(
revertedLogUnit
==
null
)
return
;
if
(!
revertedLogUnit
.
getWordsAsString
().
equals
(
scrubDigitsFromString
(
committedWord
)))
{
// Any word associated with the reverted LogUnit has already had its digits scrubbed, so
// any digits in the committedWord argument must also be scrubbed for an accurate
// comparison.
return
;
}
researchLogger
.
enqueueEvent
(
revertedLogUnit
,
LOGSTATEMENT_LATINIME_REVERTCOMMIT
,
committedWord
,
originallyTypedWord
,
separatorString
);
// 3. Update the word associated with the LogUnit
revertedLogUnit
.
setWords
(
originallyTypedWord
);
revertedLogUnit
.
setContainsUserDeletions
();
// 4. Re-add the separator LogUnit
researchLogger
.
mMainLogBuffer
.
shiftIn
(
separatorLogUnit
);
// 5. Record stats
researchLogger
.
mStatistics
.
recordRevertCommit
(
SystemClock
.
uptimeMillis
());
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment