• Stars
    star
    2,006
  • Rank 23,087 (Top 0.5 %)
  • Language
    Java
  • Created over 9 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A clone of the Google Now/Maps/Play persistent search bar

This project is deprecated

It's not been maintained for well over half a year and is formally discontinued. There are better alternatives now, such as SearchView and FloatingSearchView

Android Persistent Search Library

A library that implements the persistent search bar seen on apps such as Google Now, Google Maps and Google Play

GIF of its use

Usage

Android Studio: Add the Sonatype repository if you have not already:

maven {
        url "https://oss.sonatype.org/content/repositories/snapshots"
    }

Import it as a dependency:

compile 'com.quinny898.library.persistentsearch:library:1.1.0-SNAPSHOT'

Eclipse: Import it as a library project

In your layout:

<com.quinny898.library.persistentsearch.SearchBox
        android:layout_width="wrap_content"
		android:layout_height="wrap_content"
        android:id="@+id/searchbox"
        />

Please include this after any elements you wish to be hidden by it in a releativelayout.

Absolute requirements in the activity code

In your onCreate/onCreateView (activity or fragment):

search.enableVoiceRecognition(this);

And in the same class:

@Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (isAdded() && requestCode == SearchBox.VOICE_RECOGNITION_CODE && resultCode == getActivity().RESULT_OK) {
      ArrayList<String> matches = data
          .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
      search.populateEditText(matches);
    }
    super.onActivityResult(requestCode, resultCode, data);
}

More on implementation:

search = (SearchBox) findViewById(R.id.searchbox);
for(int x = 0; x < 10; x++){
	SearchResult option = new SearchResult("Result " + Integer.toString(x), getResources().getDrawable(R.drawable.ic_history));
	search.addSearchable(option);
}		
search.setLogoText("My App");
search.setMenuListener(new MenuListener(){

		@Override
		public void onMenuClick() {
			//Hamburger has been clicked
			Toast.makeText(MainActivity.this, "Menu click", Toast.LENGTH_LONG).show();				
		}
			
	});
search.setSearchListener(new SearchListener(){

	@Override
	public void onSearchOpened() {
		//Use this to tint the screen
	}

	@Override
	public void onSearchClosed() {
		//Use this to un-tint the screen
	}

	@Override
	public void onSearchTermChanged() {
		//React to the search term changing
		//Called after it has updated results
	}

	@Override
	public void onSearch(String searchTerm) {
		Toast.makeText(MainActivity.this, searchTerm +" Searched", Toast.LENGTH_LONG).show();
		
	}
	
	@Override
	public void onResultClick(SearchResult result){
		//React to a result being clicked
	}
	
	
	@Override
	public void onSearchCleared() {
				
	}
			
});

##Showing from a MenuItem

search.revealFromMenuItem(R.id.action_search, this);

Note that when a search occurs, the box closes. You should react to this in onSearch, maybe set your toolbar title?

Custom

Set the logo text color:

search.setLogoTextColor(Color.parse("#000000"));

SearchResult

This is a class that holds two parameters - Title and icon
The title is displayed as a suggested result and will be used for searching, the icon is displayed to the left of the title in the suggestions (eg. a history icon)
You can make a SearchResult as follows

new SearchResult("Title", getResources().getDrawable(R.drawable.icon));

All usage methods

See here for the documentation: http://quinny898.co.uk/PersistentSearch/

Licence

Copyright 2015 Kieron Quinn

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

More Repositories

1

TapTap

Port of the double tap on back of device feature from Android 12 to any Android 7.0+ device
Kotlin
3,015
star
2

AmbientMusicMod

Port of Now Playing from Pixels to other Android devices
Kotlin
1,313
star
3

DarQ

DarQ provides a per-app selectable force dark option for Android 10 and above
Kotlin
851
star
4

PixelLauncherMods

A root app that enables you to add a number of features to the stock Pixel Launcher, without needing Xposed
Kotlin
578
star
5

ClassicPowerMenu

Power Menu Replacement for Android
Kotlin
508
star
6

DiscoverKiller

Xposed module to replace the Google Discover page with whatever you like
Kotlin
272
star
7

MonetCompat

App-level wallpaper color palette generation for Android 5.0+
Kotlin
163
star
8

SIMNumberSetter

A small Xposed module to set the SIM card's phone subscriber number
Kotlin
122
star
9

NowPlaying

Now Playing component of Ambient Music Mod
Java
63
star
10

AmazfitCommunication

Two way communication library for the Amazfit Pace and Stratos
Java
44
star
11

AmazfitSpringboardPluginExample

Example for creating custom springboard pages on the Amazfit Pace
Java
39
star
12

Gear360_OSS

An archival of the Gear 360 2016 and 2017 open source code and firmwares to workaround Samsung shutting down servers
Shell
34
star
13

owoify

owo
Kotlin
28
star
14

FloatingActionButton-Compat

A backport of FloatingActionButton to 2.1+
Java
25
star
15

AmazfitSpringboardSettings

Rearrange and enable/disable springboard pages on the Amazfit Pace
Java
25
star
16

AmazfitSpringboardMusic

A better music control (for the phone) on the Amazfit Pace's homescreen
Java
20
star
17

AmazfitInternetCompanion

Open source and generic internet communication app to be installed on a PHONE to allow the Amazfit Pace/Stratos to access the internet over Bluetooth
Java
18
star
18

AmazfitStepNotify

Simple application for the Amazfit Pace to provide Fitbit-esque active/step notifications at 10 to the hour if 250 steps have not been completed
Java
16
star
19

CatLog-Holo

A holoified version of CatLog. Android 3.0+
Java
13
star
20

AmazfitBatteryTile

Simple quick settings tile showing the battery of a connected Amazfit device
Java
8
star
21

StickersforHangouts

An app and Xposed module that add the missing stickers feature to Android's version of Hangouts
Java
6
star
22

AmbientMusicManifest

Automatically updated manifest for Ambient Music Mod
6
star
23

AlloAllo

An Xposed module that allows access to SOME features of Allo without authentication, bypassing the SMS code requirement
Java
3
star
24

PMDOR

Removes the "Downloaded only" banner from Google Play Music
Java
3
star