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
4692af50
Commit
4692af50
authored
13 years ago
by
Tadashi G. Takaoka
Browse files
Options
Downloads
Patches
Plain Diff
Support multiple key preview
Bug: 4298393 Change-Id: Ibd3681f7255c85e3602e1af4ace8f8e7fce3fb06
parent
ff6ad279
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
java/src/com/android/inputmethod/keyboard/KeyboardView.java
+23
-14
23 additions, 14 deletions
java/src/com/android/inputmethod/keyboard/KeyboardView.java
java/src/com/android/inputmethod/keyboard/PointerTracker.java
+8
-0
8 additions, 0 deletions
.../src/com/android/inputmethod/keyboard/PointerTracker.java
with
31 additions
and
14 deletions
java/src/com/android/inputmethod/keyboard/KeyboardView.java
+
23
−
14
View file @
4692af50
...
...
@@ -87,8 +87,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
private
final
KeyDrawParams
mKeyDrawParams
;
// Key preview
private
final
int
mKeyPreviewLayoutId
;
private
final
KeyPreviewDrawParams
mKeyPreviewDrawParams
;
private
final
TextView
mPreviewText
;
private
boolean
mShowKeyPreviewPopup
=
true
;
private
final
int
mDelayBeforePreview
;
private
int
mDelayAfterPreview
;
...
...
@@ -139,9 +139,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
keyboardView
.
showKey
(
msg
.
arg1
,
tracker
);
break
;
case
MSG_DISMISS_KEY_PREVIEW:
if
(
keyboardView
.
mPreviewText
!=
null
)
{
keyboardView
.
mPreviewText
.
setVisibility
(
View
.
INVISIBLE
);
}
tracker
.
getKeyPreviewText
().
setVisibility
(
View
.
INVISIBLE
);
break
;
}
}
...
...
@@ -150,7 +148,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
removeMessages
(
MSG_SHOW_KEY_PREVIEW
);
final
KeyboardView
keyboardView
=
getOuterInstance
();
if
(
keyboardView
==
null
)
return
;
if
(
keyboardView
.
m
PreviewText
.
getVisibility
()
==
VISIBLE
||
delay
==
0
)
{
if
(
tracker
.
getKey
PreviewText
()
.
getVisibility
()
==
VISIBLE
||
delay
==
0
)
{
// Show right away, if it's already visible and finger is moving around
keyboardView
.
showKey
(
keyIndex
,
tracker
);
}
else
{
...
...
@@ -171,6 +169,10 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
sendMessageDelayed
(
obtainMessage
(
MSG_DISMISS_KEY_PREVIEW
,
tracker
),
delay
);
}
public
void
cancelDismissKeyPreview
(
PointerTracker
tracker
)
{
removeMessages
(
MSG_DISMISS_KEY_PREVIEW
,
tracker
);
}
public
void
cancelAllDismissKeyPreviews
()
{
removeMessages
(
MSG_DISMISS_KEY_PREVIEW
);
}
...
...
@@ -317,11 +319,8 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
mKeyDrawParams
=
new
KeyDrawParams
(
a
);
mKeyPreviewDrawParams
=
new
KeyPreviewDrawParams
(
a
,
mKeyDrawParams
);
final
int
previewLayout
=
a
.
getResourceId
(
R
.
styleable
.
KeyboardView_keyPreviewLayout
,
0
);
if
(
previewLayout
!=
0
)
{
mPreviewText
=
(
TextView
)
LayoutInflater
.
from
(
context
).
inflate
(
previewLayout
,
null
);
}
else
{
mPreviewText
=
null
;
mKeyPreviewLayoutId
=
a
.
getResourceId
(
R
.
styleable
.
KeyboardView_keyPreviewLayout
,
0
);
if
(
mKeyPreviewLayoutId
==
0
)
{
mShowKeyPreviewPopup
=
false
;
}
mBackgroundDimAmount
=
a
.
getFloat
(
R
.
styleable
.
KeyboardView_backgroundDimAmount
,
0.5f
);
...
...
@@ -730,6 +729,17 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
mDrawingHandler
.
cancelAllMessages
();
}
// Called by {@link PointerTracker} constructor to create a TextView.
@Override
public
TextView
inflateKeyPreviewText
()
{
final
Context
context
=
getContext
();
if
(
mKeyPreviewLayoutId
!=
0
)
{
return
(
TextView
)
LayoutInflater
.
from
(
context
).
inflate
(
mKeyPreviewLayoutId
,
null
);
}
else
{
return
new
TextView
(
context
);
}
}
@Override
public
void
showKeyPreview
(
int
keyIndex
,
PointerTracker
tracker
)
{
if
(
mShowKeyPreviewPopup
)
{
...
...
@@ -760,15 +770,15 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
}
// TODO: Introduce minimum duration for displaying key previews
// TODO: Display up to two key previews when the user presses two keys at the same time
private
void
showKey
(
final
int
keyIndex
,
PointerTracker
tracker
)
{
final
TextView
previewText
=
m
PreviewText
;
final
TextView
previewText
=
tracker
.
getKey
PreviewText
()
;
// If the key preview has no parent view yet, add it to the ViewGroup which can place
// key preview absolutely in SoftInputWindow.
if
(
previewText
.
getParent
()
==
null
)
{
addKeyPreview
(
previewText
);
}
mDrawingHandler
.
cancelDismissKeyPreview
(
tracker
);
final
Key
key
=
tracker
.
getKey
(
keyIndex
);
// If keyIndex is invalid or IME is already closed, we must not show key preview.
// Trying to show key preview while root window is closed causes
...
...
@@ -776,7 +786,6 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
if
(
key
==
null
)
return
;
mDrawingHandler
.
cancelAllDismissKeyPreviews
();
final
KeyPreviewDrawParams
params
=
mKeyPreviewDrawParams
;
final
int
keyDrawX
=
key
.
mX
+
key
.
mVisualInsetsLeft
;
final
int
keyDrawWidth
=
key
.
mWidth
-
key
.
mVisualInsetsLeft
-
key
.
mVisualInsetsRight
;
...
...
@@ -858,7 +867,7 @@ public class KeyboardView extends View implements PointerTracker.DrawingProxy {
}
public
void
closing
()
{
mPreviewText
.
setVisibility
(
View
.
GONE
);
PointerTracker
.
dismissAllKeyPreviews
(
);
cancelAllMessages
();
mDirtyRect
.
union
(
0
,
0
,
getWidth
(),
getHeight
());
...
...
This diff is collapsed.
Click to expand it.
java/src/com/android/inputmethod/keyboard/PointerTracker.java
+
8
−
0
View file @
4692af50
...
...
@@ -19,6 +19,7 @@ package com.android.inputmethod.keyboard;
import
android.content.Context
;
import
android.content.res.Resources
;
import
android.util.Log
;
import
android.widget.TextView
;
import
com.android.inputmethod.keyboard.internal.PointerTrackerQueue
;
import
com.android.inputmethod.latin.LatinImeLogger
;
...
...
@@ -64,6 +65,7 @@ public class PointerTracker {
public
interface
DrawingProxy
{
public
void
invalidateKey
(
Key
key
);
public
TextView
inflateKeyPreviewText
();
public
void
showKeyPreview
(
int
keyIndex
,
PointerTracker
tracker
);
public
void
cancelShowKeyPreview
(
PointerTracker
tracker
);
public
void
dismissKeyPreview
(
PointerTracker
tracker
);
...
...
@@ -100,6 +102,7 @@ public class PointerTracker {
private
Keyboard
mKeyboard
;
private
List
<
Key
>
mKeys
;
private
int
mKeyQuarterWidthSquared
;
private
final
TextView
mKeyPreviewText
;
// The position and time at which first down event occurred.
private
long
mDownTime
;
...
...
@@ -215,6 +218,11 @@ public class PointerTracker {
mListener
=
handler
.
getKeyboardActionListener
();
mDrawingProxy
=
handler
.
getDrawingProxy
();
mTimerProxy
=
handler
.
getTimerProxy
();
mKeyPreviewText
=
mDrawingProxy
.
inflateKeyPreviewText
();
}
public
TextView
getKeyPreviewText
()
{
return
mKeyPreviewText
;
}
// Returns true if keyboard has been changed by this callback.
...
...
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