AndroidFilePicker

FilePicker is a small and fast file selector framework that is constantly evolving with the goal of rapid integration, high customization and configurability~

Github星跟踪图

Banner

Android File Picker?️

中文简体

Well, it doesn't have a name like Rocky, Cosmos or Fish. Android File Picker, like its name, is a local file selector framework. Some of his characteristics are described below:

  • Launcher in Activity or Fragment
    • Start with a single line of code
  • Browse and select all files in local storage
    • Custom Root path to start
    • Built-in default file type and file discriminator
    • Or you can implement the file type yourself
  • Built in Single Choice mode and Multiple Choice mode.
  • Custom list filter
    • Just want to show pictures(Or videos, audio...)? No problem!
    • Of course, you can just display the folder
  • Custom item click event: only need to implement the listener
  • Apply different themes, including four built-in themes and custom themes
  • More to find out yourself, Rail Style(default), Reply Style, Crane Style, Shrine Style, :----------------------------------------------------------:, :----------------------------------------------------------:, :----------------------------------------------------------:, :----------------------------------------------------------:, , , , , ## Download

Gradle:

In your project build.gradle:

allprojects {
    repositories {
	    ...
    	maven { url 'https://jitpack.io' }
    }
}

In your module build.gradle:

dependencies {
    implementation 'me.rosuh:AndroidFilePicker:$latest_version'
}

Check out releases page to see more versions.

Usage ?

Permission

The library requires two permissions:

  • android.permission.READ_EXTERNAL_STORAGE
  • android.permission.WRITE_EXTERNAL_STORAGE

If you do not have permission to apply, this framework will check and apply at startup.

Launch ? (Kotlin)

FilePickerManager
        .from(this@SampleActivity)
        .forResult(FilePickerManager.REQUEST_CODE)

Now that you have taken off ?️ ... ( there are really only two lines )

You only need to add .INSTANCE to use it:

FilePickerManager.INSTANCE
                .from(this)
                .forResult(FilePickerManager.REQUEST_CODE);

Receive Result

In onActivityResult() callback of the starting Activity or Fragment:

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    when (requestCode) {
        FilePickerManager.instance.REQUEST_CODE -> {
            if (resultCode == Activity.RESULT_OK) {
                val list = FilePickerManager.instance.obtainData()
                // do your work
            } else {
                Toast.makeText(this@SampleActivity, "You didn't choose anything~", Toast.LENGTH_SHORT).show()
            }
        }
    }
}

The result is a path list of the selected file (ArrayList<String>()).

proguard-rules(For pre v0.5.1)

-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
-keepnames class kotlinx.coroutines.android.AndroidExceptionPreHandler {}
-keepnames class kotlinx.coroutines.android.AndroidDispatcherFactory {}

-keepclassmembernames class kotlinx.** {
    volatile <fields>;
}

Starting with 0.5.2, we removed the coroutine library and implemented it using native threads, so there is no need to add proguard-rules.

More and more


Special Thanks To:

主要指标

概览
名称与所有者rosuH/AndroidFilePicker
主编程语言Kotlin
编程语言Java (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2018-11-24 02:53:29
推送于2024-04-10 21:27:19
最后一次提交2024-01-28 18:06:46
发布数59
最新版本名称1.0.1 (发布于 )
第一版名称v0.1 (发布于 )
用户参与
星数1k
关注者数20
派生数91
提交数181
已启用问题?
问题数121
打开的问题数8
拉请求数36
打开的拉请求数6
关闭的拉请求数64
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?