├── sample ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable-hdpi │ │ │ │ ├── ic_logo.png │ │ │ │ └── ic_action_search.png │ │ │ ├── drawable-mdpi │ │ │ │ ├── ic_logo.png │ │ │ │ └── ic_action_search.png │ │ │ ├── drawable-xhdpi │ │ │ │ ├── ic_logo.png │ │ │ │ └── ic_action_search.png │ │ │ ├── drawable-xxhdpi │ │ │ │ ├── ic_logo.png │ │ │ │ └── ic_action_search.png │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xxxhdpi │ │ │ │ ├── ic_logo.png │ │ │ │ └── ic_action_search.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── menu │ │ │ │ └── menu_searchview.xml │ │ │ └── layout │ │ │ │ ├── layout_item_search_result.xml │ │ │ │ ├── activity_search.xml │ │ │ │ ├── activity_menu_item_sample.xml │ │ │ │ └── activity_main.xml │ │ ├── java │ │ │ └── org │ │ │ │ └── cryse │ │ │ │ └── widget │ │ │ │ └── persistentsearch │ │ │ │ └── sample │ │ │ │ ├── SearchFragment.java │ │ │ │ ├── SimpleAnimationListener.java │ │ │ │ ├── SearchResult.java │ │ │ │ ├── SampleSuggestionsBuilder.java │ │ │ │ ├── SearchResultAdapter.java │ │ │ │ ├── SearchActivity.java │ │ │ │ ├── MenuItemSampleActivity.java │ │ │ │ └── MainActivity.java │ │ └── AndroidManifest.xml │ └── androidTest │ │ └── java │ │ └── org │ │ └── cryse │ │ └── widget │ │ └── persistentsearch │ │ └── sample │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── persistentsearchview ├── .gitignore ├── gradle.properties ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── attrs.xml │ │ │ ├── drawable-hdpi │ │ │ │ ├── ic_search_black.png │ │ │ │ ├── ic_history_black.png │ │ │ │ ├── ic_action_mic_black.png │ │ │ │ └── ic_action_clear_black.png │ │ │ ├── drawable-mdpi │ │ │ │ ├── ic_search_black.png │ │ │ │ ├── ic_history_black.png │ │ │ │ ├── ic_action_mic_black.png │ │ │ │ └── ic_action_clear_black.png │ │ │ ├── drawable-xhdpi │ │ │ │ ├── ic_history_black.png │ │ │ │ ├── ic_search_black.png │ │ │ │ ├── ic_action_mic_black.png │ │ │ │ └── ic_action_clear_black.png │ │ │ ├── drawable-xxhdpi │ │ │ │ ├── ic_search_black.png │ │ │ │ ├── ic_history_black.png │ │ │ │ ├── ic_action_mic_black.png │ │ │ │ └── ic_action_clear_black.png │ │ │ ├── drawable-xxxhdpi │ │ │ │ ├── ic_history_black.png │ │ │ │ ├── ic_search_black.png │ │ │ │ ├── ic_action_mic_black.png │ │ │ │ └── ic_action_clear_black.png │ │ │ └── layout │ │ │ │ ├── layout_searchitem.xml │ │ │ │ └── layout_searchview.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ ├── org │ │ │ └── cryse │ │ │ │ └── widget │ │ │ │ └── persistentsearch │ │ │ │ ├── SearchSuggestionsBuilder.java │ │ │ │ ├── SimpleSearchListener.java │ │ │ │ ├── LogoView.java │ │ │ │ ├── SearchItemAdapter.java │ │ │ │ ├── SearchItem.java │ │ │ │ ├── DefaultVoiceRecognizerDelegate.java │ │ │ │ ├── TextDrawable.java │ │ │ │ ├── VoiceRecognitionDelegate.java │ │ │ │ ├── RevealViewGroup.java │ │ │ │ ├── HomeButton.java │ │ │ │ └── PersistentSearchView.java │ │ │ ├── android │ │ │ └── support │ │ │ │ └── v7 │ │ │ │ └── graphics │ │ │ │ └── drawable │ │ │ │ └── SupportDrawerArrowDrawable.java │ │ │ └── io │ │ │ └── codetail │ │ │ ├── animation │ │ │ ├── SupportAnimatorPreL.java │ │ │ ├── SupportAnimatorLollipop.java │ │ │ ├── RevealAnimator.java │ │ │ ├── ViewAnimationUtils.java │ │ │ └── SupportAnimator.java │ │ │ └── widget │ │ │ ├── RevealLinearLayout.java │ │ │ └── RevealFrameLayout.java │ └── androidTest │ │ └── java │ │ └── org │ │ └── cryse │ │ └── widget │ │ └── persistentsearch │ │ └── ApplicationTest.java ├── proguard-rules.pro ├── install.gradle ├── bintray.gradle └── build.gradle ├── settings.gradle ├── sample-apk └── sample.apk ├── screenshots ├── screenshot1.png └── screenshot2.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── gradlew ├── README.md └── LICENSE /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /persistentsearchview/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':persistentsearchview', ':sample' 2 | -------------------------------------------------------------------------------- /sample-apk/sample.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/sample-apk/sample.apk -------------------------------------------------------------------------------- /persistentsearchview/gradle.properties: -------------------------------------------------------------------------------- 1 | POM_NAME=Persistent Search 2 | POM_ARTIFACT_ID=library 3 | POM_PACKAGING=aar -------------------------------------------------------------------------------- /screenshots/screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/screenshots/screenshot1.png -------------------------------------------------------------------------------- /screenshots/screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/screenshots/screenshot2.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Speak now 4 | 5 | 6 | -------------------------------------------------------------------------------- /persistentsearchview/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/sample/src/main/res/drawable-hdpi/ic_logo.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/sample/src/main/res/drawable-mdpi/ic_logo.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/sample/src/main/res/drawable-xhdpi/ic_logo.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/sample/src/main/res/drawable-xxhdpi/ic_logo.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/ic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/sample/src/main/res/drawable-xxxhdpi/ic_logo.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-hdpi/ic_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/sample/src/main/res/drawable-hdpi/ic_action_search.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-mdpi/ic_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/sample/src/main/res/drawable-mdpi/ic_action_search.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xhdpi/ic_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/sample/src/main/res/drawable-xhdpi/ic_action_search.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/sample/src/main/res/drawable-xxhdpi/ic_action_search.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/ic_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/sample/src/main/res/drawable-xxxhdpi/ic_action_search.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-hdpi/ic_search_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-hdpi/ic_search_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-mdpi/ic_search_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-mdpi/ic_search_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-hdpi/ic_history_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-hdpi/ic_history_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-mdpi/ic_history_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-mdpi/ic_history_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-xhdpi/ic_history_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-xhdpi/ic_history_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-xhdpi/ic_search_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-xhdpi/ic_search_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-xxhdpi/ic_search_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-xxhdpi/ic_search_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-hdpi/ic_action_mic_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-hdpi/ic_action_mic_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-mdpi/ic_action_mic_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-mdpi/ic_action_mic_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-xhdpi/ic_action_mic_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-xhdpi/ic_action_mic_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-xxhdpi/ic_history_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-xxhdpi/ic_history_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-xxxhdpi/ic_history_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-xxxhdpi/ic_history_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-xxxhdpi/ic_search_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-xxxhdpi/ic_search_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-hdpi/ic_action_clear_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-hdpi/ic_action_clear_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-mdpi/ic_action_clear_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-mdpi/ic_action_clear_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-xhdpi/ic_action_clear_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-xhdpi/ic_action_clear_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-xxhdpi/ic_action_mic_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-xxhdpi/ic_action_mic_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-xxxhdpi/ic_action_mic_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-xxxhdpi/ic_action_mic_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-xxhdpi/ic_action_clear_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-xxhdpi/ic_action_clear_black.png -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/drawable-xxxhdpi/ic_action_clear_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/crysehillmes/PersistentSearchView/HEAD/persistentsearchview/src/main/res/drawable-xxxhdpi/ic_action_clear_black.png -------------------------------------------------------------------------------- /sample/src/main/java/org/cryse/widget/persistentsearch/sample/SearchFragment.java: -------------------------------------------------------------------------------- 1 | package org.cryse.widget.persistentsearch.sample; 2 | 3 | /** 4 | * Created by tyk55 on 8/17/2015. 5 | */ 6 | public class SearchFragment { 7 | } 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 7 | -------------------------------------------------------------------------------- /persistentsearchview/src/main/java/org/cryse/widget/persistentsearch/SearchSuggestionsBuilder.java: -------------------------------------------------------------------------------- 1 | package org.cryse.widget.persistentsearch; 2 | 3 | import java.util.Collection; 4 | 5 | public interface SearchSuggestionsBuilder { 6 | Collection buildEmptySearchSuggestion(int maxCount); 7 | Collection buildSearchSuggestion(int maxCount, String query); 8 | } 9 | -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8dp 4 | 4dp 5 | 2dp 6 | 48dp 7 | -------------------------------------------------------------------------------- /persistentsearchview/src/androidTest/java/org/cryse/widget/persistentsearch/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package org.cryse.widget.persistentsearch; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /sample/src/androidTest/java/org/cryse/widget/persistentsearch/sample/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package org.cryse.widget.persistentsearch.sample; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Persistent SearchView 5 | MenuItem Sample 6 | Toolbar Back Sample 7 | GitHub Repo 8 | https://github.com/crysehillmes/PersistentSearchView 9 | TextLogo 10 | 11 | 12 | -------------------------------------------------------------------------------- /sample/src/main/res/menu/menu_searchview.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /sample/src/main/java/org/cryse/widget/persistentsearch/sample/SimpleAnimationListener.java: -------------------------------------------------------------------------------- 1 | package org.cryse.widget.persistentsearch.sample; 2 | 3 | import android.animation.Animator; 4 | 5 | public class SimpleAnimationListener implements Animator.AnimatorListener { 6 | @Override 7 | public void onAnimationStart(Animator animation) { 8 | 9 | } 10 | 11 | @Override 12 | public void onAnimationEnd(Animator animation) { 13 | } 14 | 15 | @Override 16 | public void onAnimationCancel(Animator animation) { 17 | 18 | } 19 | 20 | @Override 21 | public void onAnimationRepeat(Animator animation) { 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /persistentsearchview/src/main/java/android/support/v7/graphics/drawable/SupportDrawerArrowDrawable.java: -------------------------------------------------------------------------------- 1 | package android.support.v7.graphics.drawable; 2 | 3 | import android.content.Context; 4 | 5 | public class SupportDrawerArrowDrawable extends DrawerArrowDrawable { 6 | 7 | public SupportDrawerArrowDrawable(Context themedContext) { 8 | super(themedContext); 9 | } 10 | 11 | public void setPosition(float position) { 12 | if (position == 1f) { 13 | setVerticalMirror(true); 14 | } else if (position == 0f) { 15 | setVerticalMirror(false); 16 | } 17 | super.setProgress(position); 18 | } 19 | 20 | public float getPosition() { 21 | return super.getProgress(); 22 | } 23 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | .DS_Store 5 | 6 | # Crashlytics 7 | com_crashlytics_export_strings.xml 8 | 9 | # built application files 10 | *.ap_ 11 | 12 | # files for the dex VM 13 | *.dex 14 | 15 | # Java class files 16 | *.class 17 | 18 | # generated files 19 | bin/ 20 | gen/ 21 | build/ 22 | 23 | # Local configuration file (sdk path, etc) 24 | local.properties 25 | 26 | # Eclipse project files 27 | .classpath 28 | .project 29 | 30 | # Proguard folder generated by Eclipse 31 | proguard/ 32 | 33 | # Android Studio 34 | .idea/ 35 | .gradle 36 | /*/local.properties 37 | /*/out 38 | /*/*/build 39 | /*/*/production 40 | *.iml 41 | *.iws 42 | *.ipr 43 | *~ 44 | *.swp 45 | 46 | # SigningConfig 47 | signing.properties 48 | *.keystore 49 | javadoc/ -------------------------------------------------------------------------------- /sample/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:/Users/Kieron/Android/adt-bundle-windows-x86_64-20140702/adt-bundle-windows-x86_64-20140702/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /persistentsearchview/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:/Users/Kieron/Android/adt-bundle-windows-x86_64-20140702/adt-bundle-windows-x86_64-20140702/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /persistentsearchview/src/main/java/org/cryse/widget/persistentsearch/SimpleSearchListener.java: -------------------------------------------------------------------------------- 1 | package org.cryse.widget.persistentsearch; 2 | 3 | public class SimpleSearchListener implements PersistentSearchView.SearchListener { 4 | 5 | @Override 6 | public boolean onSuggestion(SearchItem searchItem) { 7 | return true; 8 | } 9 | 10 | @Override 11 | public void onSearchCleared() { 12 | 13 | } 14 | 15 | @Override 16 | public void onSearchTermChanged(String term) { 17 | 18 | } 19 | 20 | @Override 21 | public void onSearch(String query) { 22 | 23 | } 24 | 25 | @Override 26 | public void onSearchEditOpened() { 27 | 28 | } 29 | 30 | @Override 31 | public void onSearchEditClosed() { 32 | 33 | } 34 | 35 | @Override 36 | public boolean onSearchEditBackPressed() { 37 | return false; 38 | } 39 | 40 | @Override 41 | public void onSearchExit() { 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | org.gradle.parallel=true 19 | org.gradle.daemon=true 20 | org.gradle.configureondemand=true 21 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /sample/src/main/java/org/cryse/widget/persistentsearch/sample/SearchResult.java: -------------------------------------------------------------------------------- 1 | package org.cryse.widget.persistentsearch.sample; 2 | 3 | public class SearchResult { 4 | private String title; 5 | private String description; 6 | private String iconUrl; 7 | 8 | public SearchResult(String title, String description, String iconUrl) { 9 | this.title = title; 10 | this.description = description; 11 | this.iconUrl = iconUrl; 12 | } 13 | 14 | public String getTitle() { 15 | return title; 16 | } 17 | 18 | public void setTitle(String title) { 19 | this.title = title; 20 | } 21 | 22 | public String getDescription() { 23 | return description; 24 | } 25 | 26 | public void setDescription(String description) { 27 | this.description = description; 28 | } 29 | 30 | public String getIconUrl() { 31 | return iconUrl; 32 | } 33 | 34 | public void setIconUrl(String iconUrl) { 35 | this.iconUrl = iconUrl; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 12 | 20 | 21 | -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /persistentsearchview/install.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.github.dcendents.android-maven' 2 | 3 | group = publishedGroupId // Maven Group ID for the artifact 4 | 5 | install { 6 | repositories.mavenInstaller { 7 | // This generates POM.xml with proper parameters 8 | pom { 9 | project { 10 | packaging 'aar' 11 | groupId publishedGroupId 12 | artifactId artifactId 13 | 14 | // Add your description here 15 | name libraryName 16 | description libraryDescription 17 | url siteUrl 18 | 19 | // Set your license 20 | licenses { 21 | license { 22 | name licenseName 23 | url licenseUrl 24 | } 25 | } 26 | developers { 27 | developer { 28 | id developerId 29 | name developerName 30 | email developerEmail 31 | } 32 | } 33 | scm { 34 | connection gitUrl 35 | developerConnection gitUrl 36 | url siteUrl 37 | 38 | } 39 | } 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /sample/src/main/res/layout/layout_item_search_result.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 11 | 20 | 21 | 26 | 27 | 32 | 33 | -------------------------------------------------------------------------------- /persistentsearchview/bintray.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.jfrog.bintray' 2 | 3 | version = libraryVersion 4 | 5 | task sourcesJar(type: Jar) { 6 | from android.sourceSets.main.java.srcDirs 7 | classifier = 'sources' 8 | } 9 | 10 | task javadoc(type: Javadoc) { 11 | source = android.sourceSets.main.java.srcDirs 12 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 13 | destinationDir = file("../javadoc/") 14 | failOnError false 15 | } 16 | 17 | task javadocJar(type: Jar, dependsOn: javadoc) { 18 | classifier = 'javadoc' 19 | from javadoc.destinationDir 20 | } 21 | artifacts { 22 | archives javadocJar 23 | archives sourcesJar 24 | } 25 | 26 | // Bintray 27 | Properties properties = new Properties() 28 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) 29 | 30 | bintray { 31 | user = properties.getProperty("bintray.user") 32 | key = properties.getProperty("bintray.apikey") 33 | 34 | configurations = ['archives'] 35 | pkg { 36 | repo = bintrayRepo 37 | name = bintrayName 38 | desc = libraryDescription 39 | websiteUrl = siteUrl 40 | vcsUrl = gitUrl 41 | licenses = allLicenses 42 | publish = true 43 | publicDownloadNumbers = true 44 | version { 45 | desc = libraryDescription 46 | gpg { 47 | sign = true //Determines whether to GPG sign the files. The default is false 48 | passphrase = properties.getProperty("bintray.gpg.password") 49 | //Optional. The passphrase for GPG signing' 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /persistentsearchview/src/main/res/layout/layout_searchitem.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 20 | 21 | 34 | 35 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /persistentsearchview/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion appCompileSdkVersion 5 | buildToolsVersion appBuildToolsVersion 6 | 7 | defaultConfig { 8 | minSdkVersion appMinSdkVersion 9 | targetSdkVersion appTargetSdkVersion 10 | versionCode appVersionCode 11 | versionName appVersionName 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | lintOptions { 20 | abortOnError false 21 | } 22 | 23 | } 24 | 25 | dependencies { 26 | compile fileTree(dir: 'libs', include: ['*.jar']) 27 | compile "com.android.support:appcompat-v7:$supportlibraryVersion" 28 | compile "com.android.support:cardview-v7:$supportlibraryVersion" 29 | } 30 | 31 | 32 | 33 | ext { 34 | bintrayRepo = 'maven' 35 | bintrayName = 'persistent-searchview' 36 | 37 | publishedGroupId = 'org.cryse.widget' 38 | libraryName = 'PersistentSearchView' 39 | artifact = 'persistentsearchview' 40 | 41 | libraryDescription = 'A library that implements Google Play like PersistentSearch view.' 42 | 43 | siteUrl = 'https://github.com/crysehillmes/PersistentSearchView' 44 | gitUrl = 'https://github.com/crysehillmes/PersistentSearchView.git' 45 | 46 | libraryVersion = appVersionName 47 | 48 | developerId = 'tyk5555' 49 | developerName = 'Cryse Hillmes' 50 | developerEmail = 'tikey0328@gmail.com' 51 | 52 | licenseName = 'The Apache Software License, Version 2.0' 53 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' 54 | allLicenses = ["Apache-2.0"] 55 | } 56 | 57 | apply from: 'install.gradle' 58 | apply from: 'bintray.gradle' -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_search.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | 25 | 26 | 41 | -------------------------------------------------------------------------------- /persistentsearchview/src/main/java/org/cryse/widget/persistentsearch/LogoView.java: -------------------------------------------------------------------------------- 1 | package org.cryse.widget.persistentsearch; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.graphics.Canvas; 6 | import android.graphics.drawable.Drawable; 7 | import android.os.Build; 8 | import android.support.annotation.DrawableRes; 9 | import android.support.v4.content.res.ResourcesCompat; 10 | import android.text.TextUtils; 11 | import android.util.AttributeSet; 12 | import android.widget.TextView; 13 | 14 | public class LogoView extends TextView { 15 | private Drawable mLogoDrawable; 16 | public LogoView(Context context) { 17 | super(context); 18 | } 19 | 20 | public LogoView(Context context, AttributeSet attrs) { 21 | super(context, attrs); 22 | } 23 | 24 | public LogoView(Context context, AttributeSet attrs, int defStyleAttr) { 25 | super(context, attrs, defStyleAttr); 26 | } 27 | 28 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 29 | public LogoView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 30 | super(context, attrs, defStyleAttr, defStyleRes); 31 | } 32 | 33 | public void setLogo(String logoText) 34 | { 35 | setLogo(new TextDrawable(getResources(), logoText)); 36 | } 37 | 38 | public void setLogo(@DrawableRes int drawableRes) { 39 | setLogo(ResourcesCompat.getDrawable(getResources(), drawableRes, null)); 40 | } 41 | 42 | public void setLogo(Drawable drawable) { 43 | this.mLogoDrawable = drawable; 44 | mLogoDrawable.setBounds(0,0, mLogoDrawable.getIntrinsicWidth(), mLogoDrawable.getIntrinsicHeight()); 45 | this.invalidate(); 46 | } 47 | 48 | @Override 49 | protected void onDraw(Canvas canvas) { 50 | if(!TextUtils.isEmpty(getText())) 51 | super.onDraw(canvas); 52 | else { 53 | if(mLogoDrawable != null) { 54 | mLogoDrawable.draw(canvas); 55 | } 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /persistentsearchview/src/main/java/org/cryse/widget/persistentsearch/SearchItemAdapter.java: -------------------------------------------------------------------------------- 1 | package org.cryse.widget.persistentsearch; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | import android.widget.ArrayAdapter; 8 | import android.widget.ImageView; 9 | import android.widget.TextView; 10 | 11 | import java.util.ArrayList; 12 | 13 | public class SearchItemAdapter extends ArrayAdapter { 14 | 15 | public SearchItemAdapter(Context context, ArrayList options) { 16 | super(context, 0, options); 17 | } 18 | 19 | @Override 20 | public View getView(int position, View convertView, ViewGroup parent) { 21 | SearchItem searchItem = getItem(position); 22 | if (convertView == null) { 23 | convertView = LayoutInflater.from(getContext()).inflate( 24 | R.layout.layout_searchitem, parent, false); 25 | } 26 | 27 | View border = convertView.findViewById(R.id.view_border); 28 | if (position == 0) { 29 | border.setVisibility(View.VISIBLE); 30 | } else { 31 | border.setVisibility(View.GONE); 32 | } 33 | final TextView title = (TextView) convertView 34 | .findViewById(R.id.textview_title); 35 | title.setText(searchItem.getTitle()); 36 | ImageView icon = (ImageView) convertView.findViewById(R.id.imageview_icon); 37 | if(searchItem.getIcon() == null) { 38 | switch (searchItem.getType()) { 39 | case SearchItem.TYPE_SEARCH_ITEM_HISTORY: 40 | icon.setImageResource(R.drawable.ic_history_black); 41 | break; 42 | default: 43 | case SearchItem.TYPE_SEARCH_ITEM_SUGGESTION: 44 | icon.setImageResource(R.drawable.ic_search_black); 45 | break; 46 | } 47 | } else { 48 | icon.setImageDrawable(searchItem.getIcon()); 49 | } 50 | return convertView; 51 | } 52 | } -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_menu_item_sample.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 15 | 16 | 23 | 24 | 33 | 34 | 49 | 50 | -------------------------------------------------------------------------------- /persistentsearchview/src/main/java/org/cryse/widget/persistentsearch/SearchItem.java: -------------------------------------------------------------------------------- 1 | package org.cryse.widget.persistentsearch; 2 | 3 | import android.graphics.drawable.Drawable; 4 | 5 | public class SearchItem { 6 | private String mTitle; 7 | private String mValue; 8 | private Drawable mIcon; 9 | private int mType; 10 | public static final int TYPE_SEARCH_ITEM_HISTORY = 0; 11 | public static final int TYPE_SEARCH_ITEM_SUGGESTION = 1; 12 | public static final int TYPE_SEARCH_ITEM_OPTION = 2; 13 | public static final int TYPE_SEARCH_ITEM_CUSTOM = 3; 14 | public static final int TYPE_SEARCH_ITEM_DEFAULT = TYPE_SEARCH_ITEM_HISTORY; 15 | 16 | 17 | public SearchItem(String title, String value) { 18 | this(title, value, TYPE_SEARCH_ITEM_DEFAULT, null); 19 | } 20 | /** 21 | * Create a search result with text and an icon 22 | * @param title display value 23 | * @param value inner value for search 24 | * @param type item type 25 | */ 26 | public SearchItem(String title, String value, int type) { 27 | this(title, value, type, null); 28 | } 29 | 30 | public SearchItem(String title, String value, int type, Drawable icon) { 31 | this.mTitle = title; 32 | this.mValue = value; 33 | this.mType = type; 34 | this.mIcon = icon; 35 | } 36 | 37 | /** 38 | * Return the title of the result 39 | */ 40 | @Override 41 | public String toString() { 42 | return mTitle; 43 | } 44 | 45 | public String getTitle() { 46 | return mTitle; 47 | } 48 | 49 | public void setTitle(String title) { 50 | this.mTitle = title; 51 | } 52 | 53 | public String getValue() { 54 | return mValue; 55 | } 56 | 57 | public void setValue(String value) { 58 | this.mValue = value; 59 | } 60 | 61 | public Drawable getIcon() { 62 | return mIcon; 63 | } 64 | 65 | public void setIcon(Drawable icon) { 66 | this.mIcon = icon; 67 | } 68 | 69 | public int getType() { 70 | return mType; 71 | } 72 | 73 | public void setType(int type) { 74 | this.mType = type; 75 | } 76 | } -------------------------------------------------------------------------------- /persistentsearchview/src/main/java/org/cryse/widget/persistentsearch/DefaultVoiceRecognizerDelegate.java: -------------------------------------------------------------------------------- 1 | package org.cryse.widget.persistentsearch; 2 | 3 | import android.app.Activity; 4 | import android.app.Fragment; 5 | import android.content.Intent; 6 | import android.content.pm.PackageManager; 7 | import android.content.pm.ResolveInfo; 8 | import android.speech.RecognizerIntent; 9 | 10 | import java.util.List; 11 | 12 | public class DefaultVoiceRecognizerDelegate extends VoiceRecognitionDelegate { 13 | 14 | public DefaultVoiceRecognizerDelegate(Activity activity) { 15 | super(activity); 16 | } 17 | 18 | public DefaultVoiceRecognizerDelegate(Activity activity, int activityRequestCode) { 19 | super(activity, activityRequestCode); 20 | } 21 | 22 | public DefaultVoiceRecognizerDelegate(Fragment fragment) { 23 | super(fragment); 24 | } 25 | 26 | public DefaultVoiceRecognizerDelegate(Fragment fragment, int activityRequestCode) { 27 | super(fragment, activityRequestCode); 28 | } 29 | 30 | public DefaultVoiceRecognizerDelegate(android.support.v4.app.Fragment supportFragment) { 31 | super(supportFragment); 32 | } 33 | 34 | public DefaultVoiceRecognizerDelegate(android.support.v4.app.Fragment supportFragment, int activityRequestCode) { 35 | super(supportFragment, activityRequestCode); 36 | } 37 | 38 | @Override 39 | public Intent buildVoiceRecognitionIntent() { 40 | Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); 41 | intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, 42 | RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); 43 | intent.putExtra(RecognizerIntent.EXTRA_PROMPT, 44 | getContext().getString(R.string.speak_now)); 45 | return intent; 46 | } 47 | 48 | @Override 49 | public boolean isVoiceRecognitionAvailable() { 50 | Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); 51 | PackageManager mgr = getContext().getPackageManager(); 52 | if (mgr != null) { 53 | List list = mgr.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); 54 | return list.size() > 0; 55 | } 56 | return false; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /persistentsearchview/src/main/java/org/cryse/widget/persistentsearch/TextDrawable.java: -------------------------------------------------------------------------------- 1 | package org.cryse.widget.persistentsearch; 2 | 3 | import android.content.res.Resources; 4 | import android.graphics.Canvas; 5 | import android.graphics.Color; 6 | import android.graphics.ColorFilter; 7 | import android.graphics.Paint; 8 | import android.graphics.PixelFormat; 9 | import android.graphics.Rect; 10 | import android.graphics.drawable.Drawable; 11 | import android.util.TypedValue; 12 | 13 | public class TextDrawable extends Drawable { 14 | 15 | private final String mText; 16 | private final Paint mPaint; 17 | private int mIntrinsicWidth; 18 | private int mIntrinsicHeight; 19 | private float mTextSize; 20 | 21 | public TextDrawable(Resources resources, String text) { 22 | 23 | this.mText = text; 24 | 25 | mTextSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 26 | 24f, resources.getDisplayMetrics()); 27 | 28 | this.mPaint = new Paint(); 29 | mPaint.setColor(Color.GRAY); 30 | mPaint.setTextSize(mTextSize); 31 | mPaint.setAntiAlias(true); 32 | mPaint.setFakeBoldText(false); 33 | mPaint.setShadowLayer(2f, 0, 0, Color.BLACK); 34 | mPaint.setStyle(Paint.Style.FILL); 35 | mPaint.setTextAlign(Paint.Align.LEFT); 36 | 37 | Rect bounds = new Rect(); 38 | mPaint.getTextBounds(mText, 0, mText.length(), bounds); 39 | mIntrinsicWidth = bounds.width(); 40 | mIntrinsicHeight = bounds.height(); 41 | } 42 | 43 | @Override 44 | public void draw(Canvas canvas) { 45 | Rect r = getBounds(); 46 | 47 | int count = canvas.save(); 48 | canvas.translate(r.left, r.top); 49 | int height = canvas.getHeight() < 0 ? r.height() : canvas.getHeight(); 50 | canvas.drawText(mText, 0, height / 2 - ((mPaint.descent() + mPaint.ascent()) / 2), mPaint); 51 | canvas.restoreToCount(count); 52 | } 53 | 54 | @Override 55 | public int getIntrinsicWidth() { 56 | return mIntrinsicWidth; 57 | } 58 | @Override 59 | public int getIntrinsicHeight() { 60 | return mIntrinsicHeight; 61 | } 62 | 63 | @Override 64 | public void setAlpha(int alpha) { 65 | mPaint.setAlpha(alpha); 66 | } 67 | 68 | @Override 69 | public void setColorFilter(ColorFilter cf) { 70 | mPaint.setColorFilter(cf); 71 | } 72 | 73 | @Override 74 | public int getOpacity() { 75 | return PixelFormat.TRANSLUCENT; 76 | } 77 | } -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion appCompileSdkVersion 5 | buildToolsVersion appBuildToolsVersion 6 | defaultConfig { 7 | applicationId "org.cryse.widget.persistentsearch.sample" 8 | minSdkVersion appMinSdkVersion 9 | targetSdkVersion appTargetSdkVersion 10 | versionCode appVersionCode 11 | versionName appVersionName 12 | signingConfig signingConfigs.debug 13 | } 14 | signingConfigs { 15 | debug {} 16 | release {} 17 | } 18 | buildTypes { 19 | debug { 20 | debuggable true 21 | signingConfig signingConfigs.debug 22 | } 23 | release { 24 | minifyEnabled true 25 | shrinkResources true 26 | signingConfig signingConfigs.release 27 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 28 | } 29 | } 30 | } 31 | 32 | dependencies { 33 | compile fileTree(dir: 'libs', include: ['*.jar']) 34 | compile project(':persistentsearchview') 35 | compile "com.android.support:appcompat-v7:$supportlibraryVersion" 36 | compile "com.android.support:recyclerview-v7:$supportlibraryVersion" 37 | compile "com.android.support:cardview-v7:$supportlibraryVersion" 38 | } 39 | 40 | 41 | def Properties props = new Properties() 42 | def propFile = new File('sample/signing.properties') 43 | if (propFile.canRead()){ 44 | props.load(new FileInputStream(propFile)) 45 | 46 | if (props!=null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') && 47 | props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) { 48 | android.signingConfigs.debug.storeFile = file(props['STORE_FILE']) 49 | android.signingConfigs.debug.storePassword = props['STORE_PASSWORD'] 50 | android.signingConfigs.debug.keyAlias = props['KEY_ALIAS'] 51 | android.signingConfigs.debug.keyPassword = props['KEY_PASSWORD'] 52 | android.signingConfigs.release.storeFile = file(props['STORE_FILE']) 53 | android.signingConfigs.release.storePassword = props['STORE_PASSWORD'] 54 | android.signingConfigs.release.keyAlias = props['KEY_ALIAS'] 55 | android.signingConfigs.release.keyPassword = props['KEY_PASSWORD'] 56 | } else { 57 | println 'signing.properties found but some entries are missing' 58 | android.buildTypes.debug.signingConfig = null 59 | android.buildTypes.release.signingConfig = null 60 | } 61 | } else { 62 | println 'signing.properties not found' 63 | android.buildTypes.debug.signingConfig = null 64 | android.buildTypes.release.signingConfig = null 65 | } -------------------------------------------------------------------------------- /persistentsearchview/src/main/java/org/cryse/widget/persistentsearch/VoiceRecognitionDelegate.java: -------------------------------------------------------------------------------- 1 | package org.cryse.widget.persistentsearch; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | 7 | public abstract class VoiceRecognitionDelegate { 8 | public static final int DEFAULT_VOICE_REQUEST_CODE = 8185102; 9 | private int mVoiceRecognitionRequestCode; 10 | private Activity mActivity; 11 | private android.app.Fragment mFragment; 12 | private android.support.v4.app.Fragment mSupportFragment; 13 | 14 | public VoiceRecognitionDelegate(Activity activity) { 15 | this(activity, DEFAULT_VOICE_REQUEST_CODE); 16 | } 17 | 18 | public VoiceRecognitionDelegate(Activity activity, int activityRequestCode) { 19 | this.mActivity = activity; 20 | this.mVoiceRecognitionRequestCode = activityRequestCode; 21 | } 22 | 23 | public VoiceRecognitionDelegate(android.app.Fragment fragment) { 24 | this(fragment, DEFAULT_VOICE_REQUEST_CODE); 25 | } 26 | 27 | public VoiceRecognitionDelegate(android.app.Fragment fragment, int activityRequestCode) { 28 | this.mFragment = fragment; 29 | this.mVoiceRecognitionRequestCode = activityRequestCode; 30 | } 31 | 32 | public VoiceRecognitionDelegate(android.support.v4.app.Fragment supportFragment) { 33 | this(supportFragment, DEFAULT_VOICE_REQUEST_CODE); 34 | } 35 | 36 | public VoiceRecognitionDelegate(android.support.v4.app.Fragment supportFragment, int activityRequestCode) { 37 | this.mSupportFragment = supportFragment; 38 | this.mVoiceRecognitionRequestCode = activityRequestCode; 39 | } 40 | 41 | public void onStartVoiceRecognition() { 42 | if (mActivity != null) { 43 | Intent intent = buildVoiceRecognitionIntent(); 44 | mActivity.startActivityForResult(intent, mVoiceRecognitionRequestCode); 45 | } else if(mFragment != null) { 46 | Intent intent = buildVoiceRecognitionIntent(); 47 | mFragment.startActivityForResult(intent, mVoiceRecognitionRequestCode); 48 | } else if(mSupportFragment != null) { 49 | Intent intent = buildVoiceRecognitionIntent(); 50 | mSupportFragment.startActivityForResult(intent, mVoiceRecognitionRequestCode); 51 | } 52 | } 53 | 54 | protected Context getContext() { 55 | if (mActivity != null) { 56 | return mActivity; 57 | } else if(mFragment != null) { 58 | return mFragment.getContext(); 59 | } else if(mSupportFragment != null) { 60 | return mSupportFragment.getContext(); 61 | } else { 62 | throw new IllegalStateException("Could not get context in VoiceRecognitionDelegate."); 63 | } 64 | } 65 | 66 | public abstract Intent buildVoiceRecognitionIntent(); 67 | 68 | public abstract boolean isVoiceRecognitionAvailable(); 69 | } 70 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 17 | 18 |