├── .gitattributes ├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── will │ │ └── example │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── will │ │ │ └── example │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── will │ └── example │ └── ExampleUnitTest.java ├── build.gradle ├── filesearcher ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── will │ │ └── filesearcher │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── will │ │ │ └── filesearcher │ │ │ ├── FileSearcher.java │ │ │ ├── FileSearcherActivity.java │ │ │ ├── FileSearcherAdapter.java │ │ │ ├── delegate │ │ │ └── FileSearcherDelegateActivity.java │ │ │ ├── filter │ │ │ └── FileFilter.java │ │ │ ├── searchengine │ │ │ ├── CallbackExecutor.java │ │ │ ├── FileItem.java │ │ │ └── SearchEngine.java │ │ │ └── util │ │ │ ├── FileSearcherUtil.java │ │ │ └── IntervalTimer.java │ └── res │ │ ├── drawable-hdpi │ │ ├── back_holo_dark_no_trim_no_padding.png │ │ ├── check_holo_dark_no_padding_no_trim.png │ │ ├── check_holo_dark_no_padding_trimmed.png │ │ └── select_all_holo_dark_no_padding_no_trim.png │ │ ├── drawable-mdpi │ │ ├── back_holo_dark_no_trim_no_padding.png │ │ ├── check_holo_dark_no_padding_no_trim.png │ │ ├── check_holo_dark_no_padding_trimmed.png │ │ └── select_all_holo_dark_no_padding_no_trim.png │ │ ├── drawable-xhdpi │ │ ├── back_holo_dark_no_trim_no_padding.png │ │ ├── check_holo_dark_no_padding_no_trim.png │ │ ├── check_holo_dark_no_padding_trimmed.png │ │ ├── file_searcher_file_icon.png │ │ └── select_all_holo_dark_no_padding_no_trim.png │ │ ├── drawable-xxhdpi │ │ ├── back_holo_dark_no_trim_no_padding.png │ │ ├── check_holo_dark_no_padding_no_trim.png │ │ ├── check_holo_dark_no_padding_trimmed.png │ │ └── select_all_holo_dark_no_padding_no_trim.png │ │ ├── layout │ │ ├── file_searcher_item.xml │ │ └── file_searcher_main.xml │ │ ├── menu │ │ └── file_searcher_activity_menu.xml │ │ ├── values-zh │ │ └── strings.xml │ │ └── values │ │ ├── color.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── will │ └── filesearcher │ └── ExampleUnitTest.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # FileSearcher 2 | A simple fileSearcher. 3 | 4 | ![image](http://i.makeagif.com/media/11-15-2016/iu91EH.gif) 5 | 6 | ## How to 7 | start FileSearcherActivity from our activity,do not forget the keyword. 8 | ```java 9 | Intent intent = new Intent(MainActivity.this, FileSearcherActivity.class); 10 | intent.putExtra("keyword",".txt"); 11 | //optional------ 12 | 13 | //intent.putExtra("max",50 * 1024);//size filter 14 | intent.putExtra("min",50 * 1024); 15 | intent.putExtra("theme",R.style.SearchTheme);//set custom theme here 16 | 17 | 18 | startActivityForResult(intent,REQUEST_CODE); 19 | ``` 20 | then we deal selected data in onActivityResult 21 | ```java 22 | @Override 23 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 24 | if(requestCode == REQUEST_CODE && resultCode ==FileSearcherActivity.OK && data != null){ 25 | ArrayList list = ( ArrayList) data.getSerializableExtra("data"); 26 | Toast.makeText(this,"you selected"+list.size()+"items",Toast.LENGTH_SHORT).show(); 27 | } 28 | } 29 | ``` 30 | ## Theme 31 | optional,you can use custom theme. 32 | ```xml 33 | 34 | 39 | ``` 40 | ## Dependency 41 | 42 | Step 1. Add the JitPack repository to your build file 43 | 44 | Add it in your root build.gradle at the end of repositories: 45 | 46 | allprojects { 47 | repositories { 48 | ... 49 | maven { url "https://jitpack.io" } 50 | } 51 | } 52 | Step 2. Add the dependency 53 | 54 | dependencies { 55 | compile 'com.github.YuanWenHai:FileSearcher:1.3.3' 56 | } 57 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | buildToolsVersion "26.0.2" 6 | defaultConfig { 7 | applicationId "com.will.filesearcher" 8 | minSdkVersion 19 9 | targetSdkVersion 26 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | /* 28 | compile 'com.android.support:appcompat-v7:26.1.0' 29 | */ 30 | testCompile 'junit:junit:4.12' 31 | compile project(':filesearcher') 32 | } 33 | -------------------------------------------------------------------------------- /app/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\will\AppData\Local\Android\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 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/will/example/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.will.example; 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 | * Instrumentation 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() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.will.filesearcher", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/will/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.will.example; 2 | 3 | import android.app.ProgressDialog; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | import android.widget.Button; 8 | import android.widget.CheckBox; 9 | import android.widget.EditText; 10 | import android.widget.Toast; 11 | 12 | import com.will.filesearcher.FileSearcher; 13 | 14 | import java.io.File; 15 | import java.io.IOException; 16 | import java.util.List; 17 | 18 | public class MainActivity extends AppCompatActivity { 19 | private static final int REQUEST_CODE = 888; 20 | @Override 21 | protected void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | setContentView(R.layout.activity_main); 24 | //makeMockedData(); 25 | final EditText keywordEdit = findViewById(R.id.example_keyword); 26 | final EditText extensionEdit = findViewById(R.id.example_extension); 27 | final EditText minSizeEdit = findViewById(R.id.example_min); 28 | final EditText maxSizeEdit = findViewById(R.id.example_max); 29 | final CheckBox showHiddenCheckBox = findViewById(R.id.example_show_hidden); 30 | Button button = (Button) findViewById(R.id.example_confirm); 31 | button.setOnClickListener(new View.OnClickListener() { 32 | @Override 33 | public void onClick(View v) { 34 | String content = keywordEdit.getText().toString().replaceAll(" ",""); 35 | String extension = extensionEdit.getText().toString(); 36 | long minSize = Long.valueOf(minSizeEdit.getText().toString().isEmpty() ? "0" : minSizeEdit.getText().toString()); 37 | long maxSize = Long.valueOf(maxSizeEdit.getText().toString().isEmpty() ? "-1" : maxSizeEdit.getText().toString()); 38 | boolean showHidden = showHiddenCheckBox.isChecked(); 39 | 40 | FileSearcher fileSearcher = new FileSearcher(MainActivity.this); 41 | fileSearcher 42 | .withKeyword(content) 43 | .withExtension(extension) 44 | .withSizeLimit(minSize,maxSize) 45 | .showHidden(showHidden) 46 | .search(new FileSearcher.FileSearcherCallback() { 47 | @Override 48 | public void onSelect(List files) { 49 | Toast.makeText(MainActivity.this, "you have selected "+files.size()+" file(s).", Toast.LENGTH_SHORT).show(); 50 | } 51 | }); 52 | } 53 | }); 54 | } 55 | private void makeMockedData(){ 56 | 57 | final File cacheDir = getExternalCacheDir(); 58 | if(cacheDir != null){ 59 | if(!cacheDir.exists()){ 60 | cacheDir.mkdirs(); 61 | } 62 | if(cacheDir.listFiles().length > 0){ 63 | return; 64 | } 65 | final ProgressDialog p = new ProgressDialog(this); 66 | p.show(); 67 | new Thread(new Runnable() { 68 | @Override 69 | public void run() { 70 | try{ 71 | for(int i=0;i<200;i++){ 72 | File dir = new File(cacheDir.getPath()+File.separator+i); 73 | dir.mkdir(); 74 | for(int a=0;a<200;a++){ 75 | File file = new File(dir.getPath()+File.separator+i+"-"+a); 76 | file.createNewFile(); 77 | } 78 | } 79 | 80 | }catch (IOException i){ 81 | i.printStackTrace(); 82 | }finally { 83 | runOnUiThread(new Runnable() { 84 | @Override 85 | public void run() { 86 | p.cancel(); 87 | } 88 | }); 89 | } 90 | } 91 | }).start(); 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 16 | 22 | 23 | 28 | 34 | 35 | 39 | 40 | 48 | 49 | 57 | 58 | 63 |