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
2fe68b96
Commit
2fe68b96
authored
13 years ago
by
Tadashi G. Takaoka
Browse files
Options
Downloads
Patches
Plain Diff
Filter non-ascii popup charcters from password keyboard
Change-Id: I10885efd317770f892165b6bb059313abf241436
parent
48dda9e0
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/Key.java
+8
-34
8 additions, 34 deletions
java/src/com/android/inputmethod/keyboard/Key.java
java/src/com/android/inputmethod/keyboard/internal/PopupCharactersParser.java
+52
-0
52 additions, 0 deletions
.../inputmethod/keyboard/internal/PopupCharactersParser.java
with
60 additions
and
34 deletions
java/src/com/android/inputmethod/keyboard/Key.java
+
8
−
34
View file @
2fe68b96
...
@@ -33,7 +33,6 @@ import com.android.inputmethod.keyboard.internal.PopupCharactersParser;
...
@@ -33,7 +33,6 @@ import com.android.inputmethod.keyboard.internal.PopupCharactersParser;
import
com.android.inputmethod.keyboard.internal.Row
;
import
com.android.inputmethod.keyboard.internal.Row
;
import
com.android.inputmethod.latin.R
;
import
com.android.inputmethod.latin.R
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -292,13 +291,18 @@ public class Key {
...
@@ -292,13 +291,18 @@ public class Key {
mY
=
y
;
mY
=
y
;
mWidth
=
keyWidth
-
mGap
;
mWidth
=
keyWidth
-
mGap
;
final
CharSequence
[]
popupCharacters
=
style
.
getTextArray
(
keyAttr
,
CharSequence
[]
popupCharacters
=
style
.
getTextArray
(
R
.
styleable
.
Keyboard_Key_popupCharacters
);
keyAttr
,
R
.
styleable
.
Keyboard_Key_popupCharacters
);
if
(
mKeyboard
.
mId
.
mPasswordInput
)
{
popupCharacters
=
PopupCharactersParser
.
filterOut
(
res
,
popupCharacters
,
PopupCharactersParser
.
NON_ASCII_FILTER
);
}
// In Arabic symbol layouts, we'd like to keep digits in popup characters regardless of
// In Arabic symbol layouts, we'd like to keep digits in popup characters regardless of
// config_digit_popup_characters_enabled.
// config_digit_popup_characters_enabled.
if
(
mKeyboard
.
mId
.
isAlphabetKeyboard
()
&&
!
res
.
getBoolean
(
if
(
mKeyboard
.
mId
.
isAlphabetKeyboard
()
&&
!
res
.
getBoolean
(
R
.
bool
.
config_digit_popup_characters_enabled
))
{
R
.
bool
.
config_digit_popup_characters_enabled
))
{
mPopupCharacters
=
filterOutDigitPopupCharacters
(
popupCharacters
);
mPopupCharacters
=
PopupCharactersParser
.
filterOut
(
res
,
popupCharacters
,
PopupCharactersParser
.
DIGIT_FILTER
);
}
else
{
}
else
{
mPopupCharacters
=
popupCharacters
;
mPopupCharacters
=
popupCharacters
;
}
}
...
@@ -402,36 +406,6 @@ public class Key {
...
@@ -402,36 +406,6 @@ public class Key {
return
(
mLabelOption
&
LABEL_OPTION_HAS_HINT_LABEL
)
!=
0
;
return
(
mLabelOption
&
LABEL_OPTION_HAS_HINT_LABEL
)
!=
0
;
}
}
private
static
boolean
isDigitPopupCharacter
(
CharSequence
label
)
{
return
label
!=
null
&&
label
.
length
()
==
1
&&
Character
.
isDigit
(
label
.
charAt
(
0
));
}
private
static
CharSequence
[]
filterOutDigitPopupCharacters
(
CharSequence
[]
popupCharacters
)
{
if
(
popupCharacters
==
null
||
popupCharacters
.
length
<
1
)
return
null
;
if
(
popupCharacters
.
length
==
1
&&
isDigitPopupCharacter
(
PopupCharactersParser
.
getLabel
(
popupCharacters
[
0
].
toString
())))
return
null
;
ArrayList
<
CharSequence
>
filtered
=
null
;
for
(
int
i
=
0
;
i
<
popupCharacters
.
length
;
i
++)
{
final
CharSequence
popupSpec
=
popupCharacters
[
i
];
if
(
isDigitPopupCharacter
(
PopupCharactersParser
.
getLabel
(
popupSpec
.
toString
())))
{
if
(
filtered
==
null
)
{
filtered
=
new
ArrayList
<
CharSequence
>();
for
(
int
j
=
0
;
j
<
i
;
j
++)
filtered
.
add
(
popupCharacters
[
j
]);
}
}
else
if
(
filtered
!=
null
)
{
filtered
.
add
(
popupSpec
);
}
}
if
(
filtered
==
null
)
return
popupCharacters
;
if
(
filtered
.
size
()
==
0
)
return
null
;
return
filtered
.
toArray
(
new
CharSequence
[
filtered
.
size
()]);
}
public
Drawable
getIcon
()
{
public
Drawable
getIcon
()
{
return
mIcon
;
return
mIcon
;
}
}
...
...
This diff is collapsed.
Click to expand it.
java/src/com/android/inputmethod/keyboard/internal/PopupCharactersParser.java
+
52
−
0
View file @
2fe68b96
...
@@ -23,6 +23,8 @@ import android.util.Log;
...
@@ -23,6 +23,8 @@ import android.util.Log;
import
com.android.inputmethod.keyboard.Keyboard
;
import
com.android.inputmethod.keyboard.Keyboard
;
import
com.android.inputmethod.latin.R
;
import
com.android.inputmethod.latin.R
;
import
java.util.ArrayList
;
/**
/**
* String parser of popupCharacters attribute of Key.
* String parser of popupCharacters attribute of Key.
* The string is comma separated texts each of which represents one popup key.
* The string is comma separated texts each of which represents one popup key.
...
@@ -182,4 +184,54 @@ public class PopupCharactersParser {
...
@@ -182,4 +184,54 @@ public class PopupCharactersParser {
super
(
message
);
super
(
message
);
}
}
}
}
public
interface
CodeFilter
{
public
boolean
shouldFilterOut
(
int
code
);
}
public
static
final
CodeFilter
DIGIT_FILTER
=
new
CodeFilter
()
{
@Override
public
boolean
shouldFilterOut
(
int
code
)
{
return
Character
.
isDigit
(
code
);
}
};
public
static
final
CodeFilter
NON_ASCII_FILTER
=
new
CodeFilter
()
{
@Override
public
boolean
shouldFilterOut
(
int
code
)
{
return
code
<
0x20
||
code
>
0x7e
;
}
};
public
static
CharSequence
[]
filterOut
(
Resources
res
,
CharSequence
[]
popupCharacters
,
CodeFilter
filter
)
{
if
(
popupCharacters
==
null
||
popupCharacters
.
length
<
1
)
{
return
null
;
}
if
(
popupCharacters
.
length
==
1
&&
filter
.
shouldFilterOut
(
getCode
(
res
,
popupCharacters
[
0
].
toString
())))
{
return
null
;
}
ArrayList
<
CharSequence
>
filtered
=
null
;
for
(
int
i
=
0
;
i
<
popupCharacters
.
length
;
i
++)
{
final
CharSequence
popupSpec
=
popupCharacters
[
i
];
if
(
filter
.
shouldFilterOut
(
getCode
(
res
,
popupSpec
.
toString
())))
{
if
(
filtered
==
null
)
{
filtered
=
new
ArrayList
<
CharSequence
>();
for
(
int
j
=
0
;
j
<
i
;
j
++)
{
filtered
.
add
(
popupCharacters
[
j
]);
}
}
}
else
if
(
filtered
!=
null
)
{
filtered
.
add
(
popupSpec
);
}
}
if
(
filtered
==
null
)
{
return
popupCharacters
;
}
if
(
filtered
.
size
()
==
0
)
{
return
null
;
}
return
filtered
.
toArray
(
new
CharSequence
[
filtered
.
size
()]);
}
}
}
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