Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AC-5514] Android: SearchView hintTextColor #9729

Merged
merged 10 commits into from
May 1, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
TiC.PROPERTY_ICONIFIED,
TiC.PROPERTY_ICONIFIED_BY_DEFAULT,
TiC.PROPERTY_HINT_TEXT,
TiC.PROPERTY_HINT_TEXT_COLOR,
TiC.PROPERTY_VALUE
})
// clang-format on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ public void processProperties(KrollDict props)
if (props.containsKey(TiC.PROPERTY_HINT_TEXT)) {
searchView.setQueryHint(props.getString(TiC.PROPERTY_HINT_TEXT));
}
if (props.containsKey(TiC.PROPERTY_HINT_TEXT_COLOR)) {
try {
int id = TiRHelper.getResource("id.search_src_text");
EditText text = (EditText) searchView.findViewById(id);
if (text != null) {
text.setHintTextColor(TiConvert.toColor(props, TiC.PROPERTY_HINT_TEXT_COLOR));
}
} catch (ResourceNotFoundException e) {
Log.e(TAG, "Could not find SearchView EditText");
}
}
if (props.containsKey(TiC.PROPERTY_VALUE)) {
changeEventEnabled = false;
searchView.setQuery(props.getString(TiC.PROPERTY_VALUE), false);
Expand Down Expand Up @@ -96,6 +107,16 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
}
} else if (key.equals(TiC.PROPERTY_HINT_TEXT)) {
searchView.setQueryHint((String) newValue);
} else if (key.equals(TiC.PROPERTY_HINT_TEXT_COLOR)) {
try {
int id = TiRHelper.getResource("id.search_src_text");
EditText text = (EditText) searchView.findViewById(id);
if (text != null) {
text.setHintTextColor(TiConvert.toColor((String) newValue));
}
} catch (ResourceNotFoundException e) {
Log.e(TAG, "Could not find SearchView EditText");
}
} else if (key.equals(TiC.PROPERTY_VALUE)) {
searchView.setQuery((String) newValue, false);
} else if (key.equals(TiC.PROPERTY_ICONIFIED)) {
Expand Down
8 changes: 8 additions & 0 deletions apidoc/Titanium/UI/Android/SearchView.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ properties:
type: String
default: no hint text

- name: hintTextColor
summary: Color of hint text that displays when field is empty.
description: |
Color of hint text that displays when field is empty.
type: String
default: Default Android theme's hint text color.
since: 7.1.0

- name: value
summary: Value of the search view.
description: |
Expand Down