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
e968ad8a
Commit
e968ad8a
authored
13 years ago
by
satok
Committed by
Android (Google) Code Review
13 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Remove the original text from SuggestionSpan"
parents
1ddb4897
064e21bb
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/compat/SuggestionSpanUtils.java
+16
-8
16 additions, 8 deletions
...c/com/android/inputmethod/compat/SuggestionSpanUtils.java
with
16 additions
and
8 deletions
java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
+
16
−
8
View file @
e968ad8a
...
@@ -23,8 +23,10 @@ import android.content.Context;
...
@@ -23,8 +23,10 @@ import android.content.Context;
import
android.text.Spannable
;
import
android.text.Spannable
;
import
android.text.SpannableString
;
import
android.text.SpannableString
;
import
android.text.Spanned
;
import
android.text.Spanned
;
import
android.text.TextUtils
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.Constructor
;
import
java.util.ArrayList
;
import
java.util.Locale
;
import
java.util.Locale
;
public
class
SuggestionSpanUtils
{
public
class
SuggestionSpanUtils
{
...
@@ -33,6 +35,7 @@ public class SuggestionSpanUtils {
...
@@ -33,6 +35,7 @@ public class SuggestionSpanUtils {
public
static
final
String
SUGGESTION_SPAN_PICKED_AFTER
=
"after"
;
public
static
final
String
SUGGESTION_SPAN_PICKED_AFTER
=
"after"
;
public
static
final
String
SUGGESTION_SPAN_PICKED_BEFORE
=
"before"
;
public
static
final
String
SUGGESTION_SPAN_PICKED_BEFORE
=
"before"
;
public
static
final
String
SUGGESTION_SPAN_PICKED_HASHCODE
=
"hashcode"
;
public
static
final
String
SUGGESTION_SPAN_PICKED_HASHCODE
=
"hashcode"
;
public
static
final
int
SUGGESTION_MAX_SIZE
=
5
;
private
static
final
Class
<?>
CLASS_SuggestionSpan
=
CompatUtils
private
static
final
Class
<?>
CLASS_SuggestionSpan
=
CompatUtils
.
getClass
(
"android.text.style.SuggestionSpan"
);
.
getClass
(
"android.text.style.SuggestionSpan"
);
...
@@ -48,8 +51,8 @@ public class SuggestionSpanUtils {
...
@@ -48,8 +51,8 @@ public class SuggestionSpanUtils {
public
static
CharSequence
getTextWithSuggestionSpan
(
Context
context
,
public
static
CharSequence
getTextWithSuggestionSpan
(
Context
context
,
CharSequence
suggestion
,
SuggestedWords
suggestedWords
)
{
CharSequence
suggestion
,
SuggestedWords
suggestedWords
)
{
if
(
CONSTRUCTOR_SuggestionSpan
==
null
||
suggestedWords
==
null
if
(
TextUtils
.
isEmpty
(
suggestion
)
||
CONSTRUCTOR_SuggestionSpan
==
null
||
suggestedWords
.
size
()
==
0
)
{
||
suggestedWords
==
null
||
suggestedWords
.
size
()
==
0
)
{
return
suggestion
;
return
suggestion
;
}
}
...
@@ -59,14 +62,19 @@ public class SuggestionSpanUtils {
...
@@ -59,14 +62,19 @@ public class SuggestionSpanUtils {
}
else
{
}
else
{
spannable
=
new
SpannableString
(
suggestion
);
spannable
=
new
SpannableString
(
suggestion
);
}
}
// TODO: Use SUGGESTIONS_MAX_SIZE instead of 5.
final
ArrayList
<
String
>
suggestionsList
=
new
ArrayList
<
String
>();
final
int
N
=
Math
.
min
(
5
,
suggestedWords
.
size
());
for
(
int
i
=
0
;
i
<
suggestedWords
.
size
();
++
i
)
{
final
String
[]
suggestionsArray
=
new
String
[
N
];
if
(
suggestionsList
.
size
()
>=
SUGGESTION_MAX_SIZE
)
{
for
(
int
i
=
0
;
i
<
N
;
++
i
)
{
break
;
suggestionsArray
[
i
]
=
suggestedWords
.
getWord
(
i
).
toString
();
}
final
CharSequence
word
=
suggestedWords
.
getWord
(
i
);
if
(!
TextUtils
.
equals
(
suggestion
,
word
))
{
suggestionsList
.
add
(
word
.
toString
());
}
}
}
final
Object
[]
args
=
final
Object
[]
args
=
{
context
,
null
,
suggestions
Array
,
0
,
{
context
,
null
,
suggestions
List
.
toArray
(
new
String
[
suggestionsList
.
size
()])
,
0
,
(
Class
<?>)
SuggestionSpanPickedNotificationReceiver
.
class
};
(
Class
<?>)
SuggestionSpanPickedNotificationReceiver
.
class
};
final
Object
ss
=
CompatUtils
.
newInstance
(
CONSTRUCTOR_SuggestionSpan
,
args
);
final
Object
ss
=
CompatUtils
.
newInstance
(
CONSTRUCTOR_SuggestionSpan
,
args
);
if
(
ss
==
null
)
{
if
(
ss
==
null
)
{
...
...
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