From 829c9abd242f7be3f4b9715775b648f669c57917 Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Sun, 29 Dec 2013 18:13:33 +0100 Subject: [PATCH 01/18] Add maven build files. --- .gitignore | 3 +- Git-Commit.cmd | 30 ++ Git-Commit.cmd.jar | Bin 0 -> 2082 bytes Git-Commit.command | 29 ++ Git-Pull.cmd | 29 ++ Git-Pull.command | 29 ++ Maven-Deploy.cmd | 42 +++ Maven-Deploy.command | 47 +++ aFileChooser/pom.xml | 227 ++++++++++++++ aFileChooserExample/pom.xml | 233 ++++++++++++++ aFileChooserExample/proguard.cfg | 1 + pom.xml | 513 +++++++++++++++++++++++++++++++ 12 files changed, 1182 insertions(+), 1 deletion(-) create mode 100644 Git-Commit.cmd create mode 100644 Git-Commit.cmd.jar create mode 100755 Git-Commit.command create mode 100644 Git-Pull.cmd create mode 100755 Git-Pull.command create mode 100644 Maven-Deploy.cmd create mode 100755 Maven-Deploy.command create mode 100644 aFileChooser/pom.xml create mode 100644 aFileChooserExample/pom.xml create mode 100644 pom.xml diff --git a/.gitignore b/.gitignore index cf2dbca..c28b0f8 100644 --- a/.gitignore +++ b/.gitignore @@ -51,4 +51,5 @@ Thumbs.db *.swp # backup files -*.bak \ No newline at end of file +*.bak +.backups diff --git a/Git-Commit.cmd b/Git-Commit.cmd new file mode 100644 index 0000000..a3c41f6 --- /dev/null +++ b/Git-Commit.cmd @@ -0,0 +1,30 @@ +::#! +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: {{{1 :::::::^:::: +:: Copyright © 2013 Martin Krischik +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: $Author$ +:: $Revision$ +:: $Date$ +:: $Id$ +:: $HeadURL$ +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }}}1 ::::::::::: +@ECHO OFF + +SETLOCAL + SET PATH=%PATH%;C:\opt\Git\bin + SET PATH=%PATH%;C:\opt\Scala\2.10.0\bin + + CALL scala -language:postfixOps -save %~f0 %* +ENDLOCAL + +GOTO :eof +::!# + +import scala.sys.process._ + +("git" :: "add" :: "." :: Nil).! +("git" :: "commit" :: "--message" :: argv (0) :: Nil).! +("git" :: "push" :: "-u" :: Nil).! + +// vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : +// vim: set textwidth=0 filetype=scala foldmethod=marker nospell : diff --git a/Git-Commit.cmd.jar b/Git-Commit.cmd.jar new file mode 100644 index 0000000000000000000000000000000000000000..9ec9bb6ed0d5852d8d6c93aa01f10efe7ee96c47 GIT binary patch literal 2082 zcmaKt2{aqn8plH|DWXJFV(c`Kj}%Pw|KABRzb{fq~aaql7^s#MRrs(OOhDNt$)-tTNI} zv=uLI3hPe|dg3XgYHi&cbaTQ@Z#V=i5IK2T1@(^iC@PcsK;~-}s%N?JYW=41(%tH4 zf#4nJiPBkU%@G9}c}-1>|D)7(W{sL~nl5^}Y{3b3Gf5bUl4_Uc*TJIcJ+HqB z;@&`qj;)vDmv^N|fgUrpjh9gL;ScdchAy$?Zh#+aEF9oy8Do#xh5baq}pjT*p5i>3aT|^$ZaQqd!zR}wtteOsy3IBl)uk+)1U4>OxIqDXH4T5dTt)Bi1&E$vrCV~!uDJsMjd^$%)b z-ETTKU8iTh8E*JP1L{a#QLb;iLC=VjOr34>6m>bB;ePbQ39qyQm`${SsX>)QYw^aW za=1?>Ukg*P3dr7I7DWZSs@|6nhu(uoQ_DgUjz8bPv`i~-J;E}WcUdRBvo^#T23fbO zry;s>bsDl&BrCJGK`AUujomKCo-i>3DKEm#z<-lV>?Eg6%3J`)X;q>pc1k>Go_edt|Y>J|~b`PqC`7`m2SOMY6DPfk{s??;<)1e4t{PE@$( zgHm{i``Jl!W}(~xNvquI)OL-FQx4Cxc($P(#I1HRdf6FE?zI$)!`->uGSr;hUO63$ zbk~(7A0aAp&mY(!xUUIDuo*~!4NTKM)pHBKSZFK1~NtlDsii0o|fNQvT8VV zdD0~ak!{s{n3DrH=L}KSU`+R(E?`+!=-oc+l}@)y?_Qd;hg4;?Ni!|1PbM02%6Q`Y znF{6Q+ERr80G+*TeYwI&{F$kbiL$VL?GHAE?mm9497nqzA}Kk*uDz`9hg%er8)R&{ zD`=C{K^7?chtPS3uA`S+i2g)V{D7oh!_hj;wV&=p9?J{QxDk_->bL#&qUNo>-K|%iQ7M(g%5D*x2QY_}<-{aS9Sy(Wdl(=J-Ol(HPOFG&kHuwGBLdXqz0G4VUKY&KjhZ=e4yi zzo*@~NjOwtz>;E*Yb}IcUNh?&oGkHEFVy+UoOBvoi}VVU#7(_(uYX~;QEfk3m2PK~ z!R17TUQE?%YY7IQP3E-84PH6N6g=Lcl^{Ig1FKbj@6$_mY47OhuX#v6#QZ_PS;st% zYFKNni9%osOc*q2XJZt$aN0|4KG!4XCt_w9Bw&Co zJ9ZU#C#ufHy5T4$)r2BBflw4mVFeEtjus~DKKyP&Gg>JuS%%#0fr0$S5b!OCqM`=> z#$?6~kO*g34b!&0)87r3N5ubJ@zsCCL|@6P5ij-U0 z?xP}8e86md4;82Xq9P;=0erH>&y8x|7XPj^1)0C@;Rh`U4}FWG?^! literal 0 HcmV?d00001 diff --git a/Git-Commit.command b/Git-Commit.command new file mode 100755 index 0000000..8997120 --- /dev/null +++ b/Git-Commit.command @@ -0,0 +1,29 @@ +#!/opt/local/bin/zsh +########################################################### {{{1 ########### +# Copyright © 2005 … 2013 Martin Krischik +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +############################################################################ +# $Author: krischik $ +# $Revision: 4694 $ +# $Date: 2012-03-29 20:47:27 +0200 (Do, 29. Mär 2012) $ +# $Id: Start-Vim.command 4694 2012-03-29 18:47:27Z krischik $ +# $HeadURL: https://uiq3.svn.sourceforge.net/svnroot/uiq3/trunk/Java/Utilities/Start-Vim.command $ +########################################################### }}}1 ########### + +scala -save Git-Commit.cmd + +# vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : +# vim: set textwidth=0 filetype=zsh foldmethod=marker nospell : diff --git a/Git-Pull.cmd b/Git-Pull.cmd new file mode 100644 index 0000000..9813666 --- /dev/null +++ b/Git-Pull.cmd @@ -0,0 +1,29 @@ +::#! +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: {{{1 :::::::^:::: +:: Copyright © 2013 Martin Krischik +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: $Author$ +:: $Revision$ +:: $Date$ +:: $Id$ +:: $HeadURL$ +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }}}1 ::::::::::: +@ECHO OFF + +SETLOCAL + SET PATH=%PATH%;C:\opt\Git\bin + SET PATH=%PATH%;C:\opt\Scala\2.10.0\bin + + CALL scala -save %~f0 %* +ENDLOCAL + +GOTO :eof +::!# + +import scala.sys.process._ + +("git" :: "pull" :: "https://github.com/iPaulPro/aFileChooser" :: Nil).! +("git" :: "pull" :: Nil).! + +// vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : +// vim: set textwidth=0 filetype=scala foldmethod=marker nospell : diff --git a/Git-Pull.command b/Git-Pull.command new file mode 100755 index 0000000..c16dea3 --- /dev/null +++ b/Git-Pull.command @@ -0,0 +1,29 @@ +#!/opt/local/bin/zsh +########################################################### {{{1 ########### +# Copyright © 2005 … 2013 Martin Krischik +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +############################################################################ +# $Author: krischik $ +# $Revision: 4694 $ +# $Date: 2012-03-29 20:47:27 +0200 (Do, 29. Mär 2012) $ +# $Id: Start-Vim.command 4694 2012-03-29 18:47:27Z krischik $ +# $HeadURL: https://uiq3.svn.sourceforge.net/svnroot/uiq3/trunk/Java/Utilities/Start-Vim.command $ +########################################################### }}}1 ########### + +scala -save Git-Pull.cmd + +# vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : +# vim: set textwidth=0 filetype=zsh foldmethod=marker nospell : diff --git a/Maven-Deploy.cmd b/Maven-Deploy.cmd new file mode 100644 index 0000000..b639f63 --- /dev/null +++ b/Maven-Deploy.cmd @@ -0,0 +1,42 @@ +::#! +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: {{{1 :::::::^:::: +:: Copyright © 2013 Martin Krischik +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: $Author$ +:: $Revision$ +:: $Date$ +:: $Id$ +:: $HeadURL$ +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: }}}1 ::::::::::: +@ECHO OFF + +SETLOCAL + SET PATH=%PATH%;C:\opt\Git\bin + SET PATH=%PATH%;C:\opt\Scala\2.10.0\bin + SET Scala_Library="${WORK}/Repositories/Local/net/sourceforge/uiq3/Calculator-Script/${CALCULATOR_VERSION}/Calculator-Script-${CALCULATOR_VERSION}.jar" + + CALL scala -classpath %Scala_Library% -save %~f0 %* + POPD +ENDLOCAL + +GOTO :eof +::!# + +import scala.sys.process._ +import com.noser.Maven._ + +val Maven_Deploy = System.getenv ("MAVEN_DEPLOY") +val Project_Name = System.getenv ("PROJECT_NAME") +val Maven_Name = Project_Name +" Maven Repository" + +mvn ::: "--activate-profiles" :: "release" :: "install" :: Nil !; +mvn ::: "--activate-profiles" :: "release" :: "site:site" :: Nil !; + +mvn ::: + "--define" :: "repo.id=" + Project_Name :: + "--define" :: "repo.name=" + Maven_Name :: + "--define" :: "repo.url=" + Maven_Deploy :: + "deploy" :: Nil !; + +// vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : +// vim: set textwidth=0 filetype=scala foldmethod=marker nospell : diff --git a/Maven-Deploy.command b/Maven-Deploy.command new file mode 100755 index 0000000..2ecd72f --- /dev/null +++ b/Maven-Deploy.command @@ -0,0 +1,47 @@ +#!/opt/local/bin/zsh +########################################################### {{{1 ########### +# Copyright © 2005 … 2013 Martin Krischik +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +############################################################################ +# $Author: krischik $ +# $Revision: 4694 $ +# $Date: 2012-03-29 20:47:27 +0200 (Do, 29. Mär 2012) $ +# $Id: Start-Vim.command 4694 2012-03-29 18:47:27Z krischik $ +# $HeadURL: https://uiq3.svn.sourceforge.net/svnroot/uiq3/trunk/Java/Utilities/Start-Vim.command $ +########################################################### }}}1 ########### + +local Download_Server="krischik,uiq3@shell.sourceforge.net"; + +mvn \ + --define repo.id=UIQ3 \ + --define repo.url=file:///Work/HomePage/uiq3/htdocs/Repository \ + deploy + +pushd "/Work/HomePage/uiq3/htdocs" + sshpass -p ${KEY_SF} ssh ${Download_Server} create; + + rsync \ + --archive \ + --delete \ + --verbose \ + --keep-dirlinks \ + "Repository" \ + "krischik,uiq3@web.sourceforge.net:htdocs" + + sshpass -p ${KEY_SF} ssh ${Download_Server} shutdown +popd +# vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : +# vim: set textwidth=0 filetype=zsh foldmethod=marker nospell : diff --git a/aFileChooser/pom.xml b/aFileChooser/pom.xml new file mode 100644 index 0000000..0a7f4dd --- /dev/null +++ b/aFileChooser/pom.xml @@ -0,0 +1,227 @@ + + + + + + + 4.0.0 + afilechooser-library + apklib + aFileChooser Library + aFileChooser is an Android Library Project that simplifies the process of presenting a file chooser on Android 2.1+. + + com.ipaulpro + afilechooser + 1.0 + + https://github.com/krischik/aFileChooser3 + + + krischik@users.sourceforge.net + krischik + Martin Krischik + UIQ3 open-source software and tools + https://sourceforge.net/projects/uiq3/ + + Deployer + + GMT+1 + https://sourceforge.net/users/krischik + + + + + pache License, Version 2.0 + + + + scm:git:https://github.com/krischik/aFileChooser3 + scm:git:https://github.com/krischik/aFileChooser3 + main + scm:git:https://github.com/krischik/aFileChooser3 + + + + + + + + android.support + compatibility-v4 + + + android + android + + + + + + + + + src + + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + com.jayway.maven.plugins.android.generation2 + android-maven-plugin + + false + true + + proguard.cfg + + -Xms256m + -Xmx512m + + false + + + false + + + true + + + org.apache.maven.plugins + maven-resources-plugin + + ${project.build.sourceEncoding} + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + + gen + target/generated-sources/annotations + target/generated-sources/r + + + + add-source + + + + + + org.apache.maven.plugins + maven-clean-plugin + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + org.apache.maven.plugins + maven-resources-plugin + + + install + + + + + + + + + release + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + 1 + 1 + + + false + none + true + true + true + + + + com.jayway.maven.plugins.android.generation2 + android-maven-plugin + + true + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + test-jar + + + + + + + + + + + + + + + + + diff --git a/aFileChooserExample/pom.xml b/aFileChooserExample/pom.xml new file mode 100644 index 0000000..ab7b676 --- /dev/null +++ b/aFileChooserExample/pom.xml @@ -0,0 +1,233 @@ + + + + + + + 4.0.0 + afilechooser-expample + apk + aFileChooser Example + aFileChooser is an Android Library Project that simplifies the process of presenting a file chooser on Android 2.1+. + + com.ipaulpro + afilechooser + 1.0 + + https://github.com/krischik/aFileChooser3 + + + krischik@users.sourceforge.net + krischik + Martin Krischik + UIQ3 open-source software and tools + https://sourceforge.net/projects/uiq3/ + + Deployer + + GMT+1 + https://sourceforge.net/users/krischik + + + + + pache License, Version 2.0 + + + + scm:git:https://github.com/krischik/aFileChooser3 + scm:git:https://github.com/krischik/aFileChooser3 + main + scm:git:https://github.com/krischik/aFileChooser3 + + + + + + + + android.support + compatibility-v4 + compile + + + android + android + + + com.ipaulpro + afilechooser-library + apklib + + + + + + + + + src + + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + com.jayway.maven.plugins.android.generation2 + android-maven-plugin + + false + true + + proguard.cfg + + -Xms256m + -Xmx512m + + false + + + true + + + true + + + org.apache.maven.plugins + maven-resources-plugin + + ${project.build.sourceEncoding} + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + + gen + target/generated-sources/annotations + target/generated-sources/r + + + + add-source + + + + + + org.apache.maven.plugins + maven-clean-plugin + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + org.apache.maven.plugins + maven-resources-plugin + + + install + + + + + + + + + release + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + 1 + 1 + + + false + none + true + true + true + + + + com.jayway.maven.plugins.android.generation2 + android-maven-plugin + + true + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + test-jar + + + + + + + + + + + + + + + + + diff --git a/aFileChooserExample/proguard.cfg b/aFileChooserExample/proguard.cfg index b1cdf17..54cbec1 100644 --- a/aFileChooserExample/proguard.cfg +++ b/aFileChooserExample/proguard.cfg @@ -2,6 +2,7 @@ -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontpreverify +-dontoptimize -verbose -optimizations !code/simplification/arithmetic,!field/*,!class/merging/* diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..7674c99 --- /dev/null +++ b/pom.xml @@ -0,0 +1,513 @@ + + + + + + + 4.0.0 + com.ipaulpro + afilechooser + pom + 1.0 + aFileChooser + aFileChooser is an Android Library Project that simplifies the process of presenting a file chooser on Android 2.1+. + https://github.com/krischik/aFileChooser3 + + + krischik@users.sourceforge.net + krischik + Martin Krischik + UIQ3 open-source software and tools + https://sourceforge.net/projects/uiq3/ + + Developer + + GMT+1 + https://sourceforge.net/users/krischik + + + + + pache License, Version 2.0 + + + + scm:git:https://github.com/krischik/aFileChooser3 + scm:git:https://github.com/krischik/aFileChooser3 + main + scm:git:https://github.com/krischik/aFileChooser3 + + + + + + ${repo.id} + ${repo.name} + ${repo.url} + + + ${repo.id} + ${repo.name} + ${repo.url} + + + + + + + + android.support + compatibility-v4 + ${android.support.version} + provided + jar + + + android + android + ${android.version} + provided + jar + + + com.ipaulpro + afilechooser-library + 1.0 + compile + apklib + + + + + + + + + UIQ3-Library + UIQ3-Library + http://uiq3.sourceforge.net/Repository + + + codehaus.org + Codehaus repository + http://repository.codehaus.org/ + + + sonatype.org + Sonatype repository + https://oss.sonatype.org/content/groups/public + + + + + codehaus.org + http://repository.codehaus.org + Codehaus repository + + + sonatype.org + Sonatype repository + https://oss.sonatype.org/content/groups/public + + + + + + src + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9 + + + com.ipaulpro:* + + true + UTF-8 + UTF-8 + false + true + true + private + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + + + 10 + 10 + + + true + lines,vars,source + ${project.build.sourceEncoding} + + **/._* + **/.backups/* + **/.backups + **/.DS_Store + + true + 256m + 128m + false + true + true + ${java.version} + ${java.version} + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + org.apache.maven.plugins + maven-resources-plugin + 2.6 + + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.8 + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + **/.DS_Store + **/*Suite.class + **/*Test.class + **/._* + **/.backups/* + **/.backups + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.4 + + + org.apache.maven.plugins + maven-checkstyle-plugin + 2.10 + + checkstyle-suppressions.xml + checkstyle-allman.xml + false + + + + com.noser + Calculator-Checkstyle + ${CALCULATOR_VERSION} + + + + + com.jayway.maven.plugins.android.generation2 + android-maven-plugin + 3.7.0 + + true + + ${env.ANDROID_HOME} + ${android.platform} + + + false + + + + + org.apache.maven.plugins + maven-clean-plugin + 2.5 + + + + obj + + + gen + + + bin + + + gen-external-apklibs + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.7 + + + org.apache.maven.plugins + maven-scm-plugin + 1.8.1 + + developerConnection + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + org.apache.maven.plugins + maven-site-plugin + 3.3 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.15 + + true + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.7 + + + org.codehaus.mojo + dashboard-maven-plugin + 1.0.0-beta-1 + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + + + maven-antrun-plugin + + run + + org.apache.maven.plugins + [1.7,) + + + + + + + + build-helper-maven-plugin + + add-source + add-test-source + + org.codehaus.mojo + [1.7,) + + + + + + + + + + + + + install + + + + wagon-ssh + org.apache.maven.wagon + 2.4 + + + wagon-scm + org.apache.maven.wagon + 2.4 + + + maven-scm-manager-plexus + org.apache.maven.scm + 1.8.1 + + + maven-scm-provider-svnexe + org.apache.maven.scm + 1.8.1 + + + + + + + + + + release + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + test-jar + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + attach-documentation + + jar + test-jar + + + + + + org.apache.maven.plugins + maven-site-plugin + + private + true + UTF-8 + UTF-8 + true + false + + + org.apache.maven.plugins + maven-javadoc-plugin + + private + true + true + + com.noser:* + + UTF-8 + UTF-8 + true + false + + + + net.alchim31.maven + scala-maven-plugin + + ${scala.version} + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + + + org.codehaus.mojo + dashboard-maven-plugin + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.scalatest + scalatest-maven-plugin + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + + + + + + + + + + + 19 + 19 + 4.4_r1 + 1.6 + UTF-8 + UTF-8 + UTF-8 + + + + + aFileChooser + aFileChooserExample + + + + + From 50e2fcd99cdfb5c8d9a2e18a74bc3aa98473819e Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Sun, 29 Dec 2013 18:46:16 +0100 Subject: [PATCH 02/18] backup before pull --- aFileChooser/pom.xml | 18 ++++++------- aFileChooserExample/AndroidManifest.xml | 1 - aFileChooserExample/pom.xml | 30 +++++++++++----------- pom.xml | 34 ++++++++++++------------- 4 files changed, 41 insertions(+), 42 deletions(-) diff --git a/aFileChooser/pom.xml b/aFileChooser/pom.xml index 0a7f4dd..3ed69e2 100644 --- a/aFileChooser/pom.xml +++ b/aFileChooser/pom.xml @@ -70,14 +70,14 @@ - - android.support - compatibility-v4 - - - android - android - + + android.support + compatibility-v4 + + + android + android + @@ -85,7 +85,7 @@ - src + src diff --git a/aFileChooserExample/AndroidManifest.xml b/aFileChooserExample/AndroidManifest.xml index e348b00..16d51f6 100644 --- a/aFileChooserExample/AndroidManifest.xml +++ b/aFileChooserExample/AndroidManifest.xml @@ -54,7 +54,6 @@ - - - android.support - compatibility-v4 - compile - - - android - android - - - com.ipaulpro - afilechooser-library - apklib - + + android.support + compatibility-v4 + compile + + + android + android + + + com.ipaulpro + afilechooser-library + apklib + @@ -91,7 +91,7 @@ - src + src diff --git a/pom.xml b/pom.xml index 7674c99..c33513a 100644 --- a/pom.xml +++ b/pom.xml @@ -64,18 +64,18 @@ - - - ${repo.id} - ${repo.name} - ${repo.url} - - - ${repo.id} - ${repo.name} - ${repo.url} - - + + + ${repo.id} + ${repo.name} + ${repo.url} + + + ${repo.id} + ${repo.name} + ${repo.url} + + @@ -138,7 +138,7 @@ - src + src @@ -503,10 +503,10 @@ - - aFileChooser - aFileChooserExample - + + aFileChooser + aFileChooserExample + From 8aac897dd3a5631652c220cab396294072cbc636 Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Mon, 30 Dec 2013 06:43:02 +0100 Subject: [PATCH 03/18] Switch to branch. --- README.markdown | 41 +++++++++++++++---- .../afilechooser/FileChooserActivity.java | 23 ++++++++++- .../afilechooser/FileListFragment.java | 11 ++++- 3 files changed, 64 insertions(+), 11 deletions(-) diff --git a/README.markdown b/README.markdown index 7e80416..94b6f32 100644 --- a/README.markdown +++ b/README.markdown @@ -69,7 +69,7 @@ Use `startActivityForResult(Intent, int)` to launch `FileChooserActivity` direct // Create the ACTION_GET_CONTENT Intent Intent getContentIntent = FileUtils.createGetContentIntent(); - + Intent intent = Intent.createChooser(getContentIntent, "Select a file"); startActivityForResult(intent, REQUEST_CHOOSER); } @@ -77,14 +77,14 @@ Use `startActivityForResult(Intent, int)` to launch `FileChooserActivity` direct @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { - case REQUEST_CHOOSER: + case REQUEST_CHOOSER: if (resultCode == RESULT_OK) { - + final Uri uri = data.getData(); - + // Get the File path from the Uri String path = FileUtils.getPath(this, uri); - + // Alternatively, use FileUtils.getFile(Context, Uri) if (path != null && FileUtils.isLocal(path)) { File file = new File(path); @@ -98,16 +98,43 @@ A more robust example can be found in the aFileChooserExample project. __Note__ the `FileUtils` method to get a file path from a `Uri` (`FileUtils.getPath(Context, Uri)`). This works for `File`, `MediaStore`, and `DocumentProvider` `Uris`. +###Filtering by file extension + +Provide an extra `EXTRA_FILTER_INCLUDE_EXTENSIONS` which is an `ArrayList` containing all the extensions that must be included. Note that the extentions must begin with a dot character. The behavior of this extra is specified as follows: + + - If this extra is specified, then **only** files with the supplied extensions will be shown. All other files will be hidden. + - If this extra is not specified, or it is an empty `ArrayList`, then no filtering is performed. + +Example: + +``` + private static final ArrayList INCLUDE_EXTENSIONS_LIST = new ArrayList(); + static{ + INCLUDE_EXTENSIONS_LIST.add(".apk"); + INCLUDE_EXTENSIONS_LIST.add(".bin"); + } + //... + //... + Intent intent = new Intent(this, FileChooserActivity.class); + intent.putStringArrayListExtra(FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, INCLUDE_EXTENSIONS_LIST); + //Use this intent in startActivityForResult() + +``` + ## Credits Developed by Paul Burke (iPaulPro) - [paulburke.co](http://paulburke.co/) +Filtering by file extension: [curioustechizen] (https://github.com/curioustechizen) + Translations by [TomTasche](https://github.com/TomTasche), [booknara](https://github.com/booknara), [brenouchoa](https://github.com/brenouchoa) Folder by [Sergio Calcara](http://thenounproject.com/fallacyaccount) from The Noun Project (ic_provider.png) Document by [Melvin Salas](http://thenounproject.com/msalas10) from The Noun Project (ic_file.png) +Maven Deployment by [krischik](https://github.com/krischik) + ## Licenses Copyright (C) 2011 - 2013 Paul Burke @@ -127,7 +154,7 @@ Document by [Melvin Salas](http://thenounproject.com/msalas10) from The Noun Pro Portions of FileUtils.java: Copyright (C) 2007-2008 OpenIntents.org - + 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 @@ -150,4 +177,4 @@ LocalStorageProvider.java: - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java b/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java index 724cf1d..5f16eda 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java @@ -16,6 +16,8 @@ package com.ipaulpro.afilechooser; +import android.annotation.SuppressLint; + import android.app.ActionBar; import android.content.BroadcastReceiver; import android.content.Context; @@ -35,6 +37,8 @@ import android.widget.Toast; import java.io.File; +import java.util.ArrayList; +import java.util.List; /** * Main Activity that handles the FileListFragments @@ -46,6 +50,9 @@ public class FileChooserActivity extends FragmentActivity implements OnBackStackChangedListener, FileListFragment.Callbacks { public static final String PATH = "path"; + public static final String EXTRA_FILTER_INCLUDE_EXTENSIONS = + "com.ipaulpro.afilechooser.EXTRA_FILTER_INCLUDE_EXTENSIONS"; + private ArrayList mFilterIncludeExtensions = new ArrayList (); public static final String EXTERNAL_BASE_PATH = Environment .getExternalStorageDirectory().getAbsolutePath(); @@ -76,6 +83,13 @@ protected void onCreate(Bundle savedInstanceState) { mPath = savedInstanceState.getString(PATH); } + final Intent intent = getIntent(); + + if(intent != null){ + mFilterIncludeExtensions = intent.getStringArrayListExtra ( + EXTRA_FILTER_INCLUDE_EXTENSIONS); + } + setTitle(mPath); } @@ -100,6 +114,7 @@ protected void onSaveInstanceState(Bundle outState) { outState.putString(PATH, mPath); } + @SuppressLint("NewApi") // Usages of New APIs are surrounded by sufficient conditional checks @Override public void onBackStackChanged() { @@ -144,7 +159,9 @@ public boolean onOptionsItemSelected(MenuItem item) { * Add the initial Fragment with given path. */ private void addFragment() { - FileListFragment fragment = FileListFragment.newInstance(mPath); + final FileListFragment fragment = FileListFragment.newInstance( + mPath, + mFilterIncludeExtensions); mFragmentManager.beginTransaction() .add(android.R.id.content, fragment).commit(); } @@ -158,7 +175,9 @@ private void addFragment() { private void replaceFragment(File file) { mPath = file.getAbsolutePath(); - FileListFragment fragment = FileListFragment.newInstance(mPath); + final FileListFragment fragment = FileListFragment.newInstance( + mPath, + mFilterIncludeExtensions); mFragmentManager.beginTransaction() .replace(android.R.id.content, fragment) .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN) diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java b/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java index 5da363a..68649b8 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java @@ -27,10 +27,11 @@ import java.io.File; import java.util.List; +import java.util.ArrayList; /** * Fragment that displays a list of Files in a given path. - * + * * @version 2013-12-11 * @author paulburke (ipaulpro) */ @@ -53,6 +54,7 @@ public interface Callbacks { private FileListAdapter mAdapter; private String mPath; + private ArrayList mFilterIncludeExtensions = new ArrayList(); private Callbacks mListener; @@ -62,10 +64,15 @@ public interface Callbacks { * @param path The absolute path of the file (directory) to display. * @return A new Fragment with the given file path. */ - public static FileListFragment newInstance(String path) { + public static FileListFragment newInstance( + String path, + ArrayList filterIncludeExtensions ) { FileListFragment fragment = new FileListFragment(); Bundle args = new Bundle(); args.putString(FileChooserActivity.PATH, path); + args.putStringArrayList( + FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, + filterIncludeExtensions); fragment.setArguments(args); return fragment; From ca156596632fae2ea4c3452ba683ef1147241b4d Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Mon, 30 Dec 2013 09:00:11 +0100 Subject: [PATCH 04/18] Git-Commit.command --- .gitignore | 1 + Git-Commit.cmd.jar | Bin 2082 -> 2082 bytes Git-Commit.command | 2 +- Maven-Deploy.cmd | 15 ++++++++------- Maven-Deploy.command | 17 ++++++++--------- aFileChooser/pom.xml | 6 ------ aFileChooserExample/pom.xml | 6 ------ pom.xml | 2 -- 8 files changed, 18 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index c28b0f8..e986219 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ lint.xml # Java class files *.class +*.jar # generated files bin/ diff --git a/Git-Commit.cmd.jar b/Git-Commit.cmd.jar index 9ec9bb6ed0d5852d8d6c93aa01f10efe7ee96c47..bc9362dc0481a0d09f1a63f9ca4497352d4df8e5 100644 GIT binary patch delta 79 zcmZ1^utQ*KYz1f#}IU|_yoka^QGFgS)86+?{ Qi`^DXuVOa?(~sHh0iqEZ8UO$Q delta 79 zcmZ1^utmoGe}@^ R7P~E&Ud3((rXRE00|4+r8(IJW diff --git a/Git-Commit.command b/Git-Commit.command index 8997120..6069949 100755 --- a/Git-Commit.command +++ b/Git-Commit.command @@ -23,7 +23,7 @@ # $HeadURL: https://uiq3.svn.sourceforge.net/svnroot/uiq3/trunk/Java/Utilities/Start-Vim.command $ ########################################################### }}}1 ########### -scala -save Git-Commit.cmd +scala -save Git-Commit.cmd ${0} # vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : # vim: set textwidth=0 filetype=zsh foldmethod=marker nospell : diff --git a/Maven-Deploy.cmd b/Maven-Deploy.cmd index b639f63..fe5998f 100644 --- a/Maven-Deploy.cmd +++ b/Maven-Deploy.cmd @@ -23,20 +23,21 @@ GOTO :eof ::!# import scala.sys.process._ -import com.noser.Maven._ +import net.sourceforge.uiq3.Maven.mvn +import net.sourceforge.uiq3.Shell.Err_Exit_Call val Maven_Deploy = System.getenv ("MAVEN_DEPLOY") val Project_Name = System.getenv ("PROJECT_NAME") -val Maven_Name = Project_Name +" Maven Repository" +val Maven_Name = Project_Name +" Maven Repository" -mvn ::: "--activate-profiles" :: "release" :: "install" :: Nil !; -mvn ::: "--activate-profiles" :: "release" :: "site:site" :: Nil !; - -mvn ::: +Err_Exit_Call (mvn ::: "--activate-profiles" :: "release" :: "install" :: Nil) +Err_Exit_Call (mvn ::: "--activate-profiles" :: "release" :: "javadoc:javadoc" :: Nil) +Err_Exit_Call (mvn ::: "--activate-profiles" :: "release" :: "source:jar" :: Nil) +Err_Exit_Call (mvn ::: "--define" :: "repo.id=" + Project_Name :: "--define" :: "repo.name=" + Maven_Name :: "--define" :: "repo.url=" + Maven_Deploy :: - "deploy" :: Nil !; + "deploy" :: Nil ) // vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : // vim: set textwidth=0 filetype=scala foldmethod=marker nospell : diff --git a/Maven-Deploy.command b/Maven-Deploy.command index 2ecd72f..9426df4 100755 --- a/Maven-Deploy.command +++ b/Maven-Deploy.command @@ -23,16 +23,17 @@ # $HeadURL: https://uiq3.svn.sourceforge.net/svnroot/uiq3/trunk/Java/Utilities/Start-Vim.command $ ########################################################### }}}1 ########### -local Download_Server="krischik,uiq3@shell.sourceforge.net"; +local Download_Server="krischik,uiq3@shell.sourceforge.net" +local Scala_Library="${WORK}/Repositories/Local/net/sourceforge/uiq3/Calculator-Script/6.2.0/Calculator-Script-6.2.0.jar" -mvn \ - --define repo.id=UIQ3 \ - --define repo.url=file:///Work/HomePage/uiq3/htdocs/Repository \ - deploy +ssh-add \ + /Users/martin/.ssh/id_rsa \ + /Users/martin/.ssh/id_dsa \ + /Users/martin/.ssh/Martin_Krischik_SF -pushd "/Work/HomePage/uiq3/htdocs" - sshpass -p ${KEY_SF} ssh ${Download_Server} create; +scala -classpath ${Scala_Library} -save Maven-Deploy.cmd +pushd "/Work/HomePage/uiq3/htdocs" rsync \ --archive \ --delete \ @@ -40,8 +41,6 @@ pushd "/Work/HomePage/uiq3/htdocs" --keep-dirlinks \ "Repository" \ "krischik,uiq3@web.sourceforge.net:htdocs" - - sshpass -p ${KEY_SF} ssh ${Download_Server} shutdown popd # vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : # vim: set textwidth=0 filetype=zsh foldmethod=marker nospell : diff --git a/aFileChooser/pom.xml b/aFileChooser/pom.xml index 3ed69e2..15b19dd 100644 --- a/aFileChooser/pom.xml +++ b/aFileChooser/pom.xml @@ -91,8 +91,6 @@ - - @@ -158,10 +156,6 @@ org.apache.maven.plugins maven-checkstyle-plugin - - org.apache.maven.plugins - maven-resources-plugin - install diff --git a/aFileChooserExample/pom.xml b/aFileChooserExample/pom.xml index 3f88881..dc6960a 100644 --- a/aFileChooserExample/pom.xml +++ b/aFileChooserExample/pom.xml @@ -97,8 +97,6 @@ - - @@ -164,10 +162,6 @@ org.apache.maven.plugins maven-checkstyle-plugin - - org.apache.maven.plugins - maven-resources-plugin - install diff --git a/pom.xml b/pom.xml index c33513a..59b9b0b 100644 --- a/pom.xml +++ b/pom.xml @@ -365,8 +365,6 @@ - - install From d4e3bc95d58bc85c14d3411cb5b111e7e562d92d Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Mon, 30 Dec 2013 09:04:37 +0100 Subject: [PATCH 05/18] backup bevore merge --- Git-Commit.cmd | 2 +- Git-Pull.cmd | 4 +- Maven-Deploy.cmd | 2 +- Maven-Deploy.command | 17 ++++--- .../afilechooser/FileChooserActivity.java | 5 +- .../afilechooser/FileListFragment.java | 18 +++++--- .../com/ipaulpro/afilechooser/FileLoader.java | 23 ++++++---- .../afilechooser/utils/FileUtils.java | 46 +++++++++++++------ pom.xml | 15 ++++-- 9 files changed, 85 insertions(+), 47 deletions(-) diff --git a/Git-Commit.cmd b/Git-Commit.cmd index a3c41f6..42345f5 100644 --- a/Git-Commit.cmd +++ b/Git-Commit.cmd @@ -24,7 +24,7 @@ import scala.sys.process._ ("git" :: "add" :: "." :: Nil).! ("git" :: "commit" :: "--message" :: argv (0) :: Nil).! -("git" :: "push" :: "-u" :: Nil).! +("git" :: "push" :: "-u" :: "origin" :: "dev" :: Nil).! // vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : // vim: set textwidth=0 filetype=scala foldmethod=marker nospell : diff --git a/Git-Pull.cmd b/Git-Pull.cmd index 9813666..c7ecbfd 100644 --- a/Git-Pull.cmd +++ b/Git-Pull.cmd @@ -22,8 +22,8 @@ GOTO :eof import scala.sys.process._ -("git" :: "pull" :: "https://github.com/iPaulPro/aFileChooser" :: Nil).! -("git" :: "pull" :: Nil).! +("git" :: "pull" :: "https://github.com/iPaulPro/aFileChooser" :: Nil).! +("git" :: "pull" :: "origin" :: "dev" :: Nil).! // vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : // vim: set textwidth=0 filetype=scala foldmethod=marker nospell : diff --git a/Maven-Deploy.cmd b/Maven-Deploy.cmd index b639f63..e0672ab 100644 --- a/Maven-Deploy.cmd +++ b/Maven-Deploy.cmd @@ -23,7 +23,7 @@ GOTO :eof ::!# import scala.sys.process._ -import com.noser.Maven._ +import net.sourceforge.uiq3.Maven._ val Maven_Deploy = System.getenv ("MAVEN_DEPLOY") val Project_Name = System.getenv ("PROJECT_NAME") diff --git a/Maven-Deploy.command b/Maven-Deploy.command index 2ecd72f..ee5f8c5 100755 --- a/Maven-Deploy.command +++ b/Maven-Deploy.command @@ -23,15 +23,18 @@ # $HeadURL: https://uiq3.svn.sourceforge.net/svnroot/uiq3/trunk/Java/Utilities/Start-Vim.command $ ########################################################### }}}1 ########### -local Download_Server="krischik,uiq3@shell.sourceforge.net"; +local Download_Server="krischik,uiq3@shell.sourceforge.net" +local Scala_Library="${WORK}/Repositories/Local/net/sourceforge/uiq3/Calculator-Script/6.2.0/Calculator-Script-6.2.0.jar" -mvn \ - --define repo.id=UIQ3 \ - --define repo.url=file:///Work/HomePage/uiq3/htdocs/Repository \ - deploy +ssh-add \ + /Users/martin/.ssh/id_rsa \ + /Users/martin/.ssh/id_dsa \ + /Users/martin/.ssh/Martin_Krischik_SF + +#scala -classpath ${Scala_Library} -save Maven-Deploy.cmd pushd "/Work/HomePage/uiq3/htdocs" - sshpass -p ${KEY_SF} ssh ${Download_Server} create; + #sshpass -p ${KEY_SF} ssh ${Download_Server} create; rsync \ --archive \ @@ -41,7 +44,7 @@ pushd "/Work/HomePage/uiq3/htdocs" "Repository" \ "krischik,uiq3@web.sourceforge.net:htdocs" - sshpass -p ${KEY_SF} ssh ${Download_Server} shutdown + #sshpass -p Martin_Krischik_SF ssh ${Download_Server} shutdown popd # vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : # vim: set textwidth=0 filetype=zsh foldmethod=marker nospell : diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java b/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java index 5f16eda..6873bbf 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java @@ -131,12 +131,13 @@ public void onBackStackChanged() { invalidateOptionsMenu(); } + @SuppressLint("NewApi") // Usages of New APIs are surrounded by sufficient conditional checks @Override public boolean onCreateOptionsMenu(Menu menu) { if (HAS_ACTIONBAR) { - boolean hasBackStack = mFragmentManager.getBackStackEntryCount() > 0; + final boolean hasBackStack = mFragmentManager.getBackStackEntryCount() > 0; + final ActionBar actionBar = getActionBar(); - ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(hasBackStack); actionBar.setHomeButtonEnabled(hasBackStack); } diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java b/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java index 68649b8..4ebb47f 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java @@ -66,11 +66,11 @@ public interface Callbacks { */ public static FileListFragment newInstance( String path, - ArrayList filterIncludeExtensions ) { + final ArrayList filterIncludeExtensions ) { FileListFragment fragment = new FileListFragment(); Bundle args = new Bundle(); args.putString(FileChooserActivity.PATH, path); - args.putStringArrayList( + args.putStringArrayList ( FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, filterIncludeExtensions); fragment.setArguments(args); @@ -94,10 +94,16 @@ public void onAttach(Activity activity) { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + final android.os.Bundle arguments = getArguments (); + mAdapter = new FileListAdapter(getActivity()); - mPath = getArguments() != null ? getArguments().getString( - FileChooserActivity.PATH) : Environment + mPath = arguments != null ? arguments.getString ( + FileChooserActivity.PATH) : Environment .getExternalStorageDirectory().getAbsolutePath(); + if(arguments != null){ + mFilterIncludeExtensions = arguments.getStringArrayList ( + FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS); + } } @Override @@ -115,7 +121,7 @@ public void onActivityCreated(Bundle savedInstanceState) { public void onListItemClick(ListView l, View v, int position, long id) { FileListAdapter adapter = (FileListAdapter) l.getAdapter(); if (adapter != null) { - File file = (File) adapter.getItem(position); + final File file = adapter.getItem(position); mPath = file.getAbsolutePath(); mListener.onFileSelected(file); } @@ -123,7 +129,7 @@ public void onListItemClick(ListView l, View v, int position, long id) { @Override public Loader> onCreateLoader(int id, Bundle args) { - return new FileLoader(getActivity(), mPath); + return new FileLoader(getActivity(), mPath, mFilterIncludeExtensions); } @Override diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/FileLoader.java b/aFileChooser/src/com/ipaulpro/afilechooser/FileLoader.java index f8903ac..8aa635c 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/FileLoader.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/FileLoader.java @@ -26,10 +26,11 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.ArrayList; /** * Loader that returns a list of Files in a given file path. - * + * * @version 2013-12-11 * @author paulburke (ipaulpro) */ @@ -43,17 +44,22 @@ public class FileLoader extends AsyncTaskLoader> { private FileObserver mFileObserver; private List mData; - private String mPath; + private final String mPath; + private ArrayList mFilterIncludeExtensions; - public FileLoader(Context context, String path) { + public FileLoader( + Context context, + String path, + ArrayList filterIncludeExtensions) { super(context); this.mPath = path; + this.mFilterIncludeExtensions = filterIncludeExtensions; } @Override public List loadInBackground() { - ArrayList list = new ArrayList(); + final ArrayList list = new ArrayList(); // Current directory File instance final File pathDir = new File(mPath); @@ -64,18 +70,17 @@ public List loadInBackground() { // Sort the folders alphabetically Arrays.sort(dirs, FileUtils.sComparator); // Add each folder to the File list for the list adapter - for (File dir : dirs) - list.add(dir); + java.util.Collections.addAll (list, dirs); } // List file in this directory with the file filter - final File[] files = pathDir.listFiles(FileUtils.sFileFilter); + final File[] files = pathDir.listFiles( + new FileUtils.FileExtensionFilter (mFilterIncludeExtensions)); if (files != null) { // Sort the files alphabetically Arrays.sort(files, FileUtils.sComparator); // Add each file to the File list for the list adapter - for (File file : files) - list.add(file); + java.util.Collections.addAll (list, files); } return list; diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java b/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java index 25c8008..3af9096 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java @@ -36,6 +36,7 @@ import java.io.File; import java.io.FileFilter; import java.text.DecimalFormat; +import java.util.ArrayList; import java.util.Comparator; /** @@ -44,9 +45,10 @@ * @version 2013-12-11 * @author paulburke (ipaulpro) */ +@SuppressWarnings ("HardcodedFileSeparator") public class FileUtils { private FileUtils() {} //private constructor to enforce Singleton pattern - + /** TAG for log messages. */ static final String TAG = "FileUtils"; private static final boolean DEBUG = false; // Set to true to enable logging @@ -59,6 +61,32 @@ private FileUtils() {} //private constructor to enforce Singleton pattern public static final String HIDDEN_PREFIX = "."; + /** + * File Filter that includes only files with the specified extensions to pass + * @author Kiran Rao + * + */ + public static class FileExtensionFilter implements FileFilter{ + private final ArrayList mFilterIncludeExtensions; + + public FileExtensionFilter (final ArrayList filterIncludeExtensions){ + this.mFilterIncludeExtensions = filterIncludeExtensions; + } + + @Override + public boolean accept(final File file) { + final String fileName = file.getName(); + final android.net.Uri uri = android.net.Uri.fromFile (file); + final boolean passesExtensionsFilter = + mFilterIncludeExtensions.isEmpty () || mFilterIncludeExtensions.contains ( + getExtension (uri.toString ())); + // Return files only (not directories) and skip hidden files + return file.isFile() && !fileName.startsWith(HIDDEN_PREFIX) && + passesExtensionsFilter; + } + + } + /** * Gets the extension of a file name, like ".png" or ".jpg". * @@ -247,13 +275,14 @@ public static String getDataColumn(Context context, Uri uri, String selection, *
* Callers should check whether the path is local before assuming it * represents a local file. - * + * * @param context The context. * @param uri The Uri to query. * @see #isLocal(String) * @see #getFile(Context, Uri) * @author paulburke */ + @android.annotation.SuppressLint ("NewApi") // Usages of New APIs are surrounded by sufficient conditional checks public static String getPath(final Context context, final Uri uri) { if (DEBUG) @@ -482,19 +511,6 @@ public int compare(File f1, File f2) { } }; - /** - * File (not directories) filter. - * - * @author paulburke - */ - public static FileFilter sFileFilter = new FileFilter() { - @Override - public boolean accept(File file) { - final String fileName = file.getName(); - // Return files only (not directories) and skip hidden files - return file.isFile() && !fileName.startsWith(HIDDEN_PREFIX); - } - }; /** * Folder (directories) filter. diff --git a/pom.xml b/pom.xml index c33513a..81baff0 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ com.ipaulpro afilechooser pom - 1.0 + 2.0 aFileChooser aFileChooser is an Android Library Project that simplifies the process of presenting a file chooser on Android 2.1+. https://github.com/krischik/aFileChooser3 @@ -101,6 +101,13 @@ compile apklib + + com.ipaulpro + afilechooser-library + 1.0 + provided + jar +
@@ -241,9 +248,9 @@ - com.noser + net.sourceforge.uiq3 Calculator-Checkstyle - ${CALCULATOR_VERSION} + 6.2.0 @@ -447,7 +454,7 @@ true true - com.noser:* + com.ipaulpro:* UTF-8 UTF-8 From f8979838709768c17276ca0d9a3bf7b9c073c79a Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Mon, 30 Dec 2013 10:42:22 +0100 Subject: [PATCH 06/18] Git-Commit.command --- .gitignore | 1 + Git-Commit.cmd.jar | Bin 2082 -> 0 bytes Git-Commit.command | 2 +- Maven-Deploy.cmd | 18 +-- Maven-Deploy.command | 6 +- aFileChooser/pom.xml | 2 +- aFileChooserExample/AndroidManifest.xml | 4 +- aFileChooserExample/pom.xml | 13 ++- aFileChooserExample/res/layout/example.xml | 44 +++++++ aFileChooserExample/res/values/strings.xml | 10 +- .../FileChooserExampleActivity.java | 110 ++++++++++++------ pom.xml | 16 ++- 12 files changed, 165 insertions(+), 61 deletions(-) delete mode 100644 Git-Commit.cmd.jar create mode 100644 aFileChooserExample/res/layout/example.xml diff --git a/.gitignore b/.gitignore index c28b0f8..e986219 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ lint.xml # Java class files *.class +*.jar # generated files bin/ diff --git a/Git-Commit.cmd.jar b/Git-Commit.cmd.jar deleted file mode 100644 index 9ec9bb6ed0d5852d8d6c93aa01f10efe7ee96c47..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2082 zcmaKt2{aqn8plH|DWXJFV(c`Kj}%Pw|KABRzb{fq~aaql7^s#MRrs(OOhDNt$)-tTNI} zv=uLI3hPe|dg3XgYHi&cbaTQ@Z#V=i5IK2T1@(^iC@PcsK;~-}s%N?JYW=41(%tH4 zf#4nJiPBkU%@G9}c}-1>|D)7(W{sL~nl5^}Y{3b3Gf5bUl4_Uc*TJIcJ+HqB z;@&`qj;)vDmv^N|fgUrpjh9gL;ScdchAy$?Zh#+aEF9oy8Do#xh5baq}pjT*p5i>3aT|^$ZaQqd!zR}wtteOsy3IBl)uk+)1U4>OxIqDXH4T5dTt)Bi1&E$vrCV~!uDJsMjd^$%)b z-ETTKU8iTh8E*JP1L{a#QLb;iLC=VjOr34>6m>bB;ePbQ39qyQm`${SsX>)QYw^aW za=1?>Ukg*P3dr7I7DWZSs@|6nhu(uoQ_DgUjz8bPv`i~-J;E}WcUdRBvo^#T23fbO zry;s>bsDl&BrCJGK`AUujomKCo-i>3DKEm#z<-lV>?Eg6%3J`)X;q>pc1k>Go_edt|Y>J|~b`PqC`7`m2SOMY6DPfk{s??;<)1e4t{PE@$( zgHm{i``Jl!W}(~xNvquI)OL-FQx4Cxc($P(#I1HRdf6FE?zI$)!`->uGSr;hUO63$ zbk~(7A0aAp&mY(!xUUIDuo*~!4NTKM)pHBKSZFK1~NtlDsii0o|fNQvT8VV zdD0~ak!{s{n3DrH=L}KSU`+R(E?`+!=-oc+l}@)y?_Qd;hg4;?Ni!|1PbM02%6Q`Y znF{6Q+ERr80G+*TeYwI&{F$kbiL$VL?GHAE?mm9497nqzA}Kk*uDz`9hg%er8)R&{ zD`=C{K^7?chtPS3uA`S+i2g)V{D7oh!_hj;wV&=p9?J{QxDk_->bL#&qUNo>-K|%iQ7M(g%5D*x2QY_}<-{aS9Sy(Wdl(=J-Ol(HPOFG&kHuwGBLdXqz0G4VUKY&KjhZ=e4yi zzo*@~NjOwtz>;E*Yb}IcUNh?&oGkHEFVy+UoOBvoi}VVU#7(_(uYX~;QEfk3m2PK~ z!R17TUQE?%YY7IQP3E-84PH6N6g=Lcl^{Ig1FKbj@6$_mY47OhuX#v6#QZ_PS;st% zYFKNni9%osOc*q2XJZt$aN0|4KG!4XCt_w9Bw&Co zJ9ZU#C#ufHy5T4$)r2BBflw4mVFeEtjus~DKKyP&Gg>JuS%%#0fr0$S5b!OCqM`=> z#$?6~kO*g34b!&0)87r3N5ubJ@zsCCL|@6P5ij-U0 z?xP}8e86md4;82Xq9P;=0erH>&y8x|7XPj^1)0C@;Rh`U4}FWG?^! diff --git a/Git-Commit.command b/Git-Commit.command index 8997120..6069949 100755 --- a/Git-Commit.command +++ b/Git-Commit.command @@ -23,7 +23,7 @@ # $HeadURL: https://uiq3.svn.sourceforge.net/svnroot/uiq3/trunk/Java/Utilities/Start-Vim.command $ ########################################################### }}}1 ########### -scala -save Git-Commit.cmd +scala -save Git-Commit.cmd ${0} # vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : # vim: set textwidth=0 filetype=zsh foldmethod=marker nospell : diff --git a/Maven-Deploy.cmd b/Maven-Deploy.cmd index e0672ab..1506f0a 100644 --- a/Maven-Deploy.cmd +++ b/Maven-Deploy.cmd @@ -15,7 +15,8 @@ SETLOCAL SET PATH=%PATH%;C:\opt\Scala\2.10.0\bin SET Scala_Library="${WORK}/Repositories/Local/net/sourceforge/uiq3/Calculator-Script/${CALCULATOR_VERSION}/Calculator-Script-${CALCULATOR_VERSION}.jar" - CALL scala -classpath %Scala_Library% -save %~f0 %* + PUSHD "AndroidAnnotations" + CALL scala -classpath %Scala_Library% -save ..\Maven-Deploy.cm %* POPD ENDLOCAL @@ -23,20 +24,21 @@ GOTO :eof ::!# import scala.sys.process._ -import net.sourceforge.uiq3.Maven._ +import net.sourceforge.uiq3.Maven.mvn +import net.sourceforge.uiq3.Shell.Err_Exit_Call val Maven_Deploy = System.getenv ("MAVEN_DEPLOY") val Project_Name = System.getenv ("PROJECT_NAME") -val Maven_Name = Project_Name +" Maven Repository" +val Maven_Name = Project_Name +" Maven Repository" -mvn ::: "--activate-profiles" :: "release" :: "install" :: Nil !; -mvn ::: "--activate-profiles" :: "release" :: "site:site" :: Nil !; - -mvn ::: +Err_Exit_Call (mvn ::: "--activate-profiles" :: "release" :: "install" :: Nil) +Err_Exit_Call (mvn ::: "--activate-profiles" :: "release" :: "javadoc:javadoc" :: Nil) +Err_Exit_Call (mvn ::: "--activate-profiles" :: "release" :: "source:jar" :: Nil) +Err_Exit_Call (mvn ::: "--define" :: "repo.id=" + Project_Name :: "--define" :: "repo.name=" + Maven_Name :: "--define" :: "repo.url=" + Maven_Deploy :: - "deploy" :: Nil !; + "deploy" :: Nil ) // vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : // vim: set textwidth=0 filetype=scala foldmethod=marker nospell : diff --git a/Maven-Deploy.command b/Maven-Deploy.command index ee5f8c5..9426df4 100755 --- a/Maven-Deploy.command +++ b/Maven-Deploy.command @@ -31,11 +31,9 @@ ssh-add \ /Users/martin/.ssh/id_dsa \ /Users/martin/.ssh/Martin_Krischik_SF -#scala -classpath ${Scala_Library} -save Maven-Deploy.cmd +scala -classpath ${Scala_Library} -save Maven-Deploy.cmd pushd "/Work/HomePage/uiq3/htdocs" - #sshpass -p ${KEY_SF} ssh ${Download_Server} create; - rsync \ --archive \ --delete \ @@ -43,8 +41,6 @@ pushd "/Work/HomePage/uiq3/htdocs" --keep-dirlinks \ "Repository" \ "krischik,uiq3@web.sourceforge.net:htdocs" - - #sshpass -p Martin_Krischik_SF ssh ${Download_Server} shutdown popd # vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : # vim: set textwidth=0 filetype=zsh foldmethod=marker nospell : diff --git a/aFileChooser/pom.xml b/aFileChooser/pom.xml index 3ed69e2..6645260 100644 --- a/aFileChooser/pom.xml +++ b/aFileChooser/pom.xml @@ -37,7 +37,7 @@ com.ipaulpro afilechooser - 1.0 + 2.0 https://github.com/krischik/aFileChooser3 diff --git a/aFileChooserExample/AndroidManifest.xml b/aFileChooserExample/AndroidManifest.xml index 16d51f6..3ff8e02 100644 --- a/aFileChooserExample/AndroidManifest.xml +++ b/aFileChooserExample/AndroidManifest.xml @@ -30,7 +30,7 @@ android:icon="@drawable/ic_launcher" android:label="@string/app_name" > @@ -67,4 +67,4 @@
- \ No newline at end of file + diff --git a/aFileChooserExample/pom.xml b/aFileChooserExample/pom.xml index 3f88881..ccc53fe 100644 --- a/aFileChooserExample/pom.xml +++ b/aFileChooserExample/pom.xml @@ -37,7 +37,7 @@ com.ipaulpro afilechooser - 1.0 + 2.0 https://github.com/krischik/aFileChooser3 @@ -84,6 +84,15 @@ afilechooser-library apklib + + org.androidannotations + androidannotations + provided + + + org.androidannotations + androidannotations-api + @@ -121,7 +130,7 @@ -Xms256m -Xmx512m - false + true true diff --git a/aFileChooserExample/res/layout/example.xml b/aFileChooserExample/res/layout/example.xml new file mode 100644 index 0000000..8cb7fea --- /dev/null +++ b/aFileChooserExample/res/layout/example.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + diff --git a/aFileChooserExample/res/values/strings.xml b/aFileChooserExample/res/values/strings.xml index 8de29c7..c02fad9 100644 --- a/aFileChooserExample/res/values/strings.xml +++ b/aFileChooserExample/res/values/strings.xml @@ -1,5 +1,5 @@ - - - aFileChooserExample - Lorem ipsum + aFileChooserExample + Lorem ipsum + Choose from all files… + Choose pdf files… + Choose calculator files… \ No newline at end of file diff --git a/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java b/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java index 8fd11a8..798a6fd 100644 --- a/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java +++ b/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java @@ -20,58 +20,94 @@ import android.content.ActivityNotFoundException; import android.content.Intent; import android.net.Uri; -import android.os.Bundle; import android.util.Log; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.Button; -import android.widget.Toast; - +import com.ipaulpro.afilechooser.FileChooserActivity; import com.ipaulpro.afilechooser.utils.FileUtils; +import java.util.ArrayList; + /** * @author paulburke (ipaulpro) */ +@org.androidannotations.annotations.EActivity (R.layout.example) public class FileChooserExampleActivity extends Activity { - private static final String TAG = "FileChooserExampleActivity"; - - private static final int REQUEST_CODE = 6384; // onActivityResult request - // code - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // Create a simple button to start the file chooser process - Button button = new Button(this); - button.setText(R.string.choose_file); - button.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - // Display the file chooser dialog - showChooser(); - } - }); + private static final String TAG = FileChooserExampleActivity.class.getSimpleName (); + /** + *

onActivityResult request code

+ */ + private static final int REQUEST_CODE = 6384; + private static final ArrayList PDF_Files; + private static final ArrayList Calculator_Files; - setContentView(button); + static + { + PDF_Files = new java.util.ArrayList (); + PDF_Files.add (".pdf"); + Calculator_Files = new java.util.ArrayList (); + Calculator_Files.add (".af"); + Calculator_Files.add (".df"); + Calculator_Files.add (".pf"); } - private void showChooser() { + @org.androidannotations.annotations.Click (R.id.All_Files) + void appFiles() { // Use the GET_CONTENT intent from the utility class - Intent target = FileUtils.createGetContentIntent(); + final Intent target = FileUtils.createGetContentIntent(); // Create the chooser Intent - Intent intent = Intent.createChooser( + final Intent intent = Intent.createChooser( target, getString(R.string.chooser_title)); try { startActivityForResult(intent, REQUEST_CODE); - } catch (ActivityNotFoundException e) { - // The reason for the existence of aFileChooser + } catch (final ActivityNotFoundException e) { + // The reason for the existence of aFileChooser + android.util.Log.e (TAG, "LOG02230:", e); } } + @org.androidannotations.annotations.Click (R.id.PDF_Files) + void pdfFiles() { + // Use the GET_CONTENT intent from the utility class + final Intent target = FileUtils.createGetContentIntent(); + // Create the chooser Intent + final Intent intent = Intent.createChooser( + target, getString(R.string.chooser_title)); + + intent.putStringArrayListExtra( + FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, + PDF_Files); + + try { + startActivityForResult(intent, REQUEST_CODE); + } catch (final ActivityNotFoundException e) { + // The reason for the existence of aFileChooser + android.util.Log.e (TAG, "LOG02230:", e); + } + } + @org.androidannotations.annotations.Click (R.id.Calculator_Files) + void calculatorFiles() { + // Use the GET_CONTENT intent from the utility class + final Intent target = FileUtils.createGetContentIntent(); + // Create the chooser Intent + final Intent intent = Intent.createChooser( + target, getString(R.string.chooser_title)); + + intent.putStringArrayListExtra( + FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, + Calculator_Files); + + try { + startActivityForResult(intent, REQUEST_CODE); + } catch (final ActivityNotFoundException e) { + // The reason for the existence of aFileChooser + android.util.Log.e (TAG, "LOG02230:", e); + } + } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult( + final int requestCode, + final int resultCode, + final Intent data) { switch (requestCode) { case REQUEST_CODE: // If the file selection was successful @@ -83,10 +119,12 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { try { // Get the file path from the URI final String path = FileUtils.getPath(this, uri); - Toast.makeText(FileChooserExampleActivity.this, - "File Selected: " + path, Toast.LENGTH_LONG).show(); - } catch (Exception e) { - Log.e("FileSelectorTestActivity", "File select error", e); + final android.widget.Toast toast = android.widget.Toast.makeText ( + com.ipaulpro.afilechooserexample.FileChooserExampleActivity.this, + "File Selected: " + path, android.widget.Toast.LENGTH_LONG); + toast.show (); + } catch (final Exception e) { + Log.e(TAG, "File select error", e); } } } diff --git a/pom.xml b/pom.xml index 81baff0..3d13965 100644 --- a/pom.xml +++ b/pom.xml @@ -97,17 +97,28 @@ com.ipaulpro afilechooser-library - 1.0 + 2.0 compile apklib com.ipaulpro afilechooser-library - 1.0 + 2.0 provided jar + + org.androidannotations + androidannotations + ${androidannotations.version} + provided + + + org.androidannotations + androidannotations-api + ${androidannotations.version} + @@ -507,6 +518,7 @@ UTF-8 UTF-8 UTF-8 + 3.0 From a0f0b3686bfa7d13d4efd28b592d1ca0115c3be4 Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Mon, 30 Dec 2013 13:06:27 +0100 Subject: [PATCH 07/18] Git-Commit.command --- aFileChooser/pom.xml | 4 + .../localstorage/LocalStorageProvider.java | 31 +++-- .../afilechooser/FileChooserActivity.java | 56 +++++--- .../afilechooser/FileListAdapter.java | 8 +- .../afilechooser/FileListFragment.java | 66 ++++++--- .../com/ipaulpro/afilechooser/FileLoader.java | 37 ++--- .../afilechooser/utils/FileUtils.java | 126 ++++++++++++------ aFileChooserExample/pom.xml | 22 +-- aFileChooserExample/res/values-v19/bools.xml | 6 + .../FileChooserExampleActivity.java | 116 +++++++++------- pom.xml | 11 +- 11 files changed, 314 insertions(+), 169 deletions(-) create mode 100644 aFileChooserExample/res/values-v19/bools.xml diff --git a/aFileChooser/pom.xml b/aFileChooser/pom.xml index 6645260..f1a07b6 100644 --- a/aFileChooser/pom.xml +++ b/aFileChooser/pom.xml @@ -78,6 +78,10 @@ android android + + com.intellij + annotations + diff --git a/aFileChooser/src/com/ianhanniballake/localstorage/LocalStorageProvider.java b/aFileChooser/src/com/ianhanniballake/localstorage/LocalStorageProvider.java index ec59026..6f7ad8f 100644 --- a/aFileChooser/src/com/ianhanniballake/localstorage/LocalStorageProvider.java +++ b/aFileChooser/src/com/ianhanniballake/localstorage/LocalStorageProvider.java @@ -17,12 +17,15 @@ import android.webkit.MimeTypeMap; import com.ipaulpro.afilechooser.R; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +@android.annotation.TargetApi (19) public class LocalStorageProvider extends DocumentsProvider { public static final String AUTHORITY = "com.ianhanniballake.localstorage.documents"; @@ -46,8 +49,8 @@ public class LocalStorageProvider extends DocumentsProvider { Document.COLUMN_LAST_MODIFIED }; - @Override - public Cursor queryRoots(final String[] projection) throws FileNotFoundException { + @Nullable @Override + public Cursor queryRoots(@Nullable final String[] projection) throws FileNotFoundException { // Create a cursor with either the requested fields, or the default // projection if "projection" is null. final MatrixCursor result = new MatrixCursor(projection != null ? projection @@ -70,7 +73,7 @@ public Cursor queryRoots(final String[] projection) throws FileNotFoundException return result; } - @Override + @Nullable @Override public String createDocument(final String parentDocumentId, final String mimeType, final String displayName) throws FileNotFoundException { File newFile = new File(parentDocumentId, displayName); @@ -83,8 +86,9 @@ public String createDocument(final String parentDocumentId, final String mimeTyp return null; } - @Override - public AssetFileDescriptor openDocumentThumbnail(final String documentId, final Point sizeHint, + @Nullable @Override + public AssetFileDescriptor openDocumentThumbnail(final String documentId, @NotNull + final Point sizeHint, final CancellationSignal signal) throws FileNotFoundException { // Assume documentId points to an image file. Build a thumbnail no // larger than twice the sizeHint @@ -136,8 +140,9 @@ public AssetFileDescriptor openDocumentThumbnail(final String documentId, final AssetFileDescriptor.UNKNOWN_LENGTH); } - @Override - public Cursor queryChildDocuments(final String parentDocumentId, final String[] projection, + @Nullable @Override + public Cursor queryChildDocuments(final String parentDocumentId, @Nullable + final String[] projection, final String sortOrder) throws FileNotFoundException { // Create a cursor with either the requested fields, or the default // projection if "projection" is null. @@ -154,8 +159,9 @@ public Cursor queryChildDocuments(final String parentDocumentId, final String[] return result; } - @Override - public Cursor queryDocument(final String documentId, final String[] projection) + @Nullable @Override + public Cursor queryDocument(final String documentId, @Nullable + final String[] projection) throws FileNotFoundException { // Create a cursor with either the requested fields, or the default // projection if "projection" is null. @@ -165,7 +171,9 @@ public Cursor queryDocument(final String documentId, final String[] projection) return result; } - private void includeFile(final MatrixCursor result, final File file) + private void includeFile( + @NotNull final MatrixCursor result, @NotNull + final File file) throws FileNotFoundException { final MatrixCursor.RowBuilder row = result.newRow(); // These columns are required @@ -215,7 +223,8 @@ public void deleteDocument(final String documentId) throws FileNotFoundException } @Override - public ParcelFileDescriptor openDocument(final String documentId, final String mode, + public ParcelFileDescriptor openDocument(final String documentId, @NotNull + final String mode, final CancellationSignal signal) throws FileNotFoundException { File file = new File(documentId); final boolean isWrite = (mode.indexOf('w') != -1); diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java b/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java index 6873bbf..152f101 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java @@ -35,6 +35,8 @@ import android.view.Menu; import android.view.MenuItem; import android.widget.Toast; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.File; import java.util.ArrayList; @@ -49,6 +51,11 @@ public class FileChooserActivity extends FragmentActivity implements OnBackStackChangedListener, FileListFragment.Callbacks { + /** + * TAG for log messages. + * */ + static final String TAG = FileChooserActivity.class.getName (); + public static final String PATH = "path"; public static final String EXTRA_FILTER_INCLUDE_EXTENSIONS = "com.ipaulpro.afilechooser.EXTRA_FILTER_INCLUDE_EXTENSIONS"; @@ -59,9 +66,9 @@ public class FileChooserActivity extends FragmentActivity implements private static final boolean HAS_ACTIONBAR = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; private FragmentManager mFragmentManager; - private BroadcastReceiver mStorageListener = new BroadcastReceiver() { + @NotNull private BroadcastReceiver mStorageListener = new BroadcastReceiver() { @Override - public void onReceive(Context context, Intent intent) { + public void onReceive(final Context context, final Intent intent) { Toast.makeText(context, R.string.storage_removed, Toast.LENGTH_LONG).show(); finishWithResult(null); } @@ -70,11 +77,23 @@ public void onReceive(Context context, Intent intent) { private String mPath; @Override - protected void onCreate(Bundle savedInstanceState) { + protected void onCreate(@Nullable final Bundle savedInstanceState) { + android.util.Log.d (TAG, "+ onCreate"); + android.util.Log.v (TAG, "> savedInstanceState = " + savedInstanceState); + super.onCreate(savedInstanceState); + final Intent intent = getIntent(); + + android.util.Log.v (TAG, "> intent = " + intent); + + if(intent != null){ + mFilterIncludeExtensions = intent.getStringArrayListExtra ( + EXTRA_FILTER_INCLUDE_EXTENSIONS); + android.util.Log.v (TAG, "> mFilterIncludeExtensions = " + mFilterIncludeExtensions); + } mFragmentManager = getSupportFragmentManager(); - mFragmentManager.addOnBackStackChangedListener(this); + mFragmentManager.addOnBackStackChangedListener (this); if (savedInstanceState == null) { mPath = EXTERNAL_BASE_PATH; @@ -83,14 +102,9 @@ protected void onCreate(Bundle savedInstanceState) { mPath = savedInstanceState.getString(PATH); } - final Intent intent = getIntent(); + setTitle(mPath); - if(intent != null){ - mFilterIncludeExtensions = intent.getStringArrayListExtra ( - EXTRA_FILTER_INCLUDE_EXTENSIONS); - } - - setTitle(mPath); + android.util.Log.d (TAG, "- onCreate"); } @Override @@ -108,7 +122,7 @@ protected void onResume() { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NotNull final Bundle outState) { super.onSaveInstanceState(outState); outState.putString(PATH, mPath); @@ -118,9 +132,9 @@ protected void onSaveInstanceState(Bundle outState) { @Override public void onBackStackChanged() { - int count = mFragmentManager.getBackStackEntryCount(); + final int count = mFragmentManager.getBackStackEntryCount(); if (count > 0) { - BackStackEntry fragment = mFragmentManager.getBackStackEntryAt(count - 1); + final BackStackEntry fragment = mFragmentManager.getBackStackEntryAt(count - 1); mPath = fragment.getName(); } else { mPath = EXTERNAL_BASE_PATH; @@ -133,7 +147,7 @@ public void onBackStackChanged() { @SuppressLint("NewApi") // Usages of New APIs are surrounded by sufficient conditional checks @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(final Menu menu) { if (HAS_ACTIONBAR) { final boolean hasBackStack = mFragmentManager.getBackStackEntryCount() > 0; final ActionBar actionBar = getActionBar(); @@ -146,7 +160,7 @@ public boolean onCreateOptionsMenu(Menu menu) { } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(@NotNull final MenuItem item) { switch (item.getItemId()) { case android.R.id.home: mFragmentManager.popBackStack(); @@ -173,7 +187,7 @@ private void addFragment() { * * @param file The file (directory) to display. */ - private void replaceFragment(File file) { + private void replaceFragment(@NotNull final File file) { mPath = file.getAbsolutePath(); final FileListFragment fragment = FileListFragment.newInstance( @@ -190,9 +204,9 @@ private void replaceFragment(File file) { * * @param file The file selected. */ - private void finishWithResult(File file) { + private void finishWithResult(@Nullable final File file) { if (file != null) { - Uri uri = Uri.fromFile(file); + final Uri uri = Uri.fromFile(file); setResult(RESULT_OK, new Intent().setData(uri)); finish(); } else { @@ -207,7 +221,7 @@ private void finishWithResult(File file) { * @param file The file that was selected */ @Override - public void onFileSelected(File file) { + public void onFileSelected(@Nullable final File file) { if (file != null) { if (file.isDirectory()) { replaceFragment(file); @@ -224,7 +238,7 @@ public void onFileSelected(File file) { * Register the external storage BroadcastReceiver. */ private void registerStorageListener() { - IntentFilter filter = new IntentFilter(); + final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_MEDIA_REMOVED); registerReceiver(mStorageListener, filter); } diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/FileListAdapter.java b/aFileChooser/src/com/ipaulpro/afilechooser/FileListAdapter.java index 3480122..8c53586 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/FileListAdapter.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/FileListAdapter.java @@ -29,7 +29,7 @@ /** * List adapter for Files. - * + * * @version 2013-12-11 * @author paulburke (ipaulpro) */ @@ -42,8 +42,10 @@ public class FileListAdapter extends BaseAdapter { private List mData = new ArrayList(); - public FileListAdapter(Context context) { - mInflater = LayoutInflater.from(context); + public FileListAdapter(Context context) + { + super (); + mInflater = LayoutInflater.from (context); } public void add(File file) { diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java b/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java index 4ebb47f..5e18d81 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java @@ -24,6 +24,8 @@ import android.support.v4.content.Loader; import android.view.View; import android.widget.ListView; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.File; import java.util.List; @@ -35,9 +37,14 @@ * @version 2013-12-11 * @author paulburke (ipaulpro) */ +@SuppressWarnings ("CollectionDeclaredAsConcreteClass") public class FileListFragment extends ListFragment implements LoaderManager.LoaderCallbacks> { + /** + * TAG for log messages. + * */ + static final String TAG = FileListFragment.class.getName (); /** * Interface to listen for events. */ @@ -52,8 +59,14 @@ public interface Callbacks { private static final int LOADER_ID = 0; + @NotNull private FileListAdapter mAdapter; + /** + *

path to display. Not null after onCreate

+ */ + @NotNull private String mPath; + @Nullable private ArrayList mFilterIncludeExtensions = new ArrayList(); private Callbacks mListener; @@ -64,50 +77,67 @@ public interface Callbacks { * @param path The absolute path of the file (directory) to display. * @return A new Fragment with the given file path. */ - public static FileListFragment newInstance( - String path, - final ArrayList filterIncludeExtensions ) { - FileListFragment fragment = new FileListFragment(); - Bundle args = new Bundle(); + @NotNull public static FileListFragment newInstance( + @NotNull final String path, + @Nullable final ArrayList filterIncludeExtensions ) { + android.util.Log.d (TAG, "+ newInstance"); + android.util.Log.v (TAG, "> path = " + path); + android.util.Log.v (TAG, "> filterIncludeExtensions = " + filterIncludeExtensions); + + final FileListFragment fragment = new FileListFragment(); + final Bundle args = new Bundle(); + args.putString(FileChooserActivity.PATH, path); args.putStringArrayList ( FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, filterIncludeExtensions); fragment.setArguments(args); + android.util.Log.v (TAG, "> fragment = " + fragment); + android.util.Log.d (TAG, "+ newInstance"); return fragment; } @Override - public void onAttach(Activity activity) { + public void onAttach(@NotNull final Activity activity) { super.onAttach(activity); try { mListener = (Callbacks) activity; - } catch (ClassCastException e) { + } catch (@NotNull final ClassCastException e) { + android.util.Log.e (TAG, "LOG02240:", e); throw new ClassCastException(activity.toString() + " must implement FileListFragment.Callbacks"); } } @Override - public void onCreate(Bundle savedInstanceState) { + public void onCreate(final Bundle savedInstanceState) { + android.util.Log.d (TAG, "+ onCreate"); + android.util.Log.v (TAG, "> savedInstanceState = " + savedInstanceState); + super.onCreate(savedInstanceState); final android.os.Bundle arguments = getArguments (); mAdapter = new FileListAdapter(getActivity()); - mPath = arguments != null ? arguments.getString ( - FileChooserActivity.PATH) : Environment - .getExternalStorageDirectory().getAbsolutePath(); + + android.util.Log.v (TAG, "> mAdapter = " + mAdapter); + android.util.Log.v (TAG, "> arguments = " + arguments); + + mPath = arguments != null + ? arguments.getString (FileChooserActivity.PATH) + : Environment.getExternalStorageDirectory().getAbsolutePath(); if(arguments != null){ mFilterIncludeExtensions = arguments.getStringArrayList ( FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS); } + + android.util.Log.d (TAG, "+ onCreate"); } @Override - public void onActivityCreated(Bundle savedInstanceState) { + public void onActivityCreated(final Bundle savedInstanceState) { setEmptyText(getString(R.string.empty_directory)); setListAdapter(mAdapter); setListShown(false); @@ -118,8 +148,8 @@ public void onActivityCreated(Bundle savedInstanceState) { } @Override - public void onListItemClick(ListView l, View v, int position, long id) { - FileListAdapter adapter = (FileListAdapter) l.getAdapter(); + public void onListItemClick(@NotNull final ListView l, final View v, final int position, final long id) { + final FileListAdapter adapter = (FileListAdapter) l.getAdapter(); if (adapter != null) { final File file = adapter.getItem(position); mPath = file.getAbsolutePath(); @@ -127,13 +157,13 @@ public void onListItemClick(ListView l, View v, int position, long id) { } } - @Override - public Loader> onCreateLoader(int id, Bundle args) { + @Nullable @Override + public Loader> onCreateLoader(final int id, final Bundle args) { return new FileLoader(getActivity(), mPath, mFilterIncludeExtensions); } @Override - public void onLoadFinished(Loader> loader, List data) { + public void onLoadFinished(final Loader> loader, final List data) { mAdapter.setListItems(data); if (isResumed()) @@ -143,7 +173,7 @@ public void onLoadFinished(Loader> loader, List data) { } @Override - public void onLoaderReset(Loader> loader) { + public void onLoaderReset(final Loader> loader) { mAdapter.clear(); } } diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/FileLoader.java b/aFileChooser/src/com/ipaulpro/afilechooser/FileLoader.java index 8aa635c..b60cc2b 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/FileLoader.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/FileLoader.java @@ -21,12 +21,13 @@ import android.support.v4.content.AsyncTaskLoader; import com.ipaulpro.afilechooser.utils.FileUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.ArrayList; /** * Loader that returns a list of Files in a given file path. @@ -41,22 +42,22 @@ public class FileLoader extends AsyncTaskLoader> { | FileObserver.MOVED_FROM | FileObserver.MOVED_TO | FileObserver.MODIFY | FileObserver.MOVE_SELF; - private FileObserver mFileObserver; + @Nullable private FileObserver mFileObserver; - private List mData; + @Nullable private List mData; private final String mPath; - private ArrayList mFilterIncludeExtensions; + @Nullable private final ArrayList mFilterIncludeExtensions; public FileLoader( - Context context, - String path, - ArrayList filterIncludeExtensions) { + @NotNull final Context context, + final String path, + @Nullable final ArrayList filterIncludeExtensions) { super(context); this.mPath = path; this.mFilterIncludeExtensions = filterIncludeExtensions; } - @Override + @NotNull @Override public List loadInBackground() { final ArrayList list = new ArrayList(); @@ -87,13 +88,13 @@ public List loadInBackground() { } @Override - public void deliverResult(List data) { + public void deliverResult(final List data) { if (isReset()) { onReleaseResources(data); return; } - List oldData = mData; + final List oldData = mData; mData = data; if (isStarted()) @@ -105,21 +106,23 @@ public void deliverResult(List data) { @Override protected void onStartLoading() { - if (mData != null) - deliverResult(mData); + if (mData != null) { + deliverResult (mData); + } if (mFileObserver == null) { mFileObserver = new FileObserver(mPath, FILE_OBSERVER_MASK) { @Override - public void onEvent(int event, String path) { + public void onEvent(final int event, final String path) { onContentChanged(); } }; } mFileObserver.startWatching(); - if (takeContentChanged() || mData == null) - forceLoad(); + if (takeContentChanged() || mData == null) { + forceLoad (); + } } @Override @@ -138,13 +141,13 @@ protected void onReset() { } @Override - public void onCanceled(List data) { + public void onCanceled(final List data) { super.onCanceled(data); onReleaseResources(data); } - protected void onReleaseResources(List data) { + protected void onReleaseResources(final List data) { if (mFileObserver != null) { mFileObserver.stopWatching(); diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java b/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java index 3af9096..3fd32ab 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java @@ -32,6 +32,8 @@ import android.webkit.MimeTypeMap; import com.ianhanniballake.localstorage.LocalStorageProvider; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.FileFilter; @@ -49,8 +51,10 @@ public class FileUtils { private FileUtils() {} //private constructor to enforce Singleton pattern - /** TAG for log messages. */ - static final String TAG = "FileUtils"; + /** + * TAG for log messages. + * */ + static final String TAG = FileUtils.class.getName (); private static final boolean DEBUG = false; // Set to true to enable logging public static final String MIME_TYPE_AUDIO = "audio/*"; @@ -67,22 +71,37 @@ private FileUtils() {} //private constructor to enforce Singleton pattern * */ public static class FileExtensionFilter implements FileFilter{ - private final ArrayList mFilterIncludeExtensions; + /** + *

file extension filter

+ */ + @Nullable private final ArrayList mFilterIncludeExtensions; + + public FileExtensionFilter (@Nullable final ArrayList filterIncludeExtensions){ + android.util.Log.d (TAG, "+ FileExtensionFilter"); + android.util.Log.v (TAG, "> filterIncludeExtensions = " + filterIncludeExtensions); + + this.mFilterIncludeExtensions = filterIncludeExtensions; - public FileExtensionFilter (final ArrayList filterIncludeExtensions){ - this.mFilterIncludeExtensions = filterIncludeExtensions; + android.util.Log.d (TAG, "+ FileExtensionFilter"); } @Override - public boolean accept(final File file) { + public boolean accept(@NotNull final File file) { + android.util.Log.d (TAG, "+ accept"); + android.util.Log.v (TAG, "> file = " + file); + final String fileName = file.getName(); final android.net.Uri uri = android.net.Uri.fromFile (file); - final boolean passesExtensionsFilter = + final boolean passesExtensionsFilter = mFilterIncludeExtensions == null || mFilterIncludeExtensions.isEmpty () || mFilterIncludeExtensions.contains ( getExtension (uri.toString ())); // Return files only (not directories) and skip hidden files - return file.isFile() && !fileName.startsWith(HIDDEN_PREFIX) && + final boolean retval = file.isFile() && !fileName.startsWith(HIDDEN_PREFIX) && passesExtensionsFilter; + + android.util.Log.v (TAG, "> retval = " + retval); + android.util.Log.d (TAG, "- accept"); + return retval; } } @@ -94,12 +113,13 @@ public boolean accept(final File file) { * @return Extension including the dot("."); "" if there is no extension; * null if uri was null. */ - public static String getExtension(String uri) { + @Nullable + public static String getExtension(@Nullable final String uri) { if (uri == null) { return null; } - int dot = uri.lastIndexOf("."); + final int dot = uri.lastIndexOf("."); if (dot >= 0) { return uri.substring(dot); } else { @@ -111,7 +131,7 @@ public static String getExtension(String uri) { /** * @return Whether the URI is a local one. */ - public static boolean isLocal(String url) { + public static boolean isLocal(@Nullable final String url) { if (url != null && !url.startsWith("http://") && !url.startsWith("https://")) { return true; } @@ -122,7 +142,7 @@ public static boolean isLocal(String url) { * @return True if Uri is a MediaStore Uri. * @author paulburke */ - public static boolean isMediaUri(Uri uri) { + public static boolean isMediaUri(@NotNull final Uri uri) { return "media".equalsIgnoreCase(uri.getAuthority()); } @@ -132,7 +152,8 @@ public static boolean isMediaUri(Uri uri) { * @param file * @return uri */ - public static Uri getUri(File file) { + @Nullable + public static Uri getUri(@Nullable final File file) { if (file != null) { return Uri.fromFile(file); } @@ -145,14 +166,15 @@ public static Uri getUri(File file) { * @param file * @return */ - public static File getPathWithoutFilename(File file) { + @Nullable + public static File getPathWithoutFilename(@Nullable final File file) { if (file != null) { if (file.isDirectory()) { // no file to be split off. Return everything return file; } else { - String filename = file.getName(); - String filepath = file.getAbsolutePath(); + final String filename = file.getName(); + final String filepath = file.getAbsolutePath(); // Construct path without file name. String pathwithoutname = filepath.substring(0, @@ -169,9 +191,9 @@ public static File getPathWithoutFilename(File file) { /** * @return The MIME type for the given file. */ - public static String getMimeType(File file) { + public static String getMimeType(@NotNull final File file) { - String extension = getExtension(file.getName()); + final String extension = getExtension(file.getName()); if (extension.length() > 0) return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension.substring(1)); @@ -182,8 +204,10 @@ public static String getMimeType(File file) { /** * @return The MIME type for the give Uri. */ - public static String getMimeType(Context context, Uri uri) { - File file = new File(getPath(context, uri)); + public static String getMimeType( + @NotNull final Context context, @NotNull final + Uri uri) { + final File file = new File(getPath(context, uri)); return getMimeType(file); } @@ -192,7 +216,7 @@ public static String getMimeType(Context context, Uri uri) { * @return Whether the Uri authority is {@link LocalStorageProvider}. * @author paulburke */ - public static boolean isLocalStorageDocument(Uri uri) { + public static boolean isLocalStorageDocument(@NotNull final Uri uri) { return LocalStorageProvider.AUTHORITY.equals(uri.getAuthority()); } @@ -201,7 +225,7 @@ public static boolean isLocalStorageDocument(Uri uri) { * @return Whether the Uri authority is ExternalStorageProvider. * @author paulburke */ - public static boolean isExternalStorageDocument(Uri uri) { + public static boolean isExternalStorageDocument(@NotNull final Uri uri) { return "com.android.externalstorage.documents".equals(uri.getAuthority()); } @@ -210,7 +234,7 @@ public static boolean isExternalStorageDocument(Uri uri) { * @return Whether the Uri authority is DownloadsProvider. * @author paulburke */ - public static boolean isDownloadsDocument(Uri uri) { + public static boolean isDownloadsDocument(@NotNull final Uri uri) { return "com.android.providers.downloads.documents".equals(uri.getAuthority()); } @@ -219,7 +243,7 @@ public static boolean isDownloadsDocument(Uri uri) { * @return Whether the Uri authority is MediaProvider. * @author paulburke */ - public static boolean isMediaDocument(Uri uri) { + public static boolean isMediaDocument(@NotNull final Uri uri) { return "com.android.providers.media.documents".equals(uri.getAuthority()); } @@ -227,7 +251,7 @@ public static boolean isMediaDocument(Uri uri) { * @param uri The Uri to check. * @return Whether the Uri authority is Google Photos. */ - public static boolean isGooglePhotosUri(Uri uri) { + public static boolean isGooglePhotosUri(@NotNull final Uri uri) { return "com.google.android.apps.photos.content".equals(uri.getAuthority()); } @@ -242,8 +266,11 @@ public static boolean isGooglePhotosUri(Uri uri) { * @return The value of the _data column, which is typically a file path. * @author paulburke */ - public static String getDataColumn(Context context, Uri uri, String selection, - String[] selectionArgs) { + @Nullable public static String getDataColumn( + @NotNull final Context context, + final Uri uri, + final String selection, + final String[] selectionArgs) { Cursor cursor = null; final String column = "_data"; @@ -282,8 +309,10 @@ public static String getDataColumn(Context context, Uri uri, String selection, * @see #getFile(Context, Uri) * @author paulburke */ - @android.annotation.SuppressLint ("NewApi") // Usages of New APIs are surrounded by sufficient conditional checks - public static String getPath(final Context context, final Uri uri) { + @Nullable @android.annotation.SuppressLint ("NewApi") // Usages of New APIs are surrounded by sufficient conditional checks + public static String getPath( + @NotNull final Context context, @NotNull + final Uri uri) { if (DEBUG) Log.d(TAG + " File -", @@ -374,9 +403,13 @@ else if ("file".equalsIgnoreCase(uri.getScheme())) { * @see #getPath(Context, Uri) * @author paulburke */ - public static File getFile(Context context, Uri uri) { + @Nullable + public static File getFile( + @NotNull final Context context, + @Nullable final + Uri uri) { if (uri != null) { - String path = getPath(context, uri); + final String path = getPath(context, uri); if (path != null && isLocal(path)) { return new File(path); } @@ -391,7 +424,7 @@ public static File getFile(Context context, Uri uri) { * @return * @author paulburke */ - public static String getReadableFileSize(int size) { + public static String getReadableFileSize(final int size) { final int BYTES_IN_KILOBYTES = 1024; final DecimalFormat dec = new DecimalFormat("###.#"); final String KILOBYTES = " KB"; @@ -424,7 +457,10 @@ public static String getReadableFileSize(int size) { * @return * @author paulburke */ - public static Bitmap getThumbnail(Context context, File file) { + @Nullable + public static Bitmap getThumbnail( + @NotNull final Context context, + @NotNull final File file) { return getThumbnail(context, getUri(file), getMimeType(file)); } @@ -437,7 +473,10 @@ public static Bitmap getThumbnail(Context context, File file) { * @return * @author paulburke */ - public static Bitmap getThumbnail(Context context, Uri uri) { + @Nullable + public static Bitmap getThumbnail( + @NotNull final Context context, + @NotNull final Uri uri) { return getThumbnail(context, uri, getMimeType(context, uri)); } @@ -451,7 +490,10 @@ public static Bitmap getThumbnail(Context context, Uri uri) { * @return * @author paulburke */ - public static Bitmap getThumbnail(Context context, Uri uri, String mimeType) { + @Nullable + public static Bitmap getThumbnail( + @NotNull final Context context, @NotNull final + Uri uri, @NotNull final String mimeType) { if (DEBUG) Log.d(TAG, "Attempting to get thumbnail"); @@ -486,7 +528,7 @@ else if (mimeType.contains(FileUtils.MIME_TYPE_IMAGE)) { null); } } - } catch (Exception e) { + } catch (final Exception e) { if (DEBUG) Log.e(TAG, "getThumbnail", e); } finally { @@ -502,9 +544,11 @@ else if (mimeType.contains(FileUtils.MIME_TYPE_IMAGE)) { * * @author paulburke */ - public static Comparator sComparator = new Comparator() { + @NotNull public static Comparator sComparator = new Comparator() { @Override - public int compare(File f1, File f2) { + public int compare( + @NotNull final File f1, @NotNull final + File f2) { // Sort alphabetically by lower case, which is much cleaner return f1.getName().toLowerCase().compareTo( f2.getName().toLowerCase()); @@ -517,9 +561,9 @@ public int compare(File f1, File f2) { * * @author paulburke */ - public static FileFilter sDirFilter = new FileFilter() { + @NotNull public static FileFilter sDirFilter = new FileFilter() { @Override - public boolean accept(File file) { + public boolean accept(@NotNull final File file) { final String fileName = file.getName(); // Return directories only and skip hidden directories return file.isDirectory() && !fileName.startsWith(HIDDEN_PREFIX); @@ -532,7 +576,7 @@ public boolean accept(File file) { * @return The intent for opening a file with Intent.createChooser() * @author paulburke */ - public static Intent createGetContentIntent() { + @NotNull public static Intent createGetContentIntent() { // Implicitly allow the user to select a particular kind of data final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); // The MIME data type filter diff --git a/aFileChooserExample/pom.xml b/aFileChooserExample/pom.xml index ccc53fe..bb78580 100644 --- a/aFileChooserExample/pom.xml +++ b/aFileChooserExample/pom.xml @@ -84,15 +84,19 @@ afilechooser-library apklib - - org.androidannotations - androidannotations - provided - - - org.androidannotations - androidannotations-api - + + com.googlecode.androidannotations + androidannotations + provided + + + com.googlecode.androidannotations + androidannotations-api + + + com.intellij + annotations + diff --git a/aFileChooserExample/res/values-v19/bools.xml b/aFileChooserExample/res/values-v19/bools.xml new file mode 100644 index 0000000..9cdd78a --- /dev/null +++ b/aFileChooserExample/res/values-v19/bools.xml @@ -0,0 +1,6 @@ + + + + true + + \ No newline at end of file diff --git a/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java b/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java index 798a6fd..a736b86 100644 --- a/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java +++ b/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java @@ -23,22 +23,25 @@ import android.util.Log; import com.ipaulpro.afilechooser.FileChooserActivity; import com.ipaulpro.afilechooser.utils.FileUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; /** * @author paulburke (ipaulpro) */ -@org.androidannotations.annotations.EActivity (R.layout.example) +@SuppressWarnings ("CollectionDeclaredAsConcreteClass") +@com.googlecode.androidannotations.annotations.EActivity (R.layout.example) public class FileChooserExampleActivity extends Activity { - private static final String TAG = FileChooserExampleActivity.class.getSimpleName (); + private static final String TAG = FileChooserExampleActivity.class.getName (); /** *

onActivityResult request code

*/ private static final int REQUEST_CODE = 6384; - private static final ArrayList PDF_Files; - private static final ArrayList Calculator_Files; + @NotNull private static final ArrayList PDF_Files; + @NotNull private static final ArrayList Calculator_Files; static { @@ -50,64 +53,74 @@ public class FileChooserExampleActivity extends Activity { Calculator_Files.add (".pf"); } - @org.androidannotations.annotations.Click (R.id.All_Files) + @com.googlecode.androidannotations.annotations.res.StringRes (R.string.chooser_title) + String chooser_title; + + @com.googlecode.androidannotations.annotations.Click (R.id.All_Files) void appFiles() { + android.util.Log.d (TAG, "+ All_Files"); + // Use the GET_CONTENT intent from the utility class final Intent target = FileUtils.createGetContentIntent(); // Create the chooser Intent - final Intent intent = Intent.createChooser( - target, getString(R.string.chooser_title)); + final Intent intent = Intent.createChooser(target, chooser_title); try { startActivityForResult(intent, REQUEST_CODE); - } catch (final ActivityNotFoundException e) { + } catch (@NotNull final ActivityNotFoundException e) { // The reason for the existence of aFileChooser android.util.Log.e (TAG, "LOG02230:", e); } + + android.util.Log.d (TAG, "+ All_Files"); } - @org.androidannotations.annotations.Click (R.id.PDF_Files) - void pdfFiles() { - // Use the GET_CONTENT intent from the utility class - final Intent target = FileUtils.createGetContentIntent(); - // Create the chooser Intent - final Intent intent = Intent.createChooser( - target, getString(R.string.chooser_title)); - - intent.putStringArrayListExtra( - FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, - PDF_Files); - - try { - startActivityForResult(intent, REQUEST_CODE); - } catch (final ActivityNotFoundException e) { - // The reason for the existence of aFileChooser - android.util.Log.e (TAG, "LOG02230:", e); - } + @com.googlecode.androidannotations.annotations.Click (R.id.PDF_Files) + void pdfFiles() { + android.util.Log.d (TAG, "+ pdfFiles"); + + final Intent intent = new Intent (this,FileChooserActivity.class); + + intent.putStringArrayListExtra ( + FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, + PDF_Files); + + android.util.Log.v (TAG, "> intent = " + intent); + + try { + startActivityForResult(intent, REQUEST_CODE); + } catch (@NotNull final ActivityNotFoundException e) { + // The reason for the existence of aFileChooser + android.util.Log.e (TAG, "LOG02230:", e); + } + + android.util.Log.d (TAG, "- pdfFiles"); } - @org.androidannotations.annotations.Click (R.id.Calculator_Files) - void calculatorFiles() { - // Use the GET_CONTENT intent from the utility class - final Intent target = FileUtils.createGetContentIntent(); - // Create the chooser Intent - final Intent intent = Intent.createChooser( - target, getString(R.string.chooser_title)); - - intent.putStringArrayListExtra( - FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, - Calculator_Files); - - try { - startActivityForResult(intent, REQUEST_CODE); - } catch (final ActivityNotFoundException e) { - // The reason for the existence of aFileChooser - android.util.Log.e (TAG, "LOG02230:", e); - } + @com.googlecode.androidannotations.annotations.Click (R.id.Calculator_Files) + void calculatorFiles() { + android.util.Log.d (TAG, "+ calculatorFiles"); + + final Intent intent = new Intent (this,FileChooserActivity.class); + + intent.putStringArrayListExtra ( + FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, + Calculator_Files); + + android.util.Log.v (TAG, "> intent = " + intent); + + try { + startActivityForResult(intent, REQUEST_CODE); + } catch (@NotNull final ActivityNotFoundException e) { + // The reason for the existence of aFileChooser + android.util.Log.e (TAG, "LOG02230:", e); + } + + android.util.Log.d (TAG, "- calculatorFiles"); } @Override protected void onActivityResult( final int requestCode, final int resultCode, - final Intent data) { + @Nullable final Intent data) { switch (requestCode) { case REQUEST_CODE: // If the file selection was successful @@ -123,7 +136,7 @@ protected void onActivityResult( com.ipaulpro.afilechooserexample.FileChooserExampleActivity.this, "File Selected: " + path, android.widget.Toast.LENGTH_LONG); toast.show (); - } catch (final Exception e) { + } catch (@NotNull final Exception e) { Log.e(TAG, "File select error", e); } } @@ -132,4 +145,15 @@ protected void onActivityResult( } super.onActivityResult(requestCode, resultCode, data); } + + @Override public String toString () + { + return TAG + + "{super=" + + super.toString () + + ", chooser_title=“" + + chooser_title + + '”' + + '}'; + } } diff --git a/pom.xml b/pom.xml index 3d13965..5908862 100644 --- a/pom.xml +++ b/pom.xml @@ -109,16 +109,21 @@ jar - org.androidannotations + com.googlecode.androidannotations androidannotations ${androidannotations.version} provided - org.androidannotations + com.googlecode.androidannotations androidannotations-api ${androidannotations.version} + + com.intellij + annotations + 12.0 + @@ -518,7 +523,7 @@ UTF-8 UTF-8 UTF-8 - 3.0 + 2.7.1 From 70ccb3e21e7405b1a0732b4df4b4c2341b0a0b1e Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Mon, 30 Dec 2013 13:07:52 +0100 Subject: [PATCH 08/18] Git-Commit.command --- Git-Commit.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Git-Commit.cmd b/Git-Commit.cmd index 42345f5..6216085 100644 --- a/Git-Commit.cmd +++ b/Git-Commit.cmd @@ -24,7 +24,7 @@ import scala.sys.process._ ("git" :: "add" :: "." :: Nil).! ("git" :: "commit" :: "--message" :: argv (0) :: Nil).! -("git" :: "push" :: "-u" :: "origin" :: "dev" :: Nil).! +("git" :: "push" :: "-u" :: "origin" :: "2.0" :: Nil).! // vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : // vim: set textwidth=0 filetype=scala foldmethod=marker nospell : From e18b4b0a31f2a9e723f7e8e6ac3ac2f9489a7928 Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Mon, 30 Dec 2013 13:29:44 +0100 Subject: [PATCH 09/18] Git-Commit.command --- Git-Commit.cmd | 2 +- aFileChooserExample/pom.xml | 36 ++++++++++++++++++++++++++++++++++++ pom.xml | 5 +++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Git-Commit.cmd b/Git-Commit.cmd index 6216085..78c2222 100644 --- a/Git-Commit.cmd +++ b/Git-Commit.cmd @@ -1,5 +1,5 @@ ::#! -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: {{{1 :::::::^:::: +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: {{{1 ::::::::::: :: Copyright © 2013 Martin Krischik :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: $Author$ diff --git a/aFileChooserExample/pom.xml b/aFileChooserExample/pom.xml index bb78580..02f9367 100644 --- a/aFileChooserExample/pom.xml +++ b/aFileChooserExample/pom.xml @@ -181,6 +181,42 @@ org.apache.maven.plugins maven-resources-plugin + + org.apache.maven.plugins + maven-antrun-plugin + + + Initialize + initialize + + + + + + + + + + + run + + + + install diff --git a/pom.xml b/pom.xml index 5908862..55e9956 100644 --- a/pom.xml +++ b/pom.xml @@ -233,6 +233,11 @@ maven-dependency-plugin 2.8 + + org.apache.maven.plugins + maven-antrun-plugin + 1.7 + org.apache.maven.plugins maven-jar-plugin From ccda6820deb43b6c0f9fda6c438b5c5444cb4078 Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Mon, 30 Dec 2013 14:28:14 +0100 Subject: [PATCH 10/18] Git-Commit.command --- Git-Commit.cmd | 2 +- aFileChooser/pom.xml | 2 +- .../afilechooser/FileChooserActivity.java | 104 ++++++++++++++++-- .../afilechooser/FileListFragment.java | 4 +- aFileChooserExample/pom.xml | 2 +- aFileChooserExample/project.properties | 2 +- .../FileChooserExampleActivity.java | 41 ++----- pom.xml | 6 +- 8 files changed, 116 insertions(+), 47 deletions(-) diff --git a/Git-Commit.cmd b/Git-Commit.cmd index 78c2222..f30fdf9 100644 --- a/Git-Commit.cmd +++ b/Git-Commit.cmd @@ -24,7 +24,7 @@ import scala.sys.process._ ("git" :: "add" :: "." :: Nil).! ("git" :: "commit" :: "--message" :: argv (0) :: Nil).! -("git" :: "push" :: "-u" :: "origin" :: "2.0" :: Nil).! +("git" :: "push" :: "-u" :: "origin" :: "dev" :: Nil).! // vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : // vim: set textwidth=0 filetype=scala foldmethod=marker nospell : diff --git a/aFileChooser/pom.xml b/aFileChooser/pom.xml index f1a07b6..cbe2972 100644 --- a/aFileChooser/pom.xml +++ b/aFileChooser/pom.xml @@ -37,7 +37,7 @@ com.ipaulpro afilechooser - 2.0 + 2.1 https://github.com/krischik/aFileChooser3 diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java b/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java index 152f101..56f8c2a 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java @@ -40,7 +40,6 @@ import java.io.File; import java.util.ArrayList; -import java.util.List; /** * Main Activity that handles the FileListFragments @@ -48,6 +47,7 @@ * @version 2013-06-25 * @author paulburke (ipaulpro) */ +@SuppressWarnings ("CollectionDeclaredAsConcreteClass") public class FileChooserActivity extends FragmentActivity implements OnBackStackChangedListener, FileListFragment.Callbacks { @@ -56,25 +56,106 @@ public class FileChooserActivity extends FragmentActivity implements * */ static final String TAG = FileChooserActivity.class.getName (); - public static final String PATH = "path"; + public static final String SAVE_INSTANCE_PATH = "path"; public static final String EXTRA_FILTER_INCLUDE_EXTENSIONS = "com.ipaulpro.afilechooser.EXTRA_FILTER_INCLUDE_EXTENSIONS"; - private ArrayList mFilterIncludeExtensions = new ArrayList (); + public static final String EXTRA_FILTER_BASE_PATH = + "com.ipaulpro.afilechooser.EXTRA_FILTER_BASE_PATH"; public static final String EXTERNAL_BASE_PATH = Environment .getExternalStorageDirectory().getAbsolutePath(); private static final boolean HAS_ACTIONBAR = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; - + /** + *

start activity

+ * + * @param callingActivity activity opening the chooser + * @param requestCode request code used to identiefy the result + * @param filterIncludeExtensions file extensions to display + */ + public static void startActivity ( + final android.app.Activity callingActivity, + final int requestCode, + final java.util.ArrayList filterIncludeExtensions) { + android.util.Log.d (TAG, "+ startActivity"); + android.util.Log.v (TAG, "> callingActivity = " + callingActivity); + android.util.Log.v (TAG, "> requestCode = " + requestCode); + android.util.Log.v (TAG, "> filterIncludeExtensions = " + filterIncludeExtensions); + + final Intent intent = new Intent (callingActivity, FileChooserActivity.class); + + intent.putStringArrayListExtra ( + FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, + filterIncludeExtensions); + + android.util.Log.v (TAG, "> intent = " + intent); + + try { + callingActivity.startActivityForResult (intent, requestCode); + } catch (@NotNull final android.content.ActivityNotFoundException e) { + // The reason for the existence of aFileChooser + android.util.Log.e (TAG, "LOG02230:", e); + } + + android.util.Log.d (TAG, "- startActivity"); + return; + } // startActivity + + /** + *

start activity

+ * + * @param callingActivity activity opening the chooser + * @param requestCode request code used to identify the result + * @param baseDirectory base directory to show + * @param filterIncludeExtensions file extensions to display + */ + public static void startActivity ( + final android.app.Activity callingActivity, + final int requestCode, + final String baseDirectory, + final java.util.ArrayList filterIncludeExtensions) { + android.util.Log.d (TAG, "+ startActivity"); + android.util.Log.v (TAG, "> callingActivity = " + callingActivity); + android.util.Log.v (TAG, "> requestCode = " + requestCode); + android.util.Log.v (TAG, "> baseDirectory = " + baseDirectory); + android.util.Log.v (TAG, "> filterIncludeExtensions = " + filterIncludeExtensions); + + final Intent intent = new Intent (callingActivity, FileChooserActivity.class); + + intent.putExtra ( + FileChooserActivity.EXTRA_FILTER_BASE_PATH, + baseDirectory); + intent.putStringArrayListExtra ( + FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, + filterIncludeExtensions); + + android.util.Log.v (TAG, "> intent = " + intent); + + try { + callingActivity.startActivityForResult (intent, requestCode); + } catch (@NotNull final android.content.ActivityNotFoundException e) { + // The reason for the existence of aFileChooser + android.util.Log.e (TAG, "LOG02230:", e); + } + + android.util.Log.d (TAG, "- startActivity"); + return; + } // startActivity private FragmentManager mFragmentManager; - @NotNull private BroadcastReceiver mStorageListener = new BroadcastReceiver() { + @NotNull private final BroadcastReceiver mStorageListener = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { Toast.makeText(context, R.string.storage_removed, Toast.LENGTH_LONG).show(); finishWithResult(null); } }; - + /** + *

path to open first

+ */ private String mPath; + /** + *

extenstion to display

+ */ + private ArrayList mFilterIncludeExtensions = new ArrayList (); @Override protected void onCreate(@Nullable final Bundle savedInstanceState) { @@ -89,17 +170,22 @@ protected void onCreate(@Nullable final Bundle savedInstanceState) { if(intent != null){ mFilterIncludeExtensions = intent.getStringArrayListExtra ( EXTRA_FILTER_INCLUDE_EXTENSIONS); + mPath = intent.getStringExtra ( + EXTRA_FILTER_BASE_PATH); android.util.Log.v (TAG, "> mFilterIncludeExtensions = " + mFilterIncludeExtensions); + android.util.Log.v (TAG, "> mPath = " + mPath); } mFragmentManager = getSupportFragmentManager(); mFragmentManager.addOnBackStackChangedListener (this); if (savedInstanceState == null) { - mPath = EXTERNAL_BASE_PATH; + if (mPath == null) { + mPath = EXTERNAL_BASE_PATH; + } // if addFragment(); } else { - mPath = savedInstanceState.getString(PATH); + mPath = savedInstanceState.getString(SAVE_INSTANCE_PATH); } setTitle(mPath); @@ -125,7 +211,7 @@ protected void onResume() { protected void onSaveInstanceState(@NotNull final Bundle outState) { super.onSaveInstanceState(outState); - outState.putString(PATH, mPath); + outState.putString(SAVE_INSTANCE_PATH, mPath); } @SuppressLint("NewApi") // Usages of New APIs are surrounded by sufficient conditional checks diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java b/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java index 5e18d81..1894f3a 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java @@ -87,7 +87,7 @@ public interface Callbacks { final FileListFragment fragment = new FileListFragment(); final Bundle args = new Bundle(); - args.putString(FileChooserActivity.PATH, path); + args.putString(FileChooserActivity.SAVE_INSTANCE_PATH, path); args.putStringArrayList ( FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, filterIncludeExtensions); @@ -126,7 +126,7 @@ public void onCreate(final Bundle savedInstanceState) { android.util.Log.v (TAG, "> arguments = " + arguments); mPath = arguments != null - ? arguments.getString (FileChooserActivity.PATH) + ? arguments.getString (FileChooserActivity.SAVE_INSTANCE_PATH) : Environment.getExternalStorageDirectory().getAbsolutePath(); if(arguments != null){ mFilterIncludeExtensions = arguments.getStringArrayList ( diff --git a/aFileChooserExample/pom.xml b/aFileChooserExample/pom.xml index 02f9367..2f91cec 100644 --- a/aFileChooserExample/pom.xml +++ b/aFileChooserExample/pom.xml @@ -37,7 +37,7 @@ com.ipaulpro afilechooser - 2.0 + 2.1 https://github.com/krischik/aFileChooser3 diff --git a/aFileChooserExample/project.properties b/aFileChooserExample/project.properties index 6e983b1..ae36aa5 100644 --- a/aFileChooserExample/project.properties +++ b/aFileChooserExample/project.properties @@ -9,4 +9,4 @@ # Project target. target=android-19 -android.library.reference.1=../aFileChooser + diff --git a/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java b/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java index a736b86..d24b799 100644 --- a/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java +++ b/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java @@ -31,7 +31,7 @@ /** * @author paulburke (ipaulpro) */ -@SuppressWarnings ("CollectionDeclaredAsConcreteClass") +@SuppressWarnings ({"CollectionDeclaredAsConcreteClass", "HardcodedFileSeparator"}) @com.googlecode.androidannotations.annotations.EActivity (R.layout.example) public class FileChooserExampleActivity extends Activity { @@ -42,6 +42,7 @@ public class FileChooserExampleActivity extends Activity { private static final int REQUEST_CODE = 6384; @NotNull private static final ArrayList PDF_Files; @NotNull private static final ArrayList Calculator_Files; + @NotNull private static final String Calculator_Dir; static { @@ -51,6 +52,7 @@ public class FileChooserExampleActivity extends Activity { Calculator_Files.add (".af"); Calculator_Files.add (".df"); Calculator_Files.add (".pf"); + Calculator_Dir = FileChooserActivity.EXTERNAL_BASE_PATH + "/Android/FX-602P"; } @com.googlecode.androidannotations.annotations.res.StringRes (R.string.chooser_title) @@ -77,20 +79,10 @@ void appFiles() { void pdfFiles() { android.util.Log.d (TAG, "+ pdfFiles"); - final Intent intent = new Intent (this,FileChooserActivity.class); - - intent.putStringArrayListExtra ( - FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, - PDF_Files); - - android.util.Log.v (TAG, "> intent = " + intent); - - try { - startActivityForResult(intent, REQUEST_CODE); - } catch (@NotNull final ActivityNotFoundException e) { - // The reason for the existence of aFileChooser - android.util.Log.e (TAG, "LOG02230:", e); - } + FileChooserActivity.startActivity ( + /* callingActivity => */ this, + /* requestCode => */ REQUEST_CODE, + /* filterIncludeExtensions => */ PDF_Files); android.util.Log.d (TAG, "- pdfFiles"); } @@ -98,20 +90,11 @@ void pdfFiles() { void calculatorFiles() { android.util.Log.d (TAG, "+ calculatorFiles"); - final Intent intent = new Intent (this,FileChooserActivity.class); - - intent.putStringArrayListExtra ( - FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, - Calculator_Files); - - android.util.Log.v (TAG, "> intent = " + intent); - - try { - startActivityForResult(intent, REQUEST_CODE); - } catch (@NotNull final ActivityNotFoundException e) { - // The reason for the existence of aFileChooser - android.util.Log.e (TAG, "LOG02230:", e); - } + FileChooserActivity.startActivity ( + /* callingActivity => */ this, + /* requestCode => */ REQUEST_CODE, + /* baseDirectory => */ Calculator_Dir, + /* filterIncludeExtensions => */ Calculator_Files); android.util.Log.d (TAG, "- calculatorFiles"); } diff --git a/pom.xml b/pom.xml index 55e9956..1d396be 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ com.ipaulpro afilechooser pom - 2.0 + 2.1 aFileChooser aFileChooser is an Android Library Project that simplifies the process of presenting a file chooser on Android 2.1+. https://github.com/krischik/aFileChooser3 @@ -97,14 +97,14 @@ com.ipaulpro afilechooser-library - 2.0 + 2.1 compile apklib com.ipaulpro afilechooser-library - 2.0 + 2.1 provided jar From 5ffeb0dc3e6a499ef3e783c1ee6c01bac735b49d Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Tue, 31 Dec 2013 21:08:57 +0100 Subject: [PATCH 11/18] Git-Commit.command --- .../afilechooser/FileChooserActivity.java | 7 ++++--- .../ipaulpro/afilechooser/utils/FileUtils.java | 15 ++++++++------- .../FileChooserExampleActivity.java | 11 +++++++++++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java b/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java index 56f8c2a..50cb73c 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java @@ -171,7 +171,7 @@ protected void onCreate(@Nullable final Bundle savedInstanceState) { mFilterIncludeExtensions = intent.getStringArrayListExtra ( EXTRA_FILTER_INCLUDE_EXTENSIONS); mPath = intent.getStringExtra ( - EXTRA_FILTER_BASE_PATH); + EXTRA_FILTER_BASE_PATH); android.util.Log.v (TAG, "> mFilterIncludeExtensions = " + mFilterIncludeExtensions); android.util.Log.v (TAG, "> mPath = " + mPath); } @@ -227,8 +227,9 @@ public void onBackStackChanged() { } setTitle(mPath); - if (HAS_ACTIONBAR) - invalidateOptionsMenu(); + if (HAS_ACTIONBAR) { + invalidateOptionsMenu (); + } } @SuppressLint("NewApi") // Usages of New APIs are surrounded by sufficient conditional checks diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java b/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java index 3fd32ab..0d28faa 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java @@ -309,10 +309,11 @@ public static boolean isGooglePhotosUri(@NotNull final Uri uri) { * @see #getFile(Context, Uri) * @author paulburke */ - @Nullable @android.annotation.SuppressLint ("NewApi") // Usages of New APIs are surrounded by sufficient conditional checks + @Nullable + @android.annotation.SuppressLint ("NewApi") // Usages of New APIs are surrounded by sufficient conditional checks public static String getPath( - @NotNull final Context context, @NotNull - final Uri uri) { + @NotNull final Context context, + @NotNull final Uri uri) { if (DEBUG) Log.d(TAG + " File -", @@ -406,8 +407,7 @@ else if ("file".equalsIgnoreCase(uri.getScheme())) { @Nullable public static File getFile( @NotNull final Context context, - @Nullable final - Uri uri) { + @Nullable final Uri uri) { if (uri != null) { final String path = getPath(context, uri); if (path != null && isLocal(path)) { @@ -492,8 +492,9 @@ public static Bitmap getThumbnail( */ @Nullable public static Bitmap getThumbnail( - @NotNull final Context context, @NotNull final - Uri uri, @NotNull final String mimeType) { + @NotNull final Context context, + @NotNull final Uri uri, + @NotNull final String mimeType) { if (DEBUG) Log.d(TAG, "Attempting to get thumbnail"); diff --git a/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java b/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java index d24b799..2e8494c 100644 --- a/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java +++ b/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java @@ -41,7 +41,18 @@ public class FileChooserExampleActivity extends Activity { */ private static final int REQUEST_CODE = 6384; @NotNull private static final ArrayList PDF_Files; + /** + *

File types for my calculator app. Replace it with whatever you want to test.

+ * + * @author Martin Krischik" + */ @NotNull private static final ArrayList Calculator_Files; + /** + *

Directory why the unit tests of my calculator app stores there files. The + * real app uses

+ * + * @author Martin Krischik" + */ @NotNull private static final String Calculator_Dir; static From 54419bc842c39d167454bbf73ca0c04d51071e66 Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Wed, 1 Jan 2014 09:22:41 +0100 Subject: [PATCH 12/18] Git-Commit.command --- aFileChooser/pom.xml | 6 +----- aFileChooserExample/pom.xml | 10 +++------- .../FileChooserExampleActivity.java | 16 ++++++++-------- pom.xml | 17 +++++------------ 4 files changed, 17 insertions(+), 32 deletions(-) diff --git a/aFileChooser/pom.xml b/aFileChooser/pom.xml index cbe2972..b080971 100644 --- a/aFileChooser/pom.xml +++ b/aFileChooser/pom.xml @@ -37,7 +37,7 @@ com.ipaulpro afilechooser - 2.1 + 2.2 https://github.com/krischik/aFileChooser3 @@ -162,10 +162,6 @@ org.apache.maven.plugins maven-checkstyle-plugin
- - org.apache.maven.plugins - maven-resources-plugin - install diff --git a/aFileChooserExample/pom.xml b/aFileChooserExample/pom.xml index 2f91cec..6a8c8b1 100644 --- a/aFileChooserExample/pom.xml +++ b/aFileChooserExample/pom.xml @@ -37,7 +37,7 @@ com.ipaulpro afilechooser - 2.1 + 2.2 https://github.com/krischik/aFileChooser3 @@ -85,12 +85,12 @@ apklib - com.googlecode.androidannotations + org.androidannotations androidannotations provided - com.googlecode.androidannotations + org.androidannotations androidannotations-api @@ -177,10 +177,6 @@ org.apache.maven.plugins maven-checkstyle-plugin - - org.apache.maven.plugins - maven-resources-plugin - org.apache.maven.plugins maven-antrun-plugin diff --git a/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java b/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java index 2e8494c..fcfaaea 100644 --- a/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java +++ b/aFileChooserExample/src/com/ipaulpro/afilechooserexample/FileChooserExampleActivity.java @@ -32,7 +32,7 @@ * @author paulburke (ipaulpro) */ @SuppressWarnings ({"CollectionDeclaredAsConcreteClass", "HardcodedFileSeparator"}) -@com.googlecode.androidannotations.annotations.EActivity (R.layout.example) +@org.androidannotations.annotations.EActivity (R.layout.example) public class FileChooserExampleActivity extends Activity { private static final String TAG = FileChooserExampleActivity.class.getName (); @@ -44,14 +44,14 @@ public class FileChooserExampleActivity extends Activity { /** *

File types for my calculator app. Replace it with whatever you want to test.

* - * @author Martin Krischik" + * author Martin Krischik" */ @NotNull private static final ArrayList Calculator_Files; /** *

Directory why the unit tests of my calculator app stores there files. The - * real app uses

+ * real app uses {@link android.content.Context.getExternalFilesDir(java.lang.String)}

* - * @author Martin Krischik" + * author Martin Krischik" */ @NotNull private static final String Calculator_Dir; @@ -66,10 +66,10 @@ public class FileChooserExampleActivity extends Activity { Calculator_Dir = FileChooserActivity.EXTERNAL_BASE_PATH + "/Android/FX-602P"; } - @com.googlecode.androidannotations.annotations.res.StringRes (R.string.chooser_title) + @org.androidannotations.annotations.res.StringRes (R.string.chooser_title) String chooser_title; - @com.googlecode.androidannotations.annotations.Click (R.id.All_Files) + @org.androidannotations.annotations.Click (R.id.All_Files) void appFiles() { android.util.Log.d (TAG, "+ All_Files"); @@ -86,7 +86,7 @@ void appFiles() { android.util.Log.d (TAG, "+ All_Files"); } - @com.googlecode.androidannotations.annotations.Click (R.id.PDF_Files) + @org.androidannotations.annotations.Click (R.id.PDF_Files) void pdfFiles() { android.util.Log.d (TAG, "+ pdfFiles"); @@ -97,7 +97,7 @@ void pdfFiles() { android.util.Log.d (TAG, "- pdfFiles"); } - @com.googlecode.androidannotations.annotations.Click (R.id.Calculator_Files) + @org.androidannotations.annotations.Click (R.id.Calculator_Files) void calculatorFiles() { android.util.Log.d (TAG, "+ calculatorFiles"); diff --git a/pom.xml b/pom.xml index 1d396be..94e576f 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ com.ipaulpro afilechooser pom - 2.1 + 2.2 aFileChooser aFileChooser is an Android Library Project that simplifies the process of presenting a file chooser on Android 2.1+. https://github.com/krischik/aFileChooser3 @@ -97,25 +97,18 @@ com.ipaulpro afilechooser-library - 2.1 + 2.2 compile apklib - com.ipaulpro - afilechooser-library - 2.1 - provided - jar - - - com.googlecode.androidannotations + org.androidannotations androidannotations ${androidannotations.version} provided - com.googlecode.androidannotations + org.androidannotations androidannotations-api ${androidannotations.version} @@ -528,7 +521,7 @@ UTF-8 UTF-8 UTF-8 - 2.7.1 + 3.0 From e82afe9a5c55c87d2b4dbb68b4704d6ef62f3204 Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Wed, 1 Jan 2014 09:36:35 +0100 Subject: [PATCH 13/18] Git-Commit.command --- Git-Commit.cmd | 2 +- README.markdown | 87 ++++++++++++++++++++++++++++++++++++------------- 2 files changed, 65 insertions(+), 24 deletions(-) diff --git a/Git-Commit.cmd b/Git-Commit.cmd index f30fdf9..99bd081 100644 --- a/Git-Commit.cmd +++ b/Git-Commit.cmd @@ -24,7 +24,7 @@ import scala.sys.process._ ("git" :: "add" :: "." :: Nil).! ("git" :: "commit" :: "--message" :: argv (0) :: Nil).! -("git" :: "push" :: "-u" :: "origin" :: "dev" :: Nil).! +("git" :: "push" :: "-u" :: "origin" :: "master" :: Nil).! // vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : // vim: set textwidth=0 filetype=scala foldmethod=marker nospell : diff --git a/README.markdown b/README.markdown index 94b6f32..8572c42 100644 --- a/README.markdown +++ b/README.markdown @@ -23,10 +23,11 @@ Add `FileChooserActivity` to your project's AndroidManifest.xml file with a full __Important__ `FileChooserActivity` must have `android:exported="true"` and have the `` set as follows: +```xml @@ -38,13 +39,15 @@ __Important__ `FileChooserActivity` must have `android:exported="true"` and have +``` If you want to use the Storage Access Framework (API 19+), include [Ian Lake](https://github.com/ianhanniballake/)'s `LocalStorageProvider` (included in this library) in your ``: - @@ -52,6 +55,7 @@ If you want to use the Storage Access Framework (API 19+), include [Ian Lake](ht +``` __Note__ that like a `ContentProvider`, the `DocumentProvider` `authority` must be unique. You should change `com.ianhanniballake.localstorage.documents` in your Manifest, as well as the `LocalStorageProvider.AUTHORITY` field. @@ -61,6 +65,7 @@ Using `FileChooserActivity` and `LocalStorageProvider` together are redundant if Use `startActivityForResult(Intent, int)` to launch `FileChooserActivity` directly. `FileChooserActivity` returns the `Uri` of the file selected as the `Intent` data in `onActivityResult(int, int, Intent)`. Alternatively, you can use the helper method `FileUtils.createGetContentIntent()` to construct an `ACTION_GET_CONTENT` Intent that will show an "Intent Chooser" dialog on pre Kit-Kat devices, and the "Documents UI" otherwise. E.g.: +```java private static final int REQUEST_CHOOSER = 1234; @Override @@ -77,22 +82,23 @@ Use `startActivityForResult(Intent, int)` to launch `FileChooserActivity` direct @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { - case REQUEST_CHOOSER: - if (resultCode == RESULT_OK) { + case REQUEST_CHOOSER: + if (resultCode == RESULT_OK) { - final Uri uri = data.getData(); + final Uri uri = data.getData(); - // Get the File path from the Uri - String path = FileUtils.getPath(this, uri); + // Get the File path from the Uri + String path = FileUtils.getPath(this, uri); - // Alternatively, use FileUtils.getFile(Context, Uri) - if (path != null && FileUtils.isLocal(path)) { - File file = new File(path); - } - } - break; + // Alternatively, use FileUtils.getFile(Context, Uri) + if (path != null && FileUtils.isLocal(path)) { + File file = new File(path); + } + } + break; } } +``` A more robust example can be found in the aFileChooserExample project. @@ -107,7 +113,7 @@ Provide an extra `EXTRA_FILTER_INCLUDE_EXTENSIONS` which is an `ArrayList INCLUDE_EXTENSIONS_LIST = new ArrayList(); static{ INCLUDE_EXTENSIONS_LIST.add(".apk"); @@ -121,19 +127,50 @@ Example: ``` +or use the FileChooserActivity.startActivity convenience function. + +###Set base directory + +Provide an extra `EXTRA_FILTER_BASE_PATH` which is an `String` containing base directroy to be displayed: + +Example: + +```java + final Intent intent = new Intent (callingActivity, FileChooserActivity.class); + + intent.putExtra ( + FileChooserActivity.EXTRA_FILTER_BASE_PATH, + baseDirectory); + intent.putStringArrayListExtra ( + FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, + filterIncludeExtensions); + + android.util.Log.v (TAG, "> intent = " + intent); + + try { + callingActivity.startActivityForResult (intent, requestCode); + } catch (@NotNull final android.content.ActivityNotFoundException e) { + // The reason for the existence of aFileChooser + android.util.Log.e (TAG, "LOG02230:", e); + } +``` + +or use the FileChooserActivity.startActivity convenience function. + ## Credits Developed by Paul Burke (iPaulPro) - [paulburke.co](http://paulburke.co/) Filtering by file extension: [curioustechizen] (https://github.com/curioustechizen) +Set start path by [krischik](https://github.com/krischik) + Translations by [TomTasche](https://github.com/TomTasche), [booknara](https://github.com/booknara), [brenouchoa](https://github.com/brenouchoa) Folder by [Sergio Calcara](http://thenounproject.com/fallacyaccount) from The Noun Project (ic_provider.png) Document by [Melvin Salas](http://thenounproject.com/msalas10) from The Noun Project (ic_file.png) -Maven Deployment by [krischik](https://github.com/krischik) ## Licenses @@ -168,13 +205,17 @@ Portions of FileUtils.java: LocalStorageProvider.java: - Copyright (c) 2013, Ian Lake - All rights reserved. + Copyright (c) 2013, Ian Lake + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + - Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - - Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +> vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 expandtab : +> vim: set textwidth=0 filetype=markdown foldmethod=marker spell spelllang=en_gb: From 710fdbbbd4c8705d0c7c90ba05b2b5c2a7234ad6 Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Thu, 2 Jan 2014 08:02:14 +0100 Subject: [PATCH 14/18] Git-Commit.command --- aFileChooserExample/project.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/aFileChooserExample/project.properties b/aFileChooserExample/project.properties index ae36aa5..afe3f2e 100644 --- a/aFileChooserExample/project.properties +++ b/aFileChooserExample/project.properties @@ -9,4 +9,5 @@ # Project target. target=android-19 +android.library.reference.1=../aFileChooser From 0d7b6d54c4a8e4ef19e374e70e3d37af60a7e48a Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Thu, 2 Jan 2014 08:57:38 +0100 Subject: [PATCH 15/18] Git-Commit.command --- Git-Commit.cmd | 2 +- Maven-Deploy.cmd | 1 + aFileChooser/pom.xml | 2 +- .../afilechooser/FileChooserActivity.java | 38 +++++++++---------- .../afilechooser/FileListFragment.java | 20 +++++----- .../afilechooser/utils/FileUtils.java | 14 +++---- aFileChooserExample/pom.xml | 2 +- aFileChooserExample/project.properties | 1 + pom.xml | 4 +- 9 files changed, 43 insertions(+), 41 deletions(-) diff --git a/Git-Commit.cmd b/Git-Commit.cmd index 99bd081..e4600a0 100644 --- a/Git-Commit.cmd +++ b/Git-Commit.cmd @@ -24,7 +24,7 @@ import scala.sys.process._ ("git" :: "add" :: "." :: Nil).! ("git" :: "commit" :: "--message" :: argv (0) :: Nil).! -("git" :: "push" :: "-u" :: "origin" :: "master" :: Nil).! +("git" :: "push" :: "-u" :: "origin" :: "2.3" :: Nil).! // vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : // vim: set textwidth=0 filetype=scala foldmethod=marker nospell : diff --git a/Maven-Deploy.cmd b/Maven-Deploy.cmd index 1506f0a..e4649be 100644 --- a/Maven-Deploy.cmd +++ b/Maven-Deploy.cmd @@ -31,6 +31,7 @@ val Maven_Deploy = System.getenv ("MAVEN_DEPLOY") val Project_Name = System.getenv ("PROJECT_NAME") val Maven_Name = Project_Name +" Maven Repository" +Err_Exit_Call (mvn ::: "--activate-profiles" :: "release" :: "clean" :: Nil) Err_Exit_Call (mvn ::: "--activate-profiles" :: "release" :: "install" :: Nil) Err_Exit_Call (mvn ::: "--activate-profiles" :: "release" :: "javadoc:javadoc" :: Nil) Err_Exit_Call (mvn ::: "--activate-profiles" :: "release" :: "source:jar" :: Nil) diff --git a/aFileChooser/pom.xml b/aFileChooser/pom.xml index fe8b908..5a99216 100644 --- a/aFileChooser/pom.xml +++ b/aFileChooser/pom.xml @@ -37,7 +37,7 @@ com.ipaulpro afilechooser - 2.2 + 2.3 https://github.com/krischik/aFileChooser3 diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java b/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java index 50cb73c..03e1297 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/FileChooserActivity.java @@ -76,10 +76,10 @@ public static void startActivity ( final android.app.Activity callingActivity, final int requestCode, final java.util.ArrayList filterIncludeExtensions) { - android.util.Log.d (TAG, "+ startActivity"); - android.util.Log.v (TAG, "> callingActivity = " + callingActivity); - android.util.Log.v (TAG, "> requestCode = " + requestCode); - android.util.Log.v (TAG, "> filterIncludeExtensions = " + filterIncludeExtensions); + //android.util.Log.d (TAG, "+ startActivity"); + //android.util.Log.v (TAG, "> callingActivity = " + callingActivity); + //android.util.Log.v (TAG, "> requestCode = " + requestCode); + //android.util.Log.v (TAG, "> filterIncludeExtensions = " + filterIncludeExtensions); final Intent intent = new Intent (callingActivity, FileChooserActivity.class); @@ -87,7 +87,7 @@ public static void startActivity ( FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, filterIncludeExtensions); - android.util.Log.v (TAG, "> intent = " + intent); + //android.util.Log.v (TAG, "> intent = " + intent); try { callingActivity.startActivityForResult (intent, requestCode); @@ -96,7 +96,7 @@ public static void startActivity ( android.util.Log.e (TAG, "LOG02230:", e); } - android.util.Log.d (TAG, "- startActivity"); + //android.util.Log.d (TAG, "- startActivity"); return; } // startActivity @@ -113,11 +113,11 @@ public static void startActivity ( final int requestCode, final String baseDirectory, final java.util.ArrayList filterIncludeExtensions) { - android.util.Log.d (TAG, "+ startActivity"); - android.util.Log.v (TAG, "> callingActivity = " + callingActivity); - android.util.Log.v (TAG, "> requestCode = " + requestCode); - android.util.Log.v (TAG, "> baseDirectory = " + baseDirectory); - android.util.Log.v (TAG, "> filterIncludeExtensions = " + filterIncludeExtensions); + //android.util.Log.d (TAG, "+ startActivity"); + //android.util.Log.v (TAG, "> callingActivity = " + callingActivity); + //android.util.Log.v (TAG, "> requestCode = " + requestCode); + //android.util.Log.v (TAG, "> baseDirectory = " + baseDirectory); + //android.util.Log.v (TAG, "> filterIncludeExtensions = " + filterIncludeExtensions); final Intent intent = new Intent (callingActivity, FileChooserActivity.class); @@ -128,7 +128,7 @@ public static void startActivity ( FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS, filterIncludeExtensions); - android.util.Log.v (TAG, "> intent = " + intent); + //android.util.Log.v (TAG, "> intent = " + intent); try { callingActivity.startActivityForResult (intent, requestCode); @@ -137,7 +137,7 @@ public static void startActivity ( android.util.Log.e (TAG, "LOG02230:", e); } - android.util.Log.d (TAG, "- startActivity"); + //android.util.Log.d (TAG, "- startActivity"); return; } // startActivity private FragmentManager mFragmentManager; @@ -159,21 +159,21 @@ public void onReceive(final Context context, final Intent intent) { @Override protected void onCreate(@Nullable final Bundle savedInstanceState) { - android.util.Log.d (TAG, "+ onCreate"); - android.util.Log.v (TAG, "> savedInstanceState = " + savedInstanceState); + //android.util.Log.d (TAG, "+ onCreate"); + //android.util.Log.v (TAG, "> savedInstanceState = " + savedInstanceState); super.onCreate(savedInstanceState); final Intent intent = getIntent(); - android.util.Log.v (TAG, "> intent = " + intent); + //android.util.Log.v (TAG, "> intent = " + intent); if(intent != null){ mFilterIncludeExtensions = intent.getStringArrayListExtra ( EXTRA_FILTER_INCLUDE_EXTENSIONS); mPath = intent.getStringExtra ( EXTRA_FILTER_BASE_PATH); - android.util.Log.v (TAG, "> mFilterIncludeExtensions = " + mFilterIncludeExtensions); - android.util.Log.v (TAG, "> mPath = " + mPath); + //android.util.Log.v (TAG, "> mFilterIncludeExtensions = " + mFilterIncludeExtensions); + //android.util.Log.v (TAG, "> mPath = " + mPath); } mFragmentManager = getSupportFragmentManager(); @@ -190,7 +190,7 @@ protected void onCreate(@Nullable final Bundle savedInstanceState) { setTitle(mPath); - android.util.Log.d (TAG, "- onCreate"); + //android.util.Log.d (TAG, "- onCreate"); } @Override diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java b/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java index 1894f3a..6d7dd57 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/FileListFragment.java @@ -80,9 +80,9 @@ public interface Callbacks { @NotNull public static FileListFragment newInstance( @NotNull final String path, @Nullable final ArrayList filterIncludeExtensions ) { - android.util.Log.d (TAG, "+ newInstance"); - android.util.Log.v (TAG, "> path = " + path); - android.util.Log.v (TAG, "> filterIncludeExtensions = " + filterIncludeExtensions); + //android.util.Log.d (TAG, "+ newInstance"); + //android.util.Log.v (TAG, "> path = " + path); + //android.util.Log.v (TAG, "> filterIncludeExtensions = " + filterIncludeExtensions); final FileListFragment fragment = new FileListFragment(); final Bundle args = new Bundle(); @@ -93,8 +93,8 @@ public interface Callbacks { filterIncludeExtensions); fragment.setArguments(args); - android.util.Log.v (TAG, "> fragment = " + fragment); - android.util.Log.d (TAG, "+ newInstance"); + //android.util.Log.v (TAG, "> fragment = " + fragment); + //android.util.Log.d (TAG, "+ newInstance"); return fragment; } @@ -113,8 +113,8 @@ public void onAttach(@NotNull final Activity activity) { @Override public void onCreate(final Bundle savedInstanceState) { - android.util.Log.d (TAG, "+ onCreate"); - android.util.Log.v (TAG, "> savedInstanceState = " + savedInstanceState); + //android.util.Log.d (TAG, "+ onCreate"); + //android.util.Log.v (TAG, "> savedInstanceState = " + savedInstanceState); super.onCreate(savedInstanceState); @@ -122,8 +122,8 @@ public void onCreate(final Bundle savedInstanceState) { mAdapter = new FileListAdapter(getActivity()); - android.util.Log.v (TAG, "> mAdapter = " + mAdapter); - android.util.Log.v (TAG, "> arguments = " + arguments); + //android.util.Log.v (TAG, "> mAdapter = " + mAdapter); + //android.util.Log.v (TAG, "> arguments = " + arguments); mPath = arguments != null ? arguments.getString (FileChooserActivity.SAVE_INSTANCE_PATH) @@ -133,7 +133,7 @@ public void onCreate(final Bundle savedInstanceState) { FileChooserActivity.EXTRA_FILTER_INCLUDE_EXTENSIONS); } - android.util.Log.d (TAG, "+ onCreate"); + //android.util.Log.d (TAG, "+ onCreate"); } @Override diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java b/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java index 0d28faa..1556982 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java @@ -77,18 +77,18 @@ public static class FileExtensionFilter implements FileFilter{ @Nullable private final ArrayList mFilterIncludeExtensions; public FileExtensionFilter (@Nullable final ArrayList filterIncludeExtensions){ - android.util.Log.d (TAG, "+ FileExtensionFilter"); - android.util.Log.v (TAG, "> filterIncludeExtensions = " + filterIncludeExtensions); + //android.util.Log.d (TAG, "+ FileExtensionFilter"); + //android.util.Log.v (TAG, "> filterIncludeExtensions = " + filterIncludeExtensions); this.mFilterIncludeExtensions = filterIncludeExtensions; - android.util.Log.d (TAG, "+ FileExtensionFilter"); + //android.util.Log.d (TAG, "+ FileExtensionFilter"); } @Override public boolean accept(@NotNull final File file) { - android.util.Log.d (TAG, "+ accept"); - android.util.Log.v (TAG, "> file = " + file); + //android.util.Log.d (TAG, "+ accept"); + //android.util.Log.v (TAG, "> file = " + file); final String fileName = file.getName(); final android.net.Uri uri = android.net.Uri.fromFile (file); @@ -99,8 +99,8 @@ public boolean accept(@NotNull final File file) { final boolean retval = file.isFile() && !fileName.startsWith(HIDDEN_PREFIX) && passesExtensionsFilter; - android.util.Log.v (TAG, "> retval = " + retval); - android.util.Log.d (TAG, "- accept"); + //android.util.Log.v (TAG, "> retval = " + retval); + //android.util.Log.d (TAG, "- accept"); return retval; } diff --git a/aFileChooserExample/pom.xml b/aFileChooserExample/pom.xml index 13f4f31..1d515f5 100644 --- a/aFileChooserExample/pom.xml +++ b/aFileChooserExample/pom.xml @@ -37,7 +37,7 @@ com.ipaulpro afilechooser - 2.2 + 2.3 https://github.com/krischik/aFileChooser3 diff --git a/aFileChooserExample/project.properties b/aFileChooserExample/project.properties index afe3f2e..22fdffb 100644 --- a/aFileChooserExample/project.properties +++ b/aFileChooserExample/project.properties @@ -11,3 +11,4 @@ target=android-19 android.library.reference.1=../aFileChooser + diff --git a/pom.xml b/pom.xml index cb7ab09..2ced06a 100644 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,7 @@ com.ipaulpro afilechooser pom - 2.2 + 2.3 aFileChooser aFileChooser is an Android Library Project that simplifies the process of presenting a file chooser on Android 2.1+. https://github.com/krischik/aFileChooser3 @@ -97,7 +97,7 @@ com.ipaulpro afilechooser-library - 2.2 + 2.3 compile apklib From 0f35d9e446f06c92c904ac678c364074e93f51bc Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Thu, 2 Jan 2014 08:58:53 +0100 Subject: [PATCH 16/18] Git-Commit.command --- Git-Commit.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Git-Commit.cmd b/Git-Commit.cmd index e4600a0..99bd081 100644 --- a/Git-Commit.cmd +++ b/Git-Commit.cmd @@ -24,7 +24,7 @@ import scala.sys.process._ ("git" :: "add" :: "." :: Nil).! ("git" :: "commit" :: "--message" :: argv (0) :: Nil).! -("git" :: "push" :: "-u" :: "origin" :: "2.3" :: Nil).! +("git" :: "push" :: "-u" :: "origin" :: "master" :: Nil).! // vim: set wrap tabstop=8 shiftwidth=4 softtabstop=4 noexpandtab : // vim: set textwidth=0 filetype=scala foldmethod=marker nospell : From 58f9b09a87cf41810bae71553123f69c9c39fad6 Mon Sep 17 00:00:00 2001 From: Ardian Yuli Setyanto Date: Sat, 22 Feb 2014 10:36:50 +0700 Subject: [PATCH 17/18] Update FileUtils.java Fix warning Implicitly using the default locale is a common source of bugs: Use toLowerCase(Locale) instead --- aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java b/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java index 1556982..c21f48d 100644 --- a/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java +++ b/aFileChooser/src/com/ipaulpro/afilechooser/utils/FileUtils.java @@ -551,7 +551,7 @@ public int compare( @NotNull final File f1, @NotNull final File f2) { // Sort alphabetically by lower case, which is much cleaner - return f1.getName().toLowerCase().compareTo( + return f1.getName().toLowerCase(Locale.getDefault()).compareTo( f2.getName().toLowerCase()); } }; From f0d3403a4c6f0267d4fbea629f173d7208dd9adb Mon Sep 17 00:00:00 2001 From: Martin Krischik Date: Sun, 28 Aug 2022 19:13:22 +0200 Subject: [PATCH 18/18] Update README.markdown --- README.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.markdown b/README.markdown index 8572c42..f5828af 100644 --- a/README.markdown +++ b/README.markdown @@ -1,3 +1,7 @@ +# Archived + +This file chooser is outdated and can't be used with current Android versions any more. + # aFileChooser - Android File Chooser aFileChooser is an __Android Library Project__ that simplifies the process of presenting a file chooser on Android 2.1+.