diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
new file mode 100644
index 0000000..c1f0d04
--- /dev/null
+++ b/.idea/deploymentTargetDropDown.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index c1215b5..59f1539 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,10 @@
+## 语言(Language)
+
+#### **[中文](./README.md)** | [English](./README_EN.md)
+
## 为什么选择我
自动申请存储权限,支持 Android4.4 ~ 13,再也不用为了适配各种版本而苦恼了,快速集成,一句代码搞定,完善的文档,支持无root权限访问和操作Android/data和Android/obb目录(适配Android 13),支持SD卡,高度自定义UI满足你的所有需求,使用非常灵活,支持国际化,对于Android文件选择你只需要关注你的业务代码即可其他的都交给它。
@@ -28,13 +32,9 @@
- [x] 高度自定义UI
- [x] 国际化
- [ ] 搜索功能
-- [ ] 自定义图标
+- [x] 自定义图标
- [ ] 显示隐藏文件
-## 语言(Language)
-
-#### **[中文](./README.md)** | [English](./README_EN.md)
-
## 前言
#### 在开始之前可以给项目一个Star吗?非常感谢,你的支持是我唯一的动力。欢迎Star和Issues!
@@ -234,7 +234,7 @@ PathSelectFragment selector = PathSelector.build(this, MConstants.BUILD_DIALOG)
.setShowFileTypes("", "mp3", "mp4")//只显示(没有后缀)或(后缀为mp3)或(后缀为mp4)的文件
.setSelectFileTypes("", "mp3")//只能选择(没有后缀)或(后缀为mp3)的文件
.setMaxCount(3)//最多可以选择3个文件,默认是-1不限制
- .setRadio()//单选
+ .setRadio()//单选(如果需要单选文件夹请使用setMaxCount(0)来替换)
.setSortType(MConstants.SORT_NAME_ASC)//按名称排序
.setTitlebarMainTitle(new FontBean("My Selector"))//设置标题栏主标题,还可以设置字体大小,颜色等
.setTitlebarBG(Color.GREEN)//设置标题栏颜色
@@ -412,34 +412,73 @@ PathSelectFragment selector = PathSelector.build(this, MConstants.BUILD_DIALOG)
.show();
```
+#### 3、自定义列表item图标
+
+```java
+PathSelectFragment selector = PathSelector.build(this, MConstants.BUILD_DIALOG)
+ .setFileBeanController(new AbstractFileBeanController() {
+ @Override
+ public int getFileBeanImageResource(boolean isDir, String extension, FileBean fileBean) {
+ int resourceId;
+ switch (extension) {
+ case "jpg":
+ case "jpeg":
+ case "png":
+ //开发者自己的图片资源id
+ resourceId = R.drawable.ic_launcher_foreground;
+ break;
+ case "mp3":
+ resourceId = R.drawable.ic_launcher_foreground;
+ break;
+ case "mp4":
+ //也可以使用默认的图片资源id
+ resourceId = com.molihuan.pathselector.R.mipmap.movie;
+ break;
+ default:
+ if (isDir) {
+ //开发者自己的图片资源id
+ resourceId = R.drawable.ml192;
+ } else {
+ resourceId = R.drawable.ic_launcher_background;
+ }
+ break;
+ }
+ return resourceId;
+ }
+ })
+ .show();
+```
+
+
+
## 四、接口与方法(尽量看源码,都写了注释,懒得写文档)
##### IConfigDataBuilder
-| 方法 | 注释 | 备注 |
-| ------------------------------------------------------------ | ---------------------------- | ----------------------------------------------- |
-| setFrameLayoutId(int id) | 设置加载位置FrameLayoutID | 当构建模式为MConstants.BUILD_FRAGMENT时必须设置 |
-| setRequestCode(int code) | 设置请求码 | 当构建模式为MConstants.BUILD_ACTIVITY时必须设置 |
-| setRootPath(String path) | 设置开始默认路径 | 默认为内部存储根路径 |
-| setMaxCount(int maxCount) | 设置最大选择数量 | 不设置默认为-1 即无限 |
-| setShowFileTypes(String... fileTypes) | 设置显示文件类型 | 没有后缀请用"" |
-| setSelectFileTypes(String... fileTypes) | 设置选择文件类型 | 没有后缀请用"" |
-| setSortType(int sortType) | 设置排序规则 | 类型请看MConstants |
-| setRadio() | 设置单选 | 默认多选 |
-| setShowSelectStorageBtn(boolean var) | 设置是否显示内部存储选择按钮 | 默认true |
-| setShowTitlebarFragment(boolean var) | 是否显示标题栏 | 默认true |
-| setShowTabbarFragment(boolean var) | 是否显示面包屑 | 默认true |
-| setAlwaysShowHandleFragment(boolean var) | 是否总是显示长按弹出选项 | 默认false |
-| setTitlebarMainTitle(FontBean titlebarMainTitle) | 设置标题栏主标题 | 还可以设置字体大小,颜色等 |
-| setTitlebarBG(Integer titlebarBG) | 设置标题栏背景颜色 | |
-| setFileItemListener(FileItemListener fileItemListener) | 设置文件item点击回调 | 点击是文件才会回调,如果点击是文件夹则不会 |
-| setMorePopupItemListeners(CommonItemListener... morePopupItemListener) | 设置右上角选项回调 | |
-| setHandleItemListeners(CommonItemListener... handleItemListener) | 设置长按弹出选项回调 | |
-| setTitlebarFragment(AbstractTitlebarFragment titlebarFragment) | 设置自定义标题栏UI | 自己的Fragment必须继承AbstractTitlebarFragment |
-| setHandleFragment(AbstractHandleFragment handleFragment) | 设置长按弹出自定义UI | 自己的Fragment必须继承AbstractHandleFragment |
-| start() | 开始构建 | 必须调用 |
-| ...... | ...... | |
+| 方法 | 作用 | 备注 |
+| ------------------------------------------------------------ | ------------------------------------------------------ | ----------------------------------------------- |
+| setFrameLayoutId(int id) | 设置加载位置FrameLayoutID | 当构建模式为MConstants.BUILD_FRAGMENT时必须设置 |
+| setRequestCode(int code) | 设置请求码 | 当构建模式为MConstants.BUILD_ACTIVITY时必须设置 |
+| setRootPath(String path) | 设置开始默认路径 | 默认为内部存储根路径 |
+| setMaxCount(int maxCount) | 设置最大选择数量 | 不设置默认为-1 即无限 |
+| setShowFileTypes(String... fileTypes) | 设置显示文件类型 | 没有后缀请用"" |
+| setSelectFileTypes(String... fileTypes) | 设置选择文件类型 | 没有后缀请用"" |
+| setSortType(int sortType) | 设置排序规则 | 类型请看MConstants |
+| setRadio() | 设置单选(如果需要单选文件夹请使用setMaxCount(0)来替换) | 默认多选 |
+| setShowSelectStorageBtn(boolean var) | 设置是否显示内部存储选择按钮 | 默认true |
+| setShowTitlebarFragment(boolean var) | 是否显示标题栏 | 默认true |
+| setShowTabbarFragment(boolean var) | 是否显示面包屑 | 默认true |
+| setAlwaysShowHandleFragment(boolean var) | 是否总是显示长按弹出选项 | 默认false |
+| setTitlebarMainTitle(FontBean titlebarMainTitle) | 设置标题栏主标题 | 还可以设置字体大小,颜色等 |
+| setTitlebarBG(Integer titlebarBG) | 设置标题栏背景颜色 | |
+| setFileItemListener(FileItemListener fileItemListener) | 设置文件item点击回调 | 点击是文件才会回调,如果点击是文件夹则不会 |
+| setMorePopupItemListeners(CommonItemListener... morePopupItemListener) | 设置右上角选项回调 | |
+| setHandleItemListeners(CommonItemListener... handleItemListener) | 设置长按弹出选项回调 | |
+| setTitlebarFragment(AbstractTitlebarFragment titlebarFragment) | 设置自定义标题栏UI | 自己的Fragment必须继承AbstractTitlebarFragment |
+| setHandleFragment(AbstractHandleFragment handleFragment) | 设置长按弹出自定义UI | 自己的Fragment必须继承AbstractHandleFragment |
+| start() | 开始构建 | 必须调用 |
+| ...... | ...... | |
## 五、!!!特别注意 !!!
diff --git a/README_EN.md b/README_EN.md
index 068d819..95779e4 100644
--- a/README_EN.md
+++ b/README_EN.md
@@ -13,7 +13,9 @@
support custom UI,support SD card.
(The Keyword:file selector operator android/data android 11 android 13)
+## Language(语言)
+#### **[Chinese](./README.md)** | [English](./README_EN.md)
## Why choose me?
@@ -28,13 +30,9 @@ Automatically apply storage permission, support Android4.4 ~ 13, no longer need
- [x] Highly customizable UI
- [x] Internationalization
- [ ] Search function
-- [ ] Custom icon
+- [x] Custom icon
- [ ] Show hidden files
-## Language(语言)
-
-#### **[Chinese](./README.md)** | [English](./README_EN.md)
-
## Preface
#### Can you give the project a Star before starting? Thank you very much, your support is the only thing that keeps me going. Welcome Star and Issues!
@@ -234,7 +232,7 @@ PathSelectFragment selector = PathSelector.build(this, MConstants.BUILD_DIALOG)
.setShowFileTypes("", "mp3", "mp4")//Show only files with (no suffix) or (mp3 suffix) or (mp4 suffix)
.setSelectFileTypes("", "mp3")//Only files with (no suffix) or (mp3 suffix) can be selected
.setMaxCount(3)//You can select up to 3 files. The default is - 1 unlimited
- .setRadio()//Single choice
+ .setRadio()//Single choice(Use setMaxCount(0) to replace it if you need a single-selected folder)
.setSortType(MConstants.SORT_NAME_ASC)//Sort by name
.setTitlebarMainTitle(new FontBean("My Selector"))//Set the title bar main title, you can also set the font size, color, etc.
.setTitlebarBG(Color.GREEN)//Set the title bar background color
@@ -412,6 +410,43 @@ PathSelectFragment selector = PathSelector.build(this, MConstants.BUILD_DIALOG)
.show();
```
+#### 3、Customize list item icons
+
+```java
+PathSelectFragment selector = PathSelector.build(this, MConstants.BUILD_DIALOG)
+ .setFileBeanController(new AbstractFileBeanController() {
+ @Override
+ public int getFileBeanImageResource(boolean isDir, String extension, FileBean fileBean) {
+ int resourceId;
+ switch (extension) {
+ case "jpg":
+ case "jpeg":
+ case "png":
+ //Developer's own image resource id
+ resourceId = R.drawable.ic_launcher_foreground;
+ break;
+ case "mp3":
+ resourceId = R.drawable.ic_launcher_foreground;
+ break;
+ case "mp4":
+ //You can also use the default image resource id
+ resourceId = com.molihuan.pathselector.R.mipmap.movie;
+ break;
+ default:
+ if (isDir) {
+ //Developer's own image resource id
+ resourceId = R.drawable.ml192;
+ } else {
+ resourceId = R.drawable.ic_launcher_background;
+ }
+ break;
+ }
+ return resourceId;
+ }
+ })
+ .show();
+```
+
## IV.Interface and methods (try to see the source code, are written comments, lazy to write the document)
##### IConfigDataBuilder
@@ -426,7 +461,7 @@ PathSelectFragment selector = PathSelector.build(this, MConstants.BUILD_DIALOG)
| setShowFileTypes(String... fileTypes) | Set the display file type | No suffix please use "" |
| setSelectFileTypes(String... fileTypes) | Set the selection file type | No suffix please use "" |
| setSortType(int sortType) | Set sorting rules | See MConstants for types |
-| setRadio() | Set radio selection | Default Multiple Choice |
+| setRadio() | Set radio selection(Use setMaxCount(0) to replace it if you need a single-selected folder) | Default Multiple Choice |
| setShowSelectStorageBtn(boolean var) | Set whether to display the internal storage selection button | Default true |
| setShowTitlebarFragment(boolean var) | Whether to display the title bar | Default true |
| setShowTabbarFragment(boolean var) | Whether to show breadcrumbs | Default true |
diff --git a/app/build.gradle b/app/build.gradle
index fa959ba..dcad6f0 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -44,7 +44,7 @@ dependencies {
// implementation fileTree(dir: "../pathselector/build/outputs/aar/", includes: ["*-release.aar", "*.jar"])
// implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.11'
-// implementation 'com.github.getActivity:XXPermissions:16.2'
+ implementation 'com.github.getActivity:XXPermissions:16.5'
//调试用
diff --git a/app/release/app-release.apk b/app/release/app-release.apk
index ad1f9c7..43c3395 100644
Binary files a/app/release/app-release.apk and b/app/release/app-release.apk differ
diff --git a/app/src/main/java/com/molihuan/pathselectdemo/activity/MainActivity.java b/app/src/main/java/com/molihuan/pathselectdemo/activity/MainActivity.java
index 633072c..b15d74c 100644
--- a/app/src/main/java/com/molihuan/pathselectdemo/activity/MainActivity.java
+++ b/app/src/main/java/com/molihuan/pathselectdemo/activity/MainActivity.java
@@ -14,6 +14,7 @@
import com.molihuan.pathselectdemo.fragments.CustomTitlebarFragment;
import com.molihuan.pathselector.PathSelector;
import com.molihuan.pathselector.configs.PathSelectorConfig;
+import com.molihuan.pathselector.controller.AbstractFileBeanController;
import com.molihuan.pathselector.entity.FileBean;
import com.molihuan.pathselector.entity.FontBean;
import com.molihuan.pathselector.fragment.BasePathSelectFragment;
@@ -40,6 +41,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private Button btnDialogSelector;
private Button btnCustomSelector;
private Button btnTest;
+ private Button btnCustomImgSelector;
private PathSelectFragment selector;
private long firstBackTime;
@@ -62,6 +64,7 @@ private void getComponents() {
btnDialogSelector = findViewById(R.id.btn_dialog_selector);
btnCustomSelector = findViewById(R.id.btn_custom_toolbar_selector);
btnTest = findViewById(R.id.btn_test);
+ btnCustomImgSelector = findViewById(R.id.btn_custom_filebean_img_selector);
}
private void initData() {
@@ -79,11 +82,11 @@ private void setListeners() {
btnDialogSelector.setOnClickListener(this);
btnCustomSelector.setOnClickListener(this);
btnTest.setOnClickListener(this);
+ btnCustomImgSelector.setOnClickListener(this);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
-
super.onActivityResult(requestCode, resultCode, data);
}
@@ -102,7 +105,6 @@ public void onClick(View v) {
break;
case R.id.btn_custom_toolbar_selector:
customTitlebarSelectShow();
-// t1();
break;
case R.id.btn_test:
FragmentTools.fragmentReplace(
@@ -111,6 +113,10 @@ public void onClick(View v) {
new CustomTitlebarFragment(),
"55"
);
+
+ break;
+ case R.id.btn_custom_filebean_img_selector:
+ customFilebeanImgSelectShow();
break;
}
}
@@ -122,6 +128,7 @@ public void onClick(View v) {
private void dialogSelectShow() {
//获取PathSelectFragment实例onBackPressed中处理返回按钮点击事件
selector = PathSelector.build(MainActivity.this, MConstants.BUILD_DIALOG)
+ .setRootPath("/storage/emulated/0/bilibili视频合并/")
.setMorePopupItemListeners(
new CommonItemListener("SelectAll") {
@Override
@@ -275,7 +282,7 @@ public boolean onClick(View v, TextView tv, List selectedFiles, String
* 自定义Toolbar方式
*/
private void customTitlebarSelectShow() {
- PathSelectFragment selector = PathSelector.build(this, MConstants.BUILD_DIALOG)
+ selector = PathSelector.build(this, MConstants.BUILD_DIALOG)
.setTitlebarFragment(new CustomTitlebarFragment())
.show();
}
@@ -285,7 +292,7 @@ private void customTitlebarSelectShow() {
*/
private void CompleteConfiguration() {
- PathSelectFragment selector = PathSelector.build(this, MConstants.BUILD_DIALOG)
+ selector = PathSelector.build(this, MConstants.BUILD_DIALOG)
//.setBuildType(MConstants.BUILD_DIALOG)//已经在build中已经设置了
//.setContext(this)//已经在build中已经设置了
.setRootPath("/storage/emulated/0/")//初始路径
@@ -350,6 +357,46 @@ public boolean onClick(View v, TextView tv, List selectedFiles, String
}
+
+ /**
+ * 自定义Filebean Img
+ */
+ private void customFilebeanImgSelectShow() {
+ PathSelectFragment selector = PathSelector.build(this, MConstants.BUILD_DIALOG)
+ .setFileBeanController(new AbstractFileBeanController() {
+ @Override
+ public int getFileBeanImageResource(boolean isDir, String extension, FileBean fileBean) {
+ int resourceId;
+ switch (extension) {
+ case "jpg":
+ case "jpeg":
+ case "png":
+ //开发者自己的图片资源id
+ resourceId = R.drawable.ic_launcher_foreground;
+ break;
+ case "mp3":
+ resourceId = R.drawable.ic_launcher_foreground;
+ break;
+ case "mp4":
+ //也可以使用默认的图片资源id
+ resourceId = com.molihuan.pathselector.R.mipmap.movie_mlh;
+ break;
+ default:
+ if (isDir) {
+ //开发者自己的图片资源id
+ resourceId = R.drawable.ml192;
+ } else {
+ resourceId = R.drawable.ic_launcher_background;
+ }
+ break;
+ }
+ return resourceId;
+ }
+ })
+ .show();
+
+ }
+
@Override
public void onBackPressed() {
diff --git a/app/src/main/java/com/molihuan/pathselectdemo/fragments/CustomTitlebarFragment.java b/app/src/main/java/com/molihuan/pathselectdemo/fragments/CustomTitlebarFragment.java
index 4425d62..c982464 100644
--- a/app/src/main/java/com/molihuan/pathselectdemo/fragments/CustomTitlebarFragment.java
+++ b/app/src/main/java/com/molihuan/pathselectdemo/fragments/CustomTitlebarFragment.java
@@ -7,6 +7,11 @@
import com.molihuan.pathselector.fragment.AbstractTitlebarFragment;
import com.molihuan.pathselector.utils.Mtools;
+/**
+ * @ClassName CustomTitlebarFragment
+ * @Author molihuan
+ * @Date 2022/12/22 6:50
+ */
public class CustomTitlebarFragment extends AbstractTitlebarFragment {
private Button btn1;
@@ -35,5 +40,5 @@ public void onClick(View v) {
}
});
}
-
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/molihuan/pathselectdemo/utils/DocumentsUtils.java b/app/src/main/java/com/molihuan/pathselectdemo/utils/DocumentsUtils.java
deleted file mode 100644
index f01f3c4..0000000
--- a/app/src/main/java/com/molihuan/pathselectdemo/utils/DocumentsUtils.java
+++ /dev/null
@@ -1,323 +0,0 @@
-package com.molihuan.pathselectdemo.utils;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.net.Uri;
-import android.os.Build;
-import android.preference.PreferenceManager;
-import android.provider.DocumentsContract;
-import android.util.Log;
-
-import androidx.documentfile.provider.DocumentFile;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-
-public class DocumentsUtils {
-
- private static final String TAG = DocumentsUtils.class.getSimpleName();
-
- public static final int OPEN_DOCUMENT_TREE_CODE = 8000;
-
- private static List sExtSdCardPaths = new ArrayList<>();
-
- private DocumentsUtils() {
-
- }
-
- public static void cleanCache() {
- sExtSdCardPaths.clear();
- }
-
- /**
- * Get a list of external SD card paths. (Kitkat or higher.)
- *
- * @return A list of external SD card paths.
- */
- @TargetApi(Build.VERSION_CODES.KITKAT)
- private static String[] getExtSdCardPaths(Context context) {
- if (sExtSdCardPaths.size() > 0) {
- return sExtSdCardPaths.toArray(new String[0]);
- }
- for (File file : context.getExternalFilesDirs("external")) {
- if (file != null && !file.equals(context.getExternalFilesDir("external"))) {
- int index = file.getAbsolutePath().lastIndexOf("/Android/data");
- if (index < 0) {
- Log.w(TAG, "Unexpected external file dir: " + file.getAbsolutePath());
- } else {
- String path = file.getAbsolutePath().substring(0, index);
- try {
- path = new File(path).getCanonicalPath();
- } catch (IOException e) {
- // Keep non-canonical path.
- }
- sExtSdCardPaths.add(path);
- }
- }
- }
- if (sExtSdCardPaths.isEmpty()) sExtSdCardPaths.add("/storage/sdcard1");
- return sExtSdCardPaths.toArray(new String[0]);
- }
-
- /**
- * Determine the main folder of the external SD card containing the given file.
- *
- * @param file the file.
- * @return The main folder of the external SD card containing this file, if the file is on an SD
- * card. Otherwise,
- * null is returned.
- */
- @TargetApi(Build.VERSION_CODES.KITKAT)
- private static String getExtSdCardFolder(final File file, Context context) {
- String[] extSdPaths = getExtSdCardPaths(context);
- try {
- for (int i = 0; i < extSdPaths.length; i++) {
- if (file.getCanonicalPath().startsWith(extSdPaths[i])) {
- return extSdPaths[i];
- }
- }
- } catch (IOException e) {
- return null;
- }
- return null;
- }
-
- /**
- * Determine if a file is on external sd card. (Kitkat or higher.)
- *
- * @param file The file.
- * @return true if on external sd card.
- */
- @TargetApi(Build.VERSION_CODES.KITKAT)
- public static boolean isOnExtSdCard(final File file, Context c) {
- return getExtSdCardFolder(file, c) != null;
- }
-
- /**
- * Get a DocumentFile corresponding to the given file (for writing on ExtSdCard on Android 5).
- * If the file is not
- * existing, it is created.
- *
- * @param file The file.
- * @param isDirectory flag indicating if the file should be a directory.
- * @return The DocumentFile
- */
- public static DocumentFile getDocumentFile(final File file, final boolean isDirectory,
- Context context) {
-
- if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
- return DocumentFile.fromFile(file);
- }
-
- String baseFolder = getExtSdCardFolder(file, context);
- Log.i(TAG, " baseFolder " + baseFolder);
- boolean originalDirectory = false;
- if (baseFolder == null) {
- return null;
- }
-
- String relativePath = null;
- try {
- String fullPath = file.getCanonicalPath();
- if (!baseFolder.equals(fullPath)) {
- relativePath = fullPath.substring(baseFolder.length() + 1);
- } else {
- originalDirectory = true;
- }
- } catch (IOException e) {
- return null;
- } catch (Exception f) {
- originalDirectory = true;
- //continue
- }
- String as = PreferenceManager.getDefaultSharedPreferences(context).getString(baseFolder,
- null);
-
- Uri treeUri = null;
- if (as != null) treeUri = Uri.parse(as);
- if (treeUri == null) {
- return null;
- }
-
- // start with root of SD card and then parse through document tree.
- DocumentFile document = DocumentFile.fromTreeUri(context, treeUri);
- if (originalDirectory) return document;
- String[] parts = relativePath.split("/");
- for (int i = 0; i < parts.length; i++) {
- DocumentFile nextDocument = document.findFile(parts[i]);
-
- if (nextDocument == null) {
- if ((i < parts.length - 1) || isDirectory) {
- nextDocument = document.createDirectory(parts[i]);
- } else {
- nextDocument = document.createFile("image", parts[i]);
- }
- }
- document = nextDocument;
- }
-
- return document;
- }
-
- public static boolean mkdirs(Context context, File dir) {
- boolean res = dir.mkdirs();
- if (!res) {
- if (DocumentsUtils.isOnExtSdCard(dir, context)) {
- DocumentFile documentFile = DocumentsUtils.getDocumentFile(dir, true, context);
- res = documentFile != null && documentFile.canWrite();
- }
- }
- return res;
- }
-
- public static boolean delete(Context context, File file) {
- boolean ret = file.delete();
- if (!ret && DocumentsUtils.isOnExtSdCard(file, context)) {
- DocumentFile f = DocumentsUtils.getDocumentFile(file, false, context);
- if (f != null) {
- ret = f.delete();
- }
- }
- return ret;
- }
-
- public static boolean canWrite(File file) {
- boolean res = file.exists() && file.canWrite();
-
- if (!res && !file.exists()) {
- try {
- if (!file.isDirectory()) {
- res = file.createNewFile() && file.delete();
- } else {
- res = file.mkdirs() && file.delete();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return res;
- }
-
- public static boolean canWrite(Context context, File file) {
- boolean res = canWrite(file);
-
- if (!res && DocumentsUtils.isOnExtSdCard(file, context)) {
- DocumentFile documentFile = DocumentsUtils.getDocumentFile(file, true, context);
- res = documentFile != null && documentFile.canWrite();
- }
- return res;
- }
-
- public static boolean renameTo(Context context, File src, File dest) {
- boolean res = src.renameTo(dest);
-
- if (!res && isOnExtSdCard(dest, context)) {
- DocumentFile srcDoc;
- if (isOnExtSdCard(src, context)) {
- srcDoc = getDocumentFile(src, false, context);
- } else {
- srcDoc = DocumentFile.fromFile(src);
- }
- DocumentFile destDoc = getDocumentFile(dest.getParentFile(), true, context);
- if (srcDoc != null && destDoc != null) {
- try {
- if (src.getParent().equals(dest.getParent())) {
- res = srcDoc.renameTo(dest.getName());
- } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
- res = DocumentsContract.moveDocument(context.getContentResolver(),
- srcDoc.getUri(),
- srcDoc.getParentFile().getUri(),
- destDoc.getUri()) != null;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- return res;
- }
-
- public static InputStream getInputStream(Context context, File destFile) {
- InputStream in = null;
- try {
- if (!canWrite(destFile) && isOnExtSdCard(destFile, context)) {
- DocumentFile file = DocumentsUtils.getDocumentFile(destFile, false, context);
- if (file != null && file.canWrite()) {
- in = context.getContentResolver().openInputStream(file.getUri());
- }
- } else {
- in = new FileInputStream(destFile);
-
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- return in;
- }
-
- public static OutputStream getOutputStream(Context context, File destFile) {
- OutputStream out = null;
- try {
- if (!canWrite(destFile) && isOnExtSdCard(destFile, context)) {
- DocumentFile file = DocumentsUtils.getDocumentFile(destFile, false, context);
- if (file != null && file.canWrite()) {
- out = context.getContentResolver().openOutputStream(file.getUri());
- }
- } else {
- out = new FileOutputStream(destFile);
-
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- return out;
- }
-
- public static boolean saveTreeUri(Context context, String rootPath, Uri uri) {
- DocumentFile file = DocumentFile.fromTreeUri(context, uri);
- if (file != null && file.canWrite()) {
- SharedPreferences perf = PreferenceManager.getDefaultSharedPreferences(context);
- perf.edit().putString(rootPath, uri.toString()).apply();
- Log.e(TAG, "save uri" + rootPath);
- return true;
- } else {
- Log.e(TAG, "no write permission: " + rootPath);
- }
- return false;
- }
-
- public static boolean checkWritableRootPath(Context context, String rootPath) {
- File root = new File(rootPath);
- if (!root.canWrite()) {
-
- if (DocumentsUtils.isOnExtSdCard(root, context)) {
- Log.i(TAG, "isOnExtSdCard");
- DocumentFile documentFile = DocumentsUtils.getDocumentFile(root, true, context);
- return documentFile == null || !documentFile.canWrite();
- } else {
- Log.i(TAG, " get perf");
- SharedPreferences perf = PreferenceManager.getDefaultSharedPreferences(context);
-
- String documentUri = perf.getString(rootPath, "");
-
- if (documentUri == null || documentUri.isEmpty()) {
- return true;
- } else {
- DocumentFile file = DocumentFile.fromTreeUri(context, Uri.parse(documentUri));
- return !(file != null && file.canWrite());
- }
- }
- }
- return false;
- }
-}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 9531c9a..214b41c 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -40,6 +40,12 @@
android:layout_height="wrap_content"
android:text="自定义toolbar选择器" />
+
+
= Build.VERSION_CODES.M) {
+ titlebarBG = context.getColor(R.color.orange_mlh);//橙色
+ } else {
+ titlebarBG = Color.rgb(255, 165, 0);
+ }
morePopupItemListeners = null;//空即没有
showTabbarFragment = true;
fileItemListener = null;//空即没有
+ fileBeanController = null;
showHandleFragment = true;
alwaysShowHandleFragment = false;
handleItemListeners = null;//空即没有
+
+ titlebarFragment = null;
+ tabbarFragment = null;
+ handleFragment = null;
+
Mtools.log("默认配置SelectConfigData init end");
@@ -150,8 +165,8 @@ public void initAllFragment() throws IllegalAccessException, InstantiationExcept
//使用自定义视图 或者 不需要显示则不创建
if (showTitlebarFragment) {
-
if (titlebarFragment == null || titlebarFragment.getClass().isAssignableFrom(TitlebarFragment.class)) {
+ //使用默认的titlebar
titlebarFragment = new TitlebarFragment();
} else {
titlebarFragment = titlebarFragment.getClass().newInstance();
@@ -176,4 +191,19 @@ public void initAllFragment() throws IllegalAccessException, InstantiationExcept
Mtools.log("各种Fragment init end");
}
+ /**
+ * 初始化控制器
+ */
+ public void initController() throws IllegalAccessException, InstantiationException {
+ Mtools.log("控制器Controller init start");
+
+ if (fileBeanController == null) {
+ //没有设置就使用默认的fileBean控制器
+ fileBeanController = new FileBeanControllerImpl();
+ }
+
+ Mtools.log("控制器Controller init end");
+ }
+
+
}
diff --git a/pathselector/src/main/java/com/molihuan/pathselector/dialog/BaseDialog.java b/pathselector/src/main/java/com/molihuan/pathselector/dialog/BaseDialog.java
index e290395..0e907e7 100644
--- a/pathselector/src/main/java/com/molihuan/pathselector/dialog/BaseDialog.java
+++ b/pathselector/src/main/java/com/molihuan/pathselector/dialog/BaseDialog.java
@@ -5,7 +5,6 @@
import android.os.Bundle;
import android.view.View;
-import androidx.annotation.CallSuper;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -65,7 +64,7 @@ protected void onCreate(Bundle savedInstanceState) {
public abstract void getComponents();
- @CallSuper
+
public void initData() {
psf = (BasePathSelectFragment) mConfigData.fragmentManager.findFragmentByTag(MConstants.TAG_ACTIVITY_FRAGMENT);
}
diff --git a/pathselector/src/main/java/com/molihuan/pathselector/dialog/impl/MessageDialog.java b/pathselector/src/main/java/com/molihuan/pathselector/dialog/impl/MessageDialog.java
index 9d5452b..041bedf 100644
--- a/pathselector/src/main/java/com/molihuan/pathselector/dialog/impl/MessageDialog.java
+++ b/pathselector/src/main/java/com/molihuan/pathselector/dialog/impl/MessageDialog.java
@@ -74,7 +74,7 @@ public void getComponents() {
@Override
public void initData() {
- super.initData();
+
}
diff --git a/pathselector/src/main/java/com/molihuan/pathselector/fragment/impl/FileShowFragment.java b/pathselector/src/main/java/com/molihuan/pathselector/fragment/impl/FileShowFragment.java
index 30a9ea1..75a3afa 100644
--- a/pathselector/src/main/java/com/molihuan/pathselector/fragment/impl/FileShowFragment.java
+++ b/pathselector/src/main/java/com/molihuan/pathselector/fragment/impl/FileShowFragment.java
@@ -19,6 +19,7 @@
import com.molihuan.pathselector.service.impl.PathFileManager;
import com.molihuan.pathselector.utils.CommonTools;
import com.molihuan.pathselector.utils.FileTools;
+import com.molihuan.pathselector.utils.MConstants;
import com.molihuan.pathselector.utils.Mtools;
import com.xuexiang.xtask.XTask;
import com.xuexiang.xtask.core.ITaskChainEngine;
@@ -85,6 +86,7 @@ public void getComponents(View view) {
@Override
public void initData() {
super.initData();
+
//初始化选择列表
selectedFileList = new ArrayList<>();
//获取路径管理者
@@ -248,7 +250,7 @@ public void onItemClick(@NonNull BaseQuickAdapter, ?> adapter, @NonNull View v
selectedNumber++;
} else {
//超过选择的最大数量
- Mtools.toast(getString(R.string.tip_filebeanitem_select_limit_exceeded));
+ Mtools.toast(getString(R.string.tip_filebeanitem_select_limit_exceeded_mlh));
}
@@ -264,9 +266,16 @@ public void onItemClick(@NonNull BaseQuickAdapter, ?> adapter, @NonNull View v
//如果是返回FileBean
if (position == 0) {
- updateFileList(item.getPath());//更新当前路径
+ String path = item.getPath();
+ //如果当前路径比"/storage/emulated/0"还短则设置currentPath为"/storage/emulated/0"
+ if (path.length() <= MConstants.DEFAULT_ROOTPATH.length() && (!MConstants.DEFAULT_ROOTPATH.equals(path))) {
+ Mtools.toast(String.format(getString(R.string.tips_path_jump_error_exceeds_default_path_mlh), path, MConstants.DEFAULT_ROOTPATH));
+ path = MConstants.DEFAULT_ROOTPATH;
+ }
+
+ updateFileList(path);//更新当前路径
//刷新面包屑
- psf.updateTabbarList();
+ psf.updateTabbarList(path);
return;
}
diff --git a/pathselector/src/main/java/com/molihuan/pathselector/fragment/impl/PathSelectFragment.java b/pathselector/src/main/java/com/molihuan/pathselector/fragment/impl/PathSelectFragment.java
index f90b901..52981ed 100644
--- a/pathselector/src/main/java/com/molihuan/pathselector/fragment/impl/PathSelectFragment.java
+++ b/pathselector/src/main/java/com/molihuan/pathselector/fragment/impl/PathSelectFragment.java
@@ -51,7 +51,7 @@ public class PathSelectFragment extends BasePathSelectFragment {
private AbstractTabbarFragment tabbarFragment;
private AbstractFileShowFragment fileShowFragment;
private AbstractHandleFragment handleFragment;
-
+
//路径管理者
private IFileDataManager pathFileManager;
//uri管理者
@@ -70,25 +70,6 @@ public void getComponents(View view) {
@Override
public void initData() {
- if (PathSelectorConfig.AUTO_GET_PERMISSION) {
- //存储权限的申请
- PermissionsTools.getStoragePermissions(
- mActivity,
- new OnPermissionCallback() {
- @Override
- public void onGranted(@NonNull List permissions, boolean all) {
-
- }
- },
- new OnPermissionCallback() {
- @Override
- public void onGranted(@NonNull List permissions, boolean all) {
-
- }
- }
- );
- }
-
//获取Fragment
titlebarFragment = mConfigData.titlebarFragment;
tabbarFragment = mConfigData.tabbarFragment;
@@ -102,6 +83,7 @@ public void onGranted(@NonNull List permissions, boolean all) {
}
+
@Override
public void initView() {
showAllFragment();
@@ -206,61 +188,100 @@ public boolean isMultipleSelectionMode() {
@Override
public TabbarListAdapter getTabbarListAdapter() {
+ if (tabbarFragment == null) {
+ return null;
+ }
return tabbarFragment.getTabbarListAdapter();
}
@Override
public List getTabbarList() {
+ if (tabbarFragment == null) {
+ return null;
+ }
return tabbarFragment.getTabbarList();
}
@Override
public List updateTabbarList() {
//设置了不显示TabbarFragment则返回null
- if (mConfigData.showTabbarFragment) {
+ if (mConfigData.showTabbarFragment && tabbarFragment != null) {
return tabbarFragment.updateTabbarList();
} else {
return null;
}
}
+ @Override
+ public List updateTabbarList(String path) {
+ if (mConfigData.showTabbarFragment && tabbarFragment != null) {
+ return tabbarFragment.updateTabbarList(path);
+ } else {
+ return null;
+ }
+ }
+
@Override
public void refreshTabbarList() {
+ if (tabbarFragment == null) {
+ return;
+ }
tabbarFragment.refreshTabbarList();
}
@Override
public List getHandleItemListeners() {
+ if (handleFragment == null) {
+ return null;
+ }
return handleFragment.getHandleItemListeners();
}
@Override
public HandleListAdapter getHandleListAdapter() {
+ if (handleFragment == null) {
+ return null;
+ }
return handleFragment.getHandleListAdapter();
}
@Override
public void refreshHandleList() {
+ if (handleFragment == null) {
+ return;
+ }
handleFragment.refreshHandleList();
}
@Override
public MorePopupAdapter getMorePopupAdapter() {
+ if (titlebarFragment == null) {
+ return null;
+ }
return titlebarFragment.getMorePopupAdapter();
}
@Override
public List getMorePopupItemListeners() {
+ if (titlebarFragment == null) {
+ return null;
+ }
return titlebarFragment.getMorePopupItemListeners();
}
@Override
public void refreshMorePopup() {
+ if (titlebarFragment == null) {
+ return;
+ }
titlebarFragment.refreshMorePopup();
}
@Override
public TextView getOnlyOneMorePopupTextView() {
+ if (titlebarFragment == null) {
+ return null;
+ }
return titlebarFragment.getOnlyOneMorePopupTextView();
}
@@ -286,15 +307,17 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d
//保存这个uri目录的访问权限
if (VersionTool.isAndroid11()) {
if (requestCode == PermissionsTools.PERMISSION_REQUEST_CODE) {
- Uri uri;
- if ((uri = data.getData()) != null) {
- mActivity.getContentResolver()
- .takePersistableUriPermission(uri,
- data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
- );
+ if (data != null) {
+ Uri uri;
+ if ((uri = data.getData()) != null) {
+ mActivity.getContentResolver()
+ .takePersistableUriPermission(uri,
+ data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
+ );
+ }
+ //更新列表数据
+ fileShowFragment.updateFileList();
}
- //更新列表数据
- fileShowFragment.updateFileList();
}
}
super.onActivityResult(requestCode, resultCode, data);
@@ -356,6 +379,29 @@ public void handleShowHide(boolean isShow) {
}
}
+ @Override
+ public void onStart() {
+ super.onStart();
+ //是否需要自动申请权限
+ if (PathSelectorConfig.AUTO_GET_PERMISSION) {
+ //存储权限的申请
+ PermissionsTools.generalPermissionsOfStorage(mActivity, new OnPermissionCallback() {
+ @Override
+ public void onGranted(@NonNull List permissions, boolean all) {
+ updateFileList();
+ }
+ });
+
+ PermissionsTools.specialPermissionsOfStorageWithDialog(mActivity, true, new OnPermissionCallback() {
+ @Override
+ public void onGranted(@NonNull List permissions, boolean all) {
+ updateFileList();
+ }
+ });
+ }
+
+ }
+
@Override
public boolean onBackPressed() {
return fileShowFragment.onBackPressed();
diff --git a/pathselector/src/main/java/com/molihuan/pathselector/fragment/impl/TabbarFragment.java b/pathselector/src/main/java/com/molihuan/pathselector/fragment/impl/TabbarFragment.java
index bb7bb0f..ff98d41 100644
--- a/pathselector/src/main/java/com/molihuan/pathselector/fragment/impl/TabbarFragment.java
+++ b/pathselector/src/main/java/com/molihuan/pathselector/fragment/impl/TabbarFragment.java
@@ -17,6 +17,8 @@
import com.molihuan.pathselector.fragment.AbstractTabbarFragment;
import com.molihuan.pathselector.service.IFileDataManager;
import com.molihuan.pathselector.service.impl.PathFileManager;
+import com.molihuan.pathselector.utils.MConstants;
+import com.molihuan.pathselector.utils.Mtools;
import com.xuexiang.xtask.XTask;
import com.xuexiang.xtask.core.ITaskChainEngine;
import com.xuexiang.xtask.core.param.ITaskResult;
@@ -121,14 +123,18 @@ private List initTabbarList() {
@Override
public List updateTabbarList() {
+ return updateTabbarList(psf.getCurrentPath());
+ }
+ @Override
+ public List updateTabbarList(String path) {
//开始异步获取数据
XTask.getTaskChain()
.addTask(XTask.getTask(new TaskCommand() {
@Override
public void run() throws Exception {
//TODO 开始异步处理数据
- tabbarList = pathFileManager.updateTabbarList(initPath, psf.getCurrentPath(), tabbarList, tabbarListAdapter);
+ tabbarList = pathFileManager.updateTabbarList(initPath, path, tabbarList, tabbarListAdapter);
}
}))
@@ -156,8 +162,16 @@ public void refreshTabbarList() {
public void onItemClick(@NonNull BaseQuickAdapter, ?> adapter, @NonNull View v, int position) {
if (adapter instanceof TabbarListAdapter) {
TabbarFileBean item = tabbarList.get(position);
- psf.updateFileList(item.getPath());
- updateTabbarList();
+ String path = item.getPath();
+
+ //如果当前路径比"/storage/emulated/0"还短则设置currentPath为"/storage/emulated/0"
+ if (path.length() <= MConstants.DEFAULT_ROOTPATH.length() && (!MConstants.DEFAULT_ROOTPATH.equals(path))) {
+ Mtools.toast(String.format(getString(R.string.tips_path_jump_error_exceeds_default_path_mlh), path, MConstants.DEFAULT_ROOTPATH));
+ path = MConstants.DEFAULT_ROOTPATH;
+ }
+
+ psf.updateFileList(path);
+ updateTabbarList(path);
}
}
}
diff --git a/pathselector/src/main/java/com/molihuan/pathselector/interfaces/ITabbarFragment.java b/pathselector/src/main/java/com/molihuan/pathselector/interfaces/ITabbarFragment.java
index 634272a..5175166 100644
--- a/pathselector/src/main/java/com/molihuan/pathselector/interfaces/ITabbarFragment.java
+++ b/pathselector/src/main/java/com/molihuan/pathselector/interfaces/ITabbarFragment.java
@@ -19,6 +19,8 @@ public interface ITabbarFragment {
List updateTabbarList();
+ List updateTabbarList(String path);
+
/**
* 刷新 TabbarList ui
*
diff --git a/pathselector/src/main/java/com/molihuan/pathselector/service/BaseFileManager.java b/pathselector/src/main/java/com/molihuan/pathselector/service/BaseFileManager.java
index ffc8d97..d234f58 100644
--- a/pathselector/src/main/java/com/molihuan/pathselector/service/BaseFileManager.java
+++ b/pathselector/src/main/java/com/molihuan/pathselector/service/BaseFileManager.java
@@ -6,8 +6,11 @@
import com.molihuan.pathselector.adapter.FileListAdapter;
import com.molihuan.pathselector.adapter.TabbarListAdapter;
+import com.molihuan.pathselector.controller.AbstractFileBeanController;
+import com.molihuan.pathselector.dao.SelectConfigData;
import com.molihuan.pathselector.entity.FileBean;
import com.molihuan.pathselector.entity.TabbarFileBean;
+import com.molihuan.pathselector.service.impl.ConfigDataBuilderImpl;
import com.molihuan.pathselector.utils.FileTools;
import com.molihuan.pathselector.utils.MConstants;
@@ -29,6 +32,8 @@ public abstract class BaseFileManager implements IFileDataManager {
public static final int TYPE_REFRESH_TABBAR = 2;
public static final int TYPE_REFRESH_FILE_TABBAR = 3;
+ protected SelectConfigData mConfigData = ConfigDataBuilderImpl.getInstance().getSelectConfigData();
+ protected AbstractFileBeanController mFileBeanController = mConfigData.fileBeanController;
@Override
public List initFileList(String currentPath, List fileList) {
@@ -41,7 +46,15 @@ public List initFileList(String currentPath, List fileList)
String parentPath = FileTools.getParentPath(currentPath);
switch (fileList.size()) {
case 0://如果列表个数为0则需要添加一个充当返回的FileBean item提供点击就可以返回到上一级目录这个FileBean.path应设置为上一级目录的路径
- fileList.add(new FileBean(parentPath, "...", MConstants.FILEBEAN_BACK_FLAG));
+ FileBean fileBean = new FileBean(parentPath, "...", MConstants.FILEBEAN_BACK_FLAG);
+
+ fileBean.setFileIcoType(mFileBeanController.getFileBeanImageResource(
+ true,
+ "This is back filebean item",
+ fileBean
+ ));
+
+ fileList.add(fileBean);
break;
default://如果已经有了就修改,并且把0索引后面的实例都进行赋值null初始化
fileList.get(0).setPath(parentPath);
@@ -186,9 +199,8 @@ public List initTabbarList(String initPath, List
//tabbarList.add(new TabbarFileBean(initPath, "Storage", MConstants.TABBARFILEBEAN_INIT_FLAG));
break;
default://如果已经有了就修改,并且把0索引后面的实例都进行赋值null初始化
- tabbarList.get(0).setPath(initPath);
- for (int i = 1; i < tabbarList.size(); i++) {
- tabbarList.get(i).clear();
+ for (int i = tabbarList.size() - 1; i >= 0; i--) {
+ tabbarList.remove(i);
}
}
return tabbarList;
@@ -207,49 +219,36 @@ public List clearTabbarListCache(List tabbarList
@Override
public List updateTabbarList(String initPath, String currentPath, List tabbarList, TabbarListAdapter tabbarAdapter) {
- //currentPath = "/storage/emulated/0/Tencent/ams/mmm/rrr/ppp/qqqq";
- tabbarList = initTabbarList(initPath, tabbarList);
- //获取缓存的item数量
- int cacheTabbarSize = tabbarList.size() - 1;
- //去除当前路径中的原始路径: /Tencent/ams/mmm/rrr/ppp/qqqq
- String noInitPath = currentPath.replaceFirst(initPath, "");
+
+ //currentPath = "/storage/emulated/0";
+ tabbarList = initTabbarList(currentPath, tabbarList);
//通过/分割
- String[] parts = noInitPath.split(File.separator);
+ String[] parts = currentPath.split(File.separator);
/**
* (空)
- * Tencent
- * ams
- * mmm
- * rrr
- * ppp
- * qqqq
+ * storage
+ * emulated
+ * 0
*/
+
if (parts.length == 0) {
return tabbarList;
}
StringBuilder builder = new StringBuilder();
- builder.append(initPath);
/**组合成分级
- * args[0] = /storage/emulated/0
- * args[1] = /storage/emulated/0/Tencent
- * args[2] = /storage/emulated/0/Tencent/ams
- * args[3] = /storage/emulated/0/Tencent/ams/mmm
- * args[4] = /storage/emulated/0/Tencent/ams/mmm/rrr
- * args[5] = /storage/emulated/0/Tencent/ams/mmm/rrr/ppp
- * args[6] = /storage/emulated/0/Tencent/ams/mmm/rrr/ppp/qqqq
+ * parts[0] = (null)
+ * parts[1] = /storage
+ * parts[2] = /storage/emulated
+ * parts[3] = /storage/emulated/0
*/
- for (int i = 0; i < parts.length; i++) {
- if (i == 0) {
- parts[i] = builder.append(parts[i]).toString();
- } else {
- parts[i] = builder.append(File.separator + parts[i]).toString();
- }
+ for (int i = 1; i < parts.length; i++) {
+ parts[i] = builder.append(File.separator + parts[i]).toString();
}
TabbarFileBean tabbarBean;
- for (int i = 0; i < parts.length; i++) {
- if (i <= cacheTabbarSize) {
+ for (int i = 1; i < parts.length; i++) {
+ if (false) {
/**
* 如果还有缓存的FileBean就设置属性即可
* 0索引FileBean为返回按钮所以+1
@@ -344,4 +343,6 @@ public List setBoxChecked(List fileList, FileListAdapter fil
}
return fileList;
}
+
+
}
diff --git a/pathselector/src/main/java/com/molihuan/pathselector/service/IConfigDataBuilder.java b/pathselector/src/main/java/com/molihuan/pathselector/service/IConfigDataBuilder.java
index 9ed29d8..ed62e35 100644
--- a/pathselector/src/main/java/com/molihuan/pathselector/service/IConfigDataBuilder.java
+++ b/pathselector/src/main/java/com/molihuan/pathselector/service/IConfigDataBuilder.java
@@ -5,6 +5,7 @@
import androidx.annotation.IdRes;
import androidx.fragment.app.FragmentManager;
+import com.molihuan.pathselector.controller.AbstractFileBeanController;
import com.molihuan.pathselector.entity.FontBean;
import com.molihuan.pathselector.fragment.AbstractFileShowFragment;
import com.molihuan.pathselector.fragment.AbstractHandleFragment;
@@ -82,6 +83,8 @@ public interface IConfigDataBuilder {
IConfigDataBuilder setFileItemListener(FileItemListener fileItemListener);
+ IConfigDataBuilder setFileBeanController(AbstractFileBeanController fileBeanController);
+
/****************** HandleFragment **************************/
IConfigDataBuilder setHandleFragment(AbstractHandleFragment handleFragment);
diff --git a/pathselector/src/main/java/com/molihuan/pathselector/service/impl/ConfigDataBuilderImpl.java b/pathselector/src/main/java/com/molihuan/pathselector/service/impl/ConfigDataBuilderImpl.java
index 611138e..da2a6e1 100644
--- a/pathselector/src/main/java/com/molihuan/pathselector/service/impl/ConfigDataBuilderImpl.java
+++ b/pathselector/src/main/java/com/molihuan/pathselector/service/impl/ConfigDataBuilderImpl.java
@@ -5,6 +5,7 @@
import androidx.fragment.app.FragmentManager;
import com.molihuan.pathselector.controller.AbstractBuildController;
+import com.molihuan.pathselector.controller.AbstractFileBeanController;
import com.molihuan.pathselector.controller.impl.ActivityController;
import com.molihuan.pathselector.controller.impl.DialogController;
import com.molihuan.pathselector.controller.impl.FragmentController;
@@ -38,14 +39,13 @@ public SelectConfigData getSelectConfigData() {
return mConfigData;
}
- protected void init() {
- mConfigData.initDefaultConfig();
+ protected void init(Context context) {
+ mConfigData.initDefaultConfig(context);
}
@Override
public IConfigDataBuilder setContext(Context context) {
- init();
- mConfigData.context = context;
+ init(context);
return this;
}
@@ -235,6 +235,12 @@ public IConfigDataBuilder setFileItemListener(FileItemListener fileItemListener)
return this;
}
+ @Override
+ public IConfigDataBuilder setFileBeanController(AbstractFileBeanController fileBeanController) {
+ mConfigData.fileBeanController = fileBeanController;
+ return this;
+ }
+
/****************** HandleFragment **************************/
@Override
@@ -267,14 +273,19 @@ public IConfigDataBuilder setHandleItemListeners(CommonItemListener... handleIte
@Override
public PathSelectFragment show() {
- //这里初始化各种fragment
+
try {
+ //初始化各种fragment
mConfigData.initAllFragment();
+ //初始化控制器
+ mConfigData.initController();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
}
+
+
return mConfigData.buildController.show();
}
diff --git a/pathselector/src/main/java/com/molihuan/pathselector/service/impl/PathFileManager.java b/pathselector/src/main/java/com/molihuan/pathselector/service/impl/PathFileManager.java
index 7b68aa8..a5681fe 100644
--- a/pathselector/src/main/java/com/molihuan/pathselector/service/impl/PathFileManager.java
+++ b/pathselector/src/main/java/com/molihuan/pathselector/service/impl/PathFileManager.java
@@ -36,6 +36,8 @@ public List updateFileList(@Nullable Fragment fragment, String initPat
File[] subFiles = file.listFiles();
String extension;
int addNumber = 0;//添加的数量
+ FileBean fileBean;
+
if (subFiles != null) {
for (int i = 0; i < subFiles.length; i++) {
//获取后缀
@@ -48,15 +50,11 @@ public List updateFileList(@Nullable Fragment fragment, String initPat
* 如果还有缓存的FileBean就设置属性即可
* 0索引FileBean为返回按钮所以+1
*/
- fileList.get(addNumber + 1)
- .setPath(subFiles[i].getAbsolutePath())
+ fileBean = fileList.get(addNumber + 1);
+ fileBean.setPath(subFiles[i].getAbsolutePath())
.setName(subFiles[i].getName())
.setDir(subFiles[i].isDirectory())
.setFileExtension(extension)
- .setFileIcoType(FileTools.getImageResourceByExtension(
- subFiles[i].isDirectory(),
- extension
- ))
.setChildrenFileNumber(FileTools.getChildrenNumber(subFiles[i])[0])
.setChildrenDirNumber(FileTools.getChildrenNumber(subFiles[i])[1])
.setBoxVisible(false)
@@ -64,18 +62,21 @@ public List updateFileList(@Nullable Fragment fragment, String initPat
.setModifyTime(subFiles[i].lastModified())
.setSize(subFiles[i].length())
.setSizeString(FileTools.computeFileSize(subFiles[i]))
- .setUseUri(false);
+ .setUseUri(false)
+ //需要放在最后
+ .setFileIcoType(mFileBeanController.getFileBeanImageResource(
+ subFiles[i].isDirectory(),
+ extension,
+ fileBean
+ ));
+
} else {
//如果不够就new
- FileBean fileBean = new FileBean();
+ fileBean = new FileBean();
fileBean.setPath(subFiles[i].getAbsolutePath())
.setName(subFiles[i].getName())
.setDir(subFiles[i].isDirectory())
.setFileExtension(extension)
- .setFileIcoType(FileTools.getImageResourceByExtension(
- subFiles[i].isDirectory(),
- extension
- ))
.setChildrenFileNumber(FileTools.getChildrenNumber(subFiles[i])[0])
.setChildrenDirNumber(FileTools.getChildrenNumber(subFiles[i])[1])
.setBoxVisible(false)
@@ -83,7 +84,12 @@ public List updateFileList(@Nullable Fragment fragment, String initPat
.setModifyTime(subFiles[i].lastModified())
.setSize(subFiles[i].length())
.setSizeString(FileTools.computeFileSize(subFiles[i]))
- .setUseUri(false);
+ .setUseUri(false)
+ .setFileIcoType(mFileBeanController.getFileBeanImageResource(
+ subFiles[i].isDirectory(),
+ extension,
+ fileBean
+ ));
fileList.add(fileBean);
}
diff --git a/pathselector/src/main/java/com/molihuan/pathselector/service/impl/UriFileManager.java b/pathselector/src/main/java/com/molihuan/pathselector/service/impl/UriFileManager.java
index 8021cca..cb738e0 100644
--- a/pathselector/src/main/java/com/molihuan/pathselector/service/impl/UriFileManager.java
+++ b/pathselector/src/main/java/com/molihuan/pathselector/service/impl/UriFileManager.java
@@ -64,6 +64,8 @@ public List updateFileList(Fragment fragment, String initPath, String
String extension;
int addNumber = 0;//添加的数量
+ FileBean fileBean;
+
for (int i = 0; i < subFiles.size(); i++) {
tempSubFile = subFiles.get(i);
//获取后缀
@@ -76,15 +78,11 @@ public List updateFileList(Fragment fragment, String initPath, String
* 如果还有缓存的FileBean就设置属性即可
* 0索引FileBean为返回按钮所以+1
*/
- fileList.get(addNumber + 1)
- .setPath(tempSubFile.getAbsolutePath())
+ fileBean = fileList.get(addNumber + 1);
+ fileBean.setPath(tempSubFile.getAbsolutePath())
.setName(tempSubFile.getName())
.setDir(tempSubFile.isDirectory())
.setFileExtension(extension)
- .setFileIcoType(FileTools.getImageResourceByExtension(
- tempSubFile.isDirectory(),
- extension
- ))
.setChildrenFileNumber(FileTools.getChildrenNumber(tempSubFile)[0])
.setChildrenDirNumber(FileTools.getChildrenNumber(tempSubFile)[1])
.setBoxVisible(false)
@@ -92,18 +90,19 @@ public List updateFileList(Fragment fragment, String initPath, String
.setModifyTime(tempSubFile.lastModified())
.setSize(tempSubFile.length())
.setSizeString(FileTools.computeFileSize(tempSubFile))
- .setUseUri(false);
+ .setUseUri(false)
+ .setFileIcoType(mFileBeanController.getFileBeanImageResource(
+ tempSubFile.isDirectory(),
+ extension,
+ fileBean
+ ));
} else {
//如果不够就new
- FileBean fileBean = new FileBean()
- .setPath(tempSubFile.getAbsolutePath())
+ fileBean = new FileBean();
+ fileBean.setPath(tempSubFile.getAbsolutePath())
.setName(tempSubFile.getName())
.setDir(tempSubFile.isDirectory())
.setFileExtension(extension)
- .setFileIcoType(FileTools.getImageResourceByExtension(
- tempSubFile.isDirectory(),
- extension
- ))
.setChildrenFileNumber(FileTools.getChildrenNumber(tempSubFile)[0])
.setChildrenDirNumber(FileTools.getChildrenNumber(tempSubFile)[1])
.setBoxVisible(false)
@@ -111,7 +110,12 @@ public List updateFileList(Fragment fragment, String initPath, String
.setModifyTime(tempSubFile.lastModified())
.setSize(tempSubFile.length())
.setSizeString(FileTools.computeFileSize(tempSubFile))
- .setUseUri(false);
+ .setUseUri(false)
+ .setFileIcoType(mFileBeanController.getFileBeanImageResource(
+ tempSubFile.isDirectory(),
+ extension,
+ fileBean
+ ));
fileList.add(fileBean);
}
@@ -181,6 +185,8 @@ public boolean onClick(View v, BaseDialog dialog) {
String extension;
int addNumber = 0;//添加的数量
+ FileBean fileBean;
+
for (int i = 0; i < documentFiles.length; i++) {
//获取后缀
extension = FileTools.getFileExtension(documentFiles[i].getName());
@@ -192,15 +198,11 @@ public boolean onClick(View v, BaseDialog dialog) {
* 如果还有缓存的FileBean就设置属性即可
* 0索引FileBean为返回按钮所以+1
*/
- fileList.get(addNumber + 1)
- .setPath(currentPath + File.separator + documentFiles[i].getName())
+ fileBean = fileList.get(addNumber + 1);
+ fileBean.setPath(currentPath + File.separator + documentFiles[i].getName())
.setName(documentFiles[i].getName())
.setDir(documentFiles[i].isDirectory())
.setFileExtension(extension)
- .setFileIcoType(FileTools.getImageResourceByExtension(
- documentFiles[i].isDirectory(),
- extension
- ))
.setChildrenFileNumber(FileTools.getChildrenNumber(documentFiles[i])[0])
.setChildrenDirNumber(FileTools.getChildrenNumber(documentFiles[i])[1])
.setBoxVisible(false)
@@ -209,19 +211,20 @@ public boolean onClick(View v, BaseDialog dialog) {
.setSize(-1L)
.setSizeString(FileTools.ERROR_GETTING_FILE_SIZE)
.setUseUri(true)
- .setDocumentFile(documentFiles[i]);
+ .setDocumentFile(documentFiles[i])
+ .setFileIcoType(mFileBeanController.getFileBeanImageResource(
+ documentFiles[i].isDirectory(),
+ extension,
+ fileBean
+ ));
} else {
//如果不够就new
- FileBean fileBean = new FileBean()
- .setPath(currentPath + File.separator + documentFiles[i].getName())
+ fileBean = new FileBean();
+ fileBean.setPath(currentPath + File.separator + documentFiles[i].getName())
.setName(documentFiles[i].getName())
.setDir(documentFiles[i].isDirectory())
.setFileExtension(extension)
- .setFileIcoType(FileTools.getImageResourceByExtension(
- documentFiles[i].isDirectory(),
- extension
- ))
.setChildrenFileNumber(FileTools.getChildrenNumber(documentFiles[i])[0])
.setChildrenDirNumber(FileTools.getChildrenNumber(documentFiles[i])[1])
.setBoxVisible(false)
@@ -230,7 +233,12 @@ public boolean onClick(View v, BaseDialog dialog) {
.setSize(-1L)
.setSizeString(FileTools.ERROR_GETTING_FILE_SIZE)
.setUseUri(true)
- .setDocumentFile(documentFiles[i]);
+ .setDocumentFile(documentFiles[i])
+ .setFileIcoType(mFileBeanController.getFileBeanImageResource(
+ documentFiles[i].isDirectory(),
+ extension,
+ fileBean
+ ));
fileList.add(fileBean);
}
diff --git a/pathselector/src/main/java/com/molihuan/pathselector/utils/FileTools.java b/pathselector/src/main/java/com/molihuan/pathselector/utils/FileTools.java
index c4131ee..2b6e42b 100644
--- a/pathselector/src/main/java/com/molihuan/pathselector/utils/FileTools.java
+++ b/pathselector/src/main/java/com/molihuan/pathselector/utils/FileTools.java
@@ -4,7 +4,6 @@
import com.blankj.molihuan.utilcode.util.ConvertUtils;
import com.blankj.molihuan.utilcode.util.FileUtils;
-import com.molihuan.pathselector.R;
import java.io.File;
import java.util.List;
@@ -225,74 +224,4 @@ public static boolean stringIsEmpty(String s) {
return s == null || s.trim().isEmpty();
}
- /**
- * 根据后缀选择显示图片
- *
- * @param isDir
- * @param extension
- * @return
- */
-
- public static int getImageResourceByExtension(boolean isDir, String extension) {
- int resourceId;
- switch (extension) {
- case "apk":
- resourceId = R.mipmap.apk;
- break;
- case "avi":
- resourceId = R.mipmap.avi;
- break;
- case "doc":
- case "docx":
- resourceId = R.mipmap.doc;
- break;
- case "exe":
- resourceId = R.mipmap.exe;
- break;
- case "flv":
- resourceId = R.mipmap.flv;
- break;
- case "gif":
- resourceId = R.mipmap.gif;
- break;
- case "jpg":
- case "jpeg":
- case "png":
- resourceId = R.mipmap.png;
- break;
- case "mp3":
- resourceId = R.mipmap.mp3;
- break;
- case "mp4":
- case "f4v":
- resourceId = R.mipmap.movie;
- break;
- case "pdf":
- resourceId = R.mipmap.pdf;
- break;
- case "ppt":
- case "pptx":
- resourceId = R.mipmap.ppt;
- break;
- case "wav":
- resourceId = R.mipmap.wav;
- break;
- case "xls":
- case "xlsx":
- resourceId = R.mipmap.xls;
- break;
- case "zip":
- resourceId = R.mipmap.zip;
- break;
- case "ext":
- default:
- if (isDir) {
- resourceId = R.mipmap.folder;
- } else {
- resourceId = R.mipmap.documents;
- }
- break;
- }
- return resourceId;
- }
}
diff --git a/pathselector/src/main/java/com/molihuan/pathselector/utils/PermissionsTools.java b/pathselector/src/main/java/com/molihuan/pathselector/utils/PermissionsTools.java
index b4b3215..bb0ca8c 100644
--- a/pathselector/src/main/java/com/molihuan/pathselector/utils/PermissionsTools.java
+++ b/pathselector/src/main/java/com/molihuan/pathselector/utils/PermissionsTools.java
@@ -7,6 +7,7 @@
import android.net.Uri;
import android.os.Build;
import android.provider.DocumentsContract;
+import android.view.View;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.Fragment;
@@ -17,6 +18,9 @@
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
import com.molihuan.pathselector.R;
+import com.molihuan.pathselector.dialog.BaseDialog;
+import com.molihuan.pathselector.dialog.impl.MessageDialog;
+import com.molihuan.pathselector.entity.FontBean;
import java.util.List;
import java.util.Objects;
@@ -39,7 +43,13 @@ public class PermissionsTools {
public OnPermissionCallback specialPermissionCallback;
public OnPermissionCallback generalPermissionCallback;
-
+ /**
+ * 获取存储权限
+ *
+ * @param context
+ * @param specialPermissionCallback
+ * @param generalPermissionCallback
+ */
public static void getStoragePermissions(Context context, OnPermissionCallback specialPermissionCallback, OnPermissionCallback generalPermissionCallback) {
//所有文件访问权限Android 11 +
@@ -50,10 +60,58 @@ public static void getStoragePermissions(Context context, OnPermissionCallback s
}
+ /**
+ * 带弹窗的全文件读写权限申请
+ *
+ * @param context
+ * @param useDialog 是否使用弹窗
+ * @param specialPermissionCallback 权限申请结果回调
+ */
+ public static void specialPermissionsOfStorageWithDialog(Context context, boolean useDialog, OnPermissionCallback specialPermissionCallback) {
+ if (useDialog) {
+
+ if (!VersionTool.isAndroid11()) {
+ return;
+ }
+
+ boolean isGet = XXPermissions.isGranted(context, Permission.MANAGE_EXTERNAL_STORAGE);
+ //已有权限则返回
+ if (isGet) {
+ Mtools.log("全文件读取权限------已获取");
+ return;
+ }
+
+ new MessageDialog(context)
+ .setContent(new FontBean(context.getString(R.string.tip_dialog_get_special_permissions_mlh)))
+ .setConfirm(new FontBean(context.getString(R.string.option_confirm_mlh)), new BaseDialog.IOnConfirmListener() {
+ @Override
+ public boolean onClick(View v, BaseDialog dialog) {
+ PermissionsTools.specialPermissionsOfStorageNoCheck(context, specialPermissionCallback);
+ dialog.dismiss();
+ return false;
+ }
+ })
+ .setCancel(new FontBean(context.getString(R.string.option_cancel_mlh)), new BaseDialog.IOnCancelListener() {
+ @Override
+ public boolean onClick(View v, BaseDialog dialog) {
+ dialog.dismiss();
+ return false;
+ }
+ })
+ .show();
+
+ } else {
+ specialPermissionsOfStorage(context, specialPermissionCallback);
+ }
+ }
+
/**
* 获取一般读写权限
* Android 11 -
+ *
+ * @param context
+ * @param generalPermissionCallback 权限申请结果回调
*/
public static void generalPermissionsOfStorage(Context context, OnPermissionCallback generalPermissionCallback) {
@@ -78,11 +136,11 @@ public void onGranted(List permissions, boolean all) {
@Override
public void onDenied(List permissions, boolean never) {
if (never) {
- ToastUtils.make().show(R.string.tip_denial_authorization);
+ ToastUtils.make().show(R.string.tip_denial_authorization_mlh);
//如果是被永久拒绝就跳转到应用权限系统设置页面
//XXPermissions.startPermissionActivity(context, permissions);
} else {
- ToastUtils.make().show(R.string.tip_permission_failed);
+ ToastUtils.make().show(R.string.tip_permission_failed_mlh);
}
generalPermissionCallback.onDenied(permissions, never);
@@ -91,11 +149,13 @@ public void onDenied(List permissions, boolean never) {
});
}
+
/**
* 获取全文件读取权限
* Android 11 +
*
* @param context
+ * @param specialPermissionCallback 权限申请结果回调
*/
public static void specialPermissionsOfStorage(Context context, OnPermissionCallback specialPermissionCallback) {
if (!VersionTool.isAndroid11()) {
@@ -109,6 +169,11 @@ public static void specialPermissionsOfStorage(Context context, OnPermissionCall
return;
}
+ specialPermissionsOfStorageNoCheck(context, specialPermissionCallback);
+
+ }
+
+ public static void specialPermissionsOfStorageNoCheck(Context context, OnPermissionCallback specialPermissionCallback) {
XXPermissions.with(context)
// 申请单个权限
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
@@ -124,18 +189,16 @@ public void onGranted(List permissions, boolean all) {
@Override
public void onDenied(List permissions, boolean never) {
if (never) {
- ToastUtils.make().show(R.string.tip_denial_authorization);
+ ToastUtils.make().show(R.string.tip_denial_authorization_mlh);
//如果是被永久拒绝就跳转到应用权限系统设置页面
XXPermissions.startPermissionActivity(context, permissions);
} else {
- ToastUtils.make().show(R.string.tip_permission_failed);
+ ToastUtils.make().show(R.string.tip_permission_failed_mlh);
}
specialPermissionCallback.onDenied(permissions, never);
}
});
-
-
}
/**
diff --git a/pathselector/src/main/res/drawable/ic_back.png b/pathselector/src/main/res/drawable/ic_back_mlh.png
similarity index 100%
rename from pathselector/src/main/res/drawable/ic_back.png
rename to pathselector/src/main/res/drawable/ic_back_mlh.png
diff --git a/pathselector/src/main/res/drawable/ic_partition_tabbar_black.png b/pathselector/src/main/res/drawable/ic_partition_tabbar_black_mlh.png
similarity index 100%
rename from pathselector/src/main/res/drawable/ic_partition_tabbar_black.png
rename to pathselector/src/main/res/drawable/ic_partition_tabbar_black_mlh.png
diff --git a/pathselector/src/main/res/drawable/ic_tabbar_storage.png b/pathselector/src/main/res/drawable/ic_tabbar_storage_mlh.png
similarity index 100%
rename from pathselector/src/main/res/drawable/ic_tabbar_storage.png
rename to pathselector/src/main/res/drawable/ic_tabbar_storage_mlh.png
diff --git a/pathselector/src/main/res/drawable/ic_titlebar_back.png b/pathselector/src/main/res/drawable/ic_titlebar_back_mlh.png
similarity index 100%
rename from pathselector/src/main/res/drawable/ic_titlebar_back.png
rename to pathselector/src/main/res/drawable/ic_titlebar_back_mlh.png
diff --git a/pathselector/src/main/res/drawable/ic_titlebar_options.png b/pathselector/src/main/res/drawable/ic_titlebar_options_mlh.png
similarity index 100%
rename from pathselector/src/main/res/drawable/ic_titlebar_options.png
rename to pathselector/src/main/res/drawable/ic_titlebar_options_mlh.png
diff --git a/pathselector/src/main/res/drawable/ic_titlebar_search.png b/pathselector/src/main/res/drawable/ic_titlebar_search_mlh.png
similarity index 100%
rename from pathselector/src/main/res/drawable/ic_titlebar_search.png
rename to pathselector/src/main/res/drawable/ic_titlebar_search_mlh.png
diff --git a/pathselector/src/main/res/layout/fragment_empty_mlh.xml b/pathselector/src/main/res/layout/fragment_empty_mlh.xml
index dd69938..aed646b 100644
--- a/pathselector/src/main/res/layout/fragment_empty_mlh.xml
+++ b/pathselector/src/main/res/layout/fragment_empty_mlh.xml
@@ -16,7 +16,7 @@
android:layout_height="120dp"
android:gravity="center"
android:layout_centerInParent="true"
- android:background="@mipmap/ic_file_empty" />
+ android:background="@mipmap/ic_file_empty_mlh" />
diff --git a/pathselector/src/main/res/layout/fragment_tabbar_mlh.xml b/pathselector/src/main/res/layout/fragment_tabbar_mlh.xml
index 9a8a2b4..3dafd36 100644
--- a/pathselector/src/main/res/layout/fragment_tabbar_mlh.xml
+++ b/pathselector/src/main/res/layout/fragment_tabbar_mlh.xml
@@ -19,7 +19,7 @@
android:layout_gravity="center"
android:src="@drawable/ic_tabbar_storage_black"
android:background="@drawable/style_click_rectangle_transp_gray_mlh"
- android:tooltipText="@string/internal_storage"
+ android:tooltipText="@string/internal_storage_mlh"
android:visibility="gone" />
@@ -37,7 +37,7 @@
android:layout_width="30dp"
android:layout_height="30dp"
android:adjustViewBounds="true"
- android:src="@drawable/ic_tabbar_storage"
+ android:src="@drawable/ic_tabbar_storage_mlh"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:background="@drawable/style_click_round_transp_gray_mlh"
@@ -63,7 +63,7 @@
android:id="@+id/tv_main_title_titlebar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="@string/test_text"
+ android:text="@string/test_text_mlh"
android:textSize="21dp"
android:textColor="@color/white_mlh" />
@@ -74,7 +74,7 @@
android:layout_below="@id/tv_main_title_titlebar"
android:layout_centerHorizontal="true"
android:textColor="@color/white_mlh"
- android:text="@string/test_text"
+ android:text="@string/test_text_mlh"
android:visibility="gone" />
@@ -94,7 +94,7 @@
android:adjustViewBounds="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
- android:src="@drawable/ic_titlebar_search"
+ android:src="@drawable/ic_titlebar_search_mlh"
android:layout_marginRight="15dp"
android:background="@drawable/style_click_round_transp_gray_mlh"
android:visibility="gone" />
@@ -106,7 +106,7 @@
android:adjustViewBounds="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
- android:src="@drawable/ic_titlebar_options"
+ android:src="@drawable/ic_titlebar_options_mlh"
android:layout_marginRight="15dp"
android:background="@drawable/style_click_round_transp_gray_mlh" />
diff --git a/pathselector/src/main/res/layout/general_item_tv_mlh.xml b/pathselector/src/main/res/layout/general_item_tv_mlh.xml
index 4c765b0..b7c5abe 100644
--- a/pathselector/src/main/res/layout/general_item_tv_mlh.xml
+++ b/pathselector/src/main/res/layout/general_item_tv_mlh.xml
@@ -17,7 +17,7 @@
android:id="@+id/general_item_imav_ico_mlh"
android:layout_height="18dp"
android:layout_width="18dp"
- android:src="@drawable/ic_partition_tabbar_black"
+ android:src="@drawable/ic_partition_tabbar_black_mlh"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:visibility="gone" />
@@ -28,7 +28,7 @@
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:gravity="center"
- android:text="@string/test_text"
+ android:text="@string/test_text_mlh"
android:textSize="20dp"
android:layout_toRightOf="@id/general_item_imav_ico_mlh"
diff --git a/pathselector/src/main/res/layout/general_title_content_btn_mlh.xml b/pathselector/src/main/res/layout/general_title_content_btn_mlh.xml
index 5fb2b59..a7172ad 100644
--- a/pathselector/src/main/res/layout/general_title_content_btn_mlh.xml
+++ b/pathselector/src/main/res/layout/general_title_content_btn_mlh.xml
@@ -8,7 +8,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="18dp"
- android:text="@string/test_text"
+ android:text="@string/test_text_mlh"
android:gravity="center"
android:textSize="20sp" />
@@ -30,7 +30,7 @@
android:layout_height="wrap_content"
android:paddingBottom="18dp"
android:paddingHorizontal="30dp"
- android:text="@string/test_text" />
+ android:text="@string/test_text_mlh" />
@@ -64,7 +64,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingVertical="15dp"
- android:text="@string/test_text"
+ android:text="@string/test_text_mlh"
android:gravity="center"
android:background="@drawable/style_click_r_rectangle_white_gray_mlh" />
diff --git a/pathselector/src/main/res/layout/general_title_recyview_btn_mlh.xml b/pathselector/src/main/res/layout/general_title_recyview_btn_mlh.xml
index 69da7cd..2212163 100644
--- a/pathselector/src/main/res/layout/general_title_recyview_btn_mlh.xml
+++ b/pathselector/src/main/res/layout/general_title_recyview_btn_mlh.xml
@@ -8,7 +8,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="18dp"
- android:text="@string/test_text"
+ android:text="@string/test_text_mlh"
android:gravity="center"
android:textSize="20sp" />
@@ -42,7 +42,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingVertical="15dp"
- android:text="@string/test_text"
+ android:text="@string/test_text_mlh"
android:gravity="center"
android:background="@drawable/style_click_r_rectangle_white_gray_mlh" />
@@ -57,7 +57,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingVertical="15dp"
- android:text="@string/test_text"
+ android:text="@string/test_text_mlh"
android:gravity="center"
android:background="@drawable/style_click_r_rectangle_white_gray_mlh" />
diff --git a/pathselector/src/main/res/layout/item_file_mlh.xml b/pathselector/src/main/res/layout/item_file_mlh.xml
index 967776a..2d6e4b3 100644
--- a/pathselector/src/main/res/layout/item_file_mlh.xml
+++ b/pathselector/src/main/res/layout/item_file_mlh.xml
@@ -26,7 +26,7 @@
android:id="@+id/imgv_item_file_ico"
android:layout_width="36dp"
android:layout_height="42dp"
- android:src="@mipmap/folder"
+ android:src="@mipmap/folder_mlh"
android:layout_centerInParent="true" />
@@ -80,7 +80,7 @@
android:layout_width="16dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
- android:src="@drawable/ic_partition_tabbar_black" />
+ android:src="@drawable/ic_partition_tabbar_black_mlh" />
diff --git a/pathselector/src/main/res/layout/item_handle_mlh.xml b/pathselector/src/main/res/layout/item_handle_mlh.xml
index e156867..d6d47d1 100644
--- a/pathselector/src/main/res/layout/item_handle_mlh.xml
+++ b/pathselector/src/main/res/layout/item_handle_mlh.xml
@@ -18,7 +18,7 @@
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_centerVertical="true"
- android:src="@drawable/ic_partition_tabbar_black"
+ android:src="@drawable/ic_partition_tabbar_black_mlh"
android:layout_toLeftOf="@id/item_handle_tv_mlh"
android:visibility="gone" />
@@ -28,7 +28,7 @@
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center"
- android:text="@string/test_text"
+ android:text="@string/test_text_mlh"
android:textColor="@color/black_mlh"
android:textSize="20dp" />
diff --git a/pathselector/src/main/res/layout/item_tabbar_mlh.xml b/pathselector/src/main/res/layout/item_tabbar_mlh.xml
index e2b29c9..320b2ea 100644
--- a/pathselector/src/main/res/layout/item_tabbar_mlh.xml
+++ b/pathselector/src/main/res/layout/item_tabbar_mlh.xml
@@ -15,7 +15,7 @@
android:id="@+id/imgv_item_tabbar_mlh"
android:layout_width="20dp"
android:layout_height="20dp"
- android:src="@drawable/ic_partition_tabbar_black"
+ android:src="@drawable/ic_partition_tabbar_black_mlh"
android:clickable="false"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true" />
@@ -26,7 +26,7 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center"
- android:text="@string/test_text"
+ android:text="@string/test_text_mlh"
android:textSize="20sp"
android:minWidth="25dp"
android:textColor="@color/black_mlh"
diff --git a/pathselector/src/main/res/mipmap-xhdpi/apk.png b/pathselector/src/main/res/mipmap-xhdpi/apk_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/apk.png
rename to pathselector/src/main/res/mipmap-xhdpi/apk_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/attachment.png b/pathselector/src/main/res/mipmap-xhdpi/attachment_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/attachment.png
rename to pathselector/src/main/res/mipmap-xhdpi/attachment_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/avi.png b/pathselector/src/main/res/mipmap-xhdpi/avi_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/avi.png
rename to pathselector/src/main/res/mipmap-xhdpi/avi_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/delete.png b/pathselector/src/main/res/mipmap-xhdpi/delete_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/delete.png
rename to pathselector/src/main/res/mipmap-xhdpi/delete_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/doc.png b/pathselector/src/main/res/mipmap-xhdpi/doc_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/doc.png
rename to pathselector/src/main/res/mipmap-xhdpi/doc_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/documents.png b/pathselector/src/main/res/mipmap-xhdpi/documents_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/documents.png
rename to pathselector/src/main/res/mipmap-xhdpi/documents_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/exe.png b/pathselector/src/main/res/mipmap-xhdpi/exe_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/exe.png
rename to pathselector/src/main/res/mipmap-xhdpi/exe_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/flv.png b/pathselector/src/main/res/mipmap-xhdpi/flv_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/flv.png
rename to pathselector/src/main/res/mipmap-xhdpi/flv_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/folder.png b/pathselector/src/main/res/mipmap-xhdpi/folder_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/folder.png
rename to pathselector/src/main/res/mipmap-xhdpi/folder_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/gif.png b/pathselector/src/main/res/mipmap-xhdpi/gif_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/gif.png
rename to pathselector/src/main/res/mipmap-xhdpi/gif_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/ic_file_empty.png b/pathselector/src/main/res/mipmap-xhdpi/ic_file_empty_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/ic_file_empty.png
rename to pathselector/src/main/res/mipmap-xhdpi/ic_file_empty_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/ic_right.png b/pathselector/src/main/res/mipmap-xhdpi/ic_right_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/ic_right.png
rename to pathselector/src/main/res/mipmap-xhdpi/ic_right_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/ic_tabbar_partition.png b/pathselector/src/main/res/mipmap-xhdpi/ic_tabbar_partition_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/ic_tabbar_partition.png
rename to pathselector/src/main/res/mipmap-xhdpi/ic_tabbar_partition_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/jpg.png b/pathselector/src/main/res/mipmap-xhdpi/jpg_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/jpg.png
rename to pathselector/src/main/res/mipmap-xhdpi/jpg_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/more.png b/pathselector/src/main/res/mipmap-xhdpi/more_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/more.png
rename to pathselector/src/main/res/mipmap-xhdpi/more_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/movie.png b/pathselector/src/main/res/mipmap-xhdpi/movie_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/movie.png
rename to pathselector/src/main/res/mipmap-xhdpi/movie_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/mp3.png b/pathselector/src/main/res/mipmap-xhdpi/mp3_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/mp3.png
rename to pathselector/src/main/res/mipmap-xhdpi/mp3_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/password.png b/pathselector/src/main/res/mipmap-xhdpi/password_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/password.png
rename to pathselector/src/main/res/mipmap-xhdpi/password_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/pdf.png b/pathselector/src/main/res/mipmap-xhdpi/pdf_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/pdf.png
rename to pathselector/src/main/res/mipmap-xhdpi/pdf_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/png.png b/pathselector/src/main/res/mipmap-xhdpi/png_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/png.png
rename to pathselector/src/main/res/mipmap-xhdpi/png_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/ppt.png b/pathselector/src/main/res/mipmap-xhdpi/ppt_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/ppt.png
rename to pathselector/src/main/res/mipmap-xhdpi/ppt_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/wav.png b/pathselector/src/main/res/mipmap-xhdpi/wav_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/wav.png
rename to pathselector/src/main/res/mipmap-xhdpi/wav_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/xls.png b/pathselector/src/main/res/mipmap-xhdpi/xls_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/xls.png
rename to pathselector/src/main/res/mipmap-xhdpi/xls_mlh.png
diff --git a/pathselector/src/main/res/mipmap-xhdpi/zip.png b/pathselector/src/main/res/mipmap-xhdpi/zip_mlh.png
similarity index 100%
rename from pathselector/src/main/res/mipmap-xhdpi/zip.png
rename to pathselector/src/main/res/mipmap-xhdpi/zip_mlh.png
diff --git a/pathselector/src/main/res/values-en/strings.xml b/pathselector/src/main/res/values-en/strings.xml
index 0ddba00..6fbc1e1 100644
--- a/pathselector/src/main/res/values-en/strings.xml
+++ b/pathselector/src/main/res/values-en/strings.xml
@@ -1,16 +1,18 @@
- No Data
- Permanently denied authorization, please manually grant read permission
- Permission failed to be obtained
- storage
- Test text
+ No Data
+ Permanently denied authorization, please manually grant read permission
+ Permission failed to be obtained
+ storage
+ Test text
Select a memory path
Confirm
Cancel
- The number of selections exceeds the limit
+ The number of selections exceeds the limit
Wrong selection type
dir:%s file:%s
Reminder
Access to the `%s` directory requires authorization.\nDo you want to authorize?
+ Full file read and write permissions are required to run the software
+ Cannot enter the %s path, has jumped to the %s path for you
\ No newline at end of file
diff --git a/pathselector/src/main/res/values/strings.xml b/pathselector/src/main/res/values/strings.xml
index 80b89cc..615d688 100644
--- a/pathselector/src/main/res/values/strings.xml
+++ b/pathselector/src/main/res/values/strings.xml
@@ -1,16 +1,18 @@
- 无数据
- 被永久拒绝授权,请手动授予读取权限
- 获取权限失败
- 内部存储
- 测试文本
+ 无数据
+ 被永久拒绝授权,请手动授予读取权限
+ 获取权限失败
+ 内部存储
+ 测试文本
请选择内部存储
确定
取消
- 选择数量超过限制
+ 选择数量超过限制
选择类型错误
文件夹:%s 文件:%s
提示
访问%s目录需要授予权限,\n是否进行授权?
+ 软件运行需要授予全文件读写权限
+ 不能进入%s路径,已经为你跳往%s路径