├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ ├── search.xml │ │ │ │ └── activity_main.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── drawable │ │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── tangguna │ │ │ │ └── searchbox │ │ │ │ └── searchbox │ │ │ │ ├── SearchActivity.java │ │ │ │ └── MainActivity.java │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── tangguna │ │ │ └── searchbox │ │ │ └── searchbox │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── tangguna │ │ └── searchbox │ │ └── searchbox │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── library ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable-xhdpi │ │ │ │ ├── icon_close.png │ │ │ │ ├── icon_clear_data.png │ │ │ │ ├── explore_search_icon.png │ │ │ │ ├── explore_search_close.png │ │ │ │ ├── explore_search_icon_nt.png │ │ │ │ └── explore_search_close_nt.png │ │ │ ├── drawable │ │ │ │ ├── bg_shadow_set_bottom.xml │ │ │ │ ├── ll_clear_bg.xml │ │ │ │ ├── sousuo_bg_gray_state_pressed_shap.xml │ │ │ │ ├── sousuo_bg_level.xml │ │ │ │ ├── search_baground_shap.xml │ │ │ │ ├── sousuo_bg_gray_2.xml │ │ │ │ ├── sousuo_bg_gray_1.xml │ │ │ │ ├── sousuo_bg_gray_3.xml │ │ │ │ ├── sousuo_bg_gray_4.xml │ │ │ │ ├── sousuo_bg_gray_5.xml │ │ │ │ ├── search_title_baground_shap.xml │ │ │ │ ├── search.xml │ │ │ │ ├── sousuo_back_or_search_button_shap.xml │ │ │ │ ├── sousuo_clearolddata_shap.xml │ │ │ │ └── search_title_baground_shap2.xml │ │ │ ├── values │ │ │ │ ├── style.xml │ │ │ │ ├── strings.xml │ │ │ │ └── color.xml │ │ │ └── layout │ │ │ │ ├── suosou_item.xml │ │ │ │ ├── search_olddata_item.xml │ │ │ │ ├── list_item.xml │ │ │ │ ├── msearch_top.xml │ │ │ │ ├── msearchlayout.xml │ │ │ │ └── searchlistlayout.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── tangguna │ │ │ └── searchbox │ │ │ └── library │ │ │ ├── callback │ │ │ └── onSearchCallBackListener.java │ │ │ ├── widget │ │ │ ├── SelfSearchListView.java │ │ │ ├── SelfSearchGridView.java │ │ │ ├── FlowLayout.java │ │ │ ├── SearchLayout.java │ │ │ └── SearchListLayout.java │ │ │ ├── adapter │ │ │ ├── HistoryDataAdapter.java │ │ │ └── HistoryDataListViewAdapter.java │ │ │ └── cache │ │ │ └── HistoryCache.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── tangguna │ │ │ └── searchbox │ │ │ └── library │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── tangguna │ │ └── searchbox │ │ └── library │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── img ├── Screenshot_1536113887.png ├── Screenshot_1536113915.png ├── Screenshot_1536113922.png ├── Screenshot_1536113962.png └── Screenshot_1536126402.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea ├── caches │ └── build_file_checksums.ser ├── runConfigurations.xml ├── gradle.xml ├── misc.xml └── codeStyles │ └── Project.xml ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── README.md └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':library' 2 | -------------------------------------------------------------------------------- /img/Screenshot_1536113887.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/img/Screenshot_1536113887.png -------------------------------------------------------------------------------- /img/Screenshot_1536113915.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/img/Screenshot_1536113915.png -------------------------------------------------------------------------------- /img/Screenshot_1536113922.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/img/Screenshot_1536113922.png -------------------------------------------------------------------------------- /img/Screenshot_1536113962.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/img/Screenshot_1536113962.png -------------------------------------------------------------------------------- /img/Screenshot_1536126402.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/img/Screenshot_1536126402.png -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | SearchBox 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/icon_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/library/src/main/res/drawable-xhdpi/icon_close.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/icon_clear_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/library/src/main/res/drawable-xhdpi/icon_clear_data.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/explore_search_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/library/src/main/res/drawable-xhdpi/explore_search_icon.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/explore_search_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/library/src/main/res/drawable-xhdpi/explore_search_close.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/explore_search_icon_nt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/library/src/main/res/drawable-xhdpi/explore_search_icon_nt.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/explore_search_close_nt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tangguna/SearchBox/HEAD/library/src/main/res/drawable-xhdpi/explore_search_close_nt.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/libraries 5 | /.idea/modules.xml 6 | /.idea/workspace.xml 7 | .DS_Store 8 | /build 9 | /captures 10 | .externalNativeBuild 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Sep 04 14:15:51 CST 2018 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-4.4-all.zip 7 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/bg_shadow_set_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /library/src/main/res/values/style.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | SearchmList 3 | 热门搜索 4 | 取消 5 | 搜索 6 | 热门搜索 7 | 历史搜索 8 | 清除历史 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/ll_clear_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /library/src/main/res/layout/suosou_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/test/java/com/tangguna/searchbox/searchbox/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.tangguna.searchbox.searchbox; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /library/src/test/java/com/tangguna/searchbox/library/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.tangguna.searchbox.library; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /library/src/main/res/drawable/sousuo_bg_gray_state_pressed_shap.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/layout/search.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 13 | -------------------------------------------------------------------------------- /library/src/main/res/layout/search_olddata_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/sousuo_bg_level.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /library/src/main/java/com/tangguna/searchbox/library/callback/onSearchCallBackListener.java: -------------------------------------------------------------------------------- 1 | package com.tangguna.searchbox.library.callback; 2 | 3 | import android.os.Bundle; 4 | 5 | import java.util.ArrayList; 6 | 7 | public interface onSearchCallBackListener { 8 | /** 9 | * @param str 搜索关键字 10 | */ 11 | public abstract void Search(String str); 12 | /** 13 | * 后退 14 | */ 15 | public abstract void Back(); 16 | /** 17 | * 清除历史搜索记录 18 | */ 19 | public abstract void ClearOldData(); 20 | 21 | /** 22 | * 保存搜索记录 23 | */ 24 | public abstract void SaveOldData(ArrayList AlloldDataList); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/search_baground_shap.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/java/com/tangguna/searchbox/searchbox/SearchActivity.java: -------------------------------------------------------------------------------- 1 | package com.tangguna.searchbox.searchbox; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.widget.TextView; 7 | 8 | public class SearchActivity extends AppCompatActivity { 9 | @Override 10 | protected void onCreate(@Nullable Bundle savedInstanceState) { 11 | super.onCreate(savedInstanceState); 12 | setContentView(R.layout.search); 13 | TextView textView =(TextView) findViewById(R.id.tv_show); 14 | 15 | Bundle bundle = getIntent().getExtras(); 16 | if (bundle != null){ 17 | textView.setText(bundle.getString("data")); 18 | } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | -------------------------------------------------------------------------------- /library/src/main/res/layout/list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 18 | 19 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/sousuo_bg_gray_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/sousuo_bg_gray_1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/sousuo_bg_gray_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/sousuo_bg_gray_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/sousuo_bg_gray_5.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /library/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/search_title_baground_shap.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 25 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/tangguna/searchbox/searchbox/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.tangguna.searchbox.searchbox; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.tangguna.searchbox.searchbox", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /library/src/androidTest/java/com/tangguna/searchbox/library/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.tangguna.searchbox.library; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.tangguna.searchbox.library.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/search.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 10 | 11 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/sousuo_back_or_search_button_shap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 10 | 11 | 12 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/sousuo_clearolddata_shap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | group='com.github.tangguna' 4 | android { 5 | compileSdkVersion 27 6 | 7 | 8 | 9 | defaultConfig { 10 | minSdkVersion 19 11 | targetSdkVersion 27 12 | versionCode 1 13 | versionName "1.0" 14 | 15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 16 | 17 | } 18 | 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | 26 | } 27 | 28 | dependencies { 29 | implementation fileTree(dir: 'libs', include: ['*.jar']) 30 | 31 | implementation 'com.android.support:appcompat-v7:27.0.2' 32 | testImplementation 'junit:junit:4.12' 33 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 34 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 35 | api 'com.google.code.gson:gson:2.7' 36 | } 37 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 27 5 | defaultConfig { 6 | applicationId "com.tangguna.searchbox.searchbox" 7 | minSdkVersion 19 8 | targetSdkVersion 27 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(include: ['*.jar'], dir: 'libs') 23 | implementation 'com.android.support:appcompat-v7:27.0.2' 24 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 25 | testImplementation 'junit:junit:4.12' 26 | androidTestImplementation 'com.android.support.test:runner:1.0.1' 27 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' 28 | implementation project(':library') 29 | } 30 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/search_title_baground_shap2.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 19 | 20 | 21 | 22 | 23 | 34 | -------------------------------------------------------------------------------- /library/src/main/java/com/tangguna/searchbox/library/widget/SelfSearchListView.java: -------------------------------------------------------------------------------- 1 | package com.tangguna.searchbox.library.widget; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.ViewGroup; 6 | import android.widget.ListView; 7 | 8 | public class SelfSearchListView extends ListView { 9 | 10 | public SelfSearchListView(Context context) { 11 | super(context); 12 | } 13 | 14 | public SelfSearchListView(Context context, AttributeSet attrs) { 15 | super(context, attrs); 16 | } 17 | 18 | public SelfSearchListView(Context context, AttributeSet attrs, int defStyleAttr) { 19 | super(context, attrs, defStyleAttr); 20 | } 21 | 22 | @Override 23 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 24 | 25 | int heightSpec; 26 | if(getLayoutParams().height== ViewGroup.LayoutParams.WRAP_CONTENT) 27 | { 28 | heightSpec = MeasureSpec.makeMeasureSpec( 29 | Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); 30 | //Integer.MAX_VALUE >> 2 == 2的31次方-1 表示的int的最大值 31 | } 32 | else { 33 | // Any other height should be respected as is. 34 | heightSpec = heightMeasureSpec; 35 | } 36 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /library/src/main/java/com/tangguna/searchbox/library/widget/SelfSearchGridView.java: -------------------------------------------------------------------------------- 1 | package com.tangguna.searchbox.library.widget; 2 | 3 | import android.content.Context; 4 | import android.util.AttributeSet; 5 | import android.view.ViewGroup; 6 | import android.widget.GridView; 7 | 8 | public class SelfSearchGridView extends GridView { 9 | 10 | public SelfSearchGridView(Context context) { 11 | super(context); 12 | } 13 | 14 | public SelfSearchGridView(Context context, AttributeSet attrs) { 15 | super(context, attrs); 16 | } 17 | 18 | 19 | public SelfSearchGridView(Context context, AttributeSet attrs, int defStyleAttr) { 20 | super(context, attrs, defStyleAttr); 21 | } 22 | 23 | @Override 24 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 25 | 26 | int heightSpec; 27 | if(getLayoutParams().height== ViewGroup.LayoutParams.WRAP_CONTENT) 28 | { 29 | heightSpec = MeasureSpec.makeMeasureSpec( 30 | Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); 31 | //Integer.MAX_VALUE >> 2 == 2的31次方-1 表示的int的最大值 32 | } 33 | else { 34 | // Any other height should be respected as is. 35 | heightSpec = heightMeasureSpec; 36 | } 37 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /library/src/main/java/com/tangguna/searchbox/library/adapter/HistoryDataAdapter.java: -------------------------------------------------------------------------------- 1 | package com.tangguna.searchbox.library.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.BaseAdapter; 7 | import android.widget.TextView; 8 | 9 | import com.tangguna.searchbox.library.R; 10 | 11 | import java.util.ArrayList; 12 | 13 | /** 14 | * GridView列表展示历史记录数据 15 | */ 16 | public class HistoryDataAdapter extends BaseAdapter { 17 | 18 | private Context context; 19 | private ArrayList list = new ArrayList(); 20 | 21 | 22 | public HistoryDataAdapter(Context context, ArrayList list) { 23 | this.context = context; 24 | this.list = list; 25 | } 26 | 27 | 28 | @Override 29 | public int getCount() { 30 | return list.size(); 31 | } 32 | 33 | @Override 34 | public Object getItem(int i) { 35 | return list.get(i); 36 | } 37 | 38 | @Override 39 | public long getItemId(int i) { 40 | return i; 41 | } 42 | 43 | @Override 44 | public View getView(int i, View view, ViewGroup viewGroup) { 45 | ViewHolder holder = null; 46 | if (view == null){ 47 | holder = new ViewHolder(); 48 | view = View.inflate(context,R.layout.search_olddata_item,null); 49 | holder.tv = (TextView) view.findViewById(R.id.text); 50 | view.setTag(holder); 51 | }else { 52 | holder = (ViewHolder) view.getTag(); 53 | } 54 | holder.tv.setText(list.get(i)); 55 | return view; 56 | } 57 | 58 | public class ViewHolder{ 59 | TextView tv; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /library/src/main/java/com/tangguna/searchbox/library/adapter/HistoryDataListViewAdapter.java: -------------------------------------------------------------------------------- 1 | package com.tangguna.searchbox.library.adapter; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.BaseAdapter; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import com.tangguna.searchbox.library.R; 11 | 12 | import java.util.ArrayList; 13 | 14 | /** 15 | * ListView列表展示历史记录 16 | */ 17 | public class HistoryDataListViewAdapter extends BaseAdapter { 18 | 19 | private Context context; 20 | private ArrayList list = new ArrayList(); 21 | 22 | public HistoryDataListViewAdapter(Context context, ArrayList list) { 23 | this.context = context; 24 | this.list = list; 25 | } 26 | 27 | 28 | @Override 29 | public int getCount() { 30 | return list.size(); 31 | } 32 | 33 | @Override 34 | public Object getItem(int i) { 35 | return list.get(i); 36 | } 37 | 38 | @Override 39 | public long getItemId(int i) { 40 | return i; 41 | } 42 | 43 | @Override 44 | public View getView(int i, View view, ViewGroup viewGroup) { 45 | ViewHolder holder = null; 46 | if (view == null){ 47 | holder = new ViewHolder(); 48 | view = View.inflate(context,R.layout.list_item,null); 49 | holder.tv_info = (TextView)view.findViewById(R.id.tv_info); 50 | view.setTag(holder); 51 | }else { 52 | holder = (ViewHolder) view.getTag(); 53 | } 54 | holder.tv_info.setText(list.get(i)); 55 | return view; 56 | } 57 | 58 | class ViewHolder{ 59 | TextView tv_info; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 27 | 28 | 29 | 30 | 31 | 32 | 34 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 15 | 16 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /library/src/main/java/com/tangguna/searchbox/library/cache/HistoryCache.java: -------------------------------------------------------------------------------- 1 | package com.tangguna.searchbox.library.cache; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import com.google.gson.Gson; 6 | import com.google.gson.reflect.TypeToken; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 历史缓存工具类 12 | */ 13 | public class HistoryCache { 14 | 15 | /** 16 | * 清除所有数据 17 | * @param context 18 | */ 19 | public static void clear(Context context) { 20 | SharedPreferences sp = context.getSharedPreferences("record", Context.MODE_PRIVATE); 21 | sp.edit().clear().commit(); 22 | } 23 | 24 | /** 25 | * 保存历史记录到SharedPreferences中 26 | * 27 | * @param result 28 | */ 29 | public static void saveHistory(Context context, String result) { 30 | SharedPreferences sp = context.getSharedPreferences("record", Context.MODE_PRIVATE); 31 | SharedPreferences.Editor editor = sp.edit(); 32 | editor.putString("record_key", result); 33 | editor.commit(); 34 | } 35 | 36 | /** 37 | * 获取保存在SharedPreferences中的历史记录 38 | * 39 | * @return 40 | */ 41 | public static String getHistory(Context context) { 42 | SharedPreferences sp = context.getSharedPreferences("record", Context.MODE_PRIVATE); 43 | String result = sp.getString("record_key", null); 44 | return result; 45 | } 46 | 47 | /** 48 | * 把json数据转换成list 49 | * @param context 50 | * @return 51 | */ 52 | public static List toArray(Context context) { 53 | 54 | String history = getHistory(context); 55 | Gson gson = new Gson(); 56 | List retList = gson.fromJson(history, new TypeToken>() { 57 | }.getType()); 58 | return retList; 59 | } 60 | 61 | /** 62 | * ArrayList 转换成JsonArray 63 | * @param historyList 64 | * @return 65 | */ 66 | public static String toJsonArray(List historyList) { 67 | 68 | Gson gson = new Gson(); 69 | return gson.toJson(historyList); // 将JSONArray转换得到String 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /library/src/main/res/layout/msearch_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 15 | 16 | 28 | 38 | 39 | 40 |