diff --git a/.gitignore b/.gitignore
index 46114b2453aaf291bfd9d4da9ec144d0eb65538b..37a4eb8b43d978ea05b2c6e3fb934f9b40dddd4d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,85 +1,15 @@
-# [Android] ========================
-# Built application files
-*.apk
-*.ap_
-
-# Files for the Dalvik VM
-*.dex
-
-# Java class files
-*.class
-
-# Generated files
-bin/
-gen/
-
-# Gradle files
-.gradle/
-build/
-/*/build/
-.gradletasknamecache
-
-# Local configuration file (sdk path, etc)
-local.properties
-
-# Proguard folder generated by Eclipse
-proguard/
-
-# Log Files
-*.log
-
-
-## Directory-based project format:
-.idea/
-
-## File-based project format:
-*.ipr
-*.iws
-
-## Plugin-specific files:
-
-# IntelliJ
-out/
-
-# mpeltonen/sbt-idea plugin
-.idea_modules/
-
-# JIRA plugin
-atlassian-ide-plugin.xml
-
-# Crashlytics plugin (for Android Studio and IntelliJ)
-com_crashlytics_export_strings.xml
-
-
-# [Maven] ========================
-target/
-pom.xml.tag
-pom.xml.releaseBackup
-pom.xml.versionsBackup
-pom.xml.next
-release.properties
-
-
-# [Gradle-Android] ========================
-# Ignore Gradle GUI config
-gradle-app.setting
-
-# Properties
-gradle.properties
-
-# Mobile Tools for Java (J2ME)
-.mtj.tmp/
-
-# Package Files #
-*.war
-*.ear
-
-# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
-hs_err_pid*
-
-# Misc
-/.idea/workspace.xml
+*.iml
+.gradle
+/local.properties
+/.idea/caches
/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
.DS_Store
+/build
/captures
-**/*.iml
\ No newline at end of file
+.externalNativeBuild
+/entry/.preview
+.cxx
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000000000000000000000000000000000000..78aec78f57dd51b9dee381c35fad7acdfe3e8d65
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 0.0.1-SNAPSHOT
+
+ohos 第一个版本,完整实现了原库的全部 api
diff --git a/README.OPENSOURCE b/README.OPENSOURCE
new file mode 100644
index 0000000000000000000000000000000000000000..1e0e7f7f01143b6ccc77f29348feac849014d874
--- /dev/null
+++ b/README.OPENSOURCE
@@ -0,0 +1,10 @@
+[
+ {
+ "Name": "FilePicker",
+ "License": "Apache",
+ "License File": "LICENSE",
+ "Version Number": "v8.0.19",
+ "Upstream URL": "https://github.com/TutorialsAndroid/FilePicker",
+ "Description": "从设备存储中选择文件/目录。"
+ }
+]
\ No newline at end of file
diff --git a/Readme.md b/Readme.md
index 30a8a3cefbf5f83433c1205a8baaae00970f11f1..d34e2768b62bcbc26ca3d9a5561e876d633beaaa 100644
--- a/Readme.md
+++ b/Readme.md
@@ -1,152 +1,113 @@
-
-
-# FilePicker  [](https://opensource.org/licenses/Apache-2.0) [](https://android-arsenal.com/details/1/7663)
-Android Library to select files/directories from Device Storage
-
-## And Don't Forget To Follow Me On Instagram
-
-
Follow me on instagram to stay up-to-date https://instagram.com/akshaysunilmasram
-
-## Contributors
-
-[M&R Games](https://github.com/mrgames13)
-
-[Hatzen](https://github.com/Hatzen)
-
-**Library available at JitPack.io**
-
-[](https://jitpack.io/#TutorialsAndroid/FilePicker)
-
-`Latest version of this library is migrated to androidx`
-
-### Screenshot
-
-
-
-### Features
+# FilePicker
+
+#### 项目介绍
+- 项目名称:FilePicker
+- 所属系列:openharmony的第三方组件适配移植
+- 功能:从设备存储中选择文件/目录。
+- 项目移植状态:主功能完成
+- 调用差异:无
+- 开发版本:sdk6,DevEco Studio2.1 Release
+- 基线版本:Release v8.0.19
+
+#### 效果演示
+
+
+#### 安装教程
+
+1.在项目根目录下的build.gradle文件中,
+ ```
+ allprojects {
+ repositories {
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
+ }
+ }
+ }
+```
+2.在entry模块的build.gradle文件中,
+ ```
+ dependencies {
+ implementation('com.gitee.chinasoft_ohos:FilePicker:0.0.1-SNAPSHOT')
+ ......
+ }
+```
-* Easy to Implement.
-* No permissions required.
-* Files, Directory Selection.
-* Single or Multiple File selection.
+#### 使用说明
-### Installation
+1、首先创建一个DialogProperties:
+ ```
+ DialogProperties properties = new DialogProperties();
+```
+2、使用DialogConfig类为每个对话框属性赋值。
+```
+ properties.selection_mode = DialogConfigs.SINGLE_MODE;
+ properties.selection_type = DialogConfigs.FILE_SELECT;
+ properties.root = new File(DialogConfigs.DEFAULT_DIR);
+ properties.error_dir = new File(DialogConfigs.DEFAULT_DIR);
+ properties.offset = new File(DialogConfigs.DEFAULT_DIR);
+ properties.extensions = null;
+ properties.show_hidden_files = false;
+```
+3、接下来,在点击显示Dialog时,创建实例FilePickerDialog。
+```
+ FilePickerDialog dialog = new FilePickerDialog(this, properties);
+ dialog.setTitle("Select a File");
+ dialog.setPositiveBtnName("Select");
+ dialog.setNegativeBtnName("Cancel");
+ dialog.onStart();
+ dialog.show();
+```
+4、接下来,添加DialogSelectionListener到FilePickerDialog如下:
+```
+dialog.setDialogSelectionListener((files) -> {
+ int size = listItem.size();
+ listItem.clear();
+ mFileListAdapter.notifyDataSetItemRangeRemoved(0, size);
+ for (String path : files) {
+ File file = new File(path);
+ ListItem item = new ListItem();
+ item.setName(file.getName());
+ item.setPath(file.getAbsolutePath());
+ listItem.add(item);
+ }
+ mFileListAdapter.notifyDataSetItemRangeInserted(0, listItem.size());
+ fileList.setHeight(listItem.size() * 150);
+ });
+```
-Add it in your root build.gradle at the end of repositories:
+#### 相关说明
+- defaultValue, error_dir, root_dir,offset_dir必须具有有效的目录/文件路径。
+- defaultValue 路径应以“:”结尾。
+- defaultValue 可以有几个路径,“几个路径之间应该有”。
+- extensions 不能有'.'。
+- extensions应该以':'结尾,两个扩展名之间也有':'。例如。/sdcard:/mnt:
- allprojects {
- repositories {
- ...
- maven { url 'https://jitpack.io' }
- }
- }
-Step 2. Add the dependency
+#### 测试信息
- dependencies {
- implementation 'com.github.TutorialsAndroid:FilePicker:v8.0.19'
- }
+CodeCheck代码测试无异常
-### Usage
+CloudTest代码测试无异常
-**If you are targeting Android 10 or higher. Set this to your manifest**
-```
-
-
-
- ......
-
-
-```
+病毒安全检测通过
-## FilePickerDialog
-1. Start by creating an instance of `DialogProperties`.
-
- ```java
- DialogProperties properties = new DialogProperties();
- ```
-
- Now 'DialogProperties' has certain parameters.
-
-2. Assign values to each Dialog Property using `DialogConfig` class.
-
- ```java
- properties.selection_mode = DialogConfigs.SINGLE_MODE;
- properties.selection_type = DialogConfigs.FILE_SELECT;
- properties.root = new File(DialogConfigs.DEFAULT_DIR);
- properties.error_dir = new File(DialogConfigs.DEFAULT_DIR);
- properties.offset = new File(DialogConfigs.DEFAULT_DIR);
- properties.extensions = null;
- properties.show_hidden_files = false;
- ```
-
-3. Next create an instance of `FilePickerDialog`, and pass `Context` and `DialogProperties` references as parameters. Optional: You can change the title of dialog. Default is current directory name. Set the positive button string. Default is Select. Set the negative button string. Defalut is Cancel.
-
- ```java
- FilePickerDialog dialog = new FilePickerDialog(MainActivity.this,properties);
- dialog.setTitle("Select a File");
- ```
-
-4. Next, Attach `DialogSelectionListener` to `FilePickerDialog` as below,
- ```java
- dialog.setDialogSelectionListener(new DialogSelectionListener() {
- @Override
- public void onSelectedFilePaths(String[] files) {
- //files is the array of the paths of files selected by the Application User.
- }
- });
- ```
- An array of paths is returned whenever user press the `select` button`.
-
-5. Use ```dialog.show()``` method to show dialog.
-
-### NOTE:
-Marshmallow and above requests for the permission on runtime. You should override `onRequestPermissionsResult` in Activity/AppCompatActivity class and show the dialog only if permissions have been granted.
-
-```java
- //Add this method to show Dialog when the required permission has been granted to the app.
- @Override
- public void onRequestPermissionsResult(int requestCode,@NonNull String permissions[],@NonNull int[] grantResults) {
- switch (requestCode) {
- case FilePickerDialog.EXTERNAL_READ_PERMISSION_GRANT: {
- if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- if(dialog!=null)
- { //Show dialog if the read permission has been granted.
- dialog.show();
- }
- }
- else {
- //Permission has not been granted. Notify the user.
- Toast.makeText(MainActivity.this,"Permission is Required for getting list of files",Toast.LENGTH_SHORT).show();
- }
- }
- }
- }
-```
+当前版本demo功能与原组件基本无差异
- That's It. You are good to proceed further.
+#### 版本迭代
+- 0.0.1-SNAPSHOT
-### Important:
-* `defaultValue`, `error_dir`, `root_dir`, `offset_dir` must have valid directory/file paths.
-* `defaultValue` paths should end with ':'.
-* `defaultValue` can have multiple paths, there should be a ':' between two paths.
-* `extensions` must not have '.'.
-* `extensions` should end with ':' , also have ':' between two extensions.
-eg. /sdcard:/mnt:
+#### 版权和许可信息
-### License
- Copyright (C) 2019 FilePicker
+Copyright (C) 2019 FilePicker
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 832f39494fb5e7b5da3bad2fd6417ed8feaf80ce..bf479ca657fb6b63c48c13c097af23041e8b2e1e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,29 +1,37 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply plugin: 'com.huawei.ohos.app'
+
+ohos {
+ compileSdkVersion 6
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+}
buildscript {
repositories {
- google()
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.5.3'
- classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
+ classpath 'com.huawei.ohos:hap:2.4.5.0'
+ classpath 'com.huawei.ohos:decctest:1.2.4.1'
}
}
allprojects {
repositories {
- google()
- jcenter()
maven {
- url 'https://jitpack.io'
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
}
+ jcenter()
}
}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/sample/.gitignore b/entry/.gitignore
similarity index 100%
rename from sample/.gitignore
rename to entry/.gitignore
diff --git a/entry/build.gradle b/entry/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..9e2e7bac58f127718a6d247e9b6c6b5a8b5c19c0
--- /dev/null
+++ b/entry/build.gradle
@@ -0,0 +1,37 @@
+apply plugin: 'com.huawei.ohos.hap'
+apply plugin: 'com.huawei.ohos.decctest'
+ohos {
+ compileSdkVersion 6
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+ buildTypes {
+ release {
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
+ }
+ }
+ signingConfigs {
+ debug {
+ storeFile file('D:/key/hoskey.p12')
+ storePassword '000000195D03C79E1B60E7F181253A65DFA7EE01BEB622BF1444686D52E534039B588E0D7E52EC8E63'
+ keyAlias 'hoskey'
+ keyPassword '000000190BCF3F182089EAD1D5B77FCFEDF7B2E99D1243455E4EF28FC73BF8F0773ABCB122B6B5CD9F'
+ signAlg 'SHA256withECDSA'
+ profile file('D:/key/chatvoiceplayerDebug.p7b')
+ certpath file('D:/key/hoskey.cer')
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+ testImplementation 'junit:junit:4.13'
+ ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
+ compile project(":library")
+}
+decc {
+ supportType = ['html', 'xml']
+}
diff --git a/entry/proguard-rules.pro b/entry/proguard-rules.pro
new file mode 100644
index 0000000000000000000000000000000000000000..f7666e47561d514b2a76d5a7dfbb43ede86da92a
--- /dev/null
+++ b/entry/proguard-rules.pro
@@ -0,0 +1 @@
+# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/entry/src/main/config.json b/entry/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..efba8b99748eb76971dcd002dc9a04764cf81b77
--- /dev/null
+++ b/entry/src/main/config.json
@@ -0,0 +1,53 @@
+{
+ "app": {
+ "bundleName": "me.jagar.chatvoiceplayerlibrary",
+ "vendor": "developer",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.developer.filepicker.file",
+ "name": ".MyApplication",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry"
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "name": "com.developer.filepicker.file.MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard",
+ "metaData": {
+ "customizeData": [
+ {
+ "extra": "",
+ "name": "hwc-theme",
+ "value": "androidhwext:style/Theme.Emui.Light.NoTitleBar"
+ }
+ ]
+ }
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/java/com/developer/filepicker/file/FileListAdapter.java b/entry/src/main/java/com/developer/filepicker/file/FileListAdapter.java
new file mode 100644
index 0000000000000000000000000000000000000000..9549fdb0458dda1d6f91d0425ff0317468169acd
--- /dev/null
+++ b/entry/src/main/java/com/developer/filepicker/file/FileListAdapter.java
@@ -0,0 +1,53 @@
+package com.developer.filepicker.file;
+
+import ohos.agp.components.BaseItemProvider;
+import ohos.agp.components.Component;
+import ohos.agp.components.ComponentContainer;
+import ohos.agp.components.Image;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.Text;
+import ohos.agp.components.element.ShapeElement;
+import ohos.app.Context;
+
+import java.util.ArrayList;
+
+public class FileListAdapter extends BaseItemProvider {
+
+ private final ArrayList listItems;
+ private final Context context;
+
+ public FileListAdapter(ArrayList listItems, Context context) {
+ this.listItems = listItems;
+ this.context = context;
+ }
+
+ @Override
+ public int getCount() {
+ return listItems.size();
+ }
+
+ @Override
+ public ListItem getItem(int position) {
+ return listItems.get(position);
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return position;
+ }
+
+ @Override
+ public Component getComponent(int position, Component convertComponent, ComponentContainer componentContainer) {
+ final Component cpt;
+ if (convertComponent == null) {
+ cpt = LayoutScatter.getInstance(context).parse(ResourceTable.Layout_file_list_item, null, false);
+ } else {
+ cpt = convertComponent;
+ }
+ Text name = (Text) cpt.findComponentById(ResourceTable.Id_name);
+ Text path = (Text) cpt.findComponentById(ResourceTable.Id_path);
+ name.setText(listItems.get(position).getName());
+ path.setText(listItems.get(position).getPath());
+ return cpt;
+ }
+}
\ No newline at end of file
diff --git a/sample/src/main/java/com/developer/filepicker/file/ListItem.java b/entry/src/main/java/com/developer/filepicker/file/ListItem.java
similarity index 86%
rename from sample/src/main/java/com/developer/filepicker/file/ListItem.java
rename to entry/src/main/java/com/developer/filepicker/file/ListItem.java
index 74f3131d4212c0ff0f5f9e5cdd49b2301b63b2ed..c9a49c0aebbef8d53f81f957e8cac3d1cadc8dc8 100644
--- a/sample/src/main/java/com/developer/filepicker/file/ListItem.java
+++ b/entry/src/main/java/com/developer/filepicker/file/ListItem.java
@@ -1,8 +1,9 @@
+
package com.developer.filepicker.file;
public class ListItem {
-
- private String name, path;
+ private String name;
+ private String path;
public String getName() {
return name;
diff --git a/entry/src/main/java/com/developer/filepicker/file/MainAbility.java b/entry/src/main/java/com/developer/filepicker/file/MainAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..d1c73b7cdc770b93097dcd125ea561700f3bff24
--- /dev/null
+++ b/entry/src/main/java/com/developer/filepicker/file/MainAbility.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.developer.filepicker.file;
+
+import com.developer.filepicker.file.slice.MainAbilitySlice;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+
+/** MainAbility
+ *
+ * @author ljx
+ * @since 2021-07-012
+ */
+public class MainAbility extends Ability {
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(MainAbilitySlice.class.getName());
+ }
+}
diff --git a/entry/src/main/java/com/developer/filepicker/file/MyApplication.java b/entry/src/main/java/com/developer/filepicker/file/MyApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..5484d50a8532bfd6ff4554ced60faa3f5a78b2d0
--- /dev/null
+++ b/entry/src/main/java/com/developer/filepicker/file/MyApplication.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.developer.filepicker.file;
+
+import ohos.aafwk.ability.AbilityPackage;
+
+/** MainAbility
+ *
+ * @author ljx
+ * @since 2021-07-012
+ */
+public class MyApplication extends AbilityPackage {
+ @Override
+ public void onInitialize() {
+ super.onInitialize();
+ }
+}
diff --git a/entry/src/main/java/com/developer/filepicker/file/slice/MainAbilitySlice.java b/entry/src/main/java/com/developer/filepicker/file/slice/MainAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..62cc3813d27818847d56dbb0e0d9d0b2ddc58dc3
--- /dev/null
+++ b/entry/src/main/java/com/developer/filepicker/file/slice/MainAbilitySlice.java
@@ -0,0 +1,176 @@
+package com.developer.filepicker.file.slice;
+
+import com.developer.filepicker.file.FileListAdapter;
+import com.developer.filepicker.file.ListItem;
+import com.developer.filepicker.file.ResourceTable;
+import com.developer.filepicker.model.DialogConfigs;
+import com.developer.filepicker.model.DialogProperties;
+import com.developer.filepicker.view.FilePickerDialog;
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Checkbox;
+import ohos.agp.components.ComponentContainer;
+import ohos.agp.components.ListContainer;
+import ohos.agp.components.RadioContainer;
+import ohos.agp.components.Text;
+import ohos.agp.components.TextField;
+import ohos.agp.utils.Color;
+import ohos.agp.window.dialog.ToastDialog;
+import ohos.agp.window.service.WindowManager;
+
+import java.io.File;
+import java.util.ArrayList;
+
+public class MainAbilitySlice extends AbilitySlice {
+
+ private FilePickerDialog dialog;
+ private ArrayList listItem;
+ private FileListAdapter mFileListAdapter;
+ private DialogProperties properties;
+ private ListContainer fileList;
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ WindowManager.getInstance().getTopWindow().get().setStatusBarColor(new Color(Color.getIntColor("#3F51B5")).getValue());
+ super.setUIContent(ResourceTable.Layout_ability_main);
+ initView();
+ apply();
+ initFilePickerDialog();
+ }
+
+ private void initView() {
+ listItem = new ArrayList<>();
+ fileList = (ListContainer) findComponentById(ResourceTable.Id_listView);
+ mFileListAdapter = new FileListAdapter(listItem, getContext());
+ fileList.setItemProvider(mFileListAdapter);
+ properties = new DialogProperties();
+ RadioContainer modeRadio = (RadioContainer) findComponentById(ResourceTable.Id_modeRadio);
+ modeRadio.mark(0);
+ modeRadio.setMarkChangedListener((radioContainer, index) -> {
+ switch (index) {
+ case 0:
+ properties.selection_mode = DialogConfigs.SINGLE_MODE;
+ break;
+ case 1:
+ properties.selection_mode = DialogConfigs.MULTI_MODE;
+ break;
+ }
+ });
+ RadioContainer typeRadio = (RadioContainer) findComponentById(ResourceTable.Id_typeRadio);
+ typeRadio.mark(0);
+ typeRadio.setMarkChangedListener((radioContainer, index) -> {
+ switch (index) {
+ case 0:
+ properties.selection_type = DialogConfigs.FILE_SELECT;
+ break;
+ case 1:
+ properties.selection_type = DialogConfigs.DIR_SELECT;
+ break;
+ case 2:
+ properties.selection_type = DialogConfigs.FILE_AND_DIR_SELECT;
+ break;
+ }
+ });
+ }
+
+ private void apply() {
+ TextField extension = (TextField) findComponentById(ResourceTable.Id_extensions);
+ TextField root = (TextField) findComponentById(ResourceTable.Id_root);
+ TextField offset = (TextField) findComponentById(ResourceTable.Id_offset);
+ Checkbox show_hidden_files = (Checkbox) findComponentById(ResourceTable.Id_show_hidden_files);
+ Text apply = (Text) findComponentById(ResourceTable.Id_apply);
+ apply.setClickedListener((view) -> {
+ String fextension = extension.getText();
+ if (fextension.length() > 0) {
+ int commas = countCommas(fextension);
+ String[] exts = new String[commas + 1];
+ StringBuffer buff = new StringBuffer();
+ int i = 0;
+ for (int j = 0; j < fextension.length(); j++) {
+ if (fextension.charAt(j) == ',') {
+ exts[i] = buff.toString();
+ buff = new StringBuffer();
+ i++;
+ } else {
+ buff.append(fextension.charAt(j));
+ }
+ }
+ exts[i] = buff.toString();
+ properties.extensions = exts;
+ } else {
+ properties.extensions = null;
+ }
+ String foffset = root.getText();
+ if (foffset.length() > 0 || !foffset.equals("")) {
+ properties.root = new File(foffset);
+ } else {
+ properties.root = new File(DialogConfigs.DEFAULT_DIR);
+ }
+ String fset = offset.getText();
+ if (fset.length() > 0 || !fset.equals("")) {
+ properties.offset = new File(fset);
+ } else {
+ properties.offset = new File(DialogConfigs.DEFAULT_DIR);
+ }
+ properties.show_hidden_files = show_hidden_files.isChecked();
+ properties.error_dir = new File("/mnt");
+ if (dialog != null) {
+ dialog.setProperties(properties);
+ }
+ });
+ }
+
+ private void initFilePickerDialog() {
+ Text showDialog = (Text) findComponentById(ResourceTable.Id_show_dialog);
+ showDialog.setClickedListener(v -> {
+ dialog = new FilePickerDialog(this, properties);
+ dialog.setTitle("Select a File");
+ dialog.setPositiveBtnName("SELECT");
+ dialog.setNegativeBtnName("CANCEL");
+ dialog.onStart();
+ dialog.show();
+
+ dialog.setDialogSelectionListener((files) -> {
+ int size = listItem.size();
+ listItem.clear();
+ mFileListAdapter.notifyDataSetItemRangeRemoved(0, size);
+ for (String path : files) {
+ File file = new File(path);
+ ListItem item = new ListItem();
+ item.setName(file.getName());
+ item.setPath(file.getAbsolutePath());
+ listItem.add(item);
+ }
+ mFileListAdapter.notifyDataSetItemRangeInserted(0, listItem.size());
+ fileList.setHeight(listItem.size() * 150);
+ });
+ });
+ }
+
+ private int countCommas(String fextension) {
+ int count = 0;
+ for (char ch : fextension.toCharArray()) {
+ if (ch == ',') count++;
+ }
+ return count;
+ }
+
+ @Override
+ protected void onBackPressed() {
+ if (!dialog.isShowing()){
+ super.onBackPressed();
+ }
+ dialog.destroy();
+ }
+
+ @Override
+ public void onActive() {
+ super.onActive();
+ }
+
+ @Override
+ public void onForeground(Intent intent) {
+ super.onForeground(intent);
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..92519ccc924117bade770aa540f8a0c5391935e9
--- /dev/null
+++ b/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "FilePicker"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "mainability_HelloWorld",
+ "value": "Hello World"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_main.xml b/entry/src/main/resources/base/graphic/background_ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c0c0a3df480fa387a452b9c40ca191cc918a3fc0
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_main.xml
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ability_main.xml b/entry/src/main/resources/base/layout/ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..e4cfa07d8ee58dced877b2be52a7be5d1e006180
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_main.xml
@@ -0,0 +1,198 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/file_list_item.xml b/entry/src/main/resources/base/layout/file_list_item.xml
new file mode 100644
index 0000000000000000000000000000000000000000..cd4c5f363feaa02c4c077d4138f836528f424d78
--- /dev/null
+++ b/entry/src/main/resources/base/layout/file_list_item.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/media/icon.png b/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/entry/src/main/resources/base/media/icon.png differ
diff --git a/entry/src/ohosTest/config.json b/entry/src/ohosTest/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..6ba23f9b0c9d4c4c6b81485debe467701e5caa41
--- /dev/null
+++ b/entry/src/ohosTest/config.json
@@ -0,0 +1,41 @@
+{
+ "app": {
+ "bundleName": "com.developer.filepicker.file",
+ "vendor": "developer",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ },
+ "apiVersion": {
+ "compatible": 5,
+ "target": 5,
+ "releaseType": "Release"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.developer.filepicker.file",
+ "name": "testModule",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry_test",
+ "moduleType": "feature",
+ "installationFree": true
+ },
+ "abilities": [
+ {
+ "name": "decc.testkit.runner.EntryAbility",
+ "description": "Test Entry Ability",
+ "icon": "$media:icon",
+ "label": "$string:app_name",
+ "launchType": "standard",
+ "orientation": "landscape",
+ "visible": true,
+ "type": "page"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/java/com/developer/filepicker/file/ExampleOhosTest.java b/entry/src/ohosTest/java/com/developer/filepicker/file/ExampleOhosTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..79a69393771bda10bb20439a35a2d5ee983037bf
--- /dev/null
+++ b/entry/src/ohosTest/java/com/developer/filepicker/file/ExampleOhosTest.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.developer.filepicker.file;
+
+import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/** ExampleOhosTest
+ *
+ * @author ljx
+ * @since 2021-07-012
+ */
+public class ExampleOhosTest {
+ @Test
+ public void testBundleName() {
+ final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
+ assertEquals("com.developer.filepicker.file", actualBundleName);
+ }
+}
\ No newline at end of file
diff --git a/entry/src/test/java/com/developer/filepicker/file/ExampleTest.java b/entry/src/test/java/com/developer/filepicker/file/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..731c542fbe609748ab3c105b2a57645cf2ead9ae
--- /dev/null
+++ b/entry/src/test/java/com/developer/filepicker/file/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.developer.filepicker.file;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000000000000000000000000000000000000..0daf1830fbdef07e50a44d74210c8c82f1b66278
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,10 @@
+# Project-wide Gradle settings.
+# IDE (e.g. DevEco Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+# If the Chinese output is garbled, please configure the following parameter.
+# org.gradle.jvmargs=-Dfile.encoding=GBK
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 13372aef5e24af05341d49695ee84e5f9b594659..0000000000000000000000000000000000000000
Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index d62c7c4985d08832d365695eb21003a483bd9088..0000000000000000000000000000000000000000
--- a/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Sun Jan 19 16:51:26 IST 2020
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
diff --git a/gradlew b/gradlew
index 9d82f78915133e1c35a6ea51252590fb38efac2f..536f0272dd995f3afdb5e34e0f42bdf3d1986c22 100644
--- a/gradlew
+++ b/gradlew
@@ -1,4 +1,20 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
##############################################################################
##
@@ -6,155 +22,162 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ]; do
+ ls=$(ls -ld "$PRG")
+ link=$(expr "$ls" : '.*-> \(.*\)$')
+ if expr "$link" : '/.*' >/dev/null; then
+ PRG="$link"
+ else
+ PRG=$(dirname "$PRG")"/$link"
+ fi
+done
+SAVED="$(pwd)"
+cd "$(dirname \"$PRG\")/" >/dev/null
+APP_HOME="$(pwd -P)"
+cd "$SAVED" >/dev/null
APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
+APP_BASE_NAME=$(basename "$0")
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
- echo "$*"
+warn() {
+ echo "$*"
}
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
+die() {
+ echo
+ echo "$*"
+ echo
+ exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
+nonstop=false
+case "$(uname)" in
+CYGWIN*)
+ cygwin=true
+ ;;
+Darwin*)
+ darwin=true
+ ;;
+MINGW*)
+ msys=true
+ ;;
+NONSTOP*)
+ nonstop=true
+ ;;
esac
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+if [ -n "$JAVA_HOME" ]; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ]; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ]; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
- fi
+ fi
else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ]; then
+ MAX_FD_LIMIT=$(ulimit -H -n)
+ if [ $? -eq 0 ]; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
+ MAX_FD="$MAX_FD_LIMIT"
fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ]; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ]; then
+ APP_HOME=$(cygpath --path --mixed "$APP_HOME")
+ CLASSPATH=$(cygpath --path --mixed "$CLASSPATH")
+ JAVACMD=$(cygpath --unix "$JAVACMD")
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=$(find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null)
+ SEP=""
+ for dir in $ROOTDIRSRAW; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ]; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@"; do
+ CHECK=$(echo "$arg" | egrep -c "$OURCYGPATTERN" -)
+ CHECK2=$(echo "$arg" | egrep -c "^-") ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ]; then ### Added a condition
+ eval $(echo args$i)=$(cygpath --path --ignore --mixed "$arg")
+ else
+ eval $(echo args$i)="\"$arg\""
fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
+ i=$(expr $i + 1)
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save() {
+ for i; do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/"; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 8a0b282aa6885fb573c106b3551f7275c5f17e8e..62bd9b9ccefea2b65ae41e5d9a545e2021b90a1d 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -8,14 +24,17 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,10 +65,9 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -60,11 +78,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
diff --git a/img/git.gif b/img/git.gif
new file mode 100644
index 0000000000000000000000000000000000000000..8e812863b6c43e48eb9556eef8f9f4ed0d605f54
Binary files /dev/null and b/img/git.gif differ
diff --git a/library/build.gradle b/library/build.gradle
index 8e1f4ddcd8a134503eb6ada6f4782d7dd6429d1e..7e1e475c1296e7c6d200a45810598ddff583ee7f 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -1,24 +1,21 @@
-apply plugin: 'com.android.library'
-
-apply plugin: 'com.github.dcendents.android-maven'
-group='com.github.TutorialsAndroid'
-
-android {
- compileSdkVersion 29
-
+apply plugin: 'com.huawei.ohos.library'
+ohos {
+ compileSdkVersion 6
defaultConfig {
- minSdkVersion 19
- targetSdkVersion 29
- versionCode 6
- versionName "6.0.19"
+ compatibleSdkVersion 5
}
buildTypes {
release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
}
}
- lintOptions {
- abortOnError false
- }
+
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ testImplementation 'junit:junit:4.13'
}
diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro
index de3efee3df56bd343bfb5b86dcbea150dc0ff5f9..f7666e47561d514b2a76d5a7dfbb43ede86da92a 100644
--- a/library/proguard-rules.pro
+++ b/library/proguard-rules.pro
@@ -1,17 +1 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in D:\Android\SDK/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
+# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
deleted file mode 100644
index b2bfa4813ca43167d3df062a3a69d78dd0bce8e7..0000000000000000000000000000000000000000
--- a/library/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/config.json b/library/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..74461a783a4b283bec4277f2ebcffc59698e7fdd
--- /dev/null
+++ b/library/src/main/config.json
@@ -0,0 +1,65 @@
+{
+ "app": {
+ "bundleName": "com.developer.filepicker.file",
+ "vendor": "developer",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ }
+ },
+ "deviceConfig": {
+ },
+ "module": {
+ "package": "com.developer.filepicker",
+ "deviceType": [
+ "phone"
+ ],
+ "reqPermissions": [
+ {
+ "name": "ohos.permission.WRITE_MEDIA",
+ "reason": "reason",
+ "usedScene": {
+ "ability": [
+ "me.jagar.chatvoiceplayerlibrary"
+ ],
+ "when": "always"
+ }
+ },
+ {
+ "name": "ohos.permission.READ_MEDIA",
+ "reason": "reason",
+ "usedScene": {
+ "ability": [
+ "me.jagar.chatvoiceplayerlibrary"
+ ],
+ "when": "always"
+ }
+ },
+ {
+ "name": "ohos.permission.MICROPHONE",
+ "reason": "reason",
+ "usedScene": {
+ "ability": [
+ "me.jagar.chatvoiceplayerlibrary"
+ ],
+ "when": "always"
+ }
+ },
+ {
+ "name": "ohos.permission.INTERNET",
+ "reason": "reason",
+ "usedScene": {
+ "ability": [
+ "me.jagar.chatvoiceplayerlibrary"
+ ],
+ "when": "always"
+ }
+ }
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "library",
+ "moduleType": "har"
+ }
+ }
+}
\ No newline at end of file
diff --git a/library/src/main/java/com/developer/filepicker/controller/DialogSelectionListener.java b/library/src/main/java/com/developer/filepicker/controller/DialogSelectionListener.java
index 98186b4b2f7ea7c0a6dae9be6bdca3c34e4075b9..13d14ca55a99d42534b986ac5ab49c09ea39b860 100644
--- a/library/src/main/java/com/developer/filepicker/controller/DialogSelectionListener.java
+++ b/library/src/main/java/com/developer/filepicker/controller/DialogSelectionListener.java
@@ -1,8 +1,16 @@
package com.developer.filepicker.controller;
/**
+ * DialogSelectionListener
+ *
* @author akshay sunil masram
+ * @since xxxx年x月x日
*/
public interface DialogSelectionListener {
+ /**
+ * 选择的文件
+ *
+ * @param files 文件
+ */
void onSelectedFilePaths(String[] files);
}
\ No newline at end of file
diff --git a/library/src/main/java/com/developer/filepicker/controller/NotifyItemChecked.java b/library/src/main/java/com/developer/filepicker/controller/NotifyItemChecked.java
index b713e2cddebfcad02ea308588ad1b6b5c1abc874..a24f07ea36b1610bfc5da1c5213b737414392580 100644
--- a/library/src/main/java/com/developer/filepicker/controller/NotifyItemChecked.java
+++ b/library/src/main/java/com/developer/filepicker/controller/NotifyItemChecked.java
@@ -1,8 +1,14 @@
package com.developer.filepicker.controller;
/**
+ * NotifyItemChecked
+ *
* @author akshay sunil masram
+ * @since xxxx年x月x日
*/
public interface NotifyItemChecked {
+ /**
+ * notifyCheckBoxIsClicked
+ */
void notifyCheckBoxIsClicked();
}
\ No newline at end of file
diff --git a/library/src/main/java/com/developer/filepicker/controller/adapters/FileListAdapter.java b/library/src/main/java/com/developer/filepicker/controller/adapters/FileListAdapter.java
index d53b50713aee59e14cf632c7ea8f55a7e71d332b..250a525eb967209e085168446407b1641d6c1858 100644
--- a/library/src/main/java/com/developer/filepicker/controller/adapters/FileListAdapter.java
+++ b/library/src/main/java/com/developer/filepicker/controller/adapters/FileListAdapter.java
@@ -1,17 +1,6 @@
package com.developer.filepicker.controller.adapters;
-import android.content.Context;
-import android.os.Build;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
-import android.widget.BaseAdapter;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-import com.developer.filepicker.R;
+import com.developer.filepicker.ResourceTable;
import com.developer.filepicker.controller.NotifyItemChecked;
import com.developer.filepicker.model.DialogConfigs;
import com.developer.filepicker.model.DialogProperties;
@@ -19,6 +8,13 @@ import com.developer.filepicker.model.FileListItem;
import com.developer.filepicker.model.MarkedItemList;
import com.developer.filepicker.widget.MaterialCheckbox;
import com.developer.filepicker.widget.OnCheckedChangeListener;
+import ohos.agp.components.BaseItemProvider;
+import ohos.agp.components.Component;
+import ohos.agp.components.ComponentContainer;
+import ohos.agp.components.Image;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.Text;
+import ohos.app.Context;
import java.text.DateFormat;
import java.util.ArrayList;
@@ -27,7 +23,7 @@ import java.util.Date;
/**
* @author akshay sunil masram
*/
-public class FileListAdapter extends BaseAdapter {
+public class FileListAdapter extends BaseItemProvider {
private ArrayList listItem;
private Context context;
@@ -41,94 +37,77 @@ public class FileListAdapter extends BaseAdapter {
this.properties = properties;
}
+ public void setData(ArrayList listData) {
+ this.listItem = listData;
+ notifyDataChanged();
+ }
+
@Override
public int getCount() {
return listItem.size();
}
@Override
- public FileListItem getItem(int i) {
- return listItem.get(i);
+ public FileListItem getItem(int position) {
+ return listItem.get(position);
}
@Override
- public long getItemId(int i) {
- return i;
+ public long getItemId(int position) {
+ return position;
}
@Override
- public View getView(final int i, View view, ViewGroup viewGroup) {
- final ViewHolder holder;
- if (view == null) {
- view = LayoutInflater.from(context).inflate(R.layout.dialog_file_list_item,
- viewGroup, false);
- holder = new ViewHolder(view);
- view.setTag(holder);
+ public Component getComponent(int position, Component convertComponent, ComponentContainer componentContainer) {
+ final Component cpt;
+ if (convertComponent == null) {
+ cpt = LayoutScatter.getInstance(context).parse(ResourceTable.Layout_dialog_file_list_item, null, false);
} else {
- holder = (ViewHolder) view.getTag();
- }
- final FileListItem item = listItem.get(i);
- if (MarkedItemList.hasItem(item.getLocation())) {
- Animation animation = AnimationUtils.loadAnimation(context,
- R.anim.marked_item_animation);
- view.setAnimation(animation);
- } else {
- Animation animation = AnimationUtils.loadAnimation(context,
- R.anim.unmarked_item_animation);
- view.setAnimation(animation);
+ cpt = convertComponent;
}
+ Image type_icon = (Image) cpt.findComponentById(ResourceTable.Id_image_type);
+ Text name = (Text) cpt.findComponentById(ResourceTable.Id_fname);
+ Text type = (Text) cpt.findComponentById(ResourceTable.Id_ftype);
+ MaterialCheckbox checkbox = (MaterialCheckbox) cpt.findComponentById(ResourceTable.Id_file_mark);
+ final FileListItem item = listItem.get(position);
if (item.isDirectory()) {
- holder.type_icon.setImageResource(R.mipmap.ic_type_folder);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- holder.type_icon.setColorFilter(context.getResources()
- .getColor(R.color.colorPrimary, context.getTheme()));
- } else {
- holder.type_icon.setColorFilter(context.getResources()
- .getColor(R.color.colorPrimary));
- }
+ type_icon.setImageAndDecodeBounds(ResourceTable.Media_ic_type_folder);
if (properties.selection_type == DialogConfigs.FILE_SELECT) {
- holder.checkbox.setVisibility(View.INVISIBLE);
+ checkbox.setVisibility(Component.INVISIBLE);
} else {
- holder.checkbox.setVisibility(View.VISIBLE);
+ checkbox.setVisibility(Component.VISIBLE);
}
} else {
- holder.type_icon.setImageResource(R.mipmap.ic_type_file);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- holder.type_icon.setColorFilter(context.getResources()
- .getColor(R.color.colorAccent, context.getTheme()));
- } else {
- holder.type_icon.setColorFilter(context.getResources()
- .getColor(R.color.colorAccent));
- }
+ type_icon.setImageAndDecodeBounds(ResourceTable.Media_ic_type_file);
if (properties.selection_type == DialogConfigs.DIR_SELECT) {
- holder.checkbox.setVisibility(View.INVISIBLE);
+ checkbox.setVisibility(Component.INVISIBLE);
} else {
- holder.checkbox.setVisibility(View.VISIBLE);
+ checkbox.setVisibility(Component.VISIBLE);
}
}
- holder.type_icon.setContentDescription(item.getFilename());
- holder.name.setText(item.getFilename());
- DateFormat dateFormatter = android.text.format.DateFormat.getMediumDateFormat(context);
- DateFormat timeFormatter = android.text.format.DateFormat.getTimeFormat(context);
+ type_icon.setComponentDescription(item.getFilename());
+ name.setText(item.getFilename());
+ DateFormat dateFormatter = DateFormat.getDateInstance();
+ DateFormat timeFormatter = DateFormat.getTimeInstance();
Date date = new Date(item.getTime());
- if (i == 0 && item.getFilename().startsWith(context.getString(R.string.label_parent_dir))) {
- holder.type.setText(R.string.label_parent_directory);
+ if (position == 0 && item.getFilename().startsWith("..")) {
+ type.setText("Parent Directory");
} else {
- holder.type.setText(String.format(context.getString(R.string.last_edit),
+ type.setText(String.format("Last edited: %1$s, %2$s",
dateFormatter.format(date), timeFormatter.format(date)));
}
- if (holder.checkbox.getVisibility() == View.VISIBLE) {
- if (i == 0 && item.getFilename().startsWith(context.getString(R.string.label_parent_dir))) {
- holder.checkbox.setVisibility(View.INVISIBLE);
+ if (checkbox.getVisibility() == Component.VISIBLE) {
+ if (position == 0 && item.getFilename().startsWith("..")) {
+ checkbox.setVisibility(Component.INVISIBLE);
}
if (MarkedItemList.hasItem(item.getLocation())) {
- holder.checkbox.setChecked(true);
+ checkbox.setChecked(true);
} else {
- holder.checkbox.setChecked(false);
+ checkbox.setChecked(false);
}
}
- holder.checkbox.setOnCheckedChangedListener(new OnCheckedChangeListener() {
+ checkbox.setOnCheckedChangedListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(MaterialCheckbox checkbox, boolean isChecked) {
item.setMarked(isChecked);
@@ -144,20 +123,7 @@ public class FileListAdapter extends BaseAdapter {
notifyItemChecked.notifyCheckBoxIsClicked();
}
});
- return view;
- }
-
- private class ViewHolder {
- ImageView type_icon;
- TextView name, type;
- MaterialCheckbox checkbox;
-
- ViewHolder(View itemView) {
- name = itemView.findViewById(R.id.fname);
- type = itemView.findViewById(R.id.ftype);
- type_icon = itemView.findViewById(R.id.image_type);
- checkbox = itemView.findViewById(R.id.file_mark);
- }
+ return cpt;
}
public void setNotifyItemCheckedListener(NotifyItemChecked notifyItemChecked) {
diff --git a/library/src/main/java/com/developer/filepicker/model/DialogConfigs.java b/library/src/main/java/com/developer/filepicker/model/DialogConfigs.java
index 2480c3900381dc3364595427e34cd965d4b5f980..4c68f4fdc8b882e92b80460f88a9b85924ef8553 100644
--- a/library/src/main/java/com/developer/filepicker/model/DialogConfigs.java
+++ b/library/src/main/java/com/developer/filepicker/model/DialogConfigs.java
@@ -5,18 +5,44 @@ package com.developer.filepicker.model;
*/
public abstract class DialogConfigs {
+ /**
+ * single_mode
+ */
public static final int SINGLE_MODE = 0;
+
+ /**
+ * multi_mode
+ */
public static final int MULTI_MODE = 1;
+
+ /**
+ * file_select
+ */
public static final int FILE_SELECT = 0;
+
+ /**
+ * dir_select
+ */
public static final int DIR_SELECT = 1;
+
+ /**
+ * file_and_dir_select
+ */
public static final int FILE_AND_DIR_SELECT = 2;
- /* PARENT_DIRECTORY*/
+ /**
+ * parent_directory
+ */
private static final String DIRECTORY_SEPARATOR = "/";
+
+ /**
+ * storage_dir
+ */
private static final String STORAGE_DIR = "mnt";
- /* DEFAULT_DIR is the default mount point of the SDCARD. It is the default
- * mount point.
+ /**
+ * DEFAULT_DIR is the default mount point of the SDCARD.
+ * It is the default mount point.
*/
public static final String DEFAULT_DIR = DIRECTORY_SEPARATOR + STORAGE_DIR;
}
\ No newline at end of file
diff --git a/library/src/main/java/com/developer/filepicker/model/FileListItem.java b/library/src/main/java/com/developer/filepicker/model/FileListItem.java
index 7a095b5bcb0dc665b8a4d91ae42ddcc531379a2f..0d3f7ea43d2475a385b8f685322c4c5912ae948e 100644
--- a/library/src/main/java/com/developer/filepicker/model/FileListItem.java
+++ b/library/src/main/java/com/developer/filepicker/model/FileListItem.java
@@ -7,8 +7,10 @@ import java.util.Locale;
*/
public class FileListItem implements Comparable {
- private String filename,location;
- private boolean directory,marked;
+ private String filename;
+ private String location;
+ private boolean directory;
+ private boolean marked;
private long time;
public String getFilename() {
@@ -53,16 +55,13 @@ public class FileListItem implements Comparable {
@Override
public int compareTo(FileListItem fileListItem) {
- if(fileListItem.isDirectory()&&isDirectory()) {
+ if (fileListItem.isDirectory() && isDirectory()) {
return filename.toLowerCase().compareTo(fileListItem.getFilename().toLowerCase(Locale.getDefault()));
- }
- else if(!fileListItem.isDirectory()&&!isDirectory()) {
+ } else if (!fileListItem.isDirectory() && !isDirectory()) {
return filename.toLowerCase().compareTo(fileListItem.getFilename().toLowerCase(Locale.getDefault()));
- }
- else if(fileListItem.isDirectory()&&!isDirectory()) {
+ } else if (fileListItem.isDirectory() && !isDirectory()) {
return 1;
- }
- else {
+ } else {
return -1;
}
}
diff --git a/library/src/main/java/com/developer/filepicker/utils/Utility.java b/library/src/main/java/com/developer/filepicker/utils/Utility.java
index 3cfedf2af3fe20f2f56fac6201315da2d2cf6c3b..bf0129dc3507d2d4d01d9862c854523501b30fd4 100644
--- a/library/src/main/java/com/developer/filepicker/utils/Utility.java
+++ b/library/src/main/java/com/developer/filepicker/utils/Utility.java
@@ -1,9 +1,8 @@
package com.developer.filepicker.utils;
-import android.content.Context;
-import android.content.pm.PackageManager;
-
import com.developer.filepicker.model.FileListItem;
+import ohos.app.Context;
+import ohos.bundle.IBundleManager;
import java.io.File;
import java.util.ArrayList;
@@ -16,13 +15,12 @@ import java.util.Objects;
public class Utility {
public static boolean checkStorageAccessPermissions(Context context) {
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
- String permission = "android.permission.READ_EXTERNAL_STORAGE";
- int res = context.checkCallingOrSelfPermission(permission);
- return (res == PackageManager.PERMISSION_GRANTED);
- }
- else {
+ if (context.verifySelfPermission("ohos.permission.WRITE_MEDIA") == IBundleManager.PERMISSION_GRANTED
+ && context.verifySelfPermission("ohos.permission.READ_MEDIA") == IBundleManager.PERMISSION_GRANTED) {
return true;
+ } else {
+ // 权限已被授予
+ return false;
}
}
@@ -32,7 +30,7 @@ public class Utility {
try {
for (File name : Objects.requireNonNull(inter.listFiles(filter))) {
if (name.canRead()) {
- if(name.getName().startsWith(".") && !show_hidden_files) continue;
+ if (name.getName().startsWith(".") && !show_hidden_files) continue;
FileListItem item = new FileListItem();
item.setFilename(name.getName());
item.setDirectory(name.isDirectory());
@@ -42,10 +40,9 @@ public class Utility {
}
}
Collections.sort(internalList);
- }
- catch (NullPointerException e) {
+ } catch (NullPointerException e) {
e.printStackTrace();
- internalList=new ArrayList<>();
+ internalList = new ArrayList<>();
}
return internalList;
}
diff --git a/library/src/main/java/com/developer/filepicker/view/FilePickerDialog.java b/library/src/main/java/com/developer/filepicker/view/FilePickerDialog.java
index 38064eddead9008925c2cb15503e3e0c7ec78653..62ca1db0474626a9c8ad5c8497a241afb8857a87 100644
--- a/library/src/main/java/com/developer/filepicker/view/FilePickerDialog.java
+++ b/library/src/main/java/com/developer/filepicker/view/FilePickerDialog.java
@@ -1,21 +1,6 @@
package com.developer.filepicker.view;
-import android.Manifest;
-import android.app.Activity;
-import android.app.Dialog;
-import android.content.Context;
-import android.graphics.Color;
-import android.os.Build;
-import android.os.Bundle;
-import android.view.View;
-import android.view.Window;
-import android.widget.AdapterView;
-import android.widget.Button;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.developer.filepicker.R;
+import com.developer.filepicker.ResourceTable;
import com.developer.filepicker.controller.DialogSelectionListener;
import com.developer.filepicker.controller.NotifyItemChecked;
import com.developer.filepicker.controller.adapters.FileListAdapter;
@@ -26,8 +11,25 @@ import com.developer.filepicker.model.MarkedItemList;
import com.developer.filepicker.utils.ExtensionFilter;
import com.developer.filepicker.utils.Utility;
import com.developer.filepicker.widget.MaterialCheckbox;
+import ohos.agp.components.Button;
+import ohos.agp.components.Component;
+import ohos.agp.components.DirectionalLayout;
+import ohos.agp.components.LayoutScatter;
+import ohos.agp.components.ListContainer;
+import ohos.agp.components.Text;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.LayoutAlignment;
+import ohos.agp.window.dialog.CommonDialog;
+import ohos.agp.window.dialog.ToastDialog;
+import ohos.agp.window.service.DisplayAttributes;
+import ohos.agp.window.service.DisplayManager;
+import ohos.app.Context;
+import ohos.bundle.IBundleManager;
+import ohos.global.resource.NotExistException;
+import ohos.global.resource.WrongTypeException;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -36,11 +38,15 @@ import java.util.Objects;
* @author akshay sunil masram
*/
@SuppressWarnings("unused")
-public class FilePickerDialog extends Dialog implements AdapterView.OnItemClickListener {
+public class FilePickerDialog extends CommonDialog implements ListContainer.ItemClickedListener {
+ private static final int WIDTH = 280;
+ private static final int HEIGHT = 600;
+ private static final int RADIUS = 5;
+ public static final int EXTERNAL_READ_PERMISSION_GRANT = 112;
private final Context context;
- private ListView listView;
- private TextView dname, dir_path, title;
+ private ListContainer listView;
+ private Text dname, dir_path, title;
private DialogProperties properties;
private DialogSelectionListener callbacks;
private ArrayList internalList;
@@ -51,22 +57,13 @@ public class FilePickerDialog extends Dialog implements AdapterView.OnItemClickL
private String positiveBtnNameStr = null;
private String negativeBtnNameStr = null;
- public static final int EXTERNAL_READ_PERMISSION_GRANT = 112;
-
public FilePickerDialog(Context context) {
super(context);
this.context = context;
properties = new DialogProperties();
filter = new ExtensionFilter(properties);
internalList = new ArrayList<>();
- }
-
- public FilePickerDialog(Context context, DialogProperties properties, int themeResId) {
- super(context, themeResId);
- this.context = context;
- this.properties = properties;
- filter = new ExtensionFilter(properties);
- internalList = new ArrayList<>();
+ initView();
}
public FilePickerDialog(Context context, DialogProperties properties) {
@@ -75,49 +72,49 @@ public class FilePickerDialog extends Dialog implements AdapterView.OnItemClickL
this.properties = properties;
filter = new ExtensionFilter(properties);
internalList = new ArrayList<>();
+ initView();
}
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- setContentView(R.layout.dialog_main);
- listView = findViewById(R.id.fileList);
- select = findViewById(R.id.select);
+ private void initView() {
+ Component component = LayoutScatter.getInstance(context).parse(ResourceTable.Layout_dialog_main,
+ null, false);
+ setContentCustomComponent(component);
+ setAutoClosable(false);
+ setSize(vp2px(context, WIDTH), vp2px(context, HEIGHT));
+ setAlignment(LayoutAlignment.CENTER);
+ setCornerRadius(vp2px(context, RADIUS));
+ listView = (ListContainer) component.findComponentById(ResourceTable.Id_fileList);
+ select = (Button) component.findComponentById(ResourceTable.Id_select);
int size = MarkedItemList.getFileCount();
if (size == 0) {
select.setEnabled(false);
- int color;
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
- color = context.getResources().getColor(R.color.colorAccent, context.getTheme());
- } else {
- color = context.getResources().getColor(R.color.colorAccent);
+ try {
+ select.setTextColor(new Color(context.getResourceManager().getElement(ResourceTable.Color_bt_pink).getColor()));
+ } catch (Exception e) {
+ e.printStackTrace();
}
- select.setTextColor(Color.argb(128, Color.red(color), Color.green(color),
- Color.blue(color)));
}
- dname = findViewById(R.id.dname);
- title = findViewById(R.id.title);
- dir_path = findViewById(R.id.dir_path);
- Button cancel = findViewById(R.id.cancel);
+ dname = (Text) component.findComponentById(ResourceTable.Id_dname);
+ title = (Text) component.findComponentById(ResourceTable.Id_title);
+ dir_path = (Text) component.findComponentById(ResourceTable.Id_dir_path);
+ Button cancel = (Button) component.findComponentById(ResourceTable.Id_cancel);
if (negativeBtnNameStr != null) {
cancel.setText(negativeBtnNameStr);
}
- select.setOnClickListener(new View.OnClickListener() {
+ select.setClickedListener(new Component.ClickedListener() {
@Override
- public void onClick(View view) {
+ public void onClick(Component component) {
String[] paths = MarkedItemList.getSelectedPaths();
if (callbacks != null) {
callbacks.onSelectedFilePaths(paths);
}
- dismiss();
+ destroy();
}
});
- cancel.setOnClickListener(new View.OnClickListener() {
+ cancel.setClickedListener(new Component.ClickedListener() {
@Override
- public void onClick(View view) {
- cancel();
+ public void onClick(Component component) {
+ hide();
}
});
mFileListAdapter = new FileListAdapter(internalList, context, properties);
@@ -125,44 +122,41 @@ public class FilePickerDialog extends Dialog implements AdapterView.OnItemClickL
@Override
public void notifyCheckBoxIsClicked() {
positiveBtnNameStr = positiveBtnNameStr == null ?
- context.getResources().getString(R.string.choose_button_label) : positiveBtnNameStr;
+ "Select" : positiveBtnNameStr;
int size = MarkedItemList.getFileCount();
if (size == 0) {
select.setEnabled(false);
- int color;
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
- color = context.getResources().getColor(R.color.colorAccent,
- context.getTheme());
- } else {
- color = context.getResources().getColor(R.color.colorAccent);
+ try {
+ select.setTextColor(new Color(context.getResourceManager().getElement(ResourceTable.Color_bt_pink).getColor()));
+ } catch (Exception e) {
+ e.printStackTrace();
}
- select.setTextColor(Color.argb(128, Color.red(color), Color.green(color),
- Color.blue(color)));
select.setText(positiveBtnNameStr);
} else {
select.setEnabled(true);
- int color;
- if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
- color = context.getResources().getColor(R.color.colorAccent,
- context.getTheme());
- } else {
- color = context.getResources().getColor(R.color.colorAccent);
+ try {
+ select.setTextColor(new Color(context.getResourceManager().getElement(ResourceTable.Color_bt_red).getColor()));
+ } catch (Exception e) {
+ e.printStackTrace();
}
- select.setTextColor(color);
String button_label = positiveBtnNameStr + " (" + size + ") ";
select.setText(button_label);
}
if (properties.selection_mode == DialogConfigs.SINGLE_MODE) {
- /* If a single file has to be selected, clear the previously checked
- * checkbox from the list.
- */
- mFileListAdapter.notifyDataSetChanged();
+ mFileListAdapter.notifyDataChanged();
}
}
});
- listView.setAdapter(mFileListAdapter);
+ listView.setItemProvider(mFileListAdapter);
+ setTitle();
+ }
- //Title method added in version 1.0.5
+ public void setTitle(CharSequence titleStr) {
+ if (titleStr != null) {
+ this.titleStr = titleStr.toString();
+ } else {
+ this.titleStr = null;
+ }
setTitle();
}
@@ -171,29 +165,27 @@ public class FilePickerDialog extends Dialog implements AdapterView.OnItemClickL
return;
}
if (titleStr != null) {
- if (title.getVisibility() == View.INVISIBLE) {
- title.setVisibility(View.VISIBLE);
+ if (title.getVisibility() == Component.INVISIBLE) {
+ title.setVisibility(Component.VISIBLE);
}
title.setText(titleStr);
- if (dname.getVisibility() == View.VISIBLE) {
- dname.setVisibility(View.INVISIBLE);
+ if (dname.getVisibility() == Component.VISIBLE) {
+ dname.setVisibility(Component.INVISIBLE);
}
} else {
- if (title.getVisibility() == View.VISIBLE) {
- title.setVisibility(View.INVISIBLE);
+ if (title.getVisibility() == Component.VISIBLE) {
+ title.setVisibility(Component.INVISIBLE);
}
- if (dname.getVisibility() == View.INVISIBLE) {
- dname.setVisibility(View.VISIBLE);
+ if (dname.getVisibility() == Component.INVISIBLE) {
+ dname.setVisibility(Component.VISIBLE);
}
}
}
- @Override
- protected void onStart() {
- super.onStart();
+ public void onStart() {
positiveBtnNameStr = (
positiveBtnNameStr == null ?
- context.getResources().getString(R.string.choose_button_label) :
+ "Select" :
positiveBtnNameStr
);
select.setText(positiveBtnNameStr);
@@ -203,7 +195,7 @@ public class FilePickerDialog extends Dialog implements AdapterView.OnItemClickL
if (properties.offset.isDirectory() && validateOffsetPath()) {
currLoc = new File(properties.offset.getAbsolutePath());
FileListItem parent = new FileListItem();
- parent.setFilename(context.getString(R.string.label_parent_dir));
+ parent.setFilename("..");
parent.setDirectory(true);
parent.setLocation(Objects.requireNonNull(currLoc.getParentFile())
.getAbsolutePath());
@@ -216,11 +208,13 @@ public class FilePickerDialog extends Dialog implements AdapterView.OnItemClickL
}
dname.setText(currLoc.getName());
dir_path.setText(currLoc.getAbsolutePath());
+
setTitle();
internalList = Utility.prepareFileListEntries(internalList, currLoc, filter,
properties.show_hidden_files);
- mFileListAdapter.notifyDataSetChanged();
- listView.setOnItemClickListener(this);
+ listView.setItemProvider(mFileListAdapter);
+ mFileListAdapter.setData(internalList);
+ listView.setItemClickedListener(this);
}
}
@@ -231,7 +225,7 @@ public class FilePickerDialog extends Dialog implements AdapterView.OnItemClickL
}
@Override
- public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
+ public void onItemClicked(ListContainer listContainer, Component component, int i, long l) {
if (internalList.size() > i) {
FileListItem fitem = internalList.get(i);
if (fitem.isDirectory()) {
@@ -243,7 +237,7 @@ public class FilePickerDialog extends Dialog implements AdapterView.OnItemClickL
internalList.clear();
if (!currLoc.getName().equals(properties.root.getName())) {
FileListItem parent = new FileListItem();
- parent.setFilename(context.getString(R.string.label_parent_dir));
+ parent.setFilename("..");
parent.setDirectory(true);
parent.setLocation(Objects.requireNonNull(currLoc
.getParentFile()).getAbsolutePath());
@@ -252,14 +246,13 @@ public class FilePickerDialog extends Dialog implements AdapterView.OnItemClickL
}
internalList = Utility.prepareFileListEntries(internalList, currLoc, filter,
properties.show_hidden_files);
- mFileListAdapter.notifyDataSetChanged();
+ mFileListAdapter.notifyDataChanged();
} else {
- Toast.makeText(context, R.string.error_dir_access,
- Toast.LENGTH_SHORT).show();
+ new ToastDialog(context).setText("Directory cannot be accessed").show();
}
} else {
- MaterialCheckbox fmark = view.findViewById(R.id.file_mark);
- fmark.performClick();
+ MaterialCheckbox fmark = (MaterialCheckbox) component.findComponentById(ResourceTable.Id_file_mark);
+ fmark.simulateClick();
}
}
}
@@ -277,16 +270,6 @@ public class FilePickerDialog extends Dialog implements AdapterView.OnItemClickL
this.callbacks = callbacks;
}
- @Override
- public void setTitle(CharSequence titleStr) {
- if (titleStr != null) {
- this.titleStr = titleStr.toString();
- } else {
- this.titleStr = null;
- }
- setTitle();
- }
-
public void setPositiveBtnName(CharSequence positiveBtnNameStr) {
if (positiveBtnNameStr != null) {
this.positiveBtnNameStr = positiveBtnNameStr.toString();
@@ -359,7 +342,6 @@ public class FilePickerDialog extends Dialog implements AdapterView.OnItemClickL
MarkedItemList.addSelectedItem(item);
}
break;
-
case DialogConfigs.FILE_SELECT:
temp = new File(path);
if (temp.exists() && temp.isFile()) {
@@ -394,14 +376,16 @@ public class FilePickerDialog extends Dialog implements AdapterView.OnItemClickL
@Override
public void show() {
if (!Utility.checkStorageAccessPermissions(context)) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- ((Activity) context).requestPermissions(new String[]{Manifest.permission
- .READ_EXTERNAL_STORAGE}, EXTERNAL_READ_PERMISSION_GRANT);
+ // 应用未被授予权限
+ if (context.canRequestPermission("ohos.permission.WRITE_MEDIA")) {
+ // 是否可以申请弹框授权(首次申请或者用户未选择禁止且不再提示)
+ context.requestPermissionsFromUser(
+ new String[]{"ohos.permission.WRITE_MEDIA"}, 1);
}
} else {
super.show();
positiveBtnNameStr = positiveBtnNameStr == null ?
- context.getResources().getString(R.string.choose_button_label) : positiveBtnNameStr;
+ "Select" : positiveBtnNameStr;
select.setText(positiveBtnNameStr);
int size = MarkedItemList.getFileCount();
if (size == 0) {
@@ -414,22 +398,26 @@ public class FilePickerDialog extends Dialog implements AdapterView.OnItemClickL
}
@Override
- public void onBackPressed() {
- //currentDirName is dependent on dname
+ public void destroy() {
+ // currentDirName is dependent on dname
String currentDirName = dname.getText().toString();
if (internalList.size() > 0) {
FileListItem fitem = internalList.get(0);
File currLoc = new File(fitem.getLocation());
if (currentDirName.equals(properties.root.getName()) ||
!currLoc.canRead()) {
- super.onBackPressed();
+
+ MarkedItemList.clearSelectionList();
+ internalList.clear();
+ super.destroy();
+
} else {
dname.setText(currLoc.getName());
dir_path.setText(currLoc.getAbsolutePath());
internalList.clear();
if (!currLoc.getName().equals(properties.root.getName())) {
FileListItem parent = new FileListItem();
- parent.setFilename(context.getString(R.string.label_parent_dir));
+ parent.setFilename("..");
parent.setDirectory(true);
parent.setLocation(Objects.requireNonNull(currLoc.getParentFile())
.getAbsolutePath());
@@ -438,18 +426,18 @@ public class FilePickerDialog extends Dialog implements AdapterView.OnItemClickL
}
internalList = Utility.prepareFileListEntries(internalList, currLoc, filter,
properties.show_hidden_files);
- mFileListAdapter.notifyDataSetChanged();
+ mFileListAdapter.notifyDataChanged();
}
setTitle();
} else {
- super.onBackPressed();
+ MarkedItemList.clearSelectionList();
+ internalList.clear();
+ super.destroy();
}
}
- @Override
- public void dismiss() {
- MarkedItemList.clearSelectionList();
- internalList.clear();
- super.dismiss();
+ private int vp2px(Context context, float vp) {
+ DisplayAttributes attributes = DisplayManager.getInstance().getDefaultDisplay(context).get().getAttributes();
+ return (int) (attributes.densityPixels * vp);
}
}
diff --git a/library/src/main/java/com/developer/filepicker/widget/MaterialCheckbox.java b/library/src/main/java/com/developer/filepicker/widget/MaterialCheckbox.java
index c6a51c35bb8ebf299aefbc42aacaecb51c25567f..19f6bd1a7e9b2b9cd100321746203b460cfcc684 100644
--- a/library/src/main/java/com/developer/filepicker/widget/MaterialCheckbox.java
+++ b/library/src/main/java/com/developer/filepicker/widget/MaterialCheckbox.java
@@ -1,107 +1,96 @@
package com.developer.filepicker.widget;
-import android.content.Context;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Path;
-import android.graphics.RectF;
-import android.os.Build;
-import android.util.AttributeSet;
-import android.view.View;
-
-import com.developer.filepicker.R;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Component;
+import ohos.agp.render.Canvas;
+import ohos.agp.render.Paint;
+import ohos.agp.render.Path;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.RectFloat;
+import ohos.app.Context;
/**
* @author akshay sunil masram
*/
-public class MaterialCheckbox extends View {
+public class MaterialCheckbox extends Component implements Component.DrawTask, Component.EstimateSizeListener {
- private Context context;
private int minDim;
private Paint paint;
- private RectF bounds;
+ private RectFloat bounds;
private boolean checked;
private OnCheckedChangeListener onCheckedChangeListener;
private Path tick;
public MaterialCheckbox(Context context) {
super(context);
- initView(context);
+ initView();
}
- public MaterialCheckbox(Context context, AttributeSet attrs) {
+ public MaterialCheckbox(Context context, AttrSet attrs) {
super(context, attrs);
- initView(context);
+ initView();
}
- public MaterialCheckbox(Context context, AttributeSet attrs, int defStyleAttr) {
+ public MaterialCheckbox(Context context, AttrSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- initView(context);
+ initView();
}
- public void initView(Context context) {
- this.context = context;
+ public void initView() {
checked = false;
tick = new Path();
paint = new Paint();
- bounds = new RectF();
- OnClickListener onClickListener = new OnClickListener() {
+ setClickedListener(new ClickedListener() {
+
@Override
- public void onClick(View v) {
+ public void onClick(Component component) {
setChecked(!checked);
onCheckedChangeListener.onCheckedChanged(MaterialCheckbox.this, isChecked());
}
- };
+ });
- setOnClickListener(onClickListener);
+ int height = 50;
+ int width = 50;
+ minDim = Math.min(width, height);
+ bounds = new RectFloat(minDim / 10, minDim / 10, minDim - (minDim / 10), minDim - (minDim / 10));
+ tick.moveTo(minDim / 4, minDim / 2);
+ tick.lineTo(minDim / 2.5f, minDim - (minDim / 3));
+
+ tick.moveTo(minDim / 2.75f, minDim - (minDim / 3.25f));
+ tick.lineTo(minDim - (minDim / 4), minDim / 3);
+ addDrawTask(this::onDraw);
}
@Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
+ public void onDraw(Component component, Canvas canvas) {
if (isChecked()) {
paint.reset();
paint.setAntiAlias(true);
- bounds.set(minDim / 10, minDim / 10, minDim - (minDim / 10), minDim - (minDim / 10));
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- paint.setColor(getResources().getColor(R.color.colorAccent, context.getTheme()));
- } else {
- paint.setColor(getResources().getColor(R.color.colorAccent));
- }
+ bounds = new RectFloat(minDim / 10, minDim / 10, minDim - (minDim / 10), minDim - (minDim / 10));
+ paint.setColor(Color.RED);
canvas.drawRoundRect(bounds, minDim / 8, minDim / 8, paint);
- paint.setColor(Color.parseColor("#FFFFFF"));
+ paint.setColor(Color.WHITE);
paint.setStrokeWidth(minDim / 10);
- paint.setStyle(Paint.Style.STROKE);
- paint.setStrokeJoin(Paint.Join.BEVEL);
+ paint.setStyle(Paint.Style.STROKE_STYLE);
+ paint.setStrokeJoin(Paint.Join.BEVEL_JOIN);
canvas.drawPath(tick, paint);
} else {
paint.reset();
paint.setAntiAlias(true);
- bounds.set(minDim / 10, minDim / 10, minDim - (minDim / 10), minDim - (minDim / 10));
- paint.setColor(Color.parseColor("#C1C1C1"));
+ bounds = new RectFloat(minDim / 10, minDim / 10, minDim - (minDim / 10), minDim - (minDim / 10));
+ paint.setColor(Color.GRAY);
canvas.drawRoundRect(bounds, minDim / 8, minDim / 8, paint);
- bounds.set(minDim / 5, minDim / 5, minDim - (minDim / 5), minDim - (minDim / 5));
- paint.setColor(Color.parseColor("#FFFFFF"));
+ bounds = new RectFloat(minDim / 5, minDim / 5, minDim - (minDim / 5), minDim - (minDim / 5));
+ paint.setColor(Color.WHITE);
canvas.drawRect(bounds, paint);
}
}
@Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- int height = getMeasuredHeight();
- int width = getMeasuredWidth();
- minDim = Math.min(width, height);
- bounds.set(minDim / 10, minDim / 10, minDim - (minDim / 10), minDim - (minDim / 10));
- tick.moveTo(minDim / 4, minDim / 2);
- tick.lineTo(minDim / 2.5f, minDim - (minDim / 3));
-
- tick.moveTo(minDim / 2.75f, minDim - (minDim / 3.25f));
- tick.lineTo(minDim - (minDim / 4), minDim / 3);
- setMeasuredDimension(width, height);
+ public boolean onEstimateSize(int widthMeasureSpec, int heightMeasureSpec) {
+ return false;
}
public boolean isChecked() {
@@ -116,4 +105,4 @@ public class MaterialCheckbox extends View {
public void setOnCheckedChangedListener(OnCheckedChangeListener onCheckedChangeListener) {
this.onCheckedChangeListener = onCheckedChangeListener;
}
-}
+}
\ No newline at end of file
diff --git a/library/src/main/java/com/developer/filepicker/widget/OnCheckedChangeListener.java b/library/src/main/java/com/developer/filepicker/widget/OnCheckedChangeListener.java
index 56161df06d9364bedcf7a7bc43fc6afa18b698de..531267204c45cda36dfb91e5fd4122cc4a5dbddc 100644
--- a/library/src/main/java/com/developer/filepicker/widget/OnCheckedChangeListener.java
+++ b/library/src/main/java/com/developer/filepicker/widget/OnCheckedChangeListener.java
@@ -1,8 +1,17 @@
package com.developer.filepicker.widget;
/**
+ * DialogSelectionListener
+ *
* @author akshay sunil masram
+ * @since xxxx年x月x日
*/
public interface OnCheckedChangeListener {
+ /**
+ * onCheckedChanged
+ *
+ * @param checkbox MaterialCheckbox
+ * @param isChecked isChecked
+ */
void onCheckedChanged(MaterialCheckbox checkbox, boolean isChecked);
}
\ No newline at end of file
diff --git a/library/src/main/res/anim/marked_item_animation.xml b/library/src/main/res/anim/marked_item_animation.xml
deleted file mode 100644
index 5dc9cf9864845b68710adf03e9a3c7bbee06f5e8..0000000000000000000000000000000000000000
--- a/library/src/main/res/anim/marked_item_animation.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
\ No newline at end of file
diff --git a/library/src/main/res/anim/unmarked_item_animation.xml b/library/src/main/res/anim/unmarked_item_animation.xml
deleted file mode 100644
index 5dc9cf9864845b68710adf03e9a3c7bbee06f5e8..0000000000000000000000000000000000000000
--- a/library/src/main/res/anim/unmarked_item_animation.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
\ No newline at end of file
diff --git a/library/src/main/res/drawable/bottom_shadow.9.png b/library/src/main/res/drawable/bottom_shadow.9.png
deleted file mode 100644
index b9bcc2d134caf3388c3c44e3ca97f359d6e587b1..0000000000000000000000000000000000000000
Binary files a/library/src/main/res/drawable/bottom_shadow.9.png and /dev/null differ
diff --git a/library/src/main/res/layout-v11/dialog_footer.xml b/library/src/main/res/layout-v11/dialog_footer.xml
deleted file mode 100644
index b442f445143f5e7d782907660f595c8ff3fced75..0000000000000000000000000000000000000000
--- a/library/src/main/res/layout-v11/dialog_footer.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/layout-v21/dialog_file_list_item.xml b/library/src/main/res/layout-v21/dialog_file_list_item.xml
deleted file mode 100644
index 00e2290ad33dc3e97efaaa960374493049d88c23..0000000000000000000000000000000000000000
--- a/library/src/main/res/layout-v21/dialog_file_list_item.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/layout-v23/dialog_file_list.xml b/library/src/main/res/layout-v23/dialog_file_list.xml
deleted file mode 100644
index 636f951c5dc4d1d681e6e3a1b01914e69160dd8a..0000000000000000000000000000000000000000
--- a/library/src/main/res/layout-v23/dialog_file_list.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
diff --git a/library/src/main/res/layout/dialog_file_list.xml b/library/src/main/res/layout/dialog_file_list.xml
deleted file mode 100644
index bf9f43e499ae3327bd6330a01c207035c18d74de..0000000000000000000000000000000000000000
--- a/library/src/main/res/layout/dialog_file_list.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
diff --git a/library/src/main/res/layout/dialog_file_list_item.xml b/library/src/main/res/layout/dialog_file_list_item.xml
deleted file mode 100644
index 456f8bbda23dd675a1121b4836f1af1fc8bbfedb..0000000000000000000000000000000000000000
--- a/library/src/main/res/layout/dialog_file_list_item.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/layout/dialog_footer.xml b/library/src/main/res/layout/dialog_footer.xml
deleted file mode 100644
index 1abf88fdfe172c7e37b232e5133691ce611e6ddd..0000000000000000000000000000000000000000
--- a/library/src/main/res/layout/dialog_footer.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/layout/dialog_header.xml b/library/src/main/res/layout/dialog_header.xml
deleted file mode 100644
index 4839165cbb47cc2aaa77c32006eebebda52b6449..0000000000000000000000000000000000000000
--- a/library/src/main/res/layout/dialog_header.xml
+++ /dev/null
@@ -1,64 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/layout/dialog_main.xml b/library/src/main/res/layout/dialog_main.xml
deleted file mode 100644
index fbdae024180a3247bff9fe3580612ef1ff9387c7..0000000000000000000000000000000000000000
--- a/library/src/main/res/layout/dialog_main.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/mipmap-hdpi/ic_directory_parent.png b/library/src/main/res/mipmap-hdpi/ic_directory_parent.png
deleted file mode 100644
index c8f083003cf80f26b93632fa262f2def31a61092..0000000000000000000000000000000000000000
Binary files a/library/src/main/res/mipmap-hdpi/ic_directory_parent.png and /dev/null differ
diff --git a/library/src/main/res/mipmap-hdpi/ic_type_file.png b/library/src/main/res/mipmap-hdpi/ic_type_file.png
deleted file mode 100644
index 4e283ad5d0e70ae2925e11e31d04b3fdc72ddb4d..0000000000000000000000000000000000000000
Binary files a/library/src/main/res/mipmap-hdpi/ic_type_file.png and /dev/null differ
diff --git a/library/src/main/res/mipmap-hdpi/ic_type_folder.png b/library/src/main/res/mipmap-hdpi/ic_type_folder.png
deleted file mode 100644
index 8b3903219167ae2668ec10301152e508ea1f0b56..0000000000000000000000000000000000000000
Binary files a/library/src/main/res/mipmap-hdpi/ic_type_folder.png and /dev/null differ
diff --git a/library/src/main/res/mipmap-mdpi/ic_directory_parent.png b/library/src/main/res/mipmap-mdpi/ic_directory_parent.png
deleted file mode 100644
index 086f9b439620f8b9f8ac721ab345a58a085ec082..0000000000000000000000000000000000000000
Binary files a/library/src/main/res/mipmap-mdpi/ic_directory_parent.png and /dev/null differ
diff --git a/library/src/main/res/mipmap-mdpi/ic_type_file.png b/library/src/main/res/mipmap-mdpi/ic_type_file.png
deleted file mode 100644
index 058cd1c2fa813dd9d809d9d9a35b11e880846673..0000000000000000000000000000000000000000
Binary files a/library/src/main/res/mipmap-mdpi/ic_type_file.png and /dev/null differ
diff --git a/library/src/main/res/mipmap-mdpi/ic_type_folder.png b/library/src/main/res/mipmap-mdpi/ic_type_folder.png
deleted file mode 100644
index 6e96bf9e569b4f7322d34cdb19eda8d926533c7b..0000000000000000000000000000000000000000
Binary files a/library/src/main/res/mipmap-mdpi/ic_type_folder.png and /dev/null differ
diff --git a/library/src/main/res/mipmap-xxhdpi/ic_directory_parent.png b/library/src/main/res/mipmap-xxhdpi/ic_directory_parent.png
deleted file mode 100644
index f175cf209b107ceaa6ff0db2379feb6c5fbcb46c..0000000000000000000000000000000000000000
Binary files a/library/src/main/res/mipmap-xxhdpi/ic_directory_parent.png and /dev/null differ
diff --git a/library/src/main/res/mipmap-xxhdpi/ic_type_file.png b/library/src/main/res/mipmap-xxhdpi/ic_type_file.png
deleted file mode 100644
index 2cc7eb298a9f47cdaec2494604652cded6993027..0000000000000000000000000000000000000000
Binary files a/library/src/main/res/mipmap-xxhdpi/ic_type_file.png and /dev/null differ
diff --git a/library/src/main/res/mipmap-xxhdpi/ic_type_folder.png b/library/src/main/res/mipmap-xxhdpi/ic_type_folder.png
deleted file mode 100644
index 986d1161cd70f01b6f849309840e9d16c4e4a783..0000000000000000000000000000000000000000
Binary files a/library/src/main/res/mipmap-xxhdpi/ic_type_folder.png and /dev/null differ
diff --git a/library/src/main/res/values-de/strings.xml b/library/src/main/res/values-de/strings.xml
deleted file mode 100644
index 4a1a010f0950ca1f949696b6fd13c46f04b3cc79..0000000000000000000000000000000000000000
--- a/library/src/main/res/values-de/strings.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
- Zugriff auf Verzeichnis fehlgeschlagen
- Abbrechen
- Auswählen
- Übergeordnetes Verzeichnis
- Zuletzt bearbeitet: %1$s, %2$s
-
\ No newline at end of file
diff --git a/library/src/main/res/values-w820dp/dimens.xml b/library/src/main/res/values-w820dp/dimens.xml
deleted file mode 100644
index bc7154e9ca8bbfbb5f86e4d95f694fe6214c094d..0000000000000000000000000000000000000000
--- a/library/src/main/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
- 8dp
- 16dp
- 32dp
- 32dp
-
diff --git a/library/src/main/res/values/colors.xml b/library/src/main/res/values/colors.xml
deleted file mode 100644
index bf8cebc6ab0fe021219a75e397d2350ffa759b54..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- #3F51B5
- #303F9F
- #3F51B5
- #FFFFFF
- #FFFFFF
- @color/colorPrimary
-
diff --git a/library/src/main/res/values/dimens.xml b/library/src/main/res/values/dimens.xml
deleted file mode 100644
index d07477919e851c46e5cc9ca098bcb8b3669d8590..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
- 4dp
- 8dp
- 16dp
- 24dp
-
diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml
deleted file mode 100644
index 0ff5395379573e7ff3460d46bd0037aeae8cca77..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
- Cancel
- Select
- /sdcard
- Parent Directory
- Last edited: %1$s, %2$s
- Directory cannot be accessed
- ..
-
\ No newline at end of file
diff --git a/library/src/main/resources/base/element/color.json b/library/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..af7d45257f1f8f46ecee07735f182b7972d91e57
--- /dev/null
+++ b/library/src/main/resources/base/element/color.json
@@ -0,0 +1,12 @@
+{
+ "color": [
+ {
+ "name": "bt_red",
+ "value": "#FF0000"
+ },
+ {
+ "name": "bt_pink",
+ "value": "#99FF5722"
+ }
+ ]
+}
diff --git a/library/src/main/resources/base/element/string.json b/library/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..1e2b219ccdd1183e23968586e5e2e404b41c38c9
--- /dev/null
+++ b/library/src/main/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "library"
+ }
+ ]
+}
diff --git a/library/src/main/resources/base/layout/dialog_file_list_item.xml b/library/src/main/resources/base/layout/dialog_file_list_item.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c636a6e3bbe20a253cff178676071b5bb9bfa272
--- /dev/null
+++ b/library/src/main/resources/base/layout/dialog_file_list_item.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/resources/base/layout/dialog_main.xml b/library/src/main/resources/base/layout/dialog_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..0d88e2e9ba5d35c31d5af154cd60a56d09a79208
--- /dev/null
+++ b/library/src/main/resources/base/layout/dialog_main.xml
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/src/main/res/mipmap-xhdpi/ic_directory_parent.png b/library/src/main/resources/base/media/ic_directory_parent.png
similarity index 100%
rename from library/src/main/res/mipmap-xhdpi/ic_directory_parent.png
rename to library/src/main/resources/base/media/ic_directory_parent.png
diff --git a/library/src/main/res/mipmap-xhdpi/ic_type_file.png b/library/src/main/resources/base/media/ic_type_file.png
similarity index 100%
rename from library/src/main/res/mipmap-xhdpi/ic_type_file.png
rename to library/src/main/resources/base/media/ic_type_file.png
diff --git a/library/src/main/res/mipmap-xhdpi/ic_type_folder.png b/library/src/main/resources/base/media/ic_type_folder.png
similarity index 100%
rename from library/src/main/res/mipmap-xhdpi/ic_type_folder.png
rename to library/src/main/resources/base/media/ic_type_folder.png
diff --git a/library/src/test/java/com/developer/filepicker/ExampleTest.java b/library/src/test/java/com/developer/filepicker/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..22e21920e08a9c526699b886de707dd583652a2e
--- /dev/null
+++ b/library/src/test/java/com/developer/filepicker/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.developer.filepicker;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/sample/build.gradle b/sample/build.gradle
deleted file mode 100644
index 9e6613168e9489e4c918bcda96746afe9e4efc17..0000000000000000000000000000000000000000
--- a/sample/build.gradle
+++ /dev/null
@@ -1,30 +0,0 @@
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 29
-
- defaultConfig {
- applicationId "com.developer.filepicker.file"
- minSdkVersion 19
- targetSdkVersion 29
- versionCode 6
- versionName "6.0.19"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- implementation fileTree(include: ['*.jar'], dir: 'libs')
-
- //Library Implementation
- implementation project(':library')
-
- //AndroidX Libraries
- implementation 'androidx.appcompat:appcompat:1.1.0'
- implementation 'androidx.recyclerview:recyclerview:1.1.0'
-}
diff --git a/sample/proguard-rules.pro b/sample/proguard-rules.pro
deleted file mode 100644
index de3efee3df56bd343bfb5b86dcbea150dc0ff5f9..0000000000000000000000000000000000000000
--- a/sample/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in D:\Android\SDK/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
deleted file mode 100644
index e9bb1ddabaebb52a7d8afb8cfeb2bf22e4633d06..0000000000000000000000000000000000000000
--- a/sample/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample/src/main/ic_launcher-web.png b/sample/src/main/ic_launcher-web.png
deleted file mode 100644
index 3a6eec69f521db9df298a06921df78e38cf24d42..0000000000000000000000000000000000000000
Binary files a/sample/src/main/ic_launcher-web.png and /dev/null differ
diff --git a/sample/src/main/java/com/developer/filepicker/file/FileListAdapter.java b/sample/src/main/java/com/developer/filepicker/file/FileListAdapter.java
deleted file mode 100644
index d142163500c18cbc3157ef9fc5841a7efd1daf92..0000000000000000000000000000000000000000
--- a/sample/src/main/java/com/developer/filepicker/file/FileListAdapter.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package com.developer.filepicker.file;
-
-import android.content.Context;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.recyclerview.widget.RecyclerView;
-
-import java.util.ArrayList;
-
-class FileListAdapter extends RecyclerView.Adapter {
- private final ArrayList listItems;
- private final Context context;
-
- FileListAdapter(ArrayList listItems, Context context) {
- this.listItems = listItems;
- this.context = context;
- }
-
- @NonNull
- @Override
- public FileListViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- View view = LayoutInflater.from(context).inflate(R.layout.file_list_item,
- parent, false);
- return new FileListViewHolder(view);
- }
-
- @Override
- public void onBindViewHolder(@NonNull FileListViewHolder holder, int position) {
- holder.name.setText(listItems.get(position).getName());
- holder.path.setText(listItems.get(position).getPath());
- }
-
- @Override
- public long getItemId(int i) {
- return i;
- }
-
- @Override
- public int getItemCount() {
- return listItems.size();
- }
-
- class FileListViewHolder extends RecyclerView.ViewHolder {
- private final TextView name;
- private final TextView path;
-
- FileListViewHolder(View itemView) {
- super(itemView);
- name = itemView.findViewById(R.id.name);
- path = itemView.findViewById(R.id.path);
- }
- }
-}
\ No newline at end of file
diff --git a/sample/src/main/java/com/developer/filepicker/file/FilePickerApplication.java b/sample/src/main/java/com/developer/filepicker/file/FilePickerApplication.java
deleted file mode 100644
index 2b34c13e9e0c6083cc329bf1f5e9c6a0c8c8f91e..0000000000000000000000000000000000000000
--- a/sample/src/main/java/com/developer/filepicker/file/FilePickerApplication.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.developer.filepicker.file;
-
-import android.app.Application;
-
-public class FilePickerApplication extends Application {
-
- @Override
- public void onCreate() {
- super.onCreate();
- }
-}
\ No newline at end of file
diff --git a/sample/src/main/java/com/developer/filepicker/file/MainActivity.java b/sample/src/main/java/com/developer/filepicker/file/MainActivity.java
deleted file mode 100644
index 40ba3b4acfc2c46bfdd4a688da8dc38d9b81f036..0000000000000000000000000000000000000000
--- a/sample/src/main/java/com/developer/filepicker/file/MainActivity.java
+++ /dev/null
@@ -1,228 +0,0 @@
-package com.developer.filepicker.file;
-
-import android.content.pm.PackageManager;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.EditText;
-import android.widget.RadioGroup;
-import android.widget.Toast;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.developer.filepicker.controller.DialogSelectionListener;
-import com.developer.filepicker.model.DialogConfigs;
-import com.developer.filepicker.model.DialogProperties;
-import com.developer.filepicker.view.FilePickerDialog;
-
-import java.io.File;
-import java.util.ArrayList;
-
-public class MainActivity extends AppCompatActivity {
-
- private FilePickerDialog dialog;
- private ArrayList listItem;
- private FileListAdapter mFileListAdapter;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- listItem = new ArrayList<>();
- RecyclerView fileList = findViewById(R.id.listView);
- mFileListAdapter = new FileListAdapter(listItem, MainActivity.this);
- fileList.setAdapter(mFileListAdapter);
- fileList.setLayoutManager(new LinearLayoutManager(MainActivity.this));
- fileList.setNestedScrollingEnabled(false);
-
- //Create a DialogProperties object.
- final DialogProperties properties = new DialogProperties();
-
- //Instantiate FilePickerDialog with Context and DialogProperties.
- dialog = new FilePickerDialog(MainActivity.this, properties);
- dialog.setTitle("Select a File");
- dialog.setPositiveBtnName("Select");
- dialog.setNegativeBtnName("Cancel");
- // properties.selection_mode = DialogConfigs.MULTI_MODE;
- // properties.selection_type = DialogConfigs.DIR_SELECT;
-
- RadioGroup modeRadio = findViewById(R.id.modeRadio);
- modeRadio.check(R.id.singleRadio);
- modeRadio.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(RadioGroup group, int checkedId) {
- switch (checkedId) {
- case R.id.singleRadio: //Setting selection mode to single selection.
- properties.selection_mode = DialogConfigs.SINGLE_MODE;
- break;
- case R.id.multiRadio: //Setting selection mode to multiple selection.
- properties.selection_mode = DialogConfigs.MULTI_MODE;
- break;
- }
- }
- });
- RadioGroup typeRadio = findViewById(R.id.typeRadio);
- typeRadio.check(R.id.selFile);
- typeRadio.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(RadioGroup group, int checkedId) {
- switch (checkedId) {
- case R.id.selFile: //Setting selection type to files.
- properties.selection_type = DialogConfigs.FILE_SELECT;
- break;
- case R.id.selDir: //Setting selection type to directories.
- properties.selection_type = DialogConfigs.DIR_SELECT;
- break;
- case R.id.selfilenddir: //Setting selection type to files and directories.
- properties.selection_type = DialogConfigs.FILE_AND_DIR_SELECT;
- break;
- }
- }
- });
- final EditText extension = findViewById(R.id.extensions);
- final EditText root = findViewById(R.id.root);
- final EditText offset = findViewById(R.id.offset);
- final CheckBox show_hidden_files = findViewById(R.id.show_hidden_files);
- Button apply = findViewById(R.id.apply);
- Button showDialog = findViewById(R.id.show_dialog);
- apply.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- String fextension = extension.getText().toString();
- if (fextension.length() > 0) {
- //Add extensions to be sorted from the EditText input to the array of String.
- int commas = countCommas(fextension);
-
- //Array representing extensions.
- String[] exts = new String[commas + 1];
- StringBuffer buff = new StringBuffer();
- int i = 0;
- for (int j = 0; j < fextension.length(); j++) {
- if (fextension.charAt(j) == ',') {
- exts[i] = buff.toString();
- buff = new StringBuffer();
- i++;
- } else {
- buff.append(fextension.charAt(j));
- }
- }
- exts[i] = buff.toString();
-
- //Set String Array of extensions.
- properties.extensions = exts;
- } else { //If EditText is empty, Initialise with null reference.
- properties.extensions = null;
- }
- String foffset = root.getText().toString();
- if (foffset.length() > 0 || !foffset.equals("")) {
- //Setting Parent Directory.
- properties.root = new File(foffset);
- } else {
- //Setting Parent Directory to Default SDCARD.
- properties.root = new File(DialogConfigs.DEFAULT_DIR);
- }
-
- String fset = offset.getText().toString();
- if (fset.length() > 0 || !fset.equals("")) {
- //Setting Offset Directory.
- properties.offset = new File(fset);
- } else {
- //Setting Parent Directory to Default SDCARD.
- properties.offset = new File(DialogConfigs.DEFAULT_DIR);
- }
-
- properties.show_hidden_files = show_hidden_files.isChecked();
-
- //Setting Alternative Directory, in case root is not accessible.This will be
- //used.
-
- properties.error_dir = new File("/mnt");
- //Set new properties of dialog.
- dialog.setProperties(properties);
-
-// Pre marking of files in Dialog
-// ArrayList paths=new ArrayList<>();
-// paths.add("/mnt/sdcard/.VOD");
-// paths.add("/mnt/sdcard/.VOD/100.jpg");
-// paths.add("/mnt/sdcard/.VOD/1000.jpg");
-// paths.add("/mnt/sdcard/.VOD/1010.jpg");
-// paths.add("/mnt/sdcard/.VOD/1020.jpg");
-// paths.add("/mnt/sdcard/.VOD/1070.jpg");
-// dialog.markFiles(paths);
- }
- });
-
- showDialog.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- //Showing dialog when Show Dialog button is clicked.
- dialog.show();
- }
- });
-
- //Method handle selected files.
- dialog.setDialogSelectionListener(new DialogSelectionListener() {
- @Override
- public void onSelectedFilePaths(String[] files) {
- //files is the array of paths selected by the App User.
- int size = listItem.size();
- listItem.clear();
- mFileListAdapter.notifyItemRangeRemoved(0, size);
- for (String path : files) {
- File file = new File(path);
- ListItem item = new ListItem();
- item.setName(file.getName());
- item.setPath(file.getAbsolutePath());
- listItem.add(item);
- }
- mFileListAdapter.notifyItemRangeInserted(0, listItem.size());
- }
- });
- }
-
- private int countCommas(String fextension) {
- int count = 0;
- for (char ch : fextension.toCharArray()) {
- if (ch == ',') count++;
- }
- return count;
- }
-
- //Add this method to show Dialog when the required permission has been granted to the app.
- @Override
- public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- if (requestCode == FilePickerDialog.EXTERNAL_READ_PERMISSION_GRANT) {
- if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- if (dialog != null) {
- //Show dialog if the read permission has been granted.
- dialog.show();
- }
- } else {
- //Permission has not been granted. Notify the user.
- Toast.makeText(MainActivity.this, "Permission is Required for getting list of files", Toast.LENGTH_SHORT).show();
- }
- }
- }
-
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.main_menu, menu);
- return true;
- }
-
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == R.id.settings) {
- //startActivity(new Intent(this, SettingsActivity.class));
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-}
\ No newline at end of file
diff --git a/sample/src/main/res/drawable-hdpi/ic_action_settings.png b/sample/src/main/res/drawable-hdpi/ic_action_settings.png
deleted file mode 100644
index 7d98bb3cb5cc72be60eee8f911a2a1b3fada6839..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/drawable-hdpi/ic_action_settings.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-mdpi/ic_action_settings.png b/sample/src/main/res/drawable-mdpi/ic_action_settings.png
deleted file mode 100644
index fbcc74c775a7ba6e78719c64849702fc541dd757..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/drawable-mdpi/ic_action_settings.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-xhdpi/ic_action_settings.png b/sample/src/main/res/drawable-xhdpi/ic_action_settings.png
deleted file mode 100644
index e3bf61bd19a8663319ec4ac58c8f148ca54c78ce..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/drawable-xhdpi/ic_action_settings.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-xxhdpi/ic_action_settings.png b/sample/src/main/res/drawable-xxhdpi/ic_action_settings.png
deleted file mode 100644
index 51b60a0e45eb3fa031eadce06b5f31a75aa7be57..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/drawable-xxhdpi/ic_action_settings.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-xxxhdpi/ic_action_settings.png b/sample/src/main/res/drawable-xxxhdpi/ic_action_settings.png
deleted file mode 100644
index 51b60a0e45eb3fa031eadce06b5f31a75aa7be57..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/drawable-xxxhdpi/ic_action_settings.png and /dev/null differ
diff --git a/sample/src/main/res/drawable/ic_up_navigation.png b/sample/src/main/res/drawable/ic_up_navigation.png
deleted file mode 100644
index 8dc87f56648fd28b12ba3e9915b7267785e376da..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/drawable/ic_up_navigation.png and /dev/null differ
diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml
deleted file mode 100644
index 44d73ef71ef908d4efdddd62b9ab7211cf35e9ba..0000000000000000000000000000000000000000
--- a/sample/src/main/res/layout/activity_main.xml
+++ /dev/null
@@ -1,169 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample/src/main/res/layout/file_list_item.xml b/sample/src/main/res/layout/file_list_item.xml
deleted file mode 100644
index 302b696d8b571142c25921288b55d8b7378785ed..0000000000000000000000000000000000000000
--- a/sample/src/main/res/layout/file_list_item.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample/src/main/res/layout/toolbar.xml b/sample/src/main/res/layout/toolbar.xml
deleted file mode 100644
index e7c589045335e4c94b86c6c393d75e6a5c6a53d2..0000000000000000000000000000000000000000
--- a/sample/src/main/res/layout/toolbar.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
diff --git a/sample/src/main/res/menu/main_menu.xml b/sample/src/main/res/menu/main_menu.xml
deleted file mode 100644
index 7e19a9beedae244e214528217a41e3856979ddae..0000000000000000000000000000000000000000
--- a/sample/src/main/res/menu/main_menu.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
\ No newline at end of file
diff --git a/sample/src/main/res/mipmap-hdpi/ic_launcher.png b/sample/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index 91ef332c69dc563e8180ddf42b9652a5a8e7eb75..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/sample/src/main/res/mipmap-mdpi/ic_launcher.png b/sample/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index 868c641121b73ce2430a341bfcab5b6680e51376..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/sample/src/main/res/mipmap-xhdpi/ic_launcher.png b/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index 1f57200d99fba41f24f972a58cbae595d79a6680..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png b/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index d69790c88a658e8f13f9c87b18de94d8b41ec7a7..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100644
index d0bf2dcd3c7a5b2ad96ce352c7aade1b80a130cd..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/sample/src/main/res/values-w820dp/dimens.xml b/sample/src/main/res/values-w820dp/dimens.xml
deleted file mode 100644
index 63fc816444614bd64f68a372d1f93211628ee51d..0000000000000000000000000000000000000000
--- a/sample/src/main/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- 64dp
-
diff --git a/sample/src/main/res/values/colors.xml b/sample/src/main/res/values/colors.xml
deleted file mode 100644
index 6f413d93c5911f7cad1ac36fbcb893d0cbe7f015..0000000000000000000000000000000000000000
--- a/sample/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- #3F51B5
- #283593
- #F50057
-
diff --git a/sample/src/main/res/values/dimens.xml b/sample/src/main/res/values/dimens.xml
deleted file mode 100644
index 47c82246738c4d056e8030d3a259206f42e8e15d..0000000000000000000000000000000000000000
--- a/sample/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- 16dp
- 16dp
-
diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml
deleted file mode 100644
index ee5756264c80feffca74411d98f903bfe5603725..0000000000000000000000000000000000000000
--- a/sample/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
- FilePicker
- Select
- Show Dialog
- Settings
- Apply
- eg. /mnt/sdcard/Music or leave empty
- Offset Directory
- eg. /mnt/sdcard or leave empty
- Root Directory
- eg. jpg, zip, rar or leave empty
- Single
- Multiple
- Selection Mode
- Selection Type
- File
- Directory
- Files and Directories
- Filter Extensions(Seperate with Commas, Don\'t use dots)
- Show hidden files
-
\ No newline at end of file
diff --git a/sample/src/main/res/values/styles.xml b/sample/src/main/res/values/styles.xml
deleted file mode 100644
index e9b6133d1edb157c78cc89d6ea05503f5f381562..0000000000000000000000000000000000000000
--- a/sample/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
diff --git a/sample/src/main/res/xml/backup_descriptor.xml b/sample/src/main/res/xml/backup_descriptor.xml
deleted file mode 100644
index 6fd6103a4d93e4ef450dabdafd296f1cab15dac7..0000000000000000000000000000000000000000
--- a/sample/src/main/res/xml/backup_descriptor.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/screenshots/device-2019-05-10-182300.png b/screenshots/device-2019-05-10-182300.png
deleted file mode 100644
index 06c09652e58e7228f0c174820db2ef1f883e83ce..0000000000000000000000000000000000000000
Binary files a/screenshots/device-2019-05-10-182300.png and /dev/null differ
diff --git a/settings.gradle b/settings.gradle
index 52baf7e648cbb87f360039dd6c3920b9f0db3aaa..d0c7ee8440156d4a9324ac5357770747425fef57 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':sample', ':library'
+include ':entry', ':library'