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

Request (Style Programically) #11

Open
rgocal opened this issue Aug 31, 2020 · 51 comments
Open

Request (Style Programically) #11

rgocal opened this issue Aug 31, 2020 · 51 comments

Comments

@rgocal
Copy link

rgocal commented Aug 31, 2020

Setting a style via xml doesn't really help in an app where the gui dynamically changes based on colors. I would enjoy the ability to tint the search icon and text via code.

@kojofosu
Copy link

@rgocal , you can check my pull request that gives you the ability to change the search icon color . Check it out at #16

@rgocal
Copy link
Author

rgocal commented May 18, 2021

Sweet

@kojofosu
Copy link

let me know when you have issues. Since it has not been merged with the upstream branch, you may need to go to jitpack to get my build

@rgocal
Copy link
Author

rgocal commented May 18, 2021

Alright, il give this a go sometime later. Working on a main project atm

@ryust
Copy link

ryust commented Jul 19, 2021

How do we include your build in a project? The documentation in your github still points to this project instead. What specifically is the Gradle implementation/api syntax for your build in jitpack?

@kojofosu
Copy link

@ryust use this build implementation 'com.github.kojofosu:MultiSearchView:0.4'

i updated my README, you can check it out at https://github.com/kojofosu/MultiSearchView

@ryust
Copy link

ryust commented Jul 19, 2021

Thanks for the update. Unfortunately, I wasn't able to get things to work. It would be sooooooooo much simpler if there was a getter method on the EditText so that I can easily change items programmatically (like hint) instead of messing around with XML styles and trying to hook it all together when using multiple 3rd party libraries.

@kojofosu
Copy link

@ryust your request seems to be on the edittext itself rather than the icon ..am I right? If yes, i think i can work on that for you

@ryust
Copy link

ryust commented Jul 19, 2021 via email

@ryust
Copy link

ryust commented Jul 21, 2021

@ryust your request seems to be on the edittext itself rather than the icon ..am I right? If yes, i think i can work on that for you

Any idea when you could get something working? If awhile, then I'll look at other search libraries. This one looked good, but it's very inflexible in customization... I just can't get the styles XML method to work in my project.

@kojofosu
Copy link

kojofosu commented Jul 21, 2021 via email

@ryust
Copy link

ryust commented Jul 21, 2021

Friday will work. Thanks!

@kojofosu
Copy link

@ryust I've added getter and setter method to change search hint...will have time to make the editext itself accessible. Are there any other customizations you would like me to prioritize?

@ryust
Copy link

ryust commented Jul 22, 2021

Thanks! The hint was the most important attribute, but having complete control of the EditText is ideal. I'll work with what you've done.

@kojofosu
Copy link

@ryust alright, let me know if there are any issues. And to change the hint, you will need to remove the line that sets the "style" for the search view in the xml

@ryust
Copy link

ryust commented Jul 22, 2021

Well.... that's the core of my problem... I don't use XML layouts and create UI views programmatically. So if I have to mess with styles and XML, then I'm back to my original problem... I won't be able to use what you've done.

@kojofosu
Copy link

@ryust you don't need xml for that. you can do everything programmatically now. Just try it and let me know how it goes

@ryust
Copy link

ryust commented Jul 23, 2021

OK, I got the hint to work and that works well, but have a couple other issues with the new library:

  1. I wanted change the icon color programmatically, but it appears that the setSearchIconColor expects an argument of a color resource... I want to use a Color directly instead.

  2. When creating multiple search items, the length of each is much wider than the original library... to the point that you can't see multiple items at the same time in the search.

@kojofosu
Copy link

kojofosu commented Jul 23, 2021 via email

@ryust
Copy link

ryust commented Jul 26, 2021

Great! And I also need the ability to tint the hint for dark mode colors. :)

@kojofosu
Copy link

alright

@kojofosu
Copy link

@ryust kindly check version 0.6

@ryust
Copy link

ryust commented Jul 27, 2021

That version is not found. Gradle can't find it.

@kojofosu
Copy link

try again..Jitpack didn't finish building at that time..my bad @ryust

@ryust
Copy link

ryust commented Jul 27, 2021

I'm about to give up on the library. Now creating MultiSearchView programmatically (as I've done before) results in a NPE:

java.lang.NullPointerException
at com.iammert.library.ui.multisearchviewlib.MultiSearchView.(MultiSearchView.kt:58)
at com.iammert.library.ui.multisearchviewlib.MultiSearchView.(MultiSearchView.kt:14)
at com.iammert.library.ui.multisearchviewlib.MultiSearchView.(Unknown Source:6)

@kojofosu
Copy link

@ryust i apologize once again. These were quick fixes and i didnt really test for the nullpointer exception. But that has been fixed in 0.7 now.

@ryust
Copy link

ryust commented Jul 27, 2021

android.content.res.Resources$NotFoundException: Resource ID #0xff43a047
    at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:215)
    at android.content.res.Resources.getColorStateList(Resources.java:1020)
    at androidx.core.content.res.ResourcesCompat.getColorStateList(ResourcesCompat.java:195)
    at androidx.core.content.ContextCompat.getColorStateList(ContextCompat.java:519)
    at androidx.appcompat.content.res.AppCompatResources.getColorStateList(AppCompatResources.java:48)
    at com.iammert.library.ui.multisearchviewlib.MultiSearchView.setSearchIconColor(MultiSearchView.kt:85)

@ryust
Copy link

ryust commented Jul 27, 2021

And the width of the search items still take up the full width of the parent view unlike the original library so you can't really see more than one search item at a time.

@ryust
Copy link

ryust commented Jul 27, 2021

setHintColor(Integer value)

What exactly is Integer? Resource id? Color int?

@kojofosu
Copy link

android.content.res.Resources$NotFoundException: Resource ID #0xff43a047
    at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:215)
    at android.content.res.Resources.getColorStateList(Resources.java:1020)
    at androidx.core.content.res.ResourcesCompat.getColorStateList(ResourcesCompat.java:195)
    at androidx.core.content.ContextCompat.getColorStateList(ContextCompat.java:519)
    at androidx.appcompat.content.res.AppCompatResources.getColorStateList(AppCompatResources.java:48)
    at com.iammert.library.ui.multisearchviewlib.MultiSearchView.setSearchIconColor(MultiSearchView.kt:85)

how are you setting the color?

@kojofosu
Copy link

And the width of the search items still take up the full width of the parent view unlike the original library so you can't really see more than one search item at a time.

i am not able to replicate this issue ... that's why i havent been able to fix it.. My search results do not take up the whole widht... could you tell me what your hint says and also how long it is

@kojofosu
Copy link

setHintColor(Integer value)

What exactly is Integer? Resource id? Color int?

resource id...but the is also another method to set the color using color string . e.g. "#FFFFFF" for white

@ryust
Copy link

ryust commented Jul 27, 2021

The hint is long, but I didn't realize it would expand all the search items... kinda pointless then to allow a hint change if only realistically limited to something small like "Search".

There is only one setHintColor method which requires an Integer. The other method using a string is for setIconColor.

This is really a nice search implementation, but it appears the original design was more of a showcase than a library for flexibility and customization. I'm really reevaluating using something else. This shouldn't be so difficult for such a small library.

@kojofosu
Copy link

alright, im doing my best here...sorry if it doesn't meet your expectations....but i am not writing the library from scratch ...only adding to the already existing working product...

I also didnt add the hint color using a string because you didnt request for it ..and i was rushing trying to get what you requested for as quick as possible for you to continue what you are working on

@ryust
Copy link

ryust commented Jul 27, 2021

I appreciate your efforts... no blame towards you. It just appears the library was never designed to be customized like other libraries are. If there was getter methods for the underlying components, then that would provide the ultimate flexibility without you having to keep adding API changes.

@ryust
Copy link

ryust commented Jul 27, 2021

I'm replacing the long hint with a Toast message to explain what the search is for which bypasses the long hint causing the bigger search items. If you can get both the icon and hint colors changed via a Color int, then I can implement the library. Thanks for all the effort you've done.

@kojofosu
Copy link

for clarity, could you send me a code snippet of how you would want to set the color using the color int @ryust

@ryust
Copy link

ryust commented Jul 27, 2021

setHintColor(int colorInt);
setIconColor(int colorInt);

@kojofosu
Copy link

setHintColor(int colorInt);
setIconColor(int colorInt);

no, not that. Not the method's construction... but the implementation. How you are setting it not how you want me to construct it... i dont know if i am making sense. I want to know how your input parameter . A snippet of that.

@ryust
Copy link

ryust commented Jul 27, 2021

MultiSearchView view = new MultiSearchView(context);
int colorInt = Color.parseColor("#fff");
view.setHintColor(colorInt);
view.setIconColor(colorInt);

@kojofosu
Copy link

Ok ..i see . But you could just pass the color string i.e "#fff". It will be handled from when using the setHintColor(String colorString);
So you could put that in a variable say

String baseColor = "#FFFFFF";
view.setHintColor(baseColor);
view.setIconColor(baseColor);

.Does that work well for you or you still insist to use it like how you've stated above?

@ryust
Copy link

ryust commented Jul 27, 2021

I'm fine with the way it is. Thanks again.

@kojofosu
Copy link

alright then kindly check v0.8.. hopefully there are no errors

@ryust
Copy link

ryust commented Jul 27, 2021

v0.8 is crashing on startup... v0.7 was working fine. I am not setting hint or icon colors.

android.content.res.Resources$NotFoundException: Resource ID #0x61000000
    at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:215)
    at android.content.res.Resources.getColorStateList(Resources.java:1020)
    at androidx.core.content.res.ResourcesCompat.getColorStateList(ResourcesCompat.java:195)
    at androidx.core.content.ContextCompat.getColorStateList(ContextCompat.java:519)
    at androidx.appcompat.content.res.AppCompatResources.getColorStateList(AppCompatResources.java:48)
    at com.iammert.library.ui.multisearchviewlib.MultiSearchView.setHintColor(MultiSearchView.kt:84)

@ryust
Copy link

ryust commented Jul 27, 2021

Correction... I am setting hint color, but not icon color. The stack trace starts with the setHintColor using a Color int.

@ryust
Copy link

ryust commented Jul 27, 2021

Color setting really should be similar to TextView... setTextColor(int colorInt), setTextColor(ColorStateList colorList, and setTextAppearance(int resId)

Developers will not know what the int should be for setHintColor and will likely do as accustomed with other widgets... like TextView... by supplying a color int to setHintColor.

@kojofosu
Copy link

v0.8 is crashing on startup... v0.7 was working fine. I am not setting hint or icon colors.

android.content.res.Resources$NotFoundException: Resource ID #0x61000000
    at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:215)
    at android.content.res.Resources.getColorStateList(Resources.java:1020)
    at androidx.core.content.res.ResourcesCompat.getColorStateList(ResourcesCompat.java:195)
    at androidx.core.content.ContextCompat.getColorStateList(ContextCompat.java:519)
    at androidx.appcompat.content.res.AppCompatResources.getColorStateList(AppCompatResources.java:48)
    at com.iammert.library.ui.multisearchviewlib.MultiSearchView.setHintColor(MultiSearchView.kt:84)

The int there is for resource id. e.g R.color.colorAccent

@kojofosu
Copy link

Color setting really should be similar to TextView... setTextColor(int colorInt), setTextColor(ColorStateList colorList, and setTextAppearance(int resId)

Developers will not know what the int should be for setHintColor and will likely do as accustomed with other widgets... like TextView... by supplying a color int to setHintColor.

okay..for the next update, i will build a snapshot for you ...so you test and give feedback before i create a release tag for it

@kojofosu
Copy link

@ryust implement this in your gradle implementation 'com.github.kojofosu:MultiSearchView:stable-SNAPSHOT'.

If all your requirements are met concerning colors, then i create a release tag

@ryust
Copy link

ryust commented Jul 28, 2021

That's fine... I got around the issue by converting the color int into a string and then using the existing method with the string argument.

@kojofosu
Copy link

okay ..but then i made your request ..so if you want to check it out . But i doubt you have time to test the snapshot out so i'll just put that in a new release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants