Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26822] Android: Improved customization of Ti.UI.Android.SearchView

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionWon't Do
Resolution Date2020-06-20T00:46:38.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterRene Pot
AssigneeJoshua Quick
Created2019-02-13T15:58:29.000+0000
Updated2020-06-20T00:47:19.000+0000

Description

Expose new properties to improve the customization of Ti.UI.Android.SearchView. They are as follow: - iconSearchColor - color of the Search icon in collapsed view - iconSearchCloseColor - color of the Search Close button in expanded view - iconSearchHintColor - color of the default Search Hint icon

Comments

  1. Joshua Quick 2019-02-13

    Note that this this can easily be done via themes. For example:
       <?xml version="1.0" encoding="UTF-8"?>
       <resources>
       	<style name="MyTheme" parent="@style/Theme.AppCompat">
       		<item name="searchViewStyle">@style/MySearchViewStyle</item>
       	</style>
       	<style name="MySearchViewStyle" parent="Widget.AppCompat.SearchView">
       		<item name="searchIcon">@drawable/my_search_icon</item>
       		<item name="searchHintIcon">@drawable/my_search_hint_icon</item>
       		<item name="closeIcon">@drawable/my_close_icon</item>
       	</style>
       </resources>
       
    The above works for a SearchView displayed within a window. However, the above won't work when the SearchView is hosted within the top ActionBar and I'm not sure why at the moment. I know that Google's support library overrides the "searchViewStyle" within its ActionBar style, but that shouldn't matter since Titanium creates a SearchView via the activity's context... which means it's using activity's theme/style instead. And I've noticed that Google's own Gmail app and Docs app never themes the SearchView within the ActionBar either. Makes me wonder if they're doing something programmatically that makes it ignore the theme. This is the only issue that I'm aware of. Perhaps setting this icons programmatically "is" the only option in this case.
  2. Yordan Banev 2019-02-21

    PR: https://github.com/appcelerator/titanium_mobile/pull/10719
  3. Joshua Quick 2020-06-20

    I think we should close this ticket as "Won't Do" because: * Google does not provide an official public API to do this. Doing this via Java reflection like the current PR is doing won't be maintainable because it depends on implementation details that Google may change. * Setting the colors should be done via a theme/styles XML file. This is how Google wants this to be done. * I'd prefer that we invest our time into Ti.UI.SearchBar instead of Ti.UI.Android.SearchView for the sake of parity. The native implementation of Android's Ti.UI.SearchBar should be changed to use the AndroidX SearchView class and deprecate Ti.UI.Android.SearchView.

JSON Source