arimorty / floatingsearchview

A search view that implements a floating search bar also known as persistent search
https://github.com/arimorty/floatingsearchview/blob/master/README.md
Apache License 2.0
3.54k stars 668 forks source link

didnt allow paste option when search field is empty #173

Closed furq closed 7 years ago

furq commented 7 years ago

when you click on the search field when it's empty it doesn't show a paste option, but once you entered any keyword and tap the search field it will show paste and copy option then.

Kuanghusing commented 7 years ago

I have the same problem, have you solved this issue?

shifatul-i commented 7 years ago

Yap, paste is not showing up on tap and hold.

rendecano commented 7 years ago

Hi,

Not sure what would be the side effect of my change, but this is how I did it..

Remove the following line from search_query_section.xml, SearchInputView:

android:longClickable="false"

Hope this helps.

Ren

arimorty commented 7 years ago

Thanks everyone, good catch. There appears no reason for android:longClickable="false" so @rendecano 's solution is correct. Fix will be on maven in the coming weeks.

Regards, Ari

drjunior commented 7 years ago

Hei guys, there is one reason for that "longClickable=false" -> https://github.com/arimorty/floatingsearchview/issues/87

arimorty commented 7 years ago

Hey @drjunior thanks so much for reminding me what this was for to begin with. So, if we remove longClickable=false would issue #87 be reintroduced?

drjunior commented 7 years ago

yes.

yusufozcan commented 7 years ago

Finally I solved this problem. Don't add this library as dependency. Instead, download source files and add new library module to your project. Then copy all java and resource files to your library's corresponding folders. So you will have your own library to change something. Findinit() function in SearchInputView.java file. And change it like this:

  private void init() {
        this.setTextIsSelectable(true); //This is the key point. 
        setOnKeyListener(mOnKeyListener);
    }

Maybe there is another way to override this method. If you can, override and add setTextIsSelectable(true).

Or, wait until owner of the library do this. 😄 @arimorty @drjunior @rendecano @ThunderRoid @Kuanghusing @furq

EDÄ°T: I found another trick. This time you can add library as dependency. Then in your Activity or fragment (wherever you use this view), get a referans to SearchInputView with findViewById() method and then use setTextIsSelectable(true) on it like below.

//This is search view.
mSearchView = (FloatingSearchView) view.findViewById(R.id.floating_search_view);

//this is EditText in the search view. (id:search_bar_text, don't change this.)
SearchInputView searchInputView= (SearchInputView) mSearchView.findViewById(R.id.search_bar_text); 

searchInputView.setTextIsSelectable(true);
//Now you can paste.
arimorty commented 7 years ago

@drjunior the next release 2.0.4 contains a new fix for issue #87 that also allows for long clicks. I would recommend to first make sure that the fix works for you, because I wasn't able to reproduce it.

As always, thanks for contributing. Ari