{"id":13428493,"url":"https://github.com/Mauker1/MaterialSearchView","last_synced_at":"2025-03-16T01:32:37.814Z","repository":{"id":51324844,"uuid":"56640363","full_name":"Mauker1/MaterialSearchView","owner":"Mauker1","description":"Android Search View based on Material design guidelines.","archived":false,"fork":false,"pushed_at":"2023-02-14T22:54:45.000Z","size":497,"stargazers_count":1076,"open_issues_count":23,"forks_count":154,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-03-10T18:14:56.442Z","etag":null,"topics":["android","android-library","material","material-design","materialsearchview","materialsearchview-library"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mauker1.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-04-19T23:48:39.000Z","updated_at":"2024-12-10T11:38:54.000Z","dependencies_parsed_at":"2024-01-14T02:37:15.352Z","dependency_job_id":"cff23aeb-489d-4686-bac6-2f429ea0fe71","html_url":"https://github.com/Mauker1/MaterialSearchView","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mauker1%2FMaterialSearchView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mauker1%2FMaterialSearchView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mauker1%2FMaterialSearchView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mauker1%2FMaterialSearchView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mauker1","download_url":"https://codeload.github.com/Mauker1/MaterialSearchView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814900,"owners_count":20352037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","material","material-design","materialsearchview","materialsearchview-library"],"created_at":"2024-07-31T01:00:58.660Z","updated_at":"2025-03-16T01:32:37.439Z","avatar_url":"https://github.com/Mauker1.png","language":"Kotlin","readme":"# MaterialSearchView\nAndroid SearchView based on Material Design guidelines. The MaterialSearchView will overlay a Toolbar or ActionBar as well as display a ListView for the user to show suggested or recent searches.\n\nStable: [![Download](https://img.shields.io/badge/download-1.3.0_rc02-blue.svg)](https://bintray.com/mauker/maven/MaterialSearchView/1.3.0-rc02)\nBeta: [![Download](https://img.shields.io/badge/download-2.0.0_beta02-blue.svg)](https://bintray.com/mauker/maven/MaterialSearchView/_latestVersion)\n\n[![Build Status](https://travis-ci.org/Mauker1/MaterialSearchView.svg?branch=master)](https://travis-ci.org/Mauker1/MaterialSearchView)\n![APK size](https://img.shields.io/badge/Size-94KB-e91e63.svg)\n\n\n\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-MaterialSearchView-green.svg?style=true)](https://android-arsenal.com/details/1/3469)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/Mauker1/MaterialSearchView/blob/master/LICENSE)\n\n\u003ca href='https://ko-fi.com/A623L7G' target='_blank'\u003e\u003cimg height='36' style='border:0px;height:36px;' src='https://az743702.vo.msecnd.net/cdn/kofi1.png?v=f' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e \n\n## Download\nTo add the MaterialSearchView library to your Android Studio project, simply add the following gradle dependency:\n```java\nimplementation 'br.com.mauker.materialsearchview:materialsearchview:1.3.0-rc02'\n```\n\nThis library is supported with a min SDK of 14.\n\n**Important note:** If you're still using version 1.0.3, it's recommended to upgrade to the latest version as soon as possible. For more information, please see [this issue](https://github.com/Mauker1/MaterialSearchView/issues/7).\n\n**New version note**: MSV 2.0 is now on beta stage, if you wish to test it, get it by using:\n\n```java\nimplementation 'br.com.mauker.materialsearchview:materialsearchview:2.0.0-beta02'\n```\n\n**Version 2.0 doesn't require the Content Provider setup** and had some API changes which will be added to the documentation later on. For more details please take a look at the [V_2.0 branch](https://github.com/Mauker1/MaterialSearchView/tree/milestone/2_0).\n\n**Important note on V 2.0:** Since I'm using Coroutine Actors, which is marked as obsolete, you'll get a lint warning on each class that uses MSV, to get rid of those add this to your app `build.gradle` file:\n\n```\nkotlinOptions.freeCompilerArgs += [\n        \"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi\",\n        \"-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi\"\n]\n```\n\nOnce the Actors methods are updated, I'll update the lib as well.\n\n## Setup\n\nBefore you can use this lib, you have to implement a class named `MsvAuthority` inside the `br.com.mauker` package on your app module, and it should have a public static String variable called `CONTENT_AUTHORITY`. Give it the value you want and **don't forget** to add the same name on your manifest file. The lib will use this file to set the Content Provider authority.\n\n**Example:**\n\n**MsvAuthority.java**\n\n```java\npackage br.com.mauker;\n\npublic class MsvAuthority {\n    public static final String CONTENT_AUTHORITY = \"br.com.mauker.materialsearchview.searchhistorydatabase\";\n}\n```\n\nOr if you're using Kotlin:\n\n**MsvAuthority.kt**\n```Kotlin\npackage br.com.mauker\n\nobject MsvAuthority {\n    const val CONTENT_AUTHORITY: String = \"br.com.mauker.materialsearchview.searchhistorydatabase\"\n}\n```\n\n**AndroidManifest.xml**\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cmanifest ...\u003e\n\n    \u003capplication ... \u003e\n        \u003cprovider\n        android:name=\"br.com.mauker.materialsearchview.db.HistoryProvider\"\n        android:authorities=\"br.com.mauker.materialsearchview.searchhistorydatabase\"\n        android:exported=\"false\"\n        android:protectionLevel=\"signature\"\n        android:syncable=\"true\"/\u003e\n    \u003c/application\u003e\n\n\u003c/manifest\u003e\n```\n\n**Proguard note:** Some of you might experience some problems with Proguard deleting the authority class, to solve those problems, add the following lines on your proguard file:\n\n```\n-keep class br.com.mauker.MsvAuthority\n-keepclassmembers class br.com.mauker.** { *; }\n```\n\n## Usage\n\nTo open the search view on your app, add the following code **to the end of your layout**:\n\n```xml\n\u003cbr.com.mauker.materialsearchview.MaterialSearchView\n    android:id=\"@+id/search_view\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"/\u003e\n```    \n\nThen, inside your `Activity` get the reference:\n\n```kotlin\n// Activity:\nval searchView: MaterialSearchView = findViewById(R.id.search_view)\n```\n\n- To open the search view, simply call the `searchView.openSearch()` method.\n\n- To close the search view, call the `searchView.closeSearch()` method.\n\n- You can check if the view is open by using the `searchView.isOpen()` method.\n\n- As from Version 1.2.1 it's also possible to get the query anytime by using the `searchView.getCurrentQuery()` method.\n\n- To close the search view using the back button, put the following code on your `Activity`:\n\n```kotlin\noverride fun onBackPressed() {\n    if (searchView.isOpen) {\n        // Close the search on the back button press.\n        searchView.closeSearch()\n    } else {\n        super.onBackPressed()\n    }\n}\n```\n\nFor more examples on how to use this lib, [check the sample app code here](https://github.com/Mauker1/MaterialSearchView/blob/master/app/src/main/java/br/com/mauker/materialsearchview/app/MainActivity.kt).\n\n## Search history and suggestions\n\nYou can provide search suggestions by using the following methods:\n\n- `addSuggestions(suggestions: Array\u003cString?\u003e)`\n- `addSuggestions(suggestions: List\u003cString?\u003e)`\n\nIt's also possible to add a single suggestion using the following method:\n\n- `addSuggestion(suggestion: String?)`\n\nTo remove all the search suggestions use:\n\n- `clearSuggestions()`\n\nAnd to remove a single suggestion, use the following method:\n\n- `removeSuggestion(suggestion: String?)`\n\nThe search history is automatically handled by the view, and it can be cleared by using:\n\n- `clearHistory()`\n\nYou can also remove both by using the method below:\n\n- `clearAll()`\n\n## Modifying the suggestion list behavior\n\nThe suggestion list is based on a `ListView`, and as such you can define the behavior of the item click by using the `MaterialSearchView#setOnItemClickListener()` method.\n\nIf you want to submit the query from the selected suggestion, you can use the snippet below:\n\n```kotlin\nsearchView.setOnItemClickListener { _, _, position, _ -\u003e \n    // Do something when the suggestion list is clicked.\n    val suggestion = searchView.getSuggestionAtPosition(position)\n    searchView.setQuery(suggestion, false)\n}\n```\n\nIf you just want to set the text on the search view text field when the user selects the suggestion, change the second argument from the `searchView#setQuery()` from `true` to `false`.\n\n## Styling the View\n\nYou can change how your MaterialSearchView looks like. To achieve that effect, try to add the following lines to your styles.xml:\n\n```xml\n\u003cstyle name=\"MaterialSearchViewStyle\"\u003e\n        \u003cstyle name=\"MaterialSearchViewStyle\"\u003e\n            \u003citem name=\"searchBackground\"\u003e@color/white_ish\u003c/item\u003e\n            \u003citem name=\"searchVoiceIcon\"\u003e@drawable/ic_action_voice_search\u003c/item\u003e\n            \u003citem name=\"searchCloseIcon\"\u003e@drawable/ic_action_navigation_close\u003c/item\u003e\n            \u003citem name=\"searchBackIcon\"\u003e@drawable/ic_action_navigation_arrow_back\u003c/item\u003e\n            \u003citem name=\"searchSuggestionBackground\"\u003e@color/search_layover_bg\u003c/item\u003e\n            \u003citem name=\"historyIcon\"\u003e@drawable/ic_history_white\u003c/item\u003e\n            \u003citem name=\"suggestionIcon\"\u003e@drawable/ic_action_search_white\u003c/item\u003e\n            \u003citem name=\"listTextColor\"\u003e@color/white_ish\u003c/item\u003e\n            \u003citem name=\"searchBarHeight\"\u003e?attr/actionBarSize\u003c/item\u003e\n            \u003citem name=\"voiceHintPrompt\"\u003e@string/hint_prompt\u003c/item\u003e\n            \u003citem name=\"android:textColor\"\u003e@color/black\u003c/item\u003e\n            \u003citem name=\"android:textColorHint\"\u003e@color/gray_50\u003c/item\u003e\n            \u003citem name=\"android:hint\"\u003e@string/search_hint\u003c/item\u003e\n            \u003citem name=\"android:inputType\"\u003etextCapWords\u003c/item\u003e\n        \u003c/style\u003e\n\u003c/style\u003e\n```\n\nAlternatively, you can also style the Search View programmatically by calling the methods:\n\n- `setBackgroundColor(int color);`\n- `setTintAlpha(int alpha);`\n- `setSearchBarColor(int color);`\n- `setSearchBarHeight(int height);`\n- `setTextColor(int color);`\n- `setHintTextColor(int color);`\n- `setHint(String hint);`\n- `setVoiceHintPrompt(String voiceHint);`\n- `setVoiceIcon(DrawableRes int resourceId);`\n- `setClearIcon(DrawableRes int resourceId);`\n- `setBackIcon(DrawableRes int resourceId);`\n- `setSuggestionBackground(DrawableRes int resourceId);`\n- `setHistoryIcon(@DrawableRes int resourceId);`\n- `setSuggestionIcon(@DrawableRes int resourceId);`\n- `setListTextColor(int color);`\n\nAnd add this line on your `br.com.mauker.materialsearchview.MaterialSearchView` tag:\n\n```xml\nstyle=\"@style/MaterialSearchViewStyle\"\n```\n\nSo it'll look like:\n\n```xml\n\u003cbr.com.mauker.materialsearchview.MaterialSearchView\n    android:id=\"@+id/search_view\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    style=\"@style/MaterialSearchViewStyle\"/\u003e\n```\n\n## Interfaces\nCurrently there are two interfaces that you can use to instantiate listeners for:\n\n- `OnQueryTextListener`: Use this interface to handle QueryTextChange or QueryTextSubmit events inside the MaterialSearchView.\n- `SearchViewListener`: You can use this interface to listen and handle the open or close events of the MaterialSearchView.\n\n\n## Languages\n\nThe MaterialSearchView supports the following languages:\n\n- English (en_US);\n- Brazillian Portuguese (pt_BR);\n- Italian (Thanks to [Francesco Donzello](https://github.com/wideawake));\n- French (Thanks to [Robin](https://github.com/RobinPetit));\n- Bosnian, Croatian and Serbian (Thanks to [Luke](https://github.com/luq-0));\n- Spanish (Thanks to [Gloix](https://github.com/Gloix)).\n\n## Sample GIF\n\u003cimg src='http://i.stack.imgur.com/C5LA4.gif' width='450' height='800' /\u003e\n\n## More Info\n\nFor more use cases, and some examples, you can [check the sample app](https://github.com/Mauker1/MaterialSearchView/tree/master/app/src/main/java/br/com/mauker/materialsearchview/app).\n\n## Credits\nThis library was created by Maurício Pessoa with contributions from:\n- [Adam McNeilly](http://adammcneilly.com)\n- [Pier Betos](https://github.com/peterbetos)\n\nJCenter version was made possible with help from:\n\n- [Eric Cugota](https://github.com/tryadelion)\n\nThis project was inspired by the [MaterialSearchView](https://github.com/krishnakapil/MaterialSeachView) library by krishnakapil.\n\n## License\nThe MaterialSearchView library is available under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).\n","funding_links":["https://ko-fi.com/A623L7G'"],"categories":["Libraries","SearchView"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMauker1%2FMaterialSearchView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMauker1%2FMaterialSearchView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMauker1%2FMaterialSearchView/lists"}