├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_logo.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_logo.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_logo.png │ │ │ │ └── ic_place_holder.png │ │ │ ├── values │ │ │ │ ├── ids.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── strings.xml │ │ │ ├── drawable │ │ │ │ ├── rectangle_select_strategy_normal.xml │ │ │ │ ├── rectangle_select_strategy_checked.xml │ │ │ │ ├── rectangle_select_result.xml │ │ │ │ └── sel_select_strategy_change.xml │ │ │ ├── layout │ │ │ │ ├── layout_media_store_gallery.xml │ │ │ │ ├── layout_select_file_strategy.xml │ │ │ │ ├── item_select_file_result.xml │ │ │ │ ├── activity_media_info.xml │ │ │ │ ├── activity_select_multi_files.xml │ │ │ │ ├── activity_file_info.xml │ │ │ │ ├── activity_file_core.xml │ │ │ │ ├── activity_storage_access_framework.xml │ │ │ │ ├── activity_media_store.xml │ │ │ │ └── activity_select_single_image.xml │ │ │ ├── xml │ │ │ │ └── paths.xml │ │ │ └── values-en │ │ │ │ └── strings.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── ando │ │ │ │ └── file │ │ │ │ └── sample │ │ │ │ ├── ui │ │ │ │ ├── 2024 │ │ │ │ ├── upload │ │ │ │ │ ├── IProgressResponseCallBack.java │ │ │ │ │ ├── FileUploadActivity.kt │ │ │ │ │ ├── Upload.kt │ │ │ │ │ └── UploadProgressRequestBody.java │ │ │ │ ├── selector │ │ │ │ │ ├── fragment │ │ │ │ │ │ └── FileSelectFragmentUsageActivity.kt │ │ │ │ │ └── FileSelectResultAdapter.kt │ │ │ │ ├── MainActivity.kt │ │ │ │ ├── core │ │ │ │ │ └── FileCoreActivity.kt │ │ │ │ ├── MediaInfoActivity.kt │ │ │ │ └── FileInfoActivity.kt │ │ │ │ ├── App.kt │ │ │ │ ├── utils │ │ │ │ ├── NoShakeListener.kt │ │ │ │ ├── ClearCacheUtils.kt │ │ │ │ ├── PermissionManager.kt │ │ │ │ ├── DocumentFileUtils.kt │ │ │ │ ├── CrashHandler.kt │ │ │ │ ├── MethodSignKotlinUtils.kt │ │ │ │ └── BitmapUtils.kt │ │ │ │ └── Global.kt │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── ando │ │ │ └── file │ │ │ └── sample │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── ando │ │ └── file │ │ └── sample │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── library_core ├── consumer-rules.pro ├── .gitignore ├── src │ └── main │ │ ├── java │ │ └── ando │ │ │ └── file │ │ │ └── core │ │ │ ├── FileProvider.kt │ │ │ ├── FileLogger.kt │ │ │ ├── FileOperator.kt │ │ │ ├── FileOpener.kt │ │ │ ├── FileGlobal.kt │ │ │ └── FileDirectory.kt │ │ ├── res │ │ └── xml │ │ │ └── ando_paths.xml │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── library_selector ├── .gitignore ├── consumer-rules.pro ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ ├── values │ │ │ └── strings.xml │ │ └── values-en │ │ │ └── strings.xml │ │ └── java │ │ └── ando │ │ └── file │ │ └── selector │ │ ├── FileSelectResult.kt │ │ ├── FileSelectorExt.kt │ │ ├── FileSelectOptions.kt │ │ └── FileType.kt ├── proguard-rules.pro └── build.gradle ├── library_compressor ├── .gitignore ├── consumer-rules.pro ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── ando │ │ └── file │ │ └── compressor │ │ ├── ImageCompressInterface.kt │ │ ├── ImageCompressEngine.kt │ │ └── ImageChecker.kt ├── proguard-rules.pro └── build.gradle ├── keystore.jks ├── screenshot ├── cache.png ├── func.png ├── img1.png ├── pick1.png ├── pick2.png └── pick3.png ├── screenMatch.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── settings.gradle ├── .gitignore ├── gradle.properties ├── gradlew.bat ├── README_VERSIONS.md ├── publish.gradle ├── README_BASIC.md └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library_core/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /library_selector/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /library_compressor/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /library_compressor/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /library_core/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /library_selector/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javakam/FileOperator/HEAD/keystore.jks -------------------------------------------------------------------------------- /screenshot/cache.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javakam/FileOperator/HEAD/screenshot/cache.png -------------------------------------------------------------------------------- /screenshot/func.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javakam/FileOperator/HEAD/screenshot/func.png -------------------------------------------------------------------------------- /screenshot/img1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javakam/FileOperator/HEAD/screenshot/img1.png -------------------------------------------------------------------------------- /screenshot/pick1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javakam/FileOperator/HEAD/screenshot/pick1.png -------------------------------------------------------------------------------- /screenshot/pick2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javakam/FileOperator/HEAD/screenshot/pick2.png -------------------------------------------------------------------------------- /screenshot/pick3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javakam/FileOperator/HEAD/screenshot/pick3.png -------------------------------------------------------------------------------- /library_compressor/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /library_selector/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /screenMatch.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javakam/FileOperator/HEAD/screenMatch.properties -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javakam/FileOperator/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javakam/FileOperator/HEAD/app/src/main/res/mipmap-hdpi/ic_logo.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javakam/FileOperator/HEAD/app/src/main/res/mipmap-xhdpi/ic_logo.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javakam/FileOperator/HEAD/app/src/main/res/mipmap-xxhdpi/ic_logo.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_place_holder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javakam/FileOperator/HEAD/app/src/main/res/mipmap-xxhdpi/ic_place_holder.png -------------------------------------------------------------------------------- /app/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'FileOperator' 2 | 3 | include ':app' 4 | include ':library_core' 5 | include ':library_selector' 6 | include ':library_compressor' -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | .cxx 10 | bintrayUpload.bat 11 | /buildSrc -------------------------------------------------------------------------------- /library_core/src/main/java/ando/file/core/FileProvider.kt: -------------------------------------------------------------------------------- 1 | package ando.file.core 2 | 3 | import androidx.core.content.FileProvider 4 | 5 | /** 6 | * FileProvider 7 | * 8 | * @author javakam 9 | * @date 2020/8/24 11:24 10 | */ 11 | open class FileProvider : FileProvider() -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Aug 08 16:53:14 CST 2023 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists -------------------------------------------------------------------------------- /app/src/main/res/drawable/rectangle_select_strategy_normal.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/rectangle_select_strategy_checked.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/rectangle_select_result.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/com/ando/file/sample/ui/2024: -------------------------------------------------------------------------------- 1 | ### 11 2 | https://developer.android.com/about/versions/11/summary?hl=zh-cn 3 | ### 12 4 | https://developer.android.com/about/versions/12/summary?hl=zh-cn 5 | https://developer.android.com/training/data-storage/shared/media?hl=zh-cn#well-defined-collections 6 | ### 13 7 | https://developer.android.com/about/versions/13/summary?hl=zh-cn 8 | https://developer.android.com/about/versions/13/features/photopicker?hl=zh-cn -------------------------------------------------------------------------------- /library_selector/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 文件类型不匹配 5 | 超过限定文件大小 6 | 超过限定文件总大小 7 | 设定类型文件至少选择一个 8 | 超过限定文件数量 9 | 10 | -------------------------------------------------------------------------------- /app/src/test/java/com/ando/file/sample/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.ando.file.sample 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/sel_select_strategy_change.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/ando/file/sample/ui/upload/IProgressResponseCallBack.java: -------------------------------------------------------------------------------- 1 | package com.ando.file.sample.ui.upload; 2 | 3 | /** 4 | *

描述:上传进度回调接口

5 | * 6 | * @author xuexiang 7 | * @since 2018/6/21 上午1:57 8 | */ 9 | public interface IProgressResponseCallBack { 10 | /** 11 | * 回调进度 12 | * 13 | * @param bytesWritten 当前读取响应体字节长度 14 | * @param contentLength 总长度 15 | * @param done 是否读取完成 16 | */ 17 | void onResponseProgress(long bytesWritten, long contentLength, boolean done); 18 | } 19 | -------------------------------------------------------------------------------- /library_selector/src/main/res/values-en/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | File type mismatch 5 | Exceed the limit file size 6 | Exceeds the total file size limit 7 | Select at least one set type file 8 | Exceed the limited number of files 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/com/ando/file/sample/App.kt: -------------------------------------------------------------------------------- 1 | package com.ando.file.sample 2 | 3 | import android.app.Application 4 | import ando.file.core.FileOperator 5 | import com.ando.file.sample.utils.CrashHandler 6 | 7 | /** 8 | * # App 9 | * 10 | * @author javakam 11 | * @date 2020/5/9 14:08 12 | */ 13 | class App : Application() { 14 | 15 | override fun onCreate() { 16 | super.onCreate() 17 | FileOperator.init(this, true) 18 | CrashHandler.init(this, "${externalCacheDir?.path}/Crash/") 19 | //MethodSignKotlinUtils.dumpMethods(this) 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ando/file/sample/ui/upload/FileUploadActivity.kt: -------------------------------------------------------------------------------- 1 | package com.ando.file.sample.ui.upload 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | import okhttp3.OkHttpClient 6 | 7 | /** 8 | * Title: # FileUploadActivity 9 | *

10 | * Description: 11 | *

12 | * @author javakam 13 | * @date 2021/3/2 13:52 14 | */ 15 | class FileUploadActivity: AppCompatActivity() { 16 | 17 | override fun onCreate(savedInstanceState: Bundle?) { 18 | super.onCreate(savedInstanceState) 19 | 20 | val client = OkHttpClient() 21 | val uploader=FileUploader(client,this) 22 | //uploader.uploadFromUri() 23 | 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_media_store_gallery.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/ando/file/sample/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.ando.file.sample 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.ando.file.app", appContext.packageName) 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_compressor/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 -------------------------------------------------------------------------------- /library_core/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_selector/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 -------------------------------------------------------------------------------- /library_core/src/main/res/xml/ando_paths.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 12 | 13 | 14 | 17 | 18 | 19 | 22 | 23 | 24 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #23ADE5 4 | #23ADE5 5 | #03DAC5 6 | 7 | #918D8D 8 | 9 | #FF000000 10 | #FFFFFFFF 11 | #00000000 12 | 13 | #23ADE5 14 | #CC23ADE5 15 | #323232 16 | #A2A2A2 17 | 18 | #F4F4F4 19 | #FAFAFA 20 | #C2C2C2 21 | -------------------------------------------------------------------------------- /library_core/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 9 | 10 | 11 | 16 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | 20 | 21 | 29 | 30 | -------------------------------------------------------------------------------- /library_selector/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | id 'kotlin-android' 4 | id 'kotlin-parcelize' 5 | } 6 | 7 | android { 8 | compileSdk rootProject.ext.compileSdkVersion 9 | defaultConfig { 10 | minSdk rootProject.ext.minSdkVersion 11 | targetSdk rootProject.ext.targetSdkVersion 12 | 13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 14 | consumerProguardFiles "consumer-rules.pro" 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | compileOptions { 24 | sourceCompatibility JavaVersion.VERSION_1_8 25 | targetCompatibility JavaVersion.VERSION_1_8 26 | } 27 | kotlinOptions { 28 | jvmTarget = "1.8" 29 | } 30 | lint { 31 | abortOnError false 32 | } 33 | namespace 'ando.file.selector' 34 | } 35 | 36 | dependencies { 37 | compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 38 | compileOnly 'androidx.core:core-ktx:1.10.1' 39 | compileOnly 'androidx.appcompat:appcompat:1.6.1' 40 | 41 | compileOnly project(':library_core') 42 | } 43 | 44 | ext { 45 | PUBLISH_ARTIFACT_ID = 'file.selector' 46 | } 47 | apply from: "${rootProject.projectDir}/publish.gradle" -------------------------------------------------------------------------------- /library_compressor/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | id 'kotlin-android' 4 | } 5 | 6 | android { 7 | compileSdk rootProject.ext.compileSdkVersion 8 | defaultConfig { 9 | minSdk rootProject.ext.minSdkVersion 10 | targetSdk rootProject.ext.targetSdkVersion 11 | 12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 13 | consumerProguardFiles "consumer-rules.pro" 14 | } 15 | 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | compileOptions { 23 | sourceCompatibility JavaVersion.VERSION_1_8 24 | targetCompatibility JavaVersion.VERSION_1_8 25 | } 26 | kotlinOptions { 27 | jvmTarget = "1.8" 28 | } 29 | lint { 30 | abortOnError false 31 | } 32 | namespace 'ando.file.compressor' 33 | } 34 | 35 | dependencies { 36 | compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 37 | compileOnly 'androidx.core:core-ktx:1.10.1' 38 | compileOnly 'androidx.appcompat:appcompat:1.6.1' 39 | 40 | //https://github.com/Curzibn/Luban/issues/337 41 | implementation 'androidx.exifinterface:exifinterface:1.3.6' 42 | 43 | implementation project(':library_core') 44 | 45 | } 46 | 47 | ext { 48 | PUBLISH_ARTIFACT_ID = 'file.compressor' 49 | } 50 | apply from: "${rootProject.projectDir}/publish.gradle" -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_select_file_strategy.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 20 | 21 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /library_compressor/src/main/java/ando/file/compressor/ImageCompressInterface.kt: -------------------------------------------------------------------------------- 1 | package ando.file.compressor 2 | 3 | import android.net.Uri 4 | 5 | /** 6 | * Created on 2018/1/3 19:43 7 | * 8 | * @author andy 9 | * 10 | * A functional interface (callback) that returns true or false for the given input path should be compressed. 11 | */ 12 | interface ImageCompressPredicate { 13 | /** 14 | * Determine the given input path should be compressed and return a boolean. 15 | * @param uri input uri 16 | * @return the boolean result 17 | */ 18 | fun apply(uri: Uri?): Boolean 19 | } 20 | 21 | interface OnImageCompressListener { 22 | /** 23 | * Fired when the compression is started, override to handle in your own code 24 | */ 25 | fun onStart() {} 26 | 27 | /** 28 | * Fired when a compression returns successfully, override to handle in your own code 29 | */ 30 | fun onSuccess(index: Int = 0, uri: Uri?) {} 31 | 32 | /** 33 | * Fired when a compression fails to complete, override to handle in your own code 34 | */ 35 | fun onError(e: Throwable?) {} 36 | } 37 | 38 | /** 39 | * 提供修改压缩图片命名接口 40 | * 41 | * A functional interface (callback) that used to rename the file after compress. 42 | */ 43 | interface OnImageRenameListener { 44 | /** 45 | * 压缩前调用该方法用于修改压缩后文件名 46 | * 47 | * 48 | * Call before compression begins. 49 | * 50 | * @param uri 传入文件路径/ file uri 51 | * @return 返回重命名后的字符串/ file name 52 | */ 53 | fun rename(uri: Uri?): String? 54 | } -------------------------------------------------------------------------------- /library_core/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | id 'kotlin-android' 4 | } 5 | 6 | android { 7 | compileSdk rootProject.ext.compileSdkVersion 8 | defaultConfig { 9 | minSdk rootProject.ext.minSdkVersion 10 | targetSdk rootProject.ext.targetSdkVersion 11 | 12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 13 | consumerProguardFiles 'consumer-rules.pro' 14 | } 15 | 16 | buildTypes { 17 | debug {} 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | compileOptions { 24 | sourceCompatibility JavaVersion.VERSION_1_8 25 | targetCompatibility JavaVersion.VERSION_1_8 26 | } 27 | kotlinOptions { 28 | jvmTarget = "1.8" 29 | } 30 | lint { 31 | abortOnError false 32 | } 33 | namespace 'ando.file' 34 | // More than one file was found with OS independent path 'META-INF/library_release.kotlin_module' 35 | // packagingOptions { 36 | // exclude 'META-INF/*.kotlin_module' 37 | // } 38 | } 39 | 40 | dependencies { 41 | compileOnly 'androidx.appcompat:appcompat:1.6.1' 42 | compileOnly 'androidx.annotation:annotation:1.6.0' 43 | //https://github.com/Curzibn/Luban/issues/337 44 | compileOnly 'androidx.exifinterface:exifinterface:1.3.6' 45 | } 46 | 47 | ext { 48 | PUBLISH_ARTIFACT_ID = "file.core" 49 | } 50 | apply from: "${rootProject.projectDir}/publish.gradle" -------------------------------------------------------------------------------- /app/src/main/res/layout/item_select_file_result.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 20 | 21 | 28 | 29 | 39 | 40 | -------------------------------------------------------------------------------- /library_selector/src/main/java/ando/file/selector/FileSelectResult.kt: -------------------------------------------------------------------------------- 1 | package ando.file.selector 2 | 3 | import android.net.Uri 4 | import android.os.Parcelable 5 | import kotlinx.parcelize.Parcelize 6 | import kotlinx.parcelize.RawValue 7 | 8 | /** 9 | * ### 选择结果 10 | * 11 | * @author javakam 12 | * @date 2020/5/14 10:32 13 | */ 14 | @Parcelize 15 | data class FileSelectResult( 16 | var fileType: @RawValue IFileType?, 17 | var mimeType: String?, 18 | var uri: Uri?, 19 | var filePath: String?, 20 | var fileSize: Long = 0L, 21 | ) : Parcelable { 22 | 23 | constructor() : this(null, null, null, null, 0L) 24 | 25 | override fun toString(): String { 26 | return "FileType= $fileType \n MimeType= $mimeType \n Uri= $uri \n Path= $filePath \n Size(Byte)= $fileSize \n " 27 | } 28 | 29 | override fun equals(other: Any?): Boolean { 30 | if (this === other) return true 31 | if (javaClass != other?.javaClass) return false 32 | 33 | other as FileSelectResult 34 | 35 | if (fileType != other.fileType) return false 36 | if (mimeType != other.mimeType) return false 37 | if (uri != other.uri) return false 38 | if (filePath != other.filePath) return false 39 | if (fileSize != other.fileSize) return false 40 | 41 | return true 42 | } 43 | 44 | override fun hashCode(): Int { 45 | var result = fileType?.hashCode() ?: 0 46 | result = 31 * result + (mimeType?.hashCode() ?: 0) 47 | result = 31 * result + (uri?.hashCode() ?: 0) 48 | result = 31 * result + (filePath?.hashCode() ?: 0) 49 | result = 31 * result + fileSize.hashCode() 50 | return result 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /app/src/main/java/com/ando/file/sample/utils/NoShakeListener.kt: -------------------------------------------------------------------------------- 1 | package com.ando.file.sample.utils 2 | 3 | import android.view.View 4 | import kotlin.math.abs 5 | 6 | fun View.noShake(interval: Long = 500L, block: (v: View) -> Unit) { 7 | this.apply { 8 | setOnClickListener(object : NoShakeClickListener(interval) { 9 | override fun onSingleClick(v: View) { 10 | block.invoke(v) 11 | } 12 | }) 13 | } 14 | } 15 | 16 | abstract class NoShakeClickListener @JvmOverloads constructor(interval: Long = 500L) : View.OnClickListener { 17 | 18 | private var mTimeInterval = 500L 19 | private var mLastClickTime: Long = 0 //最近一次点击的时间 20 | private var mLastClickViewId = 0 //最近一次点击的控件ID 21 | 22 | init { 23 | mTimeInterval = interval 24 | } 25 | 26 | override fun onClick(v: View) { 27 | if (isFastDoubleClick(v, mTimeInterval)) onFastClick(v) else onSingleClick(v) 28 | } 29 | 30 | /** 31 | * 是否是快速点击 32 | * 33 | * @param v 点击的控件 34 | * @param interval 时间间期(毫秒) 35 | * @return true:是,false:不是 36 | */ 37 | private fun isFastDoubleClick(v: View, interval: Long): Boolean { 38 | val viewId = v.id 39 | val nowTime = System.currentTimeMillis() 40 | val timeInterval = abs(nowTime - mLastClickTime) 41 | return if (timeInterval < interval && viewId == mLastClickViewId) { 42 | // 快速点击事件 43 | true 44 | } else { 45 | // 单次点击事件 46 | mLastClickTime = nowTime 47 | mLastClickViewId = viewId 48 | false 49 | } 50 | } 51 | 52 | protected open fun onFastClick(v: View) {} 53 | protected abstract fun onSingleClick(v: View) 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_media_info.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 |