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
ed50cf00
Commit
ed50cf00
authored
13 years ago
by
Tadashi G. Takaoka
Committed by
Android (Google) Code Review
13 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Support keyXPos/keyWidth override in <include>"
parents
566cded5
a1e370ee
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/keyboard/Keyboard.java
+38
-5
38 additions, 5 deletions
java/src/com/android/inputmethod/keyboard/Keyboard.java
with
38 additions
and
5 deletions
java/src/com/android/inputmethod/keyboard/Keyboard.java
+
38
−
5
View file @
ed50cf00
...
@@ -21,6 +21,7 @@ import android.content.res.Resources;
...
@@ -21,6 +21,7 @@ import android.content.res.Resources;
import
android.content.res.TypedArray
;
import
android.content.res.TypedArray
;
import
android.content.res.XmlResourceParser
;
import
android.content.res.XmlResourceParser
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
android.util.AttributeSet
;
import
android.util.DisplayMetrics
;
import
android.util.DisplayMetrics
;
import
android.util.Log
;
import
android.util.Log
;
import
android.util.TypedValue
;
import
android.util.TypedValue
;
...
@@ -571,7 +572,7 @@ public class Keyboard {
...
@@ -571,7 +572,7 @@ public class Keyboard {
private
final
Params
mParams
;
private
final
Params
mParams
;
/** Default width of a key in this row. */
/** Default width of a key in this row. */
p
ublic
final
float
mDefaultKeyWidth
;
p
rivate
float
mDefaultKeyWidth
;
/** Default height of a key in this row. */
/** Default height of a key in this row. */
public
final
int
mRowHeight
;
public
final
int
mRowHeight
;
...
@@ -598,6 +599,14 @@ public class Keyboard {
...
@@ -598,6 +599,14 @@ public class Keyboard {
mCurrentX
=
0.0f
;
mCurrentX
=
0.0f
;
}
}
public
float
getDefaultKeyWidth
()
{
return
mDefaultKeyWidth
;
}
public
void
setDefaultKeyWidth
(
float
defaultKeyWidth
)
{
mDefaultKeyWidth
=
defaultKeyWidth
;
}
public
void
setXPos
(
float
keyXPos
)
{
public
void
setXPos
(
float
keyXPos
)
{
mCurrentX
=
keyXPos
;
mCurrentX
=
keyXPos
;
}
}
...
@@ -638,6 +647,10 @@ public class Keyboard {
...
@@ -638,6 +647,10 @@ public class Keyboard {
return
mCurrentX
;
return
mCurrentX
;
}
}
public
float
getKeyWidth
(
TypedArray
keyAttr
)
{
return
getKeyWidth
(
keyAttr
,
mCurrentX
);
}
public
float
getKeyWidth
(
TypedArray
keyAttr
,
float
keyXPos
)
{
public
float
getKeyWidth
(
TypedArray
keyAttr
,
float
keyXPos
)
{
final
int
widthType
=
Builder
.
getEnumValue
(
keyAttr
,
final
int
widthType
=
Builder
.
getEnumValue
(
keyAttr
,
R
.
styleable
.
Keyboard_Key_keyWidth
,
KEYWIDTH_NOT_ENUM
);
R
.
styleable
.
Keyboard_Key_keyWidth
,
KEYWIDTH_NOT_ENUM
);
...
@@ -937,17 +950,33 @@ public class Keyboard {
...
@@ -937,17 +950,33 @@ public class Keyboard {
if
(
skip
)
{
if
(
skip
)
{
XmlParseUtils
.
checkEndTag
(
TAG_INCLUDE
,
parser
);
XmlParseUtils
.
checkEndTag
(
TAG_INCLUDE
,
parser
);
}
else
{
}
else
{
final
TypedArray
a
=
mResources
.
obtainAttributes
(
Xml
.
asAttributeSet
(
parser
),
final
AttributeSet
attr
=
Xml
.
asAttributeSet
(
parser
);
final
TypedArray
keyboardAttr
=
mResources
.
obtainAttributes
(
attr
,
R
.
styleable
.
Keyboard_Include
);
R
.
styleable
.
Keyboard_Include
);
final
TypedArray
keyAttr
=
mResources
.
obtainAttributes
(
attr
,
R
.
styleable
.
Keyboard_Key
);
int
keyboardLayout
=
0
;
int
keyboardLayout
=
0
;
float
savedDefaultKeyWidth
=
0
;
try
{
try
{
XmlParseUtils
.
checkAttributeExists
(
a
,
XmlParseUtils
.
checkAttributeExists
(
keyboardAttr
,
R
.
styleable
.
Keyboard_Include_keyboardLayout
,
"keyboardLayout"
,
R
.
styleable
.
Keyboard_Include_keyboardLayout
,
"keyboardLayout"
,
TAG_INCLUDE
,
parser
);
TAG_INCLUDE
,
parser
);
keyboardLayout
=
a
.
getResourceId
(
keyboardLayout
=
keyboardAttr
.
getResourceId
(
R
.
styleable
.
Keyboard_Include_keyboardLayout
,
0
);
R
.
styleable
.
Keyboard_Include_keyboardLayout
,
0
);
if
(
row
!=
null
)
{
savedDefaultKeyWidth
=
row
.
getDefaultKeyWidth
();
if
(
keyAttr
.
hasValue
(
R
.
styleable
.
Keyboard_Key_keyXPos
))
{
// Override current x coordinate.
row
.
setXPos
(
row
.
getKeyX
(
keyAttr
));
}
if
(
keyAttr
.
hasValue
(
R
.
styleable
.
Keyboard_Key_keyWidth
))
{
// Override default key width.
row
.
setDefaultKeyWidth
(
row
.
getKeyWidth
(
keyAttr
));
}
}
}
finally
{
}
finally
{
a
.
recycle
();
keyboardAttr
.
recycle
();
keyAttr
.
recycle
();
}
}
XmlParseUtils
.
checkEndTag
(
TAG_INCLUDE
,
parser
);
XmlParseUtils
.
checkEndTag
(
TAG_INCLUDE
,
parser
);
...
@@ -957,6 +986,10 @@ public class Keyboard {
...
@@ -957,6 +986,10 @@ public class Keyboard {
try
{
try
{
parseMerge
(
parserForInclude
,
row
,
skip
);
parseMerge
(
parserForInclude
,
row
,
skip
);
}
finally
{
}
finally
{
if
(
row
!=
null
)
{
// Restore default key width.
row
.
setDefaultKeyWidth
(
savedDefaultKeyWidth
);
}
parserForInclude
.
close
();
parserForInclude
.
close
();
}
}
}
}
...
...
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