Skip to content

Commit

Permalink
[AC-5514] Android: SearchView hintTextColor (#9729)
Browse files Browse the repository at this point in the history
* Android: SearchView hintTextColor

* Update SearchViewProxy.java

* Update SearchViewProxy.java

* Update SearchViewProxy.java

* Update SearchViewProxy.java
  • Loading branch information
m1ga authored and sgtcoolguy committed May 1, 2018
1 parent 7bb9fee commit 9c06e44
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
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

0 comments on commit 9c06e44

Please sign in to comment.