iammert / MultiSearchView

Yet another built-in animated search view for Android.
1.22k stars 86 forks source link

Request (Style Programically) #11

Open rgocal opened 4 years ago

rgocal commented 4 years ago

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 commented 3 years ago

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

rgocal commented 3 years ago

Sweet

kojofosu commented 3 years ago

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 commented 3 years ago

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

ryust commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

Yes, exactly. The original post request was to set styles programmatically… regardless of the widget. So getter methods is the easiest way to access underlying components so developers have the most flexibility to modify the widgets via code (not XML). I’m surprised the original library didn’t have it, but apparently that developer has abandoned the project. Thanks for taking it over!

On Jul 19, 2021, at 8:56 AM, Kojo Fosu Bempa Edue @.***> wrote:

@ryust https://github.com/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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/iammert/MultiSearchView/issues/11#issuecomment-882568679, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACGR4SXYMU4QZ5LQOM7KNLTYQVHHANCNFSM4QP6IQXQ.

ryust commented 3 years ago

@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 commented 3 years ago

Will Friday be too far out for you? Currently wrapping up on another library I'm building .

On Wed, 21 Jul 2021, 2:22 pm Ron Yust, @.***> wrote:

@ryust https://github.com/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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/iammert/MultiSearchView/issues/11#issuecomment-884230119, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE2ERLWYZDDQDF7OIN6CU3LTY3JY7ANCNFSM4QP6IQXQ .

ryust commented 3 years ago

Friday will work. Thanks!

kojofosu commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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 commented 3 years ago

Alright. I'll look into that for you !

On Fri, 23 Jul 2021, 8:50 pm Ron Yust, @.***> wrote:

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.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/iammert/MultiSearchView/issues/11#issuecomment-885907001, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE2ERLTBC4LYKUWFFKM7ZU3TZHI2RANCNFSM4QP6IQXQ .

ryust commented 3 years ago

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

kojofosu commented 3 years ago

alright

kojofosu commented 3 years ago

@ryust kindly check version 0.6

ryust commented 3 years ago

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

kojofosu commented 3 years ago

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

ryust commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago
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 commented 3 years ago

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 commented 3 years ago

setHintColor(Integer value)

What exactly is Integer? Resource id? Color int?

kojofosu commented 3 years ago
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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

ryust commented 3 years ago

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

kojofosu commented 3 years ago

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 commented 3 years ago

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

kojofosu commented 3 years ago

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 commented 3 years ago

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

kojofosu commented 3 years ago

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

ryust commented 3 years ago

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 commented 3 years ago

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

ryust commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

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.