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
7ca12497
Commit
7ca12497
authored
13 years ago
by
alanv
Browse files
Options
Downloads
Patches
Plain Diff
Refactored shift key spoken description into separate method.
Change-Id: I183462a68fdfd339404740fa1564f737430d73d9
parent
3feb99fa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java
+29
-21
29 additions, 21 deletions
...d/inputmethod/accessibility/KeyCodeDescriptionMapper.java
with
29 additions
and
21 deletions
java/src/com/android/inputmethod/accessibility/KeyCodeDescriptionMapper.java
+
29
−
21
View file @
7ca12497
...
...
@@ -38,12 +38,6 @@ public class KeyCodeDescriptionMapper {
// Map of key codes to spoken description resource IDs
private
final
HashMap
<
Integer
,
Integer
>
mKeyCodeMap
;
// Map of shifted key codes to spoken description resource IDs
private
final
HashMap
<
Integer
,
Integer
>
mShiftedKeyCodeMap
;
// Map of shift-locked key codes to spoken description resource IDs
private
final
HashMap
<
Integer
,
Integer
>
mShiftLockedKeyCodeMap
;
public
static
void
init
()
{
sInstance
.
initInternal
();
}
...
...
@@ -55,8 +49,6 @@ public class KeyCodeDescriptionMapper {
private
KeyCodeDescriptionMapper
()
{
mKeyLabelMap
=
new
HashMap
<
CharSequence
,
Integer
>();
mKeyCodeMap
=
new
HashMap
<
Integer
,
Integer
>();
mShiftedKeyCodeMap
=
new
HashMap
<
Integer
,
Integer
>();
mShiftLockedKeyCodeMap
=
new
HashMap
<
Integer
,
Integer
>();
}
private
void
initInternal
()
{
...
...
@@ -94,15 +86,10 @@ public class KeyCodeDescriptionMapper {
mKeyCodeMap
.
put
(
Keyboard
.
CODE_ENTER
,
R
.
string
.
spoken_description_return
);
mKeyCodeMap
.
put
(
Keyboard
.
CODE_SETTINGS
,
R
.
string
.
spoken_description_settings
);
mKeyCodeMap
.
put
(
Keyboard
.
CODE_SHIFT
,
R
.
string
.
spoken_description_shift
);
mKeyCodeMap
.
put
(
Keyboard
.
CODE_CAPSLOCK
,
R
.
string
.
spoken_description_caps_lock
);
mKeyCodeMap
.
put
(
Keyboard
.
CODE_SHORTCUT
,
R
.
string
.
spoken_description_mic
);
mKeyCodeMap
.
put
(
Keyboard
.
CODE_SWITCH_ALPHA_SYMBOL
,
R
.
string
.
spoken_description_to_symbol
);
mKeyCodeMap
.
put
(
Keyboard
.
CODE_TAB
,
R
.
string
.
spoken_description_tab
);
// Shifted versions of non-character codes defined in Keyboard
mShiftedKeyCodeMap
.
put
(
Keyboard
.
CODE_SHIFT
,
R
.
string
.
spoken_description_shift_shifted
);
// Shift-locked versions of non-character codes defined in Keyboard
mShiftLockedKeyCodeMap
.
put
(
Keyboard
.
CODE_SHIFT
,
R
.
string
.
spoken_description_caps_lock
);
}
/**
...
...
@@ -126,12 +113,18 @@ public class KeyCodeDescriptionMapper {
*/
public
CharSequence
getDescriptionForKey
(
Context
context
,
Keyboard
keyboard
,
Key
key
,
boolean
shouldObscure
)
{
if
(
key
.
mCode
==
Keyboard
.
CODE_SWITCH_ALPHA_SYMBOL
)
{
final
int
code
=
key
.
mCode
;
if
(
code
==
Keyboard
.
CODE_SWITCH_ALPHA_SYMBOL
)
{
final
CharSequence
description
=
getDescriptionForSwitchAlphaSymbol
(
context
,
keyboard
);
if
(
description
!=
null
)
return
description
;
}
if
(
code
==
Keyboard
.
CODE_SHIFT
)
{
return
getDescriptionForShiftKey
(
context
,
keyboard
);
}
if
(!
TextUtils
.
isEmpty
(
key
.
mLabel
))
{
final
String
label
=
key
.
mLabel
.
toString
().
trim
();
...
...
@@ -175,6 +168,27 @@ public class KeyCodeDescriptionMapper {
}
}
/**
* Returns a context-sensitive description of the "Shift" key.
*
* @param context The package's context.
* @param keyboard The keyboard on which the key resides.
* @return A context-sensitive description of the "Shift" key.
*/
private
CharSequence
getDescriptionForShiftKey
(
Context
context
,
Keyboard
keyboard
)
{
final
int
resId
;
if
(
keyboard
.
isShiftLocked
())
{
resId
=
R
.
string
.
spoken_description_caps_lock
;
}
else
if
(
keyboard
.
isShiftedOrShiftLocked
())
{
resId
=
R
.
string
.
spoken_description_shift_shifted
;
}
else
{
resId
=
R
.
string
.
spoken_description_shift
;
}
return
context
.
getString
(
resId
);
}
/**
* Returns a localized character sequence describing what will happen when
* the specified key is pressed based on its key code.
...
...
@@ -200,12 +214,6 @@ public class KeyCodeDescriptionMapper {
boolean
shouldObscure
)
{
final
int
code
=
key
.
mCode
;
if
(
keyboard
.
isShiftLocked
()
&&
mShiftLockedKeyCodeMap
.
containsKey
(
code
))
{
return
context
.
getString
(
mShiftLockedKeyCodeMap
.
get
(
code
));
}
else
if
(
keyboard
.
isShiftedOrShiftLocked
()
&&
mShiftedKeyCodeMap
.
containsKey
(
code
))
{
return
context
.
getString
(
mShiftedKeyCodeMap
.
get
(
code
));
}
// If the key description should be obscured, now is the time to do it.
final
boolean
isDefinedNonCtrl
=
Character
.
isDefined
(
code
)
&&
!
Character
.
isISOControl
(
code
);
if
(
shouldObscure
&&
isDefinedNonCtrl
)
{
...
...
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