diff --git a/.gitignore b/.gitignore index e2831af..93fa760 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,11 @@ -/demo/gen -/demo/bin -/library/gen -/library/bin +/demo/.idea +/demo/build +/demo/local.properties +/demo/aFileDialog/build +/demo/aFileDialogTesting/build + +/library/.idea +/library/build +/library/local.properties +/library/app/build + diff --git a/Readme.md b/Readme.md index ac00c3f..851562a 100644 --- a/Readme.md +++ b/Readme.md @@ -28,7 +28,21 @@ In order to use _aFileDialog_ in your application you must do three steps: ``` -Then you must only create an instance of _FileChooserDialog_ and call the _show()_ method or start the activity _FileChooserActivity_. +**4)** Then you must only create an instance of _FileChooserDialog_ and call the _show()_ method: + +```java + FileChooserDialog dialog = new FileChooserDialog(context); + dialog.show(); +``` + +Or start the activity _FileChooserActivity_: + +```java + Intent intent = new Intent(this, FileChooserActivity.class); + this.startActivityForResult(intent, 0); +``` + +> **Note:** the current version of the library is developed using _Android Studio_, if you are using _Eclipse_, then you should check the [eclipse](https://github.com/jfmdev/aFileDialog/tree/eclipse) branch. Demo ---- @@ -46,23 +60,6 @@ In order to known how to use _aFileDialog_, check the [user guide](docs/UserGuid If you want to modify or extend _aFileDialog_, you can read the [software design description](docs/SoftwareDesignDescription.md) (also available in [Spanish](docs/SoftwareDesignDescriptionEs.md)), although this is not mandatory, since the code is fully commented and you are going to figure out how it works in matters of minutes. -Code samples ------------- - -Samples codes are available in the [user guide](docs/UserGuide.md), but, to summarize, you can open a file chooser (implemented with a _Dialog_) using the following lines: - -```java -FileChooserDialog dialog = new FileChooserDialog(context); -dialog.show(); -``` - -To open a file chooser implemented with an _Activity_, you can use the following lines: - -```java -Intent intent = new Intent(this, FileChooserActivity.class); -this.startActivityForResult(intent, 0); -``` - License ------- diff --git a/demo/.classpath b/demo/.classpath deleted file mode 100644 index 5176974..0000000 --- a/demo/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/demo/.gradle/2.2.1/taskArtifacts/cache.properties b/demo/.gradle/2.2.1/taskArtifacts/cache.properties new file mode 100644 index 0000000..6e78305 --- /dev/null +++ b/demo/.gradle/2.2.1/taskArtifacts/cache.properties @@ -0,0 +1 @@ +#Fri May 08 11:01:36 UTC 2015 diff --git a/demo/.gradle/2.2.1/taskArtifacts/cache.properties.lock b/demo/.gradle/2.2.1/taskArtifacts/cache.properties.lock new file mode 100644 index 0000000..9b22739 Binary files /dev/null and b/demo/.gradle/2.2.1/taskArtifacts/cache.properties.lock differ diff --git a/demo/.gradle/2.2.1/taskArtifacts/fileHashes.bin b/demo/.gradle/2.2.1/taskArtifacts/fileHashes.bin new file mode 100644 index 0000000..6f46c37 Binary files /dev/null and b/demo/.gradle/2.2.1/taskArtifacts/fileHashes.bin differ diff --git a/demo/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin b/demo/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin new file mode 100644 index 0000000..e66c319 Binary files /dev/null and b/demo/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin differ diff --git a/demo/.gradle/2.2.1/taskArtifacts/outputFileStates.bin b/demo/.gradle/2.2.1/taskArtifacts/outputFileStates.bin new file mode 100644 index 0000000..9c00ac9 Binary files /dev/null and b/demo/.gradle/2.2.1/taskArtifacts/outputFileStates.bin differ diff --git a/demo/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin b/demo/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin new file mode 100644 index 0000000..5925498 Binary files /dev/null and b/demo/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin differ diff --git a/demo/.project b/demo/.project deleted file mode 100644 index f63f09d..0000000 --- a/demo/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - aFileDialogTesting - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/demo/.settings/org.eclipse.jdt.core.prefs b/demo/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 8fc69fa..0000000 --- a/demo/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -#Mon Apr 08 16:25:57 UTC 2013 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.source=1.5 diff --git a/demo/.settings/org.eclipse.ltk.core.refactoring.prefs b/demo/.settings/org.eclipse.ltk.core.refactoring.prefs deleted file mode 100644 index c0b9b5b..0000000 --- a/demo/.settings/org.eclipse.ltk.core.refactoring.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Thu Apr 25 09:43:49 UTC 2013 -eclipse.preferences.version=1 -org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false diff --git a/demo/aFileDialog/aFileDialog.iml b/demo/aFileDialog/aFileDialog.iml new file mode 100644 index 0000000..5597765 --- /dev/null +++ b/demo/aFileDialog/aFileDialog.iml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demo/aFileDialog/build.gradle b/demo/aFileDialog/build.gradle new file mode 100644 index 0000000..e6e4bff --- /dev/null +++ b/demo/aFileDialog/build.gradle @@ -0,0 +1,22 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 10 + buildToolsVersion "22.0.1" + + defaultConfig { + minSdkVersion 8 + targetSdkVersion 8 + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_5 + targetCompatibility JavaVersion.VERSION_1_5 + } + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + } +} diff --git a/demo/aFileDialog/lint.xml b/demo/aFileDialog/lint.xml new file mode 100644 index 0000000..8423c0e --- /dev/null +++ b/demo/aFileDialog/lint.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/library/AndroidManifest.xml b/demo/aFileDialog/src/main/AndroidManifest.xml similarity index 100% rename from library/AndroidManifest.xml rename to demo/aFileDialog/src/main/AndroidManifest.xml diff --git a/library/src/ar/com/daidalos/afiledialog/FileChooser.java b/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooser.java similarity index 97% rename from library/src/ar/com/daidalos/afiledialog/FileChooser.java rename to demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooser.java index 985732b..b3bba7d 100644 --- a/library/src/ar/com/daidalos/afiledialog/FileChooser.java +++ b/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooser.java @@ -1,5 +1,5 @@ /* - * «Copyright 2013 Jose F. Maldonado» + * * * This file is part of aFileDialog. * diff --git a/library/src/ar/com/daidalos/afiledialog/FileChooserActivity.java b/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserActivity.java similarity index 99% rename from library/src/ar/com/daidalos/afiledialog/FileChooserActivity.java rename to demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserActivity.java index c47086e..d4c462f 100644 --- a/library/src/ar/com/daidalos/afiledialog/FileChooserActivity.java +++ b/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserActivity.java @@ -1,5 +1,5 @@ /* - * «Copyright 2013 Jose F. Maldonado» + * * * This file is part of aFileDialog. * diff --git a/library/src/ar/com/daidalos/afiledialog/FileChooserCore.java b/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserCore.java similarity index 99% rename from library/src/ar/com/daidalos/afiledialog/FileChooserCore.java rename to demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserCore.java index b913734..f233e88 100644 --- a/library/src/ar/com/daidalos/afiledialog/FileChooserCore.java +++ b/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserCore.java @@ -1,5 +1,5 @@ /* - * «Copyright 2013 Jose F. Maldonado» + * * * This file is part of aFileDialog. * diff --git a/library/src/ar/com/daidalos/afiledialog/FileChooserDialog.java b/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserDialog.java similarity index 99% rename from library/src/ar/com/daidalos/afiledialog/FileChooserDialog.java rename to demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserDialog.java index a98fc1b..0da4c33 100644 --- a/library/src/ar/com/daidalos/afiledialog/FileChooserDialog.java +++ b/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserDialog.java @@ -1,5 +1,5 @@ /* - * «Copyright 2013 Jose F. Maldonado» + * * * This file is part of aFileDialog. * diff --git a/library/src/ar/com/daidalos/afiledialog/FileChooserLabels.java b/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserLabels.java similarity index 98% rename from library/src/ar/com/daidalos/afiledialog/FileChooserLabels.java rename to demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserLabels.java index e3209e1..46c4643 100644 --- a/library/src/ar/com/daidalos/afiledialog/FileChooserLabels.java +++ b/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/FileChooserLabels.java @@ -1,5 +1,5 @@ /* - * «Copyright 2013 Jose F. Maldonado» + * * * This file is part of aFileDialog. * diff --git a/library/src/ar/com/daidalos/afiledialog/view/FileItem.java b/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/view/FileItem.java similarity index 99% rename from library/src/ar/com/daidalos/afiledialog/view/FileItem.java rename to demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/view/FileItem.java index ec9f476..7aadce3 100644 --- a/library/src/ar/com/daidalos/afiledialog/view/FileItem.java +++ b/demo/aFileDialog/src/main/java/ar/com/daidalos/afiledialog/view/FileItem.java @@ -1,5 +1,5 @@ /* - * «Copyright 2013 Jose F. Maldonado» + * * * This file is part of aFileDialog. * diff --git a/library/res/drawable-hdpi/add.png b/demo/aFileDialog/src/main/res/drawable-hdpi/add.png similarity index 100% rename from library/res/drawable-hdpi/add.png rename to demo/aFileDialog/src/main/res/drawable-hdpi/add.png diff --git a/library/res/drawable-hdpi/document.png b/demo/aFileDialog/src/main/res/drawable-hdpi/document.png similarity index 100% rename from library/res/drawable-hdpi/document.png rename to demo/aFileDialog/src/main/res/drawable-hdpi/document.png diff --git a/library/res/drawable-hdpi/document_gray.png b/demo/aFileDialog/src/main/res/drawable-hdpi/document_gray.png similarity index 100% rename from library/res/drawable-hdpi/document_gray.png rename to demo/aFileDialog/src/main/res/drawable-hdpi/document_gray.png diff --git a/library/res/drawable-hdpi/folder.png b/demo/aFileDialog/src/main/res/drawable-hdpi/folder.png similarity index 100% rename from library/res/drawable-hdpi/folder.png rename to demo/aFileDialog/src/main/res/drawable-hdpi/folder.png diff --git a/library/res/drawable-hdpi/ic_launcher.png b/demo/aFileDialog/src/main/res/drawable-hdpi/ic_launcher.png similarity index 100% rename from library/res/drawable-hdpi/ic_launcher.png rename to demo/aFileDialog/src/main/res/drawable-hdpi/ic_launcher.png diff --git a/library/res/drawable-hdpi/no.png b/demo/aFileDialog/src/main/res/drawable-hdpi/no.png similarity index 100% rename from library/res/drawable-hdpi/no.png rename to demo/aFileDialog/src/main/res/drawable-hdpi/no.png diff --git a/library/res/drawable-hdpi/tick.png b/demo/aFileDialog/src/main/res/drawable-hdpi/tick.png similarity index 100% rename from library/res/drawable-hdpi/tick.png rename to demo/aFileDialog/src/main/res/drawable-hdpi/tick.png diff --git a/library/res/drawable-ldpi/add.png b/demo/aFileDialog/src/main/res/drawable-ldpi/add.png similarity index 100% rename from library/res/drawable-ldpi/add.png rename to demo/aFileDialog/src/main/res/drawable-ldpi/add.png diff --git a/library/res/drawable-ldpi/document.png b/demo/aFileDialog/src/main/res/drawable-ldpi/document.png similarity index 100% rename from library/res/drawable-ldpi/document.png rename to demo/aFileDialog/src/main/res/drawable-ldpi/document.png diff --git a/library/res/drawable-ldpi/document_gray.png b/demo/aFileDialog/src/main/res/drawable-ldpi/document_gray.png similarity index 100% rename from library/res/drawable-ldpi/document_gray.png rename to demo/aFileDialog/src/main/res/drawable-ldpi/document_gray.png diff --git a/library/res/drawable-ldpi/folder.png b/demo/aFileDialog/src/main/res/drawable-ldpi/folder.png similarity index 100% rename from library/res/drawable-ldpi/folder.png rename to demo/aFileDialog/src/main/res/drawable-ldpi/folder.png diff --git a/library/res/drawable-ldpi/ic_launcher.png b/demo/aFileDialog/src/main/res/drawable-ldpi/ic_launcher.png similarity index 100% rename from library/res/drawable-ldpi/ic_launcher.png rename to demo/aFileDialog/src/main/res/drawable-ldpi/ic_launcher.png diff --git a/library/res/drawable-ldpi/no.png b/demo/aFileDialog/src/main/res/drawable-ldpi/no.png similarity index 100% rename from library/res/drawable-ldpi/no.png rename to demo/aFileDialog/src/main/res/drawable-ldpi/no.png diff --git a/library/res/drawable-ldpi/tick.png b/demo/aFileDialog/src/main/res/drawable-ldpi/tick.png similarity index 100% rename from library/res/drawable-ldpi/tick.png rename to demo/aFileDialog/src/main/res/drawable-ldpi/tick.png diff --git a/library/res/drawable-mdpi/add.png b/demo/aFileDialog/src/main/res/drawable-mdpi/add.png similarity index 100% rename from library/res/drawable-mdpi/add.png rename to demo/aFileDialog/src/main/res/drawable-mdpi/add.png diff --git a/library/res/drawable-mdpi/document.png b/demo/aFileDialog/src/main/res/drawable-mdpi/document.png similarity index 100% rename from library/res/drawable-mdpi/document.png rename to demo/aFileDialog/src/main/res/drawable-mdpi/document.png diff --git a/library/res/drawable-mdpi/document_gray.png b/demo/aFileDialog/src/main/res/drawable-mdpi/document_gray.png similarity index 100% rename from library/res/drawable-mdpi/document_gray.png rename to demo/aFileDialog/src/main/res/drawable-mdpi/document_gray.png diff --git a/library/res/drawable-mdpi/folder.png b/demo/aFileDialog/src/main/res/drawable-mdpi/folder.png similarity index 100% rename from library/res/drawable-mdpi/folder.png rename to demo/aFileDialog/src/main/res/drawable-mdpi/folder.png diff --git a/library/res/drawable-mdpi/ic_launcher.png b/demo/aFileDialog/src/main/res/drawable-mdpi/ic_launcher.png similarity index 100% rename from library/res/drawable-mdpi/ic_launcher.png rename to demo/aFileDialog/src/main/res/drawable-mdpi/ic_launcher.png diff --git a/library/res/drawable-mdpi/no.png b/demo/aFileDialog/src/main/res/drawable-mdpi/no.png similarity index 100% rename from library/res/drawable-mdpi/no.png rename to demo/aFileDialog/src/main/res/drawable-mdpi/no.png diff --git a/library/res/drawable-mdpi/tick.png b/demo/aFileDialog/src/main/res/drawable-mdpi/tick.png similarity index 100% rename from library/res/drawable-mdpi/tick.png rename to demo/aFileDialog/src/main/res/drawable-mdpi/tick.png diff --git a/library/res/layout/daidalos_file_chooser.xml b/demo/aFileDialog/src/main/res/layout/daidalos_file_chooser.xml similarity index 100% rename from library/res/layout/daidalos_file_chooser.xml rename to demo/aFileDialog/src/main/res/layout/daidalos_file_chooser.xml diff --git a/library/res/layout/daidalos_file_item.xml b/demo/aFileDialog/src/main/res/layout/daidalos_file_item.xml similarity index 100% rename from library/res/layout/daidalos_file_item.xml rename to demo/aFileDialog/src/main/res/layout/daidalos_file_item.xml diff --git a/library/res/values-en/strings.xml b/demo/aFileDialog/src/main/res/values-en/strings.xml similarity index 100% rename from library/res/values-en/strings.xml rename to demo/aFileDialog/src/main/res/values-en/strings.xml diff --git a/library/res/values-es/strings.xml b/demo/aFileDialog/src/main/res/values-es/strings.xml similarity index 100% rename from library/res/values-es/strings.xml rename to demo/aFileDialog/src/main/res/values-es/strings.xml diff --git a/library/res/values-fr/strings.xml b/demo/aFileDialog/src/main/res/values-fr/strings.xml similarity index 100% rename from library/res/values-fr/strings.xml rename to demo/aFileDialog/src/main/res/values-fr/strings.xml diff --git a/library/res/values/strings.xml b/demo/aFileDialog/src/main/res/values/strings.xml similarity index 100% rename from library/res/values/strings.xml rename to demo/aFileDialog/src/main/res/values/strings.xml diff --git a/demo/aFileDialogTesting/aFileDialogTesting.iml b/demo/aFileDialogTesting/aFileDialogTesting.iml new file mode 100644 index 0000000..5b70629 --- /dev/null +++ b/demo/aFileDialogTesting/aFileDialogTesting.iml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demo/aFileDialogTesting/build.gradle b/demo/aFileDialogTesting/build.gradle new file mode 100644 index 0000000..2f594a4 --- /dev/null +++ b/demo/aFileDialogTesting/build.gradle @@ -0,0 +1,27 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 10 + buildToolsVersion "22.0.1" + + defaultConfig { + applicationId "ar.com.daidalos.afiledialog.test" + minSdkVersion 8 + targetSdkVersion 19 + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_5 + targetCompatibility JavaVersion.VERSION_1_5 + } + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + } +} + +dependencies { + compile project(':aFileDialog') +} diff --git a/demo/aFileDialogTesting/lint.xml b/demo/aFileDialogTesting/lint.xml new file mode 100644 index 0000000..8423c0e --- /dev/null +++ b/demo/aFileDialogTesting/lint.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/demo/AndroidManifest.xml b/demo/aFileDialogTesting/src/main/AndroidManifest.xml similarity index 90% rename from demo/AndroidManifest.xml rename to demo/aFileDialogTesting/src/main/AndroidManifest.xml index 7eb6ce4..c94ffb2 100644 --- a/demo/AndroidManifest.xml +++ b/demo/aFileDialogTesting/src/main/AndroidManifest.xml @@ -9,8 +9,7 @@ + android:icon="@drawable/ic_launcher" > diff --git a/demo/src/ar/com/daidalos/afiledialog/test/AFileDialogTestingActivity.java b/demo/aFileDialogTesting/src/main/java/ar/com/daidalos/afiledialog/test/AFileDialogTestingActivity.java similarity index 99% rename from demo/src/ar/com/daidalos/afiledialog/test/AFileDialogTestingActivity.java rename to demo/aFileDialogTesting/src/main/java/ar/com/daidalos/afiledialog/test/AFileDialogTestingActivity.java index fb2589e..b94daab 100644 --- a/demo/src/ar/com/daidalos/afiledialog/test/AFileDialogTestingActivity.java +++ b/demo/aFileDialogTesting/src/main/java/ar/com/daidalos/afiledialog/test/AFileDialogTestingActivity.java @@ -1,5 +1,5 @@ /* - * «Copyright 2013 Jose F. Maldonado» + * * * This file is part of aFileDialog. * diff --git a/demo/res/drawable-hdpi/ic_launcher.png b/demo/aFileDialogTesting/src/main/res/drawable-hdpi/ic_launcher.png similarity index 100% rename from demo/res/drawable-hdpi/ic_launcher.png rename to demo/aFileDialogTesting/src/main/res/drawable-hdpi/ic_launcher.png diff --git a/demo/res/drawable-ldpi/ic_launcher.png b/demo/aFileDialogTesting/src/main/res/drawable-ldpi/ic_launcher.png similarity index 100% rename from demo/res/drawable-ldpi/ic_launcher.png rename to demo/aFileDialogTesting/src/main/res/drawable-ldpi/ic_launcher.png diff --git a/demo/res/drawable-mdpi/ic_launcher.png b/demo/aFileDialogTesting/src/main/res/drawable-mdpi/ic_launcher.png similarity index 100% rename from demo/res/drawable-mdpi/ic_launcher.png rename to demo/aFileDialogTesting/src/main/res/drawable-mdpi/ic_launcher.png diff --git a/demo/res/layout/main.xml b/demo/aFileDialogTesting/src/main/res/layout/main.xml similarity index 100% rename from demo/res/layout/main.xml rename to demo/aFileDialogTesting/src/main/res/layout/main.xml diff --git a/demo/res/values-en/strings.xml b/demo/aFileDialogTesting/src/main/res/values-en/strings.xml similarity index 100% rename from demo/res/values-en/strings.xml rename to demo/aFileDialogTesting/src/main/res/values-en/strings.xml diff --git a/demo/res/values-es/strings.xml b/demo/aFileDialogTesting/src/main/res/values-es/strings.xml similarity index 100% rename from demo/res/values-es/strings.xml rename to demo/aFileDialogTesting/src/main/res/values-es/strings.xml diff --git a/demo/res/values-fr/strings.xml b/demo/aFileDialogTesting/src/main/res/values-fr/strings.xml similarity index 100% rename from demo/res/values-fr/strings.xml rename to demo/aFileDialogTesting/src/main/res/values-fr/strings.xml diff --git a/demo/res/values/strings.xml b/demo/aFileDialogTesting/src/main/res/values/strings.xml similarity index 100% rename from demo/res/values/strings.xml rename to demo/aFileDialogTesting/src/main/res/values/strings.xml diff --git a/demo/build.gradle b/demo/build.gradle new file mode 100644 index 0000000..01de6ef --- /dev/null +++ b/demo/build.gradle @@ -0,0 +1,15 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:1.2.2' + } +} + +allprojects { + repositories { + jcenter() + } +} diff --git a/demo/demo.iml b/demo/demo.iml new file mode 100644 index 0000000..f914fec --- /dev/null +++ b/demo/demo.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demo/gradle/wrapper/gradle-wrapper.jar b/demo/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..8c0fb64 Binary files /dev/null and b/demo/gradle/wrapper/gradle-wrapper.jar differ diff --git a/demo/gradle/wrapper/gradle-wrapper.properties b/demo/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..0c71e76 --- /dev/null +++ b/demo/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Apr 10 15:27:10 PDT 2013 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip diff --git a/demo/gradlew b/demo/gradlew new file mode 100644 index 0000000..91a7e26 --- /dev/null +++ b/demo/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +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 + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# 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\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +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 + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + 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. + +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" + 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\"" +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"` + + # 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 + 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 +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/demo/gradlew.bat b/demo/gradlew.bat new file mode 100644 index 0000000..8a0b282 --- /dev/null +++ b/demo/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@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 Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz 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. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +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 + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/demo/import-summary.txt b/demo/import-summary.txt new file mode 100644 index 0000000..df8452a --- /dev/null +++ b/demo/import-summary.txt @@ -0,0 +1,57 @@ +ECLIPSE ANDROID PROJECT IMPORT SUMMARY +====================================== + +Manifest Merging: +----------------- +Your project uses libraries that provide manifests, and your Eclipse +project did not explicitly turn on manifest merging. In Android Gradle +projects, manifests are always merged (meaning that contents from your +libraries' manifests will be merged into the app manifest. If you had +manually copied contents from library manifests into your app manifest +you may need to remove these for the app to build correctly. + +Ignored Files: +-------------- +The following files were *not* copied into the new Gradle project; you +should evaluate whether these are still needed in your project and if +so manually move them: + +From aFileDialog: +* lgpl-3.0.txt +* proguard.cfg +From aFileDialogTesting: +* lgpl-3.0.txt +* proguard.cfg + +Moved Files: +------------ +Android Gradle projects use a different directory structure than ADT +Eclipse projects. Here's how the projects were restructured: + +In aFileDialog: +* AndroidManifest.xml => aFileDialog\src\main\AndroidManifest.xml +* assets\ => aFileDialog\src\main\assets +* lint.xml => aFileDialog\lint.xml +* res\ => aFileDialog\src\main\res\ +* src\ => aFileDialog\src\main\java\ +In aFileDialogTesting: +* AndroidManifest.xml => aFileDialogTesting\src\main\AndroidManifest.xml +* assets\ => aFileDialogTesting\src\main\assets +* lint.xml => aFileDialogTesting\lint.xml +* res\ => aFileDialogTesting\src\main\res\ +* src\ => aFileDialogTesting\src\main\java\ + +Next Steps: +----------- +You can now build the project. The Gradle project needs network +connectivity to download dependencies. + +Bugs: +----- +If for some reason your project does not build, and you determine that +it is due to a bug or limitation of the Eclipse to Gradle importer, +please file a bug at http://b.android.com with category +Component-Tools. + +(This import summary is for your information only, and can be deleted +after import once you are satisfied with the results.) diff --git a/demo/lgpl-3.0.txt b/demo/lgpl-3.0.txt deleted file mode 100644 index 02bbb60..0000000 --- a/demo/lgpl-3.0.txt +++ /dev/null @@ -1,165 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. \ No newline at end of file diff --git a/demo/lint.xml b/demo/lint.xml deleted file mode 100644 index ee0eead..0000000 --- a/demo/lint.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/demo/proguard.cfg b/demo/proguard.cfg deleted file mode 100644 index b1cdf17..0000000 --- a/demo/proguard.cfg +++ /dev/null @@ -1,40 +0,0 @@ --optimizationpasses 5 --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --dontpreverify --verbose --optimizations !code/simplification/arithmetic,!field/*,!class/merging/* - --keep public class * extends android.app.Activity --keep public class * extends android.app.Application --keep public class * extends android.app.Service --keep public class * extends android.content.BroadcastReceiver --keep public class * extends android.content.ContentProvider --keep public class * extends android.app.backup.BackupAgentHelper --keep public class * extends android.preference.Preference --keep public class com.android.vending.licensing.ILicensingService - --keepclasseswithmembernames class * { - native ; -} - --keepclasseswithmembers class * { - public (android.content.Context, android.util.AttributeSet); -} - --keepclasseswithmembers class * { - public (android.content.Context, android.util.AttributeSet, int); -} - --keepclassmembers class * extends android.app.Activity { - public void *(android.view.View); -} - --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} diff --git a/demo/project.properties b/demo/project.properties deleted file mode 100644 index 3afd61d..0000000 --- a/demo/project.properties +++ /dev/null @@ -1,12 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-10 -android.library.reference.1=../library diff --git a/demo/settings.gradle b/demo/settings.gradle new file mode 100644 index 0000000..973cfeb --- /dev/null +++ b/demo/settings.gradle @@ -0,0 +1,2 @@ +include ':aFileDialog' +include ':aFileDialogTesting' diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 6b33844..c7ff070 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -21,7 +21,7 @@ In order to use _aFileDialog_ in your application you must do three steps: ``` -You can check the [Android documentation](http://developer.android.com/tools/projects/projects-eclipse.html) in order to get more information about how to reference a library project and how to declare an activity in the manifest file. +You can check the [Android documentation](https://developer.android.com/sdk/installing/create-project.html#ReferencingLibraryModule) in order to get more information about how to reference a library project and how to declare an activity in the manifest file. ### 1.2. Show the dialog diff --git a/docs/UserGuideEs.md b/docs/UserGuideEs.md index ef47cdd..67c1e7f 100644 --- a/docs/UserGuideEs.md +++ b/docs/UserGuideEs.md @@ -21,7 +21,7 @@ Para hacer uso de _aFileDialog_ en una aplicación se deben completar los siguie ``` -Más información sobre como referenciar un proyecto de una librería y como declarar una actividad en el archivo manifiesto se puede encontrar en la [documentación oficial de Android](http://developer.android.com/tools/projects/projects-eclipse.html). +Más información sobre como referenciar un proyecto de una librería y como declarar una actividad en el archivo manifiesto se puede encontrar en la [documentación oficial de Android](https://developer.android.com/sdk/installing/create-project.html#ReferencingLibraryModule). ### 1.2. Mostrar el selector de archivos diff --git a/docs/UserGuideFr.md b/docs/UserGuideFr.md index 7c8cfd7..fc6181a 100644 --- a/docs/UserGuideFr.md +++ b/docs/UserGuideFr.md @@ -21,7 +21,7 @@ Pour utiliser _aFileDialog_, dans votre logiciel, il faut suivre les suivants pa ``` -Pour plus d'information sur comment faire une référence à un projet de librairie et comment déclarer une activité dans le fichier de manifeste, vous pouvez lire la [documentation officielle d'Android](http://developer.android.com/tools/projects/projects-eclipse.html). +Pour plus d'information sur comment faire une référence à un projet de librairie et comment déclarer une activité dans le fichier de manifeste, vous pouvez lire la [documentation officielle d'Android](https://developer.android.com/sdk/installing/create-project.html#ReferencingLibraryModule). ### 1.2. Afficher le sélecteur de fichiers diff --git a/library/.classpath b/library/.classpath deleted file mode 100644 index 5176974..0000000 --- a/library/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/library/.gradle/2.2.1/taskArtifacts/cache.properties b/library/.gradle/2.2.1/taskArtifacts/cache.properties new file mode 100644 index 0000000..40b5a0d --- /dev/null +++ b/library/.gradle/2.2.1/taskArtifacts/cache.properties @@ -0,0 +1 @@ +#Fri May 08 10:54:50 UTC 2015 diff --git a/library/.gradle/2.2.1/taskArtifacts/cache.properties.lock b/library/.gradle/2.2.1/taskArtifacts/cache.properties.lock new file mode 100644 index 0000000..913bdf6 Binary files /dev/null and b/library/.gradle/2.2.1/taskArtifacts/cache.properties.lock differ diff --git a/library/.gradle/2.2.1/taskArtifacts/fileHashes.bin b/library/.gradle/2.2.1/taskArtifacts/fileHashes.bin new file mode 100644 index 0000000..649023a Binary files /dev/null and b/library/.gradle/2.2.1/taskArtifacts/fileHashes.bin differ diff --git a/library/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin b/library/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin new file mode 100644 index 0000000..31aae8c Binary files /dev/null and b/library/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin differ diff --git a/library/.gradle/2.2.1/taskArtifacts/outputFileStates.bin b/library/.gradle/2.2.1/taskArtifacts/outputFileStates.bin new file mode 100644 index 0000000..c47d03e Binary files /dev/null and b/library/.gradle/2.2.1/taskArtifacts/outputFileStates.bin differ diff --git a/library/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin b/library/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin new file mode 100644 index 0000000..2419888 Binary files /dev/null and b/library/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin differ diff --git a/library/.project b/library/.project deleted file mode 100644 index bf20802..0000000 --- a/library/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - aFileDialog - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/library/.settings/com.google.appengine.eclipse.core.prefs b/library/.settings/com.google.appengine.eclipse.core.prefs deleted file mode 100644 index 18d29bb..0000000 --- a/library/.settings/com.google.appengine.eclipse.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -#Tue Apr 09 09:30:52 UTC 2013 -eclipse.preferences.version=1 -googleCloudSqlEnabled=false -localDevMySqlEnabled=true diff --git a/library/.settings/com.google.gdt.eclipse.core.prefs b/library/.settings/com.google.gdt.eclipse.core.prefs deleted file mode 100644 index 4415d82..0000000 --- a/library/.settings/com.google.gdt.eclipse.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -#Tue Apr 09 09:30:52 UTC 2013 -eclipse.preferences.version=1 -jarsExcludedFromWebInfLib= -warSrcDir= -warSrcDirIsOutput=true diff --git a/library/.settings/org.eclipse.jdt.core.prefs b/library/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index c0b739a..0000000 --- a/library/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -#Tue Apr 09 09:30:52 UTC 2013 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.5 diff --git a/library/.settings/org.eclipse.ltk.core.refactoring.prefs b/library/.settings/org.eclipse.ltk.core.refactoring.prefs deleted file mode 100644 index e62a0fb..0000000 --- a/library/.settings/org.eclipse.ltk.core.refactoring.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Thu Apr 25 10:13:08 UTC 2013 -eclipse.preferences.version=1 -org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false diff --git a/library/aFileDialog.iml b/library/aFileDialog.iml new file mode 100644 index 0000000..397f459 --- /dev/null +++ b/library/aFileDialog.iml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/library/app/aFileDialog.iml b/library/app/aFileDialog.iml new file mode 100644 index 0000000..47dd270 --- /dev/null +++ b/library/app/aFileDialog.iml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/library/app/build.gradle b/library/app/build.gradle new file mode 100644 index 0000000..e6e4bff --- /dev/null +++ b/library/app/build.gradle @@ -0,0 +1,22 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 10 + buildToolsVersion "22.0.1" + + defaultConfig { + minSdkVersion 8 + targetSdkVersion 8 + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_5 + targetCompatibility JavaVersion.VERSION_1_5 + } + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' + } + } +} diff --git a/library/app/lint.xml b/library/app/lint.xml new file mode 100644 index 0000000..8423c0e --- /dev/null +++ b/library/app/lint.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/library/app/src/main/AndroidManifest.xml b/library/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..1618fd1 --- /dev/null +++ b/library/app/src/main/AndroidManifest.xml @@ -0,0 +1,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooser.java b/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooser.java new file mode 100644 index 0000000..b3bba7d --- /dev/null +++ b/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooser.java @@ -0,0 +1,50 @@ +/* + * + * + * This file is part of aFileDialog. + * + * aFileDialog is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * aFileDialog is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with aFileDialog. If not, see . + */ + +package ar.com.daidalos.afiledialog; + +import android.content.Context; +import android.widget.LinearLayout; + +/** + * This interface defines all the methods that a file chooser must implement, in order to being able to make use of the class FileChooserUtils. + */ +interface FileChooser { + + /** + * Gets the root of the layout 'file_chooser.xml'. + * + * @return A linear layout. + */ + LinearLayout getRootLayout(); + + /** + * Set the name of the current folder. + * + * @param name The current folder's name. + */ + void setCurrentFolderName(String name); + + /** + * Returns the current context of the file chooser. + * + * @return The current context. + */ + Context getContext(); +} diff --git a/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooserActivity.java b/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooserActivity.java new file mode 100644 index 0000000..d4c462f --- /dev/null +++ b/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooserActivity.java @@ -0,0 +1,227 @@ +/* + * + * + * This file is part of aFileDialog. + * + * aFileDialog is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * aFileDialog is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with aFileDialog. If not, see . + */ + +package ar.com.daidalos.afiledialog; + +import java.io.File; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.LinearLayout; +import ar.com.daidalos.afiledialog.R; + +/** + * A file chooser implemented in an Activity. + */ +public class FileChooserActivity extends Activity implements FileChooser { + + // ----- Fields ----- // + + /** + * The folder that the class opened by default. + */ + private File startFolder; + + /** + * The core of the file chooser. + */ + private FileChooserCore core; + + /** + * A boolean indicating if the 'back' button must be used to navigate to parent folders. + */ + private boolean useBackButton; + + // ----- Constants ----- // + + /** + * Constant used for represent the key of the bundle object (inside the start's intent) which contains the + * path of the folder which files are going to be listed. + */ + public static final String INPUT_START_FOLDER = "input_start_folder"; + + /** + * Constant used for represent the key of the bundle object (inside the start's intent) which contains + * a boolean that indicates if the user is going to select folders instead of select files. + */ + public static final String INPUT_FOLDER_MODE = "input_folder_mode"; + + /** + * Constant used for represent the key of the bundle object (inside the start's intent) which contains + * a boolean that indicates if the user can create files. + */ + public static final String INPUT_CAN_CREATE_FILES = "input_can_create_files"; + + /** + * Constant used for represent the key of the bundle object (inside the start's intent) which contains + * a regular expression which is going to be used as a filter to determine which files can be selected. + */ + public static final String INPUT_REGEX_FILTER = "input_regex_filter"; + + /** + * Constant used for represent the key of the bundle object (inside the start's intent) which contains + * a boolean that indicates if only the files that can be selected must be displayed. + */ + public static final String INPUT_SHOW_ONLY_SELECTABLE = "input_show_only_selectable"; + + /** + * Constant used for represent the key of the bundle object (inside the start's intent) which contains + * an instance of the class FileChooserLabels that allows to override the default value of the labels. + */ + public static final String INPUT_LABELS = "input_labels"; + + /** + * Constant used for represent the key of the bundle object (inside the start's intent) which contains + * a boolean that indicates if a confirmation dialog must be displayed when creating a file. + */ + public static final String INPUT_SHOW_CONFIRMATION_ON_CREATE = "input_show_confirmation_on_create"; + + /** + * Constant used for represent the key of the bundle object (inside the start's intent) which contains + * a boolean that indicates if a confirmation dialog must be displayed when selecting a file. + */ + public static final String INPUT_SHOW_CONFIRMATION_ON_SELECT = "input_show_confirmation_on_select"; + + /** + * Constant used for represent the key of the bundle object (inside the start's intent) which contains + * a boolean that indicates if the title must show the full path of the current's folder (true) or only + * the folder's name (false). + */ + public static final String INPUT_SHOW_FULL_PATH_IN_TITLE = "input_show_full_path_in_title"; + + /** + * Constant used for represent the key of the bundle object (inside the start's intent) which contains + * a boolean that indicates if the 'Back' button must be used to navigate to the parents folder (true) or + * if must follow the default behavior (and close the activity when the button is pressed). + */ + public static final String INPUT_USE_BACK_BUTTON_TO_NAVIGATE = "input_use_back_button_to_navigate"; + + /** + * Constant used for represent the key of the bundle object (inside the result's intent) which contains the + * File object, that represents the file selected by the user or the folder in which the user wants to create + * a file. + */ + public static final String OUTPUT_FILE_OBJECT = "output_file_object"; + + /** + * Constant used for represent the key of the bundle object (inside the result's intent) which contains the + * name of the file that the user wants to create. + */ + public static final String OUTPUT_NEW_FILE_NAME = "output_new_file_name"; + + // ---- Activity methods ----- // + + /** Called when the activity is first created. */ + @Override + public void onCreate(Bundle savedInstanceState) { + // Call superclass creator. + super.onCreate(savedInstanceState); + + // Set layout. + this.setContentView(R.layout.daidalos_file_chooser); + + // Set the background color. + LinearLayout layout = (LinearLayout) this.findViewById(R.id.rootLayout); + layout.setBackgroundColor(getResources().getColor(R.color.daidalos_backgroud)); + + // Initialize fields. + this.useBackButton = false; + + // Create the core of the file chooser. + this.core = new FileChooserCore(this); + + // Verify if the optional parameters has been defined. + String folderPath = null; + Bundle extras = this.getIntent().getExtras(); + if(extras != null) { + if(extras.containsKey(INPUT_START_FOLDER)) folderPath = extras.getString(INPUT_START_FOLDER); + if(extras.containsKey(INPUT_REGEX_FILTER)) core.setFilter(extras.getString(INPUT_REGEX_FILTER)); + if(extras.containsKey(INPUT_SHOW_ONLY_SELECTABLE)) core.setShowOnlySelectable(extras.getBoolean(INPUT_SHOW_ONLY_SELECTABLE)); + if(extras.containsKey(INPUT_FOLDER_MODE)) core.setFolderMode(extras.getBoolean(INPUT_FOLDER_MODE)); + if(extras.containsKey(INPUT_CAN_CREATE_FILES)) core.setCanCreateFiles(extras.getBoolean(INPUT_CAN_CREATE_FILES)); + if(extras.containsKey(INPUT_LABELS)) core.setLabels((FileChooserLabels) extras.get(INPUT_LABELS)); + if(extras.containsKey(INPUT_SHOW_CONFIRMATION_ON_CREATE)) core.setShowConfirmationOnCreate(extras.getBoolean(INPUT_SHOW_CONFIRMATION_ON_CREATE)); + if(extras.containsKey(INPUT_SHOW_CONFIRMATION_ON_SELECT)) core.setShowConfirmationOnSelect(extras.getBoolean(INPUT_SHOW_CONFIRMATION_ON_SELECT)); + if(extras.containsKey(INPUT_SHOW_FULL_PATH_IN_TITLE)) core.setShowFullPathInTitle(extras.getBoolean(INPUT_SHOW_FULL_PATH_IN_TITLE)); + if(extras.containsKey(INPUT_USE_BACK_BUTTON_TO_NAVIGATE)) this.useBackButton = extras.getBoolean(INPUT_USE_BACK_BUTTON_TO_NAVIGATE); + } + + // Load the files of a folder. + core.loadFolder(folderPath); + this.startFolder = this.core.getCurrentFolder(); + + // Add a listener for when a file is selected. + core.addListener(new FileChooserCore.OnFileSelectedListener() { + public void onFileSelected(File folder, String name) { + // Pass the data through an intent. + Intent intent = new Intent(); + Bundle bundle = new Bundle(); + bundle.putSerializable(OUTPUT_FILE_OBJECT, folder); + bundle.putString(OUTPUT_NEW_FILE_NAME, name); + intent.putExtras(bundle); + + setResult(RESULT_OK, intent); + finish(); + } + public void onFileSelected(File file) { + // Pass the data through an intent. + Intent intent = new Intent(); + Bundle bundle = new Bundle(); + bundle.putSerializable(OUTPUT_FILE_OBJECT, file); + intent.putExtras(bundle); + + setResult(RESULT_OK, intent); + finish(); + } + }); + } + + /** Called when the user push the 'back' button. */ + @Override + public void onBackPressed() { + // Verify if the activity must be finished or if the parent folder must be opened. + File current = this.core.getCurrentFolder(); + if(!this.useBackButton || current == null || current.getParent() == null || current.getPath().compareTo(this.startFolder.getPath()) == 0) { + // Close activity. + super.onBackPressed(); + }else{ + // Open parent. + this.core.loadFolder(current.getParent()); + } + } + + // ----- FileChooser methods ----- // + + public LinearLayout getRootLayout() { + View root = this.findViewById(R.id.rootLayout); + return (root instanceof LinearLayout)? (LinearLayout)root : null; + } + + public Context getContext() { + //return this.getBaseContext(); + return this; + } + + public void setCurrentFolderName(String name) { + this.setTitle(name); + } +} diff --git a/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooserCore.java b/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooserCore.java new file mode 100644 index 0000000..f233e88 --- /dev/null +++ b/library/app/src/main/java/ar/com/daidalos/afiledialog/FileChooserCore.java @@ -0,0 +1,605 @@ +/* + * + * + * This file is part of aFileDialog. + * + * aFileDialog is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * aFileDialog is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with aFileDialog. If not, see . + */ + +package ar.com.daidalos.afiledialog; + +import java.io.*; +import java.util.Arrays; +import java.util.Comparator; +import java.util.LinkedList; +import java.util.List; + +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.os.Environment; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; +import android.widget.EditText; +import android.widget.LinearLayout; +import ar.com.daidalos.afiledialog.view.FileItem; + +/** + * This class implements the common features of a file chooser. + */ +class FileChooserCore { + + // ----- Attributes ----- // + + /** + * The file chooser in which all the operations are performed. + */ + private FileChooser chooser; + + /** + * The listeners for the event of select a file. + */ + private List listeners; + + /** + * A regular expression for filter the files. + */ + private String filter; + + /** + * A boolean indicating if only the files that can be selected (they pass the filter) must be show. + */ + private boolean showOnlySelectable; + + /** + * A boolean indicating if the user can create files. + */ + private boolean canCreateFiles; + + /** + * A boolean indicating if the chooser is going to be used to select folders. + */ + private boolean folderMode; + + /** + * A file that indicates the folder that is currently being displayed. + */ + private File currentFolder; + + /** + * This attribut allows to override the default value of the labels. + */ + private FileChooserLabels labels; + + /** + * A boolean that indicates if a confirmation dialog must be displaying when selecting a file. + */ + private boolean showConfirmationOnSelect; + + /** + * A boolean that indicates if a confirmation dialog must be displaying when creating a file. + */ + private boolean showConfirmationOnCreate; + + /** + * A boolean indicating if the folder's full path must be show in the title. + */ + private boolean showFullPathInTitle; + + // ---- Static attributes ----- // + + /** + * Static attribute for save the folder displayed by default. + */ + private static File defaultFolder; + + /** + * Static constructor. + */ + static { + defaultFolder = null; + } + + // ----- Constructor ----- // + + /** + * Creates an instance of this class. + * + * @param fileChooser The graphical file chooser. + */ + public FileChooserCore(FileChooser fileChooser) { + // Initialize attributes. + this.chooser = fileChooser; + this.listeners = new LinkedList(); + this.filter = null; + this.showOnlySelectable = false; + this.setCanCreateFiles(false); + this.setFolderMode(false); + this.currentFolder = null; + this.labels = null; + this.showConfirmationOnCreate = false; + this.showConfirmationOnSelect = false; + this.showFullPathInTitle = false; + + // Add listener for the buttons. + LinearLayout root = this.chooser.getRootLayout(); + Button addButton = (Button) root.findViewById(R.id.buttonAdd); + addButton.setOnClickListener(addButtonClickListener); + Button okButton = (Button) root.findViewById(R.id.buttonOk); + okButton.setOnClickListener(okButtonClickListener); + } + + // ----- Events methods ----- // + + /** + * Implementation of the click listener for when the add button is clicked. + */ + private View.OnClickListener addButtonClickListener = new View.OnClickListener() { + public void onClick(View v) { + // Get the current context. + Context context = v.getContext(); + + // Create an alert dialog. + AlertDialog.Builder alert = new AlertDialog.Builder(context); + + // Define the dialog's labels. + String title = context.getString(FileChooserCore.this.folderMode? R.string.daidalos_create_folder : R.string.daidalos_create_file); + if(FileChooserCore.this.labels != null && FileChooserCore.this.labels.createFileDialogTitle != null) title = FileChooserCore.this.labels.createFileDialogTitle; + String message = context.getString(FileChooserCore.this.folderMode? R.string.daidalos_enter_folder_name : R.string.daidalos_enter_file_name); + if(FileChooserCore.this.labels != null && FileChooserCore.this.labels.createFileDialogMessage != null) message = FileChooserCore.this.labels.createFileDialogMessage; + String posButton = (FileChooserCore.this.labels != null && FileChooserCore.this.labels.createFileDialogAcceptButton != null)? FileChooserCore.this.labels.createFileDialogAcceptButton : context.getString(R.string.daidalos_accept); + String negButton = (FileChooserCore.this.labels != null && FileChooserCore.this.labels.createFileDialogCancelButton != null)? FileChooserCore.this.labels.createFileDialogCancelButton : context.getString(R.string.daidalos_cancel); + + // Set the title and the message. + alert.setTitle( title ); + alert.setMessage( message ); + + // Set an EditText view to get the file's name. + final EditText input = new EditText(context); + input.setSingleLine(); + alert.setView(input); + + // Set the 'ok' and 'cancel' buttons. + alert.setPositiveButton(posButton, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + String fileName = input.getText().toString(); + // Verify if a value has been entered. + if(fileName != null && fileName.length() > 0) { + // Notify the listeners. + FileChooserCore.this.notifyListeners(FileChooserCore.this.currentFolder, fileName); + } + } + }); + alert.setNegativeButton(negButton, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + // Do nothing, automatically the dialog is going to be closed. + } + }); + + // Show the dialog. + alert.show(); + } + }; + + /** + * Implementation of the click listener for when the ok button is clicked. + */ + private View.OnClickListener okButtonClickListener = new View.OnClickListener() { + public void onClick(View v) { + // Notify the listeners. + FileChooserCore.this.notifyListeners(FileChooserCore.this.currentFolder, null); + } + }; + + /** + * Implementation of the click listener for when a file item is clicked. + */ + private FileItem.OnFileClickListener fileItemClickListener = new FileItem.OnFileClickListener() { + public void onClick(FileItem source) { + // Verify if the item is a folder. + File file = source.getFile(); + if(file.isDirectory()) { + // Open the folder. + FileChooserCore.this.loadFolder(file); + } else { + // Notify the listeners. + FileChooserCore.this.notifyListeners(file, null); + } + } + }; + + /** + * Add a listener for the event of a file selected. + * + * @param listener The listener to add. + */ + public void addListener(OnFileSelectedListener listener) { + this.listeners.add(listener); + } + + /** + * Removes a listener for the event of a file selected. + * + * @param listener The listener to remove. + */ + public void removeListener(OnFileSelectedListener listener) { + this.listeners.remove(listener); + } + + /** + * Removes all the listeners for the event of a file selected. + */ + public void removeAllListeners() { + this.listeners.clear(); + } + + /** + * Interface definition for a callback to be invoked when a file is selected. + */ + public interface OnFileSelectedListener { + /** + * Called when a file has been selected. + * + * @param file The file selected. + */ + void onFileSelected(File file); + + /** + * Called when an user wants to be create a file. + * + * @param folder The file's parent folder. + * @param name The file's name. + */ + void onFileSelected(File folder, String name); + } + + /** + * Notify to all listeners that a file has been selected or created. + * + * @param file The file or folder selected or the folder in which the file must be created. + * @param name The name of the file that must be created or 'null' if a file was selected (instead of being created). + */ + private void notifyListeners(final File file, final String name) { + // Determine if a file has been selected or created. + final boolean creation = name != null && name.length() > 0; + + // Verify if a confirmation dialog must be show. + if((creation && this.showConfirmationOnCreate || !creation && this.showConfirmationOnSelect)) { + // Create an alert dialog. + Context context = this.chooser.getContext(); + AlertDialog.Builder alert = new AlertDialog.Builder(context); + + // Define the dialog's labels. + String message = null; + if(FileChooserCore.this.labels != null && ((creation && FileChooserCore.this.labels.messageConfirmCreation != null) || (!creation && FileChooserCore.this.labels.messageConfirmSelection != null))) { + message = creation? FileChooserCore.this.labels.messageConfirmCreation : FileChooserCore.this.labels.messageConfirmSelection; + } else { + if(FileChooserCore.this.folderMode) { + message = context.getString(creation? R.string.daidalos_confirm_create_folder : R.string.daidalos_confirm_select_folder); + } else { + message = context.getString(creation? R.string.daidalos_confirm_create_file : R.string.daidalos_confirm_select_file); + } + } + if(message != null) message = message.replace("$file_name", name!=null? name : file.getName()); + String posButton = (FileChooserCore.this.labels != null && FileChooserCore.this.labels.labelConfirmYesButton != null)? FileChooserCore.this.labels.labelConfirmYesButton : context.getString(R.string.daidalos_yes); + String negButton = (FileChooserCore.this.labels != null && FileChooserCore.this.labels.labelConfirmNoButton != null)? FileChooserCore.this.labels.labelConfirmNoButton : context.getString(R.string.daidalos_no); + + // Set the message and the 'yes' and 'no' buttons. + alert.setMessage( message ); + alert.setPositiveButton(posButton, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + // Notify to listeners. + for(int i=0; i 0) { + path = new File(folderPath); + } + + this.loadFolder(path); + } + + /** + * Loads all the files of a folder in the file chooser. + * + * If no path is specified ('folder' is null) the root folder of the SD card is going to be used. + * + * @param folder The folder. + */ + public void loadFolder(File folder) { + // Remove previous files. + LinearLayout root = this.chooser.getRootLayout(); + LinearLayout layout = (LinearLayout) root.findViewById(R.id.linearLayoutFiles); + layout.removeAllViews(); + + // Get the file path. + if(folder == null || !folder.exists()) { + if(defaultFolder != null) { + this.currentFolder = defaultFolder; + } else { + this.currentFolder = Environment.getExternalStorageDirectory(); + } + } else { + this.currentFolder = folder; + } + + // Verify if the path exists. + if(this.currentFolder.exists() && layout != null) { + List fileItems = new LinkedList(); + + // Add the parent folder. + if(this.currentFolder.getParent() != null) { + File parent = new File(this.currentFolder.getParent()); + if(parent.exists()) { + fileItems.add(new FileItem(this.chooser.getContext(), parent, "..")); + } + } + + // Verify if the file is a directory. + if(this.currentFolder.isDirectory()) { + // Get the folder's files. + File[] fileList = this.currentFolder.listFiles(); + if(fileList != null) { + // Order the files alphabetically and separating folders from files. + Arrays.sort(fileList, new Comparator() { + public int compare(File file1, File file2) { + if(file1 != null && file2 != null) { + if(file1.isDirectory() && (!file2.isDirectory())) return -1; + if(file2.isDirectory() && (!file1.isDirectory())) return 1; + return file1.getName().compareTo(file2.getName()); + } + return 0; + } + }); + + // Iterate all the files in the folder. + for(int i=0; i + * + * This file is part of aFileDialog. + * + * aFileDialog is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * aFileDialog is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with aFileDialog. If not, see . + */ + +package ar.com.daidalos.afiledialog; + +import java.io.File; +import java.util.LinkedList; +import java.util.List; + +import ar.com.daidalos.afiledialog.R; + +import android.app.Dialog; +import android.content.Context; +import android.view.View; +import android.view.WindowManager; +import android.widget.LinearLayout; + +/** + * A file chooser implemented in a Dialog. + */ +public class FileChooserDialog extends Dialog implements FileChooser { + + // ----- Attributes ----- // + + /** + * The core of this file chooser. + */ + private FileChooserCore core; + + /** + * The listeners for the event of select a file. + */ + private List listeners; + + // ----- Constructors ----- // + + /** + * Creates a file chooser dialog which, by default, lists all the files in the SD card. + * + * @param context The current context. + */ + public FileChooserDialog(Context context) { + this(context, null); + } + + /** + * Creates a file chooser dialog which lists all the file of a particular folder. + * + * @param context The current context. + * @param folderPath The folder which files are going to be listed. + */ + public FileChooserDialog(Context context, String folderPath) { + // Call superclass constructor. + super(context); + + // Set layout. + this.setContentView(R.layout.daidalos_file_chooser); + + // Maximize the dialog. + WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); + lp.copyFrom(this.getWindow().getAttributes()); + lp.width = WindowManager.LayoutParams.FILL_PARENT; + lp.height = WindowManager.LayoutParams.FILL_PARENT; + this.getWindow().setAttributes(lp); + + // By default, load the SD card files. + this.core = new FileChooserCore(this); + this.core.loadFolder(folderPath); + + // Initialize attributes. + this.listeners = new LinkedList(); + + // Set the background color. + LinearLayout layout = (LinearLayout) this.findViewById(R.id.rootLayout); + layout.setBackgroundColor(context.getResources().getColor(R.color.daidalos_backgroud)); + + // Add a listener for when a file is selected. + core.addListener(new FileChooserCore.OnFileSelectedListener() { + public void onFileSelected(File folder, String name) { + // Call to the listeners. + for(int i=0; i + * + * This file is part of aFileDialog. + * + * aFileDialog is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * aFileDialog is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with aFileDialog. If not, see . + */ + +package ar.com.daidalos.afiledialog; + +import java.io.Serializable; + +/** + * Instances of this classes are used to re-define the value of the labels of a file chooser. + * + * If an attribute is set to null, then the default value is going to be used. + */ +public class FileChooserLabels implements Serializable { + + /** + * Static field required by the interface Serializable. + */ + private static final long serialVersionUID = 1L; + + /** + * Default's constructor. + */ + public FileChooserLabels() { + this.labelAddButton = null; + this.labelSelectButton = null; + this.messageConfirmSelection = null; + this.messageConfirmCreation = null; + this.labelConfirmYesButton = null; + this.labelConfirmNoButton = null; + this.createFileDialogTitle = null; + this.createFileDialogTitle = null; + this.createFileDialogAcceptButton = null; + this.createFileDialogCancelButton = null; + } + + /** + * The label for the button used to create a file or a folder. + */ + public String labelAddButton; + + /** + * The label for the button for select the current folder (when using the file chooser for select folders). + */ + public String labelSelectButton; + + /** + * The message displayed by the confirmation dialog, when selecting a file. + * + * In this string, the character sequence '$file_name' is going to be replace by the file's name. + */ + public String messageConfirmSelection; + + /** + * The message displayed by the confirmation dialog, when creating a file. + * + * In this string, the character sequence '$file_name' is going to be replace by the file's name. + */ + public String messageConfirmCreation; + + /** + * The label for the 'yes' button when confirming the selection o creation of a file. + */ + public String labelConfirmYesButton; + + /** + * The label for the 'no' button when confirming the selection o creation of a file. + */ + public String labelConfirmNoButton; + + /** + * The title of the dialog for create a file. + */ + public String createFileDialogTitle; + + /** + * The message of the dialog for create a file. + */ + public String createFileDialogMessage; + + /** + * The label of the 'accept' button in the dialog for create a file. + */ + public String createFileDialogAcceptButton; + + /** + * The label of the 'cancel' button in the dialog for create a file. + */ + public String createFileDialogCancelButton; +} diff --git a/library/app/src/main/java/ar/com/daidalos/afiledialog/view/FileItem.java b/library/app/src/main/java/ar/com/daidalos/afiledialog/view/FileItem.java new file mode 100644 index 0000000..7aadce3 --- /dev/null +++ b/library/app/src/main/java/ar/com/daidalos/afiledialog/view/FileItem.java @@ -0,0 +1,261 @@ +/* + * + * + * This file is part of aFileDialog. + * + * aFileDialog is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * aFileDialog is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with aFileDialog. If not, see . + */ + +package ar.com.daidalos.afiledialog.view; + +import java.io.File; +import java.util.LinkedList; +import java.util.List; + +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; +import ar.com.daidalos.afiledialog.R; + +/** + * This class is used to represents the files that can be selected by the user. + */ +public class FileItem extends LinearLayout { + + // ----- Attributes ----- // + + /** + * The file which is represented by this item. + */ + private File file; + + /** + * The image in which show the file's icon. + */ + private ImageView icon; + + /** + * The label in which show the file's name. + */ + private TextView label; + + /** + * A boolean indicating if the item can be selected. + */ + private boolean selectable; + + /** + * The listeners for the click event. + */ + private List listeners; + + // ----- Constructor ----- // + + /** + * The class main constructor. + * + * @param context The application's context. + */ + public FileItem(Context context) { + super(context); + + // Define the layout. + LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + inflater.inflate(R.layout.daidalos_file_item, this, true); + + // Initialize attributes. + this.file = null; + this.selectable = true; + this.icon = (ImageView) this.findViewById(R.id.imageViewIcon); + this.label = (TextView) this.findViewById(R.id.textViewLabel); + this.listeners = new LinkedList(); + + // Add a listener for the click event. + this.setOnClickListener(this.clickListener); + } + + /** + * A class constructor. + * + * @param context The application's context. + * @param file The file represented by this item + */ + public FileItem(Context context, File file) { + this(context); + + // Set the file. + this.setFile(file); + } + + /** + * A class constructor. + * + * @param context The application's context. + * @param file The file represented by this item. + * @param label The label of this item. + */ + public FileItem(Context context, File file, String label) { + this(context, file); + + // Set the label. + this.setLabel(label); + } + + // ----- Get() and Set() methods ----- // + + /** + * Defines the file represented by this item. + * + * @param file A file. + */ + public void setFile(File file) { + if(file != null) { + this.file = file; + + // Replace the label by the file's name. + this.setLabel(file.getName()); + + // Change the icon, depending if the file is a folder or not. + this.updateIcon(); + } + } + + /** + * Returns the file represented by this item. + * + * @return A file. + */ + public File getFile() { + return this.file; + } + + /** + * Changes the label of this item, which by default is the file's name. + * + * This method must be called after invoking the method setFile(), otherwise + * the label is going to be overwritten with the file's name. + * + * @param label A string value. + */ + public void setLabel(String label) { + // Verify if 'label' is not null. + if(label == null) label = ""; + + // Change the label. + this.label.setText(label); + } + + /** + * Verifies if the item can be selected. + * + * @return 'true' if the item can be selected, 'false' if not. + */ + public boolean isSelectable() { + return this.selectable; + } + + /** + * Defines if the item can be selected or not. + * + * @param selectable 'true' if the item can be selected, 'false' if not. + */ + public void setSelectable(boolean selectable) { + // Save the value. + this.selectable = selectable; + + // Update the icon. + this.updateIcon(); + } + + // ----- Miscellaneous methods ----- // + + /** + * Updates the icon according to if the file is a folder and if it can be selected. + */ + private void updateIcon() { + // Define the icon. + int icon = R.drawable.document_gray; + if(this.selectable) { + icon = (this.file != null && file.isDirectory())? R.drawable.folder : R.drawable.document; + } + + // Set the icon. + this.icon.setImageDrawable(getResources().getDrawable( icon )); + + // Change the color of the text. + if(icon != R.drawable.document_gray) { + this.label.setTextColor(getResources().getColor(R.color.daidalos_active_file)); + } else { + this.label.setTextColor(getResources().getColor(R.color.daidalos_inactive_file)); + } + } + + // ----- Events ----- // + + /** + * Listener for the click event. + */ + private View.OnClickListener clickListener = new View.OnClickListener() { + + public void onClick(View v) { + // Verify if the item can be selected. + if(FileItem.this.selectable) { + // Call the listeners. + for(int i=0; i + + + + + + + + + + + +