├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── 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 │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── styles.xml │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ ├── layout │ │ │ └── activity_main.xml │ │ └── drawable │ │ │ └── ic_launcher_background.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── cn │ │ └── zfs │ │ └── fileselectorexample │ │ ├── MainActivity.kt │ │ └── CheckPermissionsActivity.java ├── proguard-rules.pro └── build.gradle ├── library ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── drawable-xhdpi │ │ │ ├── fs_pdf.png │ │ │ ├── fs_ppt.png │ │ │ ├── fs_ps.png │ │ │ ├── fs_zip.png │ │ │ ├── fs_arrow.png │ │ │ ├── fs_audio.png │ │ │ ├── fs_excel.png │ │ │ ├── fs_file.png │ │ │ ├── fs_flash.png │ │ │ ├── fs_html.png │ │ │ ├── fs_text.png │ │ │ ├── fs_word.png │ │ │ └── fs_developer.png │ │ ├── drawable │ │ │ ├── fs_action_dialog_bg.xml │ │ │ ├── fs_popun_menu_bg.xml │ │ │ ├── fs_chkbox_bg.xml │ │ │ ├── fs_simple_btn_bg.xml │ │ │ ├── fs_ic_chk_uncheck.xml │ │ │ ├── fs_ic_back.xml │ │ │ ├── fs_ic_more.xml │ │ │ ├── fs_ic_chk_checked.xml │ │ │ ├── fs_ic_fork.xml │ │ │ ├── fs_ic_folder.xml │ │ │ ├── fs_ic_del.xml │ │ │ └── fs_ic_select_all.xml │ │ ├── anim │ │ │ ├── fs_dialog_in_from_bottom.xml │ │ │ └── fs_dialog_out_from_bottom.xml │ │ ├── values │ │ │ ├── styles.xml │ │ │ └── colors.xml │ │ └── layout │ │ │ ├── fs_listview.xml │ │ │ ├── fs_item_popup_menu.xml │ │ │ ├── fs_dir_view.xml │ │ │ ├── fs_dialog_selected_item.xml │ │ │ ├── fs_file_item_view.xml │ │ │ └── fs_activity_select_file.xml │ │ ├── java │ │ └── cn │ │ │ └── wandersnail │ │ │ └── fileselector │ │ │ ├── OnFileSelectListener.java │ │ │ ├── Language.java │ │ │ ├── DirCell.java │ │ │ ├── ViewHolder.java │ │ │ ├── BaseHolder.java │ │ │ ├── Item.java │ │ │ ├── BaseListAdapter.java │ │ │ ├── ActionDialog.java │ │ │ ├── TextHolder.java │ │ │ ├── FileSelector.java │ │ │ ├── SelectedItemDialog.java │ │ │ ├── Utils.java │ │ │ ├── CharacterParser.java │ │ │ └── SelectFileActivity.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── .gitignore ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew.bat ├── README.md ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':library' 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.gradle 2 | /.idea 3 | *.iml 4 | build 5 | /local.properties 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/fs_pdf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/library/src/main/res/drawable-xhdpi/fs_pdf.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/fs_ppt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/library/src/main/res/drawable-xhdpi/fs_ppt.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/fs_ps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/library/src/main/res/drawable-xhdpi/fs_ps.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/fs_zip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/library/src/main/res/drawable-xhdpi/fs_zip.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/fs_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/library/src/main/res/drawable-xhdpi/fs_arrow.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/fs_audio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/library/src/main/res/drawable-xhdpi/fs_audio.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/fs_excel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/library/src/main/res/drawable-xhdpi/fs_excel.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/fs_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/library/src/main/res/drawable-xhdpi/fs_file.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/fs_flash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/library/src/main/res/drawable-xhdpi/fs_flash.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/fs_html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/library/src/main/res/drawable-xhdpi/fs_html.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/fs_text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/library/src/main/res/drawable-xhdpi/fs_text.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/fs_word.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/library/src/main/res/drawable-xhdpi/fs_word.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/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/wandersnail/fileselector/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/wandersnail/fileselector/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/wandersnail/fileselector/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xhdpi/fs_developer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wandersnail/fileselector/HEAD/library/src/main/res/drawable-xhdpi/fs_developer.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Mar 03 16:28:23 CST 2020 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-5.6.4-all.zip 7 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/fs_action_dialog_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/fs_popun_menu_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /library/src/main/java/cn/wandersnail/fileselector/OnFileSelectListener.java: -------------------------------------------------------------------------------- 1 | package cn.wandersnail.fileselector; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * date: 2019/8/8 14:40 7 | * author: zengfansheng 8 | */ 9 | public interface OnFileSelectListener { 10 | void onFileSelect(int requestCode, List paths); 11 | } 12 | -------------------------------------------------------------------------------- /library/src/main/res/anim/fs_dialog_in_from_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /library/src/main/res/anim/fs_dialog_out_from_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /library/src/main/java/cn/wandersnail/fileselector/Language.java: -------------------------------------------------------------------------------- 1 | package cn.wandersnail.fileselector; 2 | 3 | /** 4 | * date: 2019/8/8 14:48 5 | * author: zengfansheng 6 | */ 7 | public enum Language { 8 | SIMPLIFIED_CHINESE(0), TRADITIONAL_CHINESE(1), ENGLISH(2); 9 | 10 | int value; 11 | 12 | Language(int value) { 13 | this.value = value; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /library/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/fs_chkbox_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /library/src/main/res/layout/fs_listview.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /library/src/main/java/cn/wandersnail/fileselector/DirCell.java: -------------------------------------------------------------------------------- 1 | package cn.wandersnail.fileselector; 2 | 3 | import java.io.File; 4 | 5 | /** 6 | * date: 2019/8/8 14:39 7 | * author: zengfansheng 8 | */ 9 | class DirCell { 10 | int index; 11 | File location; 12 | 13 | DirCell() { 14 | } 15 | 16 | DirCell(int index, File location) { 17 | this.index = index; 18 | this.location = location; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/fs_simple_btn_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /library/src/main/java/cn/wandersnail/fileselector/ViewHolder.java: -------------------------------------------------------------------------------- 1 | package cn.wandersnail.fileselector; 2 | 3 | import android.view.View; 4 | import android.widget.ImageView; 5 | import android.widget.TextView; 6 | 7 | /** 8 | * date: 2019/8/8 14:41 9 | * author: zengfansheng 10 | */ 11 | abstract class ViewHolder extends BaseHolder { 12 | TextView tvName; 13 | TextView tvDesc; 14 | ImageView iv; 15 | ImageView ivSelect; 16 | View chkView; 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | fileselector 3 | 设置 4 | 取消 5 | 当前应用缺少必要权限。\n\n请点击\"设置\"-\"权限\"-打开所需权限。 6 | 申请权限 7 | 应用需要打开修改系统设置权限 8 | 应用需要打开未知来源权限 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/fs_ic_chk_uncheck.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #5F51B5 4 | #4d3F9F 5 | #FF4081 6 | 7 | #008577 8 | #00574B 9 | #F3343C 10 | #BF2830 11 | 12 | -------------------------------------------------------------------------------- /library/src/main/res/layout/fs_item_popup_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/fs_ic_back.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /library/src/main/java/cn/wandersnail/fileselector/BaseHolder.java: -------------------------------------------------------------------------------- 1 | package cn.wandersnail.fileselector; 2 | 3 | import android.view.View; 4 | 5 | /** 6 | * date: 2019/8/8 13:40 7 | * author: zengfansheng 8 | */ 9 | abstract class BaseHolder { 10 | final View convertView; 11 | 12 | BaseHolder() { 13 | convertView = createConvertView(); 14 | convertView.setTag(this); 15 | } 16 | 17 | 18 | /** 19 | * 设置数据 20 | */ 21 | abstract void setData(T data, int position); 22 | 23 | /** 24 | * 创建界面 25 | */ 26 | abstract View createConvertView(); 27 | } 28 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/fs_ic_more.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 8 | 9 | 12 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /library/src/main/res/layout/fs_dir_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 13 | 17 | -------------------------------------------------------------------------------- /library/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #4C61D9 4 | #3F51B5 5 | #FEFEFE 6 | #00000000 7 | #FFFFFF 8 | #050505 9 | #E1E1E1 10 | #989898 11 | #505050 12 | #bfbfbf 13 | #CCCCCC 14 | #b0b0b0 15 | #11000000 16 | 17 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/fs_ic_chk_checked.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/fs_ic_fork.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /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 | android.enableJetifier=true 10 | android.useAndroidX=true 11 | org.gradle.jvmargs=-Xmx1536m 12 | # When configured, Gradle will run in incubating parallel mode. 13 | # This option should only be used with decoupled projects. More details, visit 14 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 15 | # org.gradle.parallel=true 16 | -------------------------------------------------------------------------------- /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/fs_ic_folder.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 18 | 19 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/fs_ic_del.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | 5 | android { 6 | compileSdkVersion rootProject.ext.compileSdkVersion 7 | defaultConfig { 8 | minSdkVersion rootProject.ext.minSdkVersion 9 | targetSdkVersion rootProject.ext.targetSdkVersion 10 | applicationId "cn.zfs.fileselectorexample" 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | compileOptions { 21 | sourceCompatibility JavaVersion.VERSION_1_8 22 | targetCompatibility JavaVersion.VERSION_1_8 23 | } 24 | } 25 | 26 | dependencies { 27 | implementation fileTree(dir: 'libs', include: ['*.jar']) 28 | implementation "androidx.appcompat:appcompat:$appcompat_version" 29 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 30 | implementation "com.github.bumptech.glide:glide:$glide_version" 31 | implementation "cn.wandersnail:common-utils:$common_utils_version" 32 | implementation "cn.wandersnail:common-base:$common_base_version" 33 | implementation project(':library') 34 | } 35 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/fs_ic_select_all.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/java/cn/wandersnail/fileselector/Item.java: -------------------------------------------------------------------------------- 1 | package cn.wandersnail.fileselector; 2 | 3 | import java.io.File; 4 | import java.util.Objects; 5 | 6 | import androidx.annotation.NonNull; 7 | 8 | /** 9 | * date: 2019/8/8 14:44 10 | * author: zengfansheng 11 | */ 12 | class Item implements Comparable { 13 | File file; 14 | boolean checked; 15 | String desc; 16 | 17 | Item(File file, boolean checked) { 18 | this.file = file; 19 | this.checked = checked; 20 | } 21 | 22 | Item(File file, boolean checked, String desc) { 23 | this.file = file; 24 | this.checked = checked; 25 | this.desc = desc; 26 | } 27 | 28 | @Override 29 | public int compareTo(@NonNull Item other) { 30 | if (file == null) { 31 | return -1; 32 | } else if (other.file == null) { 33 | return 1; 34 | } 35 | String s = CharacterParser.getSpelling(file.getName()); 36 | String s1 = CharacterParser.getSpelling(other.file.getName()); 37 | return s.compareTo(s1); 38 | } 39 | 40 | @Override 41 | public boolean equals(Object o) { 42 | if (this == o) return true; 43 | if (!(o instanceof Item)) return false; 44 | Item item = (Item) o; 45 | return Objects.equals(file, item.file); 46 | } 47 | 48 | @Override 49 | public int hashCode() { 50 | return Objects.hash(file); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /library/src/main/java/cn/wandersnail/fileselector/BaseListAdapter.java: -------------------------------------------------------------------------------- 1 | package cn.wandersnail.fileselector; 2 | 3 | import android.content.Context; 4 | import android.view.View; 5 | import android.view.ViewGroup; 6 | import android.widget.BaseAdapter; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * date: 2019/8/8 13:43 13 | * author: zengfansheng 14 | */ 15 | abstract class BaseListAdapter extends BaseAdapter { 16 | protected Context context; 17 | protected List data; 18 | 19 | BaseListAdapter(Context context) { 20 | this(context, new ArrayList()); 21 | } 22 | 23 | BaseListAdapter(Context context, List data) { 24 | this.context = context; 25 | this.data = data; 26 | } 27 | 28 | void refresh(List data) { 29 | this.data.clear(); 30 | this.data.addAll(data); 31 | notifyDataSetChanged(); 32 | } 33 | 34 | @Override 35 | public int getCount() { 36 | return data.size(); 37 | } 38 | 39 | @Override 40 | public T getItem(int position) { 41 | return data.get(position); 42 | } 43 | 44 | @Override 45 | public long getItemId(int position) { 46 | return position; 47 | } 48 | 49 | 50 | @SuppressWarnings("unchecked") 51 | @Override 52 | public View getView(int position, View convertView, ViewGroup parent) { 53 | BaseHolder holder; 54 | if (convertView == null) { 55 | holder = getHolder(position); 56 | } else { 57 | holder = (BaseHolder) convertView.getTag(); 58 | } 59 | holder.setData(data.get(position), position); 60 | return holder.convertView; 61 | } 62 | 63 | abstract BaseHolder getHolder(int position); 64 | } 65 | -------------------------------------------------------------------------------- /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/res/layout/fs_dialog_selected_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 17 | 27 | 34 | 45 | 46 | 47 | 51 | 52 | 58 | -------------------------------------------------------------------------------- /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 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 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 Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 14 |