From d779f18b492906bb99806e067937cf9911b151f7 Mon Sep 17 00:00:00 2001 From: rosuH Date: Sun, 13 Feb 2022 20:44:45 +0800 Subject: [PATCH] UI bug fix and doc update. (#169) * :bug: [Fix] - item file name overlay in single choice mode. * :pencil2: update doc. --- README.md | 7 ++++++- README_CN.md | 8 +++++++- .../filepicker/adapter/FileListAdapter.kt | 19 +++++++++++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 654bb34..d3b3b32 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,14 @@ Well, it doesn't have a name like Rocky, Cosmos or Fish. Android File Picker, li | ![](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) | ## Version Compatibility +It depends on your targetAPI. -Support Android 11 and all versions below. +- `targetAPI <= 28`, no problem at all ;) +- `targetAPI == 29`, please enable `requestLegacyExternalStorage` feature for your project : D +- `targetAPI == 29` + - 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.) +Please check out this issue: [All About Scope Storage. ](https://github.com/rosuH/AndroidFilePicker/issues/146) ## Download Gradle: diff --git a/README_CN.md b/README_CN.md index 7688f40..dd19785 100644 --- a/README_CN.md +++ b/README_CN.md @@ -28,8 +28,14 @@ | ![](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) | ## 版本兼容性 -支持 Android 11 及其以下所有版本。 +这取决于您的 targetAPI : +- `targetAPI <= 28`,完全没有问题 ;) +- `targetAPI == 29`,请为您的项目启用 `requestLegacyExternalStorage` 特性:D +- `targetAPI == 29` + - 当运行于 Android 11以及以上的平台时,仅可以读取媒体文件(图片、音视频),除此均无法访问(比如PDF文档、apk 二进制文件等) + +请参看 issue: [All About Scope Storage. ](https://github.com/rosuH/AndroidFilePicker/issues/146) ## 下载使用 1. 在你的项目中添加依赖 diff --git a/filepicker/src/main/java/me/rosuh/filepicker/adapter/FileListAdapter.kt b/filepicker/src/main/java/me/rosuh/filepicker/adapter/FileListAdapter.kt index 874c4e9..d849a4a 100644 --- a/filepicker/src/main/java/me/rosuh/filepicker/adapter/FileListAdapter.kt +++ b/filepicker/src/main/java/me/rosuh/filepicker/adapter/FileListAdapter.kt @@ -1,11 +1,12 @@ package me.rosuh.filepicker.adapter -import androidx.collection.ArraySet -import androidx.recyclerview.widget.RecyclerView +import android.os.Build import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.* +import androidx.collection.ArraySet +import androidx.recyclerview.widget.RecyclerView import me.rosuh.filepicker.FilePickerActivity import me.rosuh.filepicker.R import me.rosuh.filepicker.bean.FileBean @@ -111,6 +112,20 @@ class FileListAdapter( private val ivIcon = itemView.findViewById(R.id.iv_icon_list_file_picker)!! private val radioButton = itemView.findViewById(R.id.rb_list_file_picker)!! + init { + val rightId = if (config.singleChoice) { + R.id.rb_list_file_picker + } else { + R.id.cb_list_file_picker + } + val params = tvFileName.layoutParams as RelativeLayout.LayoutParams + params.addRule(RelativeLayout.LEFT_OF, rightId) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { + params.addRule(RelativeLayout.START_OF, rightId) + } + tvFileName.layoutParams = params + } + fun check(isCheck: Boolean) { if (config.singleChoice) { radioButton.isChecked = isCheck