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
75e605f7
Commit
75e605f7
authored
12 years ago
by
Jean Chalard
Committed by
Android (Google) Code Review
12 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Pull up common code in the consolidated method (A76)"
parents
1e8fb312
32f5384f
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/latin/LatinIME.java
+18
-26
18 additions, 26 deletions
java/src/com/android/inputmethod/latin/LatinIME.java
with
18 additions
and
26 deletions
java/src/com/android/inputmethod/latin/LatinIME.java
+
18
−
26
View file @
75e605f7
...
...
@@ -1675,35 +1675,36 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
final
String
typedWord
=
mWordComposer
.
getTypedWord
();
final
SuggestedWords
suggestions
;
if
(!
mWordComposer
.
isComposingWord
()
&&
!
mCurrentSettings
.
mBigramPredictionEnabled
)
{
setPunctuationSuggestions
();
return
;
}
if
(!
mWordComposer
.
isComposingWord
())
{
suggestions
=
updateBigramPredictions
();
}
else
{
suggestions
=
updateSuggestions
(
typedWord
);
// Get the word on which we should search the bigrams. If we are composing a word, it's
// whatever is *before* the half-committed word in the buffer, hence 2; if we aren't, we
// should just skip whitespace if any, so 1.
// TODO: this is slow (2-way IPC) - we should probably cache this instead.
final
CharSequence
prevWord
=
mConnection
.
getNthPreviousWord
(
mCurrentSettings
.
mWordSeparators
,
mWordComposer
.
isComposingWord
()
?
2
:
1
);
SuggestedWords
suggestedWords
=
mSuggest
.
getSuggestedWords
(
mWordComposer
,
prevWord
,
mKeyboardSwitcher
.
getKeyboard
().
getProximityInfo
(),
mCurrentSettings
.
mCorrectionEnabled
,
!
mWordComposer
.
isComposingWord
());
if
(
mWordComposer
.
isComposingWord
())
{
suggestedWords
=
maybeRetrieveOlderSuggestions
(
typedWord
,
suggestedWords
);
}
if
(
null
!=
suggest
ion
s
&&
suggest
ion
s
.
size
()
>
0
)
{
showSuggestions
(
suggest
ion
s
,
typedWord
);
if
(
null
!=
suggest
edWord
s
&&
suggest
edWord
s
.
size
()
>
0
)
{
showSuggestions
(
suggest
edWord
s
,
typedWord
);
}
else
{
clearSuggestions
();
}
}
private
SuggestedWords
updateSuggestions
(
final
CharSequence
typedWord
)
{
// TODO: May need a better way of retrieving previous word
final
CharSequence
prevWord
=
mConnection
.
getNthPreviousWord
(
mCurrentSettings
.
mWordSeparators
,
2
);
// getSuggestedWords handles gracefully a null value of prevWord
final
SuggestedWords
suggestedWords
=
mSuggest
.
getSuggestedWords
(
mWordComposer
,
prevWord
,
mKeyboardSwitcher
.
getKeyboard
().
getProximityInfo
(),
// !mWordComposer.isComposingWord() is known to be false
mCurrentSettings
.
mCorrectionEnabled
,
!
mWordComposer
.
isComposingWord
());
private
SuggestedWords
maybeRetrieveOlderSuggestions
(
final
CharSequence
typedWord
,
final
SuggestedWords
suggestedWords
)
{
// TODO: consolidate this into getSuggestedWords
// Basically, we update the suggestion strip only when suggestion count > 1. However,
// there is an exception: We update the suggestion strip whenever typed word's length
// is 1 or typed word is found in dictionary, regardless of suggestion count. Actually,
...
...
@@ -1891,15 +1892,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
separatorCode
,
prevWord
);
}
private
SuggestedWords
updateBigramPredictions
()
{
final
CharSequence
prevWord
=
mConnection
.
getNthPreviousWord
(
mCurrentSettings
.
mWordSeparators
,
1
);
return
mSuggest
.
getSuggestedWords
(
mWordComposer
,
prevWord
,
mKeyboardSwitcher
.
getKeyboard
().
getProximityInfo
(),
// !mWordComposer.isComposingWord() is known to be true
mCurrentSettings
.
mCorrectionEnabled
,
!
mWordComposer
.
isComposingWord
());
}
public
void
setPunctuationSuggestions
()
{
if
(
mCurrentSettings
.
mBigramPredictionEnabled
)
{
clearSuggestions
();
...
...
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