Skip to content

Commit a0b7e48

Browse files
authored
[1.0]Migrate to Scoped Storage (#215)
# Migrated to Scoped Storage ## BREAKING CHANGES [Add] - Log proxy. [Update] - Removed permission request action in the library. Library users are now responsible for managing permissions in their own. - Upgraded targetSDK && compileSDK to 33 - Upgraded APG and Gradle. - Updated the permission handling: now, any one of the permissions being granted allows the flow to continue. - README
1 parent 8d21b76 commit a0b7e48

File tree

18 files changed

+522
-248
lines changed

18 files changed

+522
-248
lines changed

README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
[![](https://jitpack.io/v/me.rosuh/AndroidFilePicker.svg)](https://jitpack.io/#me.rosuh/AndroidFilePicker)
66

7-
[中文简体](https://github.com/rosuH/AndroidFilePicker/blob/master/README_CN.md)
7+
[中文简体](./README_CN.md)
8+
9+
If you're using `0.x` version, checkout the [README_0.x](./README_0.x.md) file.
810

911
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:
1012

@@ -22,30 +24,35 @@ Well, it doesn't have a name like Rocky, Cosmos or Fish. Android File Picker, li
2224
- Apply different themes, including four built-in themes and custom themes
2325
- More to find out yourself
2426

25-
| Rail Style(default) | Reply Style | Crane Style | Shrine Style |
27+
| Rail | Reply | Crane | Shrine |
2628
| :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
2729
| ![](https://raw.githubusercontent.com/rosuH/AndroidFilePicker/master/images/default_theme.png) | ![](https://raw.githubusercontent.com/rosuH/AndroidFilePicker/master/images/reply_theme.png) | ![](https://raw.githubusercontent.com/rosuH/AndroidFilePicker/master/images/crane_theme.png) | ![](https://raw.githubusercontent.com/rosuH/AndroidFilePicker/master/images/shrine_theme.png) |
2830

2931
## Version Compatibility
3032
It depends on your targetAPI.
3133

32-
- `targetAPI <= 28`, no problem at all ;)
33-
- `targetAPI == 29`, please enable `requestLegacyExternalStorage` feature for your project : D
34-
- `targetAPI == 29`
35-
- When running on Android 11 and above, only media files (images, audio and video) can be read, but nothing else can be accessed (e.g. PDF documents, apk binary files, etc.)
34+
- `targetAPI > 33`, may be you are finding [photo picker](https://developer.android.com/about/versions/14/changes/partial-photo-video-access?hl=zh-cn#media-reselection)
35+
- `targetAPI == 33`
36+
- Handle [media permissions](https://developer.android.com/training/data-storage/shared/media#access-other-apps-files) by your onw
37+
- This lib will only show media files which your app has permission to access
38+
- `targetAPI <= 33`
39+
- Set `android:requestLegacyExternalStorage="true"` in your `AndroidManifest.xml` file
40+
- Handler `android.permission.READ_EXTERNAL_STORAGE` permission by your own
41+
- This lib will show all files in your storage
3642

37-
Please check out this issue: [All About Scope Storage. ](https://github.com/rosuH/AndroidFilePicker/issues/146)
3843
## Download
3944

40-
Gradle:
45+
[Gradle](https://docs.jitpack.io/android/#installing):
4146

4247
In your project `build.gradle`:
4348

4449
```xml
45-
allprojects {
50+
dependencyResolutionManagement {
51+
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
4652
repositories {
47-
...
48-
maven { url 'https://jitpack.io' }
53+
google()
54+
mavenCentral()
55+
maven { url 'https://jitpack.io' }
4956
}
5057
}
5158
```
@@ -65,11 +72,8 @@ Check out [releases page](https://github.com/rosuH/AndroidFilePicker/releases) t
6572

6673
### Permission
6774

68-
The library requires one permissions:
69-
70-
- `android.permission.READ_EXTERNAL_STORAGE`
71-
72-
If you do not have permission to apply, this framework will check and apply at startup.
75+
You should request permission by yourself, this lib will not request permission for you.
76+
See [Version Compatibility](#version-compatibility) for more details.
7377

7478
### Launch 🚀
7579

README_0.x.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
![Banner](https://raw.githubusercontent.com/rosuH/AndroidFilePicker/master/images/AndroidFilePicker_Banner_Dr_Sugiyama.png)
2+
3+
# Android File Picker🛩️
4+
5+
[![](https://jitpack.io/v/me.rosuh/AndroidFilePicker.svg)](https://jitpack.io/#me.rosuh/AndroidFilePicker)
6+
7+
[中文简体](./README_CN_1.x.md)
8+
9+
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:
10+
11+
- Launcher in Activity or Fragment
12+
- Start with a single line of code
13+
- Browse and select all files in local storage
14+
- Custom Root path to start
15+
- Built-in default file type and file discriminator
16+
- Or you can implement the file type yourself
17+
- Built in Single Choice mode and Multiple Choice mode.
18+
- Custom list filter
19+
- Just want to show pictures(Or videos, audio...)? No problem!
20+
- Of course, you can just display the folder
21+
- Custom item click event: only need to implement the listener
22+
- Apply different themes, including four built-in themes and custom themes
23+
- More to find out yourself
24+
25+
| Rail Style(default) | Reply Style | Crane Style | Shrine Style |
26+
| :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
27+
| ![](https://raw.githubusercontent.com/rosuH/AndroidFilePicker/master/images/default_theme.png) | ![](https://raw.githubusercontent.com/rosuH/AndroidFilePicker/master/images/reply_theme.png) | ![](https://raw.githubusercontent.com/rosuH/AndroidFilePicker/master/images/crane_theme.png) | ![](https://raw.githubusercontent.com/rosuH/AndroidFilePicker/master/images/shrine_theme.png) |
28+
29+
## Version Compatibility
30+
It depends on your targetAPI.
31+
32+
- `targetAPI <= 28`, no problem at all ;)
33+
- `targetAPI == 29`, please enable `requestLegacyExternalStorage` feature for your project : D
34+
- `targetAPI == 29`
35+
- When running on Android 11 and above, only media files (images, audio and video) can be read, but nothing else can be accessed (e.g. PDF documents, apk binary files, etc.)
36+
37+
Please check out this issue: [All About Scope Storage. ](https://github.com/rosuH/AndroidFilePicker/issues/146)
38+
## Download
39+
40+
Gradle:
41+
42+
In your project `build.gradle`:
43+
44+
```xml
45+
allprojects {
46+
repositories {
47+
...
48+
maven { url 'https://jitpack.io' }
49+
}
50+
}
51+
```
52+
53+
In your module `build.gradle`:
54+
55+
```xml
56+
dependencies {
57+
implementation 'me.rosuh:AndroidFilePicker:$latest_version'
58+
}
59+
```
60+
This lib now support AndroidX, check the version below.
61+
62+
Check out [releases page](https://github.com/rosuH/AndroidFilePicker/releases) to see more versions.
63+
64+
## Usage 📑
65+
66+
### Permission
67+
68+
The library requires one permissions:
69+
70+
- `android.permission.READ_EXTERNAL_STORAGE`
71+
72+
If you do not have permission to apply, this framework will check and apply at startup.
73+
74+
### Launch 🚀
75+
76+
```kotlin
77+
FilePickerManager
78+
.from(context)
79+
.forResult(FilePickerManager.REQUEST_CODE)
80+
```
81+
82+
83+
84+
### Receive Result
85+
86+
In `onActivityResult()` callback of the starting `Activity` or `Fragment`:
87+
88+
```kotlin
89+
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
90+
when (requestCode) {
91+
FilePickerManager.instance.REQUEST_CODE -> {
92+
if (resultCode == Activity.RESULT_OK) {
93+
val list = FilePickerManager.instance.obtainData()
94+
// do your work
95+
} else {
96+
Toast.makeText(this@SampleActivity, "You didn't choose anything~", Toast.LENGTH_SHORT).show()
97+
}
98+
}
99+
}
100+
}
101+
```
102+
103+
The result is a path list of the selected file (`ArrayList<String>()`).
104+
105+
106+
## Docs
107+
108+
- [Source Code Explanation](https://github.com/rosuH/AndroidFilePicker/wiki/4.-%E7%A4%BA%E4%BE%8B%E5%8F%8A%E8%A7%A3%E9%87%8A).
109+
110+
- [Change Log](https://github.com/rosuH/AndroidFilePicker/wiki/Change-Log)
111+
112+
- [TODO](https://github.com/rosuH/AndroidFilePicker/wiki/TODO)
113+
114+
115+
116+
---
117+
118+
## Special Thanks To:
119+
120+
- [whichName](https://github.com/whichname)
121+
- [Matisse](https://github.com/zhihu/Matisse)
122+
- [Default Icon Author Shulk](http://iconfont.cn/collections/detail?spm=a313x.7781069.1998910419.d9df05512&cid=11271)
123+
- [Theme Color](https://material.io/design/material-studies/about-our-material-studies.html)
124+
- [Empty icon](https://github.com/rosuH/AndroidFilePicker/blob/master/filepicker/src/main/res/drawable/ic_empty_file_list_file_picker.xml) made by [freepik](https://www.freepik.com/) from www.flaticon.com

README_CN.md

Lines changed: 38 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,62 @@
11
![Banner](https://raw.githubusercontent.com/rosuH/AndroidFilePicker/master/images/AndroidFilePicker_Banner_Dr_Sugiyama.png)
22

3-
# AndroidFilePicker
3+
# Android File Picker🛩️
44

55
[![](https://jitpack.io/v/me.rosuh/AndroidFilePicker.svg)](https://jitpack.io/#me.rosuh/AndroidFilePicker)
66

7+
如果你使用的是 `1.x` 版本,请查看 [README_0.x](./README_CN_0.x.md) 文件。
78

9+
它没有像 Rocky、Cosmos 或 Fish 这样的名字。Android File Picker,正如其名,是一个本地文件选择框架。以下是它的一些特点:
810

9-
它没有像 Rocky,Cosmos 或是 Peppa 这样的名字。 Android File Picker 正如其名,是一个本地文件选择器框架。 他的一些特征如下所述:
10-
11-
-`Activity``Fragment` 中启动
12-
- 从一行代码开始
13-
- 浏览本地存储中的所有文件
14-
- 内置默认文件类型和文件鉴别器
15-
- 或者您可以自己实现文件类型
16-
- 内置了单选模式和多选模式
11+
- 在 Activity 或 Fragment 中启动
12+
- 一行代码启动
13+
- 浏览和选择本地存储中的所有文件
14+
- 自定义根路径开始
15+
- 内置默认文件类型和文件区分器
16+
- 或者你可以自己实现文件类型
17+
- 内置单选模式和多选模式。
1718
- 自定义列表过滤器
18-
- 只想显示图片(或视频,音频......)? 没问题!
19-
- 当然,您也可只显示文件夹
20-
- 自定义`item`点击事件:只需要实现监听器
21-
- 四个内置主题和自定义主题
22-
- 还有更多待您自己探索的特性(?)
23-
24-
19+
- 只想显示图片(或视频、音频...)?没问题!
20+
- 当然,你也可以只显示文件夹
21+
- 自定义条目点击事件:只需实现监听器
22+
- 应用不同的主题,包括四个内置主题和自定义主题
23+
- 更多功能等你发现
2524

26-
| Rail Style(default) | Reply Style | Crane Style | Shrine Style |
25+
| Rail | Reply | Crane | Shrine |
2726
| :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
2827
| ![](https://raw.githubusercontent.com/rosuH/AndroidFilePicker/master/images/default_theme.png) | ![](https://raw.githubusercontent.com/rosuH/AndroidFilePicker/master/images/reply_theme.png) | ![](https://raw.githubusercontent.com/rosuH/AndroidFilePicker/master/images/crane_theme.png) | ![](https://raw.githubusercontent.com/rosuH/AndroidFilePicker/master/images/shrine_theme.png) |
2928

3029
## 版本兼容性
31-
这取决于您的 targetAPI
30+
取决于你的 targetAPI
3231

33-
- `targetAPI <= 28`,完全没有问题 ;)
34-
- `targetAPI == 29`,请为您的项目启用 `requestLegacyExternalStorage` 特性:D
35-
- `targetAPI == 29`
36-
- 当运行于 Android 11以及以上的平台时,仅可以读取媒体文件(图片、音视频),除此均无法访问(比如PDF文档、apk 二进制文件等)
32+
- `targetAPI > 33`,也许你正在寻找 [照片选择器](https://developer.android.com/about/versions/14/changes/partial-photo-video-access?hl=zh-cn#media-reselection)
33+
- `targetAPI == 33`
34+
- 处理[媒体权限](https://developer.android.com/training/data-storage/shared/media#access-other-apps-files)由你自己处理
35+
- 此库将仅显示你的应用有权限访问的媒体文件
36+
- `targetAPI <= 33`
37+
- 在你的 `AndroidManifest.xml` 文件中设置 `android:requestLegacyExternalStorage="true"`
38+
- 由你自己处理 `android.permission.READ_EXTERNAL_STORAGE` 权限
39+
- 此库将显示存储中的所有文件
3740

38-
请参看 issue: [All About Scope Storage. ](https://github.com/rosuH/AndroidFilePicker/issues/146)
39-
## 下载使用
41+
## 下载
4042

41-
1. 在你的项目中添加依赖
43+
[Gradle](https://docs.jitpack.io/android/#installing):
4244

43-
现在项目 `build.gradle` 配置文件添加仓库
45+
在项目的 `build.gradle` 文件中
4446

45-
```xml
46-
allprojects {
47+
```gradle
48+
dependencyResolutionManagement {
49+
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
4750
repositories {
48-
...
49-
maven { url 'https://jitpack.io' }
51+
google()
52+
mavenCentral()
53+
maven { url 'https://jitpack.io' }
5054
}
5155
}
52-
```
56+
在模块的 build.gradle 文件中:
5357
54-
然后在子模块(`app`)的配置文件添加依赖:
55-
56-
```xml
58+
```gradle
5759
dependencies {
58-
implementation 'me.rosuh:AndroidFilePicker:latest_version'
59-
}
60-
```
61-
62-
`latest_version` 请自行替换成 [最新版本](https://github.com/rosuH/AndroidFilePicker/releases)
63-
64-
65-
66-
## 使用
67-
68-
### 权限
69-
70-
此库需要一个权限:
71-
72-
- `android.permission.READ_EXTERNAL_STORAGE`
73-
74-
如果您没有提前授予,这个库会自动申请该权限的。
75-
76-
### 开始使用
77-
78-
简单的链式调用示意:
79-
80-
```kotlin
81-
FilePickerManager
82-
.from(context)
83-
.forResult(FilePickerManager.REQUEST_CODE)
84-
```
85-
86-
现在你已经起飞了🛩️...(真的只有两行)
87-
88-
89-
### 获取结果
90-
91-
*获取结果*`onActivityResult`接受消息,然后调用`FilePickerManager.obtainData()`获取保存的数据,**结果是所选取文件的路径列表(`ArrayList<String>()`)**
92-
93-
```kotlin
94-
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
95-
when (requestCode) {
96-
FilePickerManager.instance.REQUEST_CODE -> {
97-
if (resultCode == Activity.RESULT_OK) {
98-
val list = FilePickerManager.instance.obtainData()
99-
// do your work
100-
} else {
101-
Toast.makeText(this@SampleActivity, "没有选择任何东西~", Toast.LENGTH_SHORT).show()
102-
}
103-
}
104-
}
60+
implementation 'me.rosuh:AndroidFilePicker:$latest_version'
10561
}
106-
```
107-
108-
### 更多示例
109-
110-
来翻翻我写的[飞行手册](https://github.com/rosuH/AndroidFilePicker/wiki)吧?
111-
112-
或者想看看[主题配色](https://github.com/rosuH/AndroidFilePicker/wiki/3.-%E9%85%8D%E7%BD%AE%E9%80%89%E9%A1%B9#2-%E4%B8%BB%E9%A2%98%E5%B1%95%E7%A4%BA)
113-
114-
## 功能 & 特点
115-
116-
1. 链式调用
117-
2. 默认选中实现
118-
- 点击条目(`item`)无默认实现
119-
- 点击`CheckBox`为选中
120-
- 长按条目为更改选中状态:选中/取消选中
121-
3. 内置四种主题配色 + 可自定义配色
122-
- 查看主题颜色示意图,然后调用`setTheme()`传入自定义主题
123-
4. 默认实现多种文件类型
124-
- 实现`IFileType`接口来实现你的文件类型
125-
- 实现`AbstractFileType`抽象类来实现你的文件类型甄别器
126-
5. 公开文件过滤接口
127-
- 实现`AbstractFileFilter`抽象类来定制你自己的文件过滤器,这样可以控制文件列表的展示内容
128-
6. 多种可配置选项
129-
1. 选中时是否忽略文件夹
130-
2. 是否显示隐藏文件夹(以符号`.`开头的,视为隐藏文件或隐藏文件夹)
131-
3. 可配置导航栏的文本,默认显示、多选文本、取消选择文本以及根目录默认名称
132-
7. 公开条目(`item`)选择监听器,可自定义条目被点击的实现
133-
134-
## 其他
135-
136-
- [部分源码说明](https://github.com/rosuH/AndroidFilePicker/wiki/%E9%83%A8%E5%88%86%E6%BA%90%E7%A0%81%E8%AF%B4%E6%98%8E)
137-
138-
- [更新日志](https://github.com/rosuH/AndroidFilePicker/wiki/Change-Log)
139-
140-
- [TODO](https://github.com/rosuH/AndroidFilePicker/wiki/TODO)
141-
142-
143-
144-
---
145-
146-
## Special Thanks To:
147-
148-
- [*1 @whichName](https://github.com/whichname)
149-
- [BRVAH](https://github.com/CymChad/BaseRecyclerViewAdapterHelper)
150-
- [Matisse](https://github.com/zhihu/Matisse)
151-
- [默认图标作者 Shulk](http://iconfont.cn/collections/detail?spm=a313x.7781069.1998910419.d9df05512&cid=11271)
152-
- [主题配色](https://material.io/design/material-studies/about-our-material-studies.html)
153-
- [Empty icon](https://github.com/rosuH/AndroidFilePicker/blob/master/filepicker/src/main/res/drawable/ic_empty_file_list_file_picker.xml) made by [freepik](https://www.freepik.com/) from www.flaticon.com
62+
```

0 commit comments

Comments
 (0)