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
0d212235
Commit
0d212235
authored
11 years ago
by
Jean Chalard
Committed by
Android (Google) Code Review
11 years ago
Browse files
Options
Downloads
Plain Diff
Merge "[IL44] Some factorization"
parents
c197b9ed
69e7a0d2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
java/src/com/android/inputmethod/latin/LatinIME.java
+62
-26
62 additions, 26 deletions
java/src/com/android/inputmethod/latin/LatinIME.java
java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+1
-1
1 addition, 1 deletion
.../com/android/inputmethod/latin/inputlogic/InputLogic.java
with
63 additions
and
27 deletions
java/src/com/android/inputmethod/latin/LatinIME.java
+
62
−
26
View file @
0d212235
...
...
@@ -1305,13 +1305,15 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private
static
final
int
MSG_UPDATE_GESTURE_PREVIEW_AND_SUGGESTION_STRIP
=
1
;
private
static
final
int
MSG_GET_SUGGESTED_WORDS
=
2
;
// Called on the InputUpdater thread by the Handler code.
@Override
public
boolean
handleMessage
(
final
Message
msg
)
{
// TODO: straighten message passing - we don't need two kinds of messages calling
// each other.
switch
(
msg
.
what
)
{
case
MSG_UPDATE_GESTURE_PREVIEW_AND_SUGGESTION_STRIP:
updateBatchInput
((
InputPointers
)
msg
.
obj
,
msg
.
arg2
/* sequenceNumber */
);
updateBatchInput
((
InputPointers
)
msg
.
obj
,
msg
.
arg2
/* sequenceNumber */
,
false
/* forEnd */
);
break
;
case
MSG_GET_SUGGESTED_WORDS:
mLatinIme
.
getSuggestedWords
(
msg
.
arg1
/* sessionId */
,
...
...
@@ -1321,7 +1323,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
return
true
;
}
//
Run
on the UI thread.
//
Called
on the UI thread
by LatinIME
.
public
void
onStartBatchInput
()
{
synchronized
(
mLock
)
{
mHandler
.
removeMessages
(
MSG_UPDATE_GESTURE_PREVIEW_AND_SUGGESTION_STRIP
);
...
...
@@ -1329,26 +1331,54 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
}
// Run on the Handler thread.
private
void
updateBatchInput
(
final
InputPointers
batchPointers
,
final
int
sequenceNumber
)
{
/**
* Fetch suggestions corresponding to an update of a batch input.
* @param batchPointers the updated pointers, including the part that was passed last time.
* @param sequenceNumber the sequence number associated with this batch input.
* @param forEnd true if this is the end of a batch input, false if it's an update.
*/
// This method can be called from any thread and will see to it that the correct threads
// are used for parts that require it. This method will send a message to the
// InputUpdater thread to pull suggestions, and get the inlined callback to get called
// on the InputUpdater thread. The callback will then proceed to send a message to the
// UI handler in LatinIME so that showing suggestions can be done on the UI thread.
private
void
updateBatchInput
(
final
InputPointers
batchPointers
,
final
int
sequenceNumber
,
final
boolean
forEnd
)
{
synchronized
(
mLock
)
{
if
(!
mInBatchInput
)
{
// Batch input has ended or canceled while the message was being delivered.
return
;
}
getSuggestedWordsGestureLocked
(
batchPointers
,
sequenceNumber
,
new
OnGetSuggestedWordsCallback
()
{
@Override
public
void
onGetSuggestedWords
(
final
SuggestedWords
suggestedWords
)
{
mLatinIme
.
mHandler
.
showGesturePreviewAndSuggestionStrip
(
suggestedWords
,
false
/* dismissGestureFloatingPreviewText */
);
}
});
@Override
public
void
onGetSuggestedWords
(
final
SuggestedWords
suggestedWords
)
{
// We're now inside the callback. This always runs on the
// InputUpdater thread, no matter what thread updateBatchInput
// was called on.
mLatinIme
.
mHandler
.
showGesturePreviewAndSuggestionStrip
(
suggestedWords
,
forEnd
/* dismissGestureFloatingPreviewText */
);
if
(
forEnd
)
{
mInBatchInput
=
false
;
// The following call schedules onEndBatchInputAsyncInternal
// to be called on the UI thread.
mLatinIme
.
mHandler
.
onEndBatchInput
(
suggestedWords
);
}
}
});
}
}
// Run on the UI thread.
/**
* Update a batch input.
*
* This fetches suggestions and updates the suggestion strip and the floating text preview.
*
* @param batchPointers the updated batch pointers.
* @param sequenceNumber the sequence number associated with this batch input.
*/
// Called on the UI thread by LatinIME.
public
void
onUpdateBatchInput
(
final
InputPointers
batchPointers
,
final
int
sequenceNumber
)
{
if
(
mHandler
.
hasMessages
(
MSG_UPDATE_GESTURE_PREVIEW_AND_SUGGESTION_STRIP
))
{
...
...
@@ -1358,26 +1388,32 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
sequenceNumber
/* arg2 */
,
batchPointers
/* obj */
).
sendToTarget
();
}
/**
* Cancel a batch input.
*
* Note that as opposed to onEndBatchInput, we do the UI side of this immediately on the
* same thread, rather than get this to call a method in LatinIME. This is because
* cancelling a batch input does not necessitate the long operation of pulling suggestions.
*/
// Called on the UI thread by LatinIME.
public
void
onCancelBatchInput
()
{
synchronized
(
mLock
)
{
mInBatchInput
=
false
;
}
}
// Run on the UI thread.
public
void
onEndBatchInput
(
final
InputPointers
batchPointers
)
{
synchronized
(
mLock
)
{
getSuggestedWordsGestureLocked
(
batchPointers
,
SuggestedWords
.
NOT_A_SEQUENCE_NUMBER
,
new
OnGetSuggestedWordsCallback
()
{
@Override
public
void
onGetSuggestedWords
(
final
SuggestedWords
suggestedWords
)
{
mInBatchInput
=
false
;
mLatinIme
.
mHandler
.
showGesturePreviewAndSuggestionStrip
(
suggestedWords
,
true
/* dismissGestureFloatingPreviewText */
);
mLatinIme
.
mHandler
.
onEndBatchInput
(
suggestedWords
);
}
});
}
/**
* Finish a batch input.
*
* This fetches suggestions, updates the suggestion strip and commits the first suggestion.
* It also dismisses the floating text preview.
*
* @param batchPointers the updated batch pointers.
* @param sequenceNumber the sequence number associated with this batch input.
*/
// Called on the UI thread by LatinIME.
public
void
onEndBatchInput
(
final
InputPointers
batchPointers
,
final
int
sequenceNumber
)
{
updateBatchInput
(
batchPointers
,
sequenceNumber
,
true
/* forEnd */
);
}
// {@link LatinIME#getSuggestedWords(int)} method calls with same session id have to
...
...
This diff is collapsed.
Click to expand it.
java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+
1
−
1
View file @
0d212235
...
...
@@ -402,7 +402,7 @@ public final class InputLogic {
final
InputPointers
batchPointers
,
// TODO: remove these arguments
final
LatinIME
.
InputUpdater
inputUpdater
)
{
inputUpdater
.
onEndBatchInput
(
batchPointers
);
inputUpdater
.
onEndBatchInput
(
batchPointers
,
mAutoCommitSequenceNumber
);
}
// TODO: remove these arguments
...
...
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