From: David A. Velasco
Date: Thu, 14 Mar 2013 08:13:09 +0000 (-0700)
Subject: Merge pull request #90 from espenaf/master
X-Git-Tag: oc-android-1.4.3~45
X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/c837207a40e7f647b93909c7f213e4b4b4a41d52?hp=851c576d02076cb29858f36620c22c6cc20e094a
Merge pull request #90 from espenaf/master
Build owncloud apk via Maven, replacement or supplement for the setup script.
---
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 1ea115c8..14be678e 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -3,9 +3,11 @@
ownCloud Android client application
Copyright (C) 2012 Bartek Przybylski
+ Copyright (C) 2012-2013 ownCloud Inc.
+
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 3 of the License, or
+ 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,
@@ -56,6 +58,8 @@
+
+
@@ -130,25 +134,25 @@
-
+
-
+
-
+
-
+
-
-
+
+
-
-
-
+
+
+
@@ -156,7 +160,7 @@
-
+
-
+
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 00000000..d159169d
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ 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.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/README.md b/README.md
new file mode 100644
index 00000000..3ba9f73a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,6 @@
+This is the android client for [owncloud][0].
+
+Make sure you read [SETUP.md][1] when you start working on this project.
+
+[0]: https://github.com/owncloud/core
+[1]: https://raw.github.com/owncloud/android/master/SETUP.md
\ No newline at end of file
diff --git a/README.setup b/README.setup
deleted file mode 100644
index 3d592e06..00000000
--- a/README.setup
+++ /dev/null
@@ -1,13 +0,0 @@
-If you want to start development of ownCloud android client you have two way to do so
-(a) building with console
-(b) building with eclipse
-
-1. Use setup_env.sh
-2a. ant clean;ant debug
-2b. Open Eclipse and import actionbarsherlock/library project to your workspace
-
-after those space you should be good to go.
-
-HAVE FUN!
-
-NOTE: You must have 'tools' and 'platforms-tools' in your path in order to run setup_env.sh
diff --git a/SETUP.md b/SETUP.md
new file mode 100644
index 00000000..d527d4fe
--- /dev/null
+++ b/SETUP.md
@@ -0,0 +1,23 @@
+
+ If you want to start development of ownCloud android client you have two way to do so:
+
+ 1. Building with console:
+
+ - Use setup_env.sh or setup_env.bat
+ - NOTE: You must have git, ant/bin, android/tools in your enviroment path
+
+ 2. Building with eclipse:
+
+ - Run ant clean debug
+ - Open Eclipse and import *actionbarsherlock/library* project to your workspace
+ - NOTE: You must have 'tools' and 'platforms-tools' in your path in order to run setup_env.sh
+
+ After those actions you should be good to go.
+
+ HAVE FUN!
+
+
+
+
+
+
diff --git a/actionbarsherlock b/actionbarsherlock
index 90939dc3..9598f2bb 160000
--- a/actionbarsherlock
+++ b/actionbarsherlock
@@ -1 +1 @@
-Subproject commit 90939dc3925ffaaa0de269bbbe1b35e274968ea1
+Subproject commit 9598f2bb2ceed4a834cd5586a903f270ca4c0ccc
diff --git a/oc_jb_workaround/src/com/owncloud/android/workaround/accounts/AccountAuthenticatorService.java b/oc_jb_workaround/src/com/owncloud/android/workaround/accounts/AccountAuthenticatorService.java
index 32b164b0..102f2be6 100644
--- a/oc_jb_workaround/src/com/owncloud/android/workaround/accounts/AccountAuthenticatorService.java
+++ b/oc_jb_workaround/src/com/owncloud/android/workaround/accounts/AccountAuthenticatorService.java
@@ -1,8 +1,22 @@
/* ownCloud Jelly Bean Workaround for lost credentials
- *
* Copyright (C) 2013 ownCloud Inc.
+ *
+ * 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, see .
+ *
*/
+
package com.owncloud.android.workaround.accounts;
import android.accounts.AbstractAccountAuthenticator;
diff --git a/res/anim/disappear.xml b/res/anim/disappear.xml
index b1fd5e3a..1c98f627 100644
--- a/res/anim/disappear.xml
+++ b/res/anim/disappear.xml
@@ -1,4 +1,23 @@
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
diff --git a/res/anim/push_left_out.xml b/res/anim/push_left_out.xml
deleted file mode 100644
index 28802d2e..00000000
--- a/res/anim/push_left_out.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
diff --git a/res/anim/shrink_from_bottom.xml b/res/anim/shrink_from_bottom.xml
index a98d592a..517d36c8 100644
--- a/res/anim/shrink_from_bottom.xml
+++ b/res/anim/shrink_from_bottom.xml
@@ -1,4 +1,23 @@
+
+
+
+
+
+
+
diff --git a/res/drawable/btn.xml b/res/drawable/btn.xml
index 8e01f676..b58eda87 100644
--- a/res/drawable/btn.xml
+++ b/res/drawable/btn.xml
@@ -1,4 +1,23 @@
+
diff --git a/res/drawable/btn_round.xml b/res/drawable/btn_round.xml
index a7c5063f..a2c92aa8 100644
--- a/res/drawable/btn_round.xml
+++ b/res/drawable/btn_round.xml
@@ -1,4 +1,23 @@
+
diff --git a/res/drawable/btn_round_pressed.xml b/res/drawable/btn_round_pressed.xml
index 34d860dc..e567a6bd 100644
--- a/res/drawable/btn_round_pressed.xml
+++ b/res/drawable/btn_round_pressed.xml
@@ -1,4 +1,23 @@
+
diff --git a/res/drawable/connection_secure.xml b/res/drawable/connection_secure.xml
index b988c29b..7b2944f3 100644
--- a/res/drawable/connection_secure.xml
+++ b/res/drawable/connection_secure.xml
@@ -1,8 +1,27 @@
-
+
+
-
+
diff --git a/res/drawable/icon_list_selector.xml b/res/drawable/icon_list_selector.xml
deleted file mode 100644
index f7c83929..00000000
--- a/res/drawable/icon_list_selector.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/res/drawable/list_selector.xml b/res/drawable/list_selector.xml
index f7c83929..4af9f6b0 100644
--- a/res/drawable/list_selector.xml
+++ b/res/drawable/list_selector.xml
@@ -1,29 +1,28 @@
-
-
-
-
-
-
-
-
+
+
+
-
\ No newline at end of file
+
diff --git a/res/drawable/main_header_bg.xml b/res/drawable/main_header_bg.xml
index 04bdc465..166b666d 100644
--- a/res/drawable/main_header_bg.xml
+++ b/res/drawable/main_header_bg.xml
@@ -1,4 +1,23 @@
+
+
+
+
diff --git a/res/layout-land/account_setup.xml b/res/layout-land/account_setup.xml
index 24b3e8ad..c45405fa 100644
--- a/res/layout-land/account_setup.xml
+++ b/res/layout-land/account_setup.xml
@@ -2,10 +2,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/file_activity_details.xml b/res/layout/file_activity_details.xml
index f37270ba..e4f576c2 100644
--- a/res/layout/file_activity_details.xml
+++ b/res/layout/file_activity_details.xml
@@ -3,9 +3,11 @@
ownCloud Android client application
Copyright (C) 2012 Bartek Przybylski
+ Copyright (C) 2012-2013 ownCloud Inc.
+
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 3 of the License, or
+ 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,
@@ -14,7 +16,8 @@
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, see .
+ along with this program. If not, see .
+
-->
+
+
+
+
diff --git a/res/layout/selected_account_element.xml b/res/layout/selected_account_element.xml
index fe3146e3..d4000484 100644
--- a/res/layout/selected_account_element.xml
+++ b/res/layout/selected_account_element.xml
@@ -1,4 +1,23 @@
+
+
- * DISCLAIMER: HttpClient developers DO NOT actively support this
- * component. The component is provided as a reference material, which
- * may be inappropriate for use without additional customization.
- *
- */
-
-public class EasySSLSocketFactory implements ProtocolSocketFactory {
-
- private static final String TAG = "EasySSLSocketFactory";
- private SSLContext sslcontext = null;
-
- /**
- * Constructor for EasySSLProtocolSocketFactory.
- */
- public EasySSLSocketFactory() {
- super();
- }
-
- private static SSLContext createEasySSLContext() {
- Log.d(TAG, "Creating Easy SSL Context");
- try {
- SSLContext context = SSLContext.getInstance("TLS");
- context.init(null, new TrustManager[] { new EasyX509TrustManager(
- null) }, null);
- return context;
- } catch (Exception er) {
- Log.e(TAG, er.getMessage() + "");
- throw new HttpClientError(er.toString());
- }
- }
-
- private SSLContext getSSLContext() {
- Log.d(TAG, "Getting Easy SSL Context");
- if (this.sslcontext == null) {
- this.sslcontext = createEasySSLContext();
- }
- return this.sslcontext;
- }
-
- /**
- * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int,java.net.InetAddress,int)
- */
- public Socket createSocket(String host, int port, InetAddress clientHost,
- int clientPort) throws IOException, UnknownHostException {
- Log.d(TAG, "Creating SSL Socket with remote " + host + ":" + port + ", client " + clientHost + ":" + clientPort);
-
- return getSSLContext().getSocketFactory().createSocket(host, port,
- clientHost, clientPort);
- }
-
- /**
- * Attempts to get a new socket connection to the given host within the
- * given time limit.
- *
- * To circumvent the limitations of older JREs that do not support connect
- * timeout a controller thread is executed. The controller thread attempts
- * to create a new socket within the given limit of time. If socket
- * constructor does not return until the timeout expires, the controller
- * terminates and throws an {@link ConnectTimeoutException}
- *
- *
- * @param host the host name/IP
- * @param port the port on the host
- * @param clientHost the local host name/IP to bind the socket to
- * @param clientPort the port on the local machine
- * @param params {@link HttpConnectionParams Http connection parameters}
- *
- * @return Socket a new socket
- *
- * @throws IOException if an I/O error occurs while creating the socket
- * @throws UnknownHostException if the IP address of the host cannot be
- * determined
- */
- public Socket createSocket(final String host, final int port,
- final InetAddress localAddress, final int localPort,
- final HttpConnectionParams params) throws IOException,
- UnknownHostException, ConnectTimeoutException {
- Log.d(TAG, "Creating SSL Socket with remote " + host + ":" + port + ", local " + localAddress + ":" + localPort + ", params: " + params);
- if (params == null) {
- throw new IllegalArgumentException("Parameters may not be null");
- }
- int timeout = params.getConnectionTimeout();
- SocketFactory socketfactory = getSSLContext().getSocketFactory();
- /*if (timeout == 0) {
- Log.d(TAG, " ... with connection timeout 0 and socket timeout " + params.getSoTimeout());
- Socket socket = socketfactory.createSocket(host, port, localAddress,
- localPort);
- socket.setSoTimeout(params.getSoTimeout());
- return socket;
- } else {*/
- Log.d(TAG, " ... with connection timeout " + timeout + " and socket timeout " + params.getSoTimeout());
- Socket socket = socketfactory.createSocket();
- SocketAddress localaddr = new InetSocketAddress(localAddress,
- localPort);
- SocketAddress remoteaddr = new InetSocketAddress(host, port);
- socket.setSoTimeout(params.getSoTimeout());
- socket.bind(localaddr);
- socket.connect(remoteaddr, timeout);
- return socket;
- //}
- }
-
- /**
- * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int)
- */
- public Socket createSocket(String host, int port) throws IOException,
- UnknownHostException {
- Log.d(TAG, "Creating SSL Socket with remote " + host + ":" + port);
- return getSSLContext().getSocketFactory().createSocket(host, port);
- }
-
- /**
- * @see SecureProtocolSocketFactory#createSocket(java.net.Socket,java.lang.String,int,boolean)
- */
- public Socket createSocket(Socket socket, String host, int port,
- boolean autoClose) throws IOException, UnknownHostException {
- Log.d(TAG, "Creating SSL Socket from other shocket " + socket + " to remote " + host + ":" + port);
- return getSSLContext().getSocketFactory().createSocket(socket, host,
- port, autoClose);
- }
-
- public boolean equals(Object obj) {
- return ((obj != null) && obj.getClass().equals(
- EasySSLSocketFactory.class));
- }
-
- public int hashCode() {
- return EasySSLSocketFactory.class.hashCode();
- }
-
-}
\ No newline at end of file
diff --git a/src/com/owncloud/android/network/EasyX509TrustManager.java b/src/com/owncloud/android/network/EasyX509TrustManager.java
deleted file mode 100644
index 1ac62186..00000000
--- a/src/com/owncloud/android/network/EasyX509TrustManager.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package com.owncloud.android.network;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-import javax.net.ssl.X509TrustManager;
-
-/**
- * @author olamy
- * @version $Id: EasyX509TrustManager.java 765355 2009-04-15 20:59:07Z evenisse
- * $
- * @since 1.2.3
- */
-public class EasyX509TrustManager implements X509TrustManager {
-
- private X509TrustManager standardTrustManager = null;
-
- /**
- * Constructor for EasyX509TrustManager.
- */
- public EasyX509TrustManager(KeyStore keystore)
- throws NoSuchAlgorithmException, KeyStoreException {
- super();
- TrustManagerFactory factory = TrustManagerFactory
- .getInstance(TrustManagerFactory.getDefaultAlgorithm());
- factory.init(keystore);
- TrustManager[] trustmanagers = factory.getTrustManagers();
- if (trustmanagers.length == 0) {
- throw new NoSuchAlgorithmException("no trust manager found");
- }
- this.standardTrustManager = (X509TrustManager) trustmanagers[0];
- }
-
- /**
- * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[],
- * String authType)
- */
- public void checkClientTrusted(X509Certificate[] certificates,
- String authType) throws CertificateException {
- standardTrustManager.checkClientTrusted(certificates, authType);
- }
-
- /**
- * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],
- * String authType)
- */
- public void checkServerTrusted(X509Certificate[] certificates,
- String authType) throws CertificateException {
- if ((certificates != null) && (certificates.length == 1)) {
- certificates[0].checkValidity();
- } else {
- // standardTrustManager.checkServerTrusted( certificates, authType
- // );
- }
- }
-
- /**
- * @see javax.net.ssl.X509TrustManager#getAcceptedIssuers()
- */
- public X509Certificate[] getAcceptedIssuers() {
- return this.standardTrustManager.getAcceptedIssuers();
- }
-
-}
\ No newline at end of file
diff --git a/src/com/owncloud/android/network/OwnCloudClientUtils.java b/src/com/owncloud/android/network/OwnCloudClientUtils.java
index 5cc7a9fb..19844130 100644
--- a/src/com/owncloud/android/network/OwnCloudClientUtils.java
+++ b/src/com/owncloud/android/network/OwnCloudClientUtils.java
@@ -1,9 +1,9 @@
/* ownCloud Android client application
- * Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
@@ -140,32 +140,6 @@ public class OwnCloudClientUtils {
/**
- * Allows or disallows self-signed certificates in ownCloud servers to reach
- *
- * @param allow 'True' to allow, 'false' to disallow
- */
- public static void allowSelfsignedCertificates(boolean allow) {
- Protocol pr = null;
- try {
- pr = Protocol.getProtocol("https");
- if (pr != null && mDefaultHttpsProtocol == null) {
- mDefaultHttpsProtocol = pr;
- }
- } catch (IllegalStateException e) {
- // nothing to do here; really
- }
- boolean isAllowed = (pr != null && pr.getSocketFactory() instanceof EasySSLSocketFactory);
- if (allow && !isAllowed) {
- Protocol.registerProtocol("https", new Protocol("https", new EasySSLSocketFactory(), 443));
- } else if (!allow && isAllowed) {
- if (mDefaultHttpsProtocol != null) {
- Protocol.registerProtocol("https", mDefaultHttpsProtocol);
- }
- }
- }
-
-
- /**
* Registers or unregisters the proper components for advanced SSL handling.
* @throws IOException
*/
diff --git a/src/com/owncloud/android/operations/ChunkedUploadFileOperation.java b/src/com/owncloud/android/operations/ChunkedUploadFileOperation.java
index 413a76e2..c01ee46b 100644
--- a/src/com/owncloud/android/operations/ChunkedUploadFileOperation.java
+++ b/src/com/owncloud/android/operations/ChunkedUploadFileOperation.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/operations/ConnectionCheckOperation.java b/src/com/owncloud/android/operations/ConnectionCheckOperation.java
index 558e0df2..f8ede263 100644
--- a/src/com/owncloud/android/operations/ConnectionCheckOperation.java
+++ b/src/com/owncloud/android/operations/ConnectionCheckOperation.java
@@ -1,9 +1,9 @@
/* ownCloud Android client application
- * Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/operations/DownloadFileOperation.java b/src/com/owncloud/android/operations/DownloadFileOperation.java
index d752b3cc..75bf9234 100644
--- a/src/com/owncloud/android/operations/DownloadFileOperation.java
+++ b/src/com/owncloud/android/operations/DownloadFileOperation.java
@@ -1,9 +1,9 @@
/* ownCloud Android client application
- * Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/operations/OnRemoteOperationListener.java b/src/com/owncloud/android/operations/OnRemoteOperationListener.java
index e226ef20..f2119a80 100644
--- a/src/com/owncloud/android/operations/OnRemoteOperationListener.java
+++ b/src/com/owncloud/android/operations/OnRemoteOperationListener.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/operations/OperationCancelledException.java b/src/com/owncloud/android/operations/OperationCancelledException.java
index d15af08c..975d63fb 100644
--- a/src/com/owncloud/android/operations/OperationCancelledException.java
+++ b/src/com/owncloud/android/operations/OperationCancelledException.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/operations/RemoteOperation.java b/src/com/owncloud/android/operations/RemoteOperation.java
index 5b58e0ca..1564f193 100644
--- a/src/com/owncloud/android/operations/RemoteOperation.java
+++ b/src/com/owncloud/android/operations/RemoteOperation.java
@@ -1,9 +1,9 @@
/* ownCloud Android client application
- * Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/operations/RemoteOperationResult.java b/src/com/owncloud/android/operations/RemoteOperationResult.java
index 64703386..718988a4 100644
--- a/src/com/owncloud/android/operations/RemoteOperationResult.java
+++ b/src/com/owncloud/android/operations/RemoteOperationResult.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/operations/RemoveFileOperation.java b/src/com/owncloud/android/operations/RemoveFileOperation.java
index bfc063f9..80f40977 100644
--- a/src/com/owncloud/android/operations/RemoveFileOperation.java
+++ b/src/com/owncloud/android/operations/RemoveFileOperation.java
@@ -1,9 +1,9 @@
/* ownCloud Android client application
- * Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/operations/RenameFileOperation.java b/src/com/owncloud/android/operations/RenameFileOperation.java
index f4ec7b0a..41233f18 100644
--- a/src/com/owncloud/android/operations/RenameFileOperation.java
+++ b/src/com/owncloud/android/operations/RenameFileOperation.java
@@ -1,9 +1,9 @@
/* ownCloud Android client application
- * Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/operations/SynchronizeFileOperation.java b/src/com/owncloud/android/operations/SynchronizeFileOperation.java
index 8bad631b..606017aa 100644
--- a/src/com/owncloud/android/operations/SynchronizeFileOperation.java
+++ b/src/com/owncloud/android/operations/SynchronizeFileOperation.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
@@ -116,7 +117,7 @@ public class SynchronizeFileOperation extends RemoteOperation {
serverChanged = (mServerFile.getModificationTimestamp() > mLocalFile.getModificationTimestampAtLastSyncForData());
}
boolean localChanged = (mLocalChangeAlreadyKnown || mLocalFile.getLocalModificationTimestamp() > mLocalFile.getLastSyncDateForData());
- // TODO this will be always true after the app is upgraded to database version 3; will result in unnecessary uploads
+ // TODO this will be always true after the app is upgraded to database version 2; will result in unnecessary uploads
/// decide action to perform depending upon changes
if (localChanged && serverChanged) {
diff --git a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java
index 849413fd..977460bf 100644
--- a/src/com/owncloud/android/operations/SynchronizeFolderOperation.java
+++ b/src/com/owncloud/android/operations/SynchronizeFolderOperation.java
@@ -1,9 +1,9 @@
/* ownCloud Android client application
- * Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/operations/UpdateOCVersionOperation.java b/src/com/owncloud/android/operations/UpdateOCVersionOperation.java
index 7072d39f..08a9c15f 100644
--- a/src/com/owncloud/android/operations/UpdateOCVersionOperation.java
+++ b/src/com/owncloud/android/operations/UpdateOCVersionOperation.java
@@ -1,9 +1,9 @@
/* ownCloud Android client application
- * Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/operations/UploadFileOperation.java b/src/com/owncloud/android/operations/UploadFileOperation.java
index fa5bf02c..2824b6da 100644
--- a/src/com/owncloud/android/operations/UploadFileOperation.java
+++ b/src/com/owncloud/android/operations/UploadFileOperation.java
@@ -1,9 +1,9 @@
/* ownCloud Android client application
- * Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/providers/FileContentProvider.java b/src/com/owncloud/android/providers/FileContentProvider.java
index e87d151c..5e54341b 100644
--- a/src/com/owncloud/android/providers/FileContentProvider.java
+++ b/src/com/owncloud/android/providers/FileContentProvider.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/syncadapter/AbstractOwnCloudSyncAdapter.java b/src/com/owncloud/android/syncadapter/AbstractOwnCloudSyncAdapter.java
index 92c0b720..d362c55d 100644
--- a/src/com/owncloud/android/syncadapter/AbstractOwnCloudSyncAdapter.java
+++ b/src/com/owncloud/android/syncadapter/AbstractOwnCloudSyncAdapter.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/syncadapter/ContactSyncAdapter.java b/src/com/owncloud/android/syncadapter/ContactSyncAdapter.java
index 8a8264f1..1f307c94 100644
--- a/src/com/owncloud/android/syncadapter/ContactSyncAdapter.java
+++ b/src/com/owncloud/android/syncadapter/ContactSyncAdapter.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/syncadapter/ContactSyncService.java b/src/com/owncloud/android/syncadapter/ContactSyncService.java
index cf9fbeaf..7c702d93 100644
--- a/src/com/owncloud/android/syncadapter/ContactSyncService.java
+++ b/src/com/owncloud/android/syncadapter/ContactSyncService.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java
index f66980cb..6da3e81d 100644
--- a/src/com/owncloud/android/syncadapter/FileSyncAdapter.java
+++ b/src/com/owncloud/android/syncadapter/FileSyncAdapter.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/syncadapter/FileSyncService.java b/src/com/owncloud/android/syncadapter/FileSyncService.java
index cb2f7200..3d819616 100644
--- a/src/com/owncloud/android/syncadapter/FileSyncService.java
+++ b/src/com/owncloud/android/syncadapter/FileSyncService.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/ActionItem.java b/src/com/owncloud/android/ui/ActionItem.java
index b2be7029..e97dfef0 100644
--- a/src/com/owncloud/android/ui/ActionItem.java
+++ b/src/com/owncloud/android/ui/ActionItem.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/CustomPopup.java b/src/com/owncloud/android/ui/CustomPopup.java
index b7ce4265..a9315dd7 100644
--- a/src/com/owncloud/android/ui/CustomPopup.java
+++ b/src/com/owncloud/android/ui/CustomPopup.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/ExtendedListView.java b/src/com/owncloud/android/ui/ExtendedListView.java
index ba1e3604..5b7fb98a 100644
--- a/src/com/owncloud/android/ui/ExtendedListView.java
+++ b/src/com/owncloud/android/ui/ExtendedListView.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/FragmentListView.java b/src/com/owncloud/android/ui/FragmentListView.java
index 3dbe16da..d791eed3 100644
--- a/src/com/owncloud/android/ui/FragmentListView.java
+++ b/src/com/owncloud/android/ui/FragmentListView.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/QuickAction.java b/src/com/owncloud/android/ui/QuickAction.java
index 122792d5..a6d021d7 100644
--- a/src/com/owncloud/android/ui/QuickAction.java
+++ b/src/com/owncloud/android/ui/QuickAction.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/activity/AccountSelectActivity.java b/src/com/owncloud/android/ui/activity/AccountSelectActivity.java
index 21736e1d..31b59d49 100644
--- a/src/com/owncloud/android/ui/activity/AccountSelectActivity.java
+++ b/src/com/owncloud/android/ui/activity/AccountSelectActivity.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/activity/AuthenticatorActivity.java b/src/com/owncloud/android/ui/activity/AuthenticatorActivity.java
index bd36ed1c..d2770406 100644
--- a/src/com/owncloud/android/ui/activity/AuthenticatorActivity.java
+++ b/src/com/owncloud/android/ui/activity/AuthenticatorActivity.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/activity/ConflictsResolveActivity.java b/src/com/owncloud/android/ui/activity/ConflictsResolveActivity.java
index d04d6cee..21aaed8f 100644
--- a/src/com/owncloud/android/ui/activity/ConflictsResolveActivity.java
+++ b/src/com/owncloud/android/ui/activity/ConflictsResolveActivity.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/activity/ErrorsWhileCopyingHandlerActivity.java b/src/com/owncloud/android/ui/activity/ErrorsWhileCopyingHandlerActivity.java
index cb7e721f..0522cb85 100644
--- a/src/com/owncloud/android/ui/activity/ErrorsWhileCopyingHandlerActivity.java
+++ b/src/com/owncloud/android/ui/activity/ErrorsWhileCopyingHandlerActivity.java
@@ -1,3 +1,21 @@
+/* ownCloud Android client application
+ * Copyright (C) 2012-2013 ownCloud Inc.
+ *
+ * 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, see .
+ *
+ */
+
package com.owncloud.android.ui.activity;
import java.io.File;
diff --git a/src/com/owncloud/android/ui/activity/FileDetailActivity.java b/src/com/owncloud/android/ui/activity/FileDetailActivity.java
index ee23ca3d..cd68c891 100644
--- a/src/com/owncloud/android/ui/activity/FileDetailActivity.java
+++ b/src/com/owncloud/android/ui/activity/FileDetailActivity.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java
index cfd9ae5e..46ed65e6 100644
--- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java
+++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java
@@ -1,1287 +1,1309 @@
-/* ownCloud Android client application
- * Copyright (C) 2011 Bartek Przybylski
- *
- * 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 3 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, see .
- *
- */
-
-package com.owncloud.android.ui.activity;
-
-import java.io.File;
-
-import android.accounts.Account;
-import android.app.AlertDialog;
-import android.app.ProgressDialog;
-import android.app.AlertDialog.Builder;
-import android.app.Dialog;
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnClickListener;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.ServiceConnection;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.res.Resources.NotFoundException;
-import android.database.Cursor;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.IBinder;
-import android.preference.PreferenceManager;
-import android.provider.MediaStore;
-import android.support.v4.app.FragmentTransaction;
-import android.util.Log;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
-import android.widget.EditText;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import com.actionbarsherlock.app.ActionBar;
-import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
-import com.actionbarsherlock.view.Menu;
-import com.actionbarsherlock.view.MenuInflater;
-import com.actionbarsherlock.view.MenuItem;
-import com.actionbarsherlock.view.Window;
-import com.owncloud.android.AccountUtils;
-import com.owncloud.android.authenticator.AccountAuthenticator;
-import com.owncloud.android.datamodel.DataStorageManager;
-import com.owncloud.android.datamodel.FileDataStorageManager;
-import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.files.services.FileDownloader;
-import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
-import com.owncloud.android.files.services.FileObserverService;
-import com.owncloud.android.files.services.FileUploader;
-import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
-import com.owncloud.android.network.OwnCloudClientUtils;
-import com.owncloud.android.operations.OnRemoteOperationListener;
-import com.owncloud.android.operations.RemoteOperation;
-import com.owncloud.android.operations.RemoteOperationResult;
-import com.owncloud.android.operations.RemoveFileOperation;
-import com.owncloud.android.operations.RenameFileOperation;
-import com.owncloud.android.operations.SynchronizeFileOperation;
-import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
-import com.owncloud.android.syncadapter.FileSyncService;
-import com.owncloud.android.ui.dialog.ChangelogDialog;
-import com.owncloud.android.ui.dialog.SslValidatorDialog;
-import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener;
-import com.owncloud.android.ui.fragment.FileDetailFragment;
-import com.owncloud.android.ui.fragment.OCFileListFragment;
-
-import com.owncloud.android.R;
-import eu.alefzero.webdav.WebdavClient;
-
-/**
- * Displays, what files the user has available in his ownCloud.
- *
- * @author Bartek Przybylski
- *
- */
-
-public class FileDisplayActivity extends SherlockFragmentActivity implements
- OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNavigationListener, OnSslValidatorListener, OnRemoteOperationListener {
-
- private ArrayAdapter mDirectories;
- private OCFile mCurrentDir = null;
- private OCFile mCurrentFile = null;
-
- private DataStorageManager mStorageManager;
- private SyncBroadcastReceiver mSyncBroadcastReceiver;
- private UploadFinishReceiver mUploadFinishReceiver;
- private DownloadFinishReceiver mDownloadFinishReceiver;
- private FileDownloaderBinder mDownloaderBinder = null;
- private FileUploaderBinder mUploaderBinder = null;
- private ServiceConnection mDownloadConnection = null, mUploadConnection = null;
- private RemoteOperationResult mLastSslUntrustedServerResult = null;
-
- private OCFileListFragment mFileList;
-
- private boolean mDualPane;
-
- private static final int DIALOG_SETUP_ACCOUNT = 0;
- private static final int DIALOG_CREATE_DIR = 1;
- private static final int DIALOG_ABOUT_APP = 2;
- public static final int DIALOG_SHORT_WAIT = 3;
- private static final int DIALOG_CHOOSE_UPLOAD_SOURCE = 4;
- private static final int DIALOG_SSL_VALIDATOR = 5;
- private static final int DIALOG_CERT_NOT_SAVED = 6;
- private static final String DIALOG_CHANGELOG_TAG = "DIALOG_CHANGELOG";
-
-
- private static final int ACTION_SELECT_CONTENT_FROM_APPS = 1;
- private static final int ACTION_SELECT_MULTIPLE_FILES = 2;
-
- private static final String TAG = "FileDisplayActivity";
-
- private static int[] mMenuIdentifiersToPatch = {R.id.about_app};
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- Log.d(getClass().toString(), "onCreate() start");
- super.onCreate(savedInstanceState);
-
- /// Load of parameters from received intent
- mCurrentDir = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE); // no check necessary, mCurrenDir == null if the parameter is not in the intent
- Account account = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_ACCOUNT);
- if (account != null)
- AccountUtils.setCurrentOwnCloudAccount(this, account.name);
-
- /// Load of saved instance state: keep this always before initDataFromCurrentAccount()
- if(savedInstanceState != null) {
- // TODO - test if savedInstanceState should take precedence over file in the intent ALWAYS (now), NEVER, or SOME TIMES
- mCurrentDir = savedInstanceState.getParcelable(FileDetailFragment.EXTRA_FILE);
- }
-
- if (!AccountUtils.accountsAreSetup(this)) {
- /// no account available: FORCE ACCOUNT CREATION
- mStorageManager = null;
- createFirstAccount();
-
- } else { /// at least an account is available
-
- initDataFromCurrentAccount(); // it checks mCurrentDir and mCurrentFile with the current account
-
- }
-
- mUploadConnection = new ListServiceConnection();
- mDownloadConnection = new ListServiceConnection();
- bindService(new Intent(this, FileUploader.class), mUploadConnection, Context.BIND_AUTO_CREATE);
- bindService(new Intent(this, FileDownloader.class), mDownloadConnection, Context.BIND_AUTO_CREATE);
-
- // PIN CODE request ; best location is to decide, let's try this first
- if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_MAIN) && savedInstanceState == null) {
- requestPinCode();
- }
-
- // file observer
- Intent observer_intent = new Intent(this, FileObserverService.class);
- observer_intent.putExtra(FileObserverService.KEY_FILE_CMD, FileObserverService.CMD_INIT_OBSERVED_LIST);
- startService(observer_intent);
-
-
- /// USER INTERFACE
- requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
-
- // Drop-down navigation
- mDirectories = new CustomArrayAdapter(this, R.layout.sherlock_spinner_dropdown_item);
- OCFile currFile = mCurrentDir;
- while(currFile != null && currFile.getFileName() != OCFile.PATH_SEPARATOR) {
- mDirectories.add(currFile.getFileName());
- currFile = mStorageManager.getFileById(currFile.getParentId());
- }
- mDirectories.add(OCFile.PATH_SEPARATOR);
-
- // Inflate and set the layout view
- setContentView(R.layout.files);
- mFileList = (OCFileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList);
- mDualPane = (findViewById(R.id.file_details_container) != null);
- if (mDualPane) {
- initFileDetailsInDualPane();
- }
-
- // Action bar setup
- ActionBar actionBar = getSupportActionBar();
- actionBar.setHomeButtonEnabled(true); // mandatory since Android ICS, according to the official documentation
- actionBar.setDisplayHomeAsUpEnabled(mCurrentDir != null && mCurrentDir.getParentId() != 0);
- actionBar.setDisplayShowTitleEnabled(false);
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
- actionBar.setListNavigationCallbacks(mDirectories, this);
- setSupportProgressBarIndeterminateVisibility(false); // always AFTER setContentView(...) ; to workaround bug in its implementation
-
-
- // show changelog, if needed
- showChangeLog();
-
- Log.d(getClass().toString(), "onCreate() end");
- }
-
-
- /**
- * Shows a dialog with the change log of the current version after each app update
- *
- * TODO make it permanent; by now, only to advice the workaround app for 4.1.x
- */
- private void showChangeLog() {
- if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.JELLY_BEAN) {
- final String KEY_VERSION = "version";
- SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
- int currentVersionNumber = 0;
- int savedVersionNumber = sharedPref.getInt(KEY_VERSION, 0);
- try {
- PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0);
- currentVersionNumber = pi.versionCode;
- } catch (Exception e) {}
-
- if (currentVersionNumber > savedVersionNumber) {
- ChangelogDialog.newInstance(true).show(getSupportFragmentManager(), DIALOG_CHANGELOG_TAG);
- Editor editor = sharedPref.edit();
- editor.putInt(KEY_VERSION, currentVersionNumber);
- editor.commit();
- }
- }
- }
-
-
- /**
- * Launches the account creation activity. To use when no ownCloud account is available
- */
- private void createFirstAccount() {
- Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);
- intent.putExtra(android.provider.Settings.EXTRA_AUTHORITIES, new String[] { AccountAuthenticator.AUTH_TOKEN_TYPE });
- startActivity(intent); // the new activity won't be created until this.onStart() and this.onResume() are finished;
- }
-
-
- /**
- * Load of state dependent of the existence of an ownCloud account
- */
- private void initDataFromCurrentAccount() {
- /// Storage manager initialization - access to local database
- mStorageManager = new FileDataStorageManager(
- AccountUtils.getCurrentOwnCloudAccount(this),
- getContentResolver());
-
- /// Check if mCurrentDir is a directory
- if(mCurrentDir != null && !mCurrentDir.isDirectory()) {
- mCurrentFile = mCurrentDir;
- mCurrentDir = mStorageManager.getFileById(mCurrentDir.getParentId());
- }
-
- /// Check if mCurrentDir and mCurrentFile are in the current account, and update them
- if (mCurrentDir != null) {
- mCurrentDir = mStorageManager.getFileByPath(mCurrentDir.getRemotePath()); // mCurrentDir == null if it is not in the current account
- }
- if (mCurrentFile != null) {
- if (mCurrentFile.fileExists()) {
- mCurrentFile = mStorageManager.getFileByPath(mCurrentFile.getRemotePath()); // mCurrentFile == null if it is not in the current account
- } // else : keep mCurrentFile with the received value; this is currently the case of an upload in progress, when the user presses the status notification in a landscape tablet
- }
-
- /// Default to root if mCurrentDir was not found
- if (mCurrentDir == null) {
- mCurrentDir = mStorageManager.getFileByPath("/"); // will be NULL if the database was never synchronized
- }
- }
-
-
- private void initFileDetailsInDualPane() {
- if (mDualPane && getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG) == null) {
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- if (mCurrentFile != null) {
- transaction.replace(R.id.file_details_container, new FileDetailFragment(mCurrentFile, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG); // empty FileDetailFragment
- mCurrentFile = null;
- } else {
- transaction.replace(R.id.file_details_container, new FileDetailFragment(null, null), FileDetailFragment.FTAG); // empty FileDetailFragment
- }
- transaction.commit();
- }
- }
-
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- if (mDownloadConnection != null)
- unbindService(mDownloadConnection);
- if (mUploadConnection != null)
- unbindService(mUploadConnection);
- }
-
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getSherlock().getMenuInflater();
- inflater.inflate(R.menu.menu, menu);
-
- patchHiddenAccents(menu);
-
- return true;
- }
-
- /**
- * Workaround for this: http://code.google.com/p/android/issues/detail?id=3974
- *
- * @param menu Menu to patch
- */
- private void patchHiddenAccents(Menu menu) {
- for (int i = 0; i < mMenuIdentifiersToPatch.length ; i++) {
- MenuItem aboutItem = menu.findItem(mMenuIdentifiersToPatch[i]);
- if (aboutItem != null && aboutItem.getIcon() instanceof BitmapDrawable) {
- // Clip off the bottom three (density independent) pixels of transparent padding
- Bitmap original = ((BitmapDrawable) aboutItem.getIcon()).getBitmap();
- float scale = getResources().getDisplayMetrics().density;
- int clippedHeight = (int) (original.getHeight() - (3 * scale));
- Bitmap scaled = Bitmap.createBitmap(original, 0, 0, original.getWidth(), clippedHeight);
- aboutItem.setIcon(new BitmapDrawable(getResources(), scaled));
- }
- }
- }
-
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- boolean retval = true;
- switch (item.getItemId()) {
- case R.id.createDirectoryItem: {
- showDialog(DIALOG_CREATE_DIR);
- break;
- }
- case R.id.startSync: {
- startSynchronization();
- break;
- }
- case R.id.action_upload: {
- showDialog(DIALOG_CHOOSE_UPLOAD_SOURCE);
- break;
- }
- case R.id.action_settings: {
- Intent settingsIntent = new Intent(this, Preferences.class);
- startActivity(settingsIntent);
- break;
- }
- case R.id.about_app : {
- showDialog(DIALOG_ABOUT_APP);
- break;
- }
- case android.R.id.home: {
- if(mCurrentDir != null && mCurrentDir.getParentId() != 0){
- onBackPressed();
- }
- break;
- }
- default:
- retval = super.onOptionsItemSelected(item);
- }
- return retval;
- }
-
- private void startSynchronization() {
- ContentResolver.cancelSync(null, AccountAuthenticator.AUTH_TOKEN_TYPE); // cancel the current synchronizations of any ownCloud account
- Bundle bundle = new Bundle();
- bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
- ContentResolver.requestSync(
- AccountUtils.getCurrentOwnCloudAccount(this),
- AccountAuthenticator.AUTH_TOKEN_TYPE, bundle);
- }
-
-
- @Override
- public boolean onNavigationItemSelected(int itemPosition, long itemId) {
- int i = itemPosition;
- while (i-- != 0) {
- onBackPressed();
- }
- // the next operation triggers a new call to this method, but it's necessary to
- // ensure that the name exposed in the action bar is the current directory when the
- // user selected it in the navigation list
- if (itemPosition != 0)
- getSupportActionBar().setSelectedNavigationItem(0);
- return true;
- }
-
- /**
- * Called, when the user selected something for uploading
- */
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
-
- if (requestCode == ACTION_SELECT_CONTENT_FROM_APPS && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
- requestSimpleUpload(data, resultCode);
-
- } else if (requestCode == ACTION_SELECT_MULTIPLE_FILES && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
- requestMultipleUpload(data, resultCode);
-
- }
- }
-
- private void requestMultipleUpload(Intent data, int resultCode) {
- String[] filePaths = data.getStringArrayExtra(UploadFilesActivity.EXTRA_CHOSEN_FILES);
- if (filePaths != null) {
- String[] remotePaths = new String[filePaths.length];
- String remotePathBase = "";
- for (int j = mDirectories.getCount() - 2; j >= 0; --j) {
- remotePathBase += OCFile.PATH_SEPARATOR + mDirectories.getItem(j);
- }
- if (!remotePathBase.endsWith(OCFile.PATH_SEPARATOR))
- remotePathBase += OCFile.PATH_SEPARATOR;
- for (int j = 0; j< remotePaths.length; j++) {
- remotePaths[j] = remotePathBase + (new File(filePaths[j])).getName();
- }
-
- Intent i = new Intent(this, FileUploader.class);
- i.putExtra(FileUploader.KEY_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this));
- i.putExtra(FileUploader.KEY_LOCAL_FILE, filePaths);
- i.putExtra(FileUploader.KEY_REMOTE_FILE, remotePaths);
- i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_MULTIPLE_FILES);
- if (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)
- i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE);
- startService(i);
-
- } else {
- Log.d("FileDisplay", "User clicked on 'Update' with no selection");
- Toast t = Toast.makeText(this, getString(R.string.filedisplay_no_file_selected), Toast.LENGTH_LONG);
- t.show();
- return;
- }
- }
-
-
- private void requestSimpleUpload(Intent data, int resultCode) {
- String filepath = null;
- try {
- Uri selectedImageUri = data.getData();
-
- String filemanagerstring = selectedImageUri.getPath();
- String selectedImagePath = getPath(selectedImageUri);
-
- if (selectedImagePath != null)
- filepath = selectedImagePath;
- else
- filepath = filemanagerstring;
-
- } catch (Exception e) {
- Log.e("FileDisplay", "Unexpected exception when trying to read the result of Intent.ACTION_GET_CONTENT", e);
- e.printStackTrace();
-
- } finally {
- if (filepath == null) {
- Log.e("FileDisplay", "Couldnt resolve path to file");
- Toast t = Toast.makeText(this, getString(R.string.filedisplay_unexpected_bad_get_content), Toast.LENGTH_LONG);
- t.show();
- return;
- }
- }
-
- Intent i = new Intent(this, FileUploader.class);
- i.putExtra(FileUploader.KEY_ACCOUNT,
- AccountUtils.getCurrentOwnCloudAccount(this));
- String remotepath = new String();
- for (int j = mDirectories.getCount() - 2; j >= 0; --j) {
- remotepath += OCFile.PATH_SEPARATOR + mDirectories.getItem(j);
- }
- if (!remotepath.endsWith(OCFile.PATH_SEPARATOR))
- remotepath += OCFile.PATH_SEPARATOR;
- remotepath += new File(filepath).getName();
-
- i.putExtra(FileUploader.KEY_LOCAL_FILE, filepath);
- i.putExtra(FileUploader.KEY_REMOTE_FILE, remotepath);
- i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);
- if (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)
- i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE);
- startService(i);
- }
-
-
- @Override
- public void onBackPressed() {
- if (mDirectories.getCount() <= 1) {
- finish();
- return;
- }
- popDirname();
- mFileList.onNavigateUp();
- mCurrentDir = mFileList.getCurrentFile();
-
- if (mDualPane) {
- // Resets the FileDetailsFragment on Tablets so that it always displays
- FileDetailFragment fileDetails = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
- if (fileDetails != null && !fileDetails.isEmpty()) {
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- transaction.remove(fileDetails);
- transaction.add(R.id.file_details_container, new FileDetailFragment(null, null), FileDetailFragment.FTAG);
- transaction.commit();
- }
- }
-
- if(mCurrentDir.getParentId() == 0){
- ActionBar actionBar = getSupportActionBar();
- actionBar.setDisplayHomeAsUpEnabled(false);
- }
- }
-
- @Override
- protected void onSaveInstanceState(Bundle outState) {
- // responsibility of restore is preferred in onCreate() before than in onRestoreInstanceState when there are Fragments involved
- Log.d(getClass().toString(), "onSaveInstanceState() start");
- super.onSaveInstanceState(outState);
- outState.putParcelable(FileDetailFragment.EXTRA_FILE, mCurrentDir);
- if (mDualPane) {
- FileDetailFragment fragment = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
- if (fragment != null) {
- OCFile file = fragment.getDisplayedFile();
- if (file != null) {
- outState.putParcelable(FileDetailFragment.EXTRA_FILE, file);
- }
- }
- }
- Log.d(getClass().toString(), "onSaveInstanceState() end");
- }
-
- @Override
- protected void onResume() {
- Log.d(getClass().toString(), "onResume() start");
- super.onResume();
-
- if (AccountUtils.accountsAreSetup(this)) {
-
- if (mStorageManager == null) {
- // this is necessary for handling the come back to FileDisplayActivity when the first ownCloud account is created
- initDataFromCurrentAccount();
- if (mDualPane) {
- initFileDetailsInDualPane();
- }
- }
-
- // Listen for sync messages
- IntentFilter syncIntentFilter = new IntentFilter(FileSyncService.SYNC_MESSAGE);
- mSyncBroadcastReceiver = new SyncBroadcastReceiver();
- registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
-
- // Listen for upload messages
- IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.UPLOAD_FINISH_MESSAGE);
- mUploadFinishReceiver = new UploadFinishReceiver();
- registerReceiver(mUploadFinishReceiver, uploadIntentFilter);
-
- // Listen for download messages
- IntentFilter downloadIntentFilter = new IntentFilter(FileDownloader.DOWNLOAD_FINISH_MESSAGE);
- mDownloadFinishReceiver = new DownloadFinishReceiver();
- registerReceiver(mDownloadFinishReceiver, downloadIntentFilter);
-
- // List current directory
- mFileList.listDirectory(mCurrentDir); // TODO we should find the way to avoid the need of this (maybe it's not necessary yet; to check)
-
- } else {
-
- mStorageManager = null; // an invalid object will be there if all the ownCloud accounts are removed
- showDialog(DIALOG_SETUP_ACCOUNT);
-
- }
- Log.d(getClass().toString(), "onResume() end");
- }
-
-
- @Override
- protected void onPause() {
- Log.d(getClass().toString(), "onPause() start");
- super.onPause();
- if (mSyncBroadcastReceiver != null) {
- unregisterReceiver(mSyncBroadcastReceiver);
- mSyncBroadcastReceiver = null;
- }
- if (mUploadFinishReceiver != null) {
- unregisterReceiver(mUploadFinishReceiver);
- mUploadFinishReceiver = null;
- }
- if (mDownloadFinishReceiver != null) {
- unregisterReceiver(mDownloadFinishReceiver);
- mDownloadFinishReceiver = null;
- }
- if (!AccountUtils.accountsAreSetup(this)) {
- dismissDialog(DIALOG_SETUP_ACCOUNT);
- }
-
- Log.d(getClass().toString(), "onPause() end");
- }
-
-
- @Override
- protected void onPrepareDialog(int id, Dialog dialog, Bundle args) {
- if (id == DIALOG_SSL_VALIDATOR && mLastSslUntrustedServerResult != null) {
- ((SslValidatorDialog)dialog).updateResult(mLastSslUntrustedServerResult);
- }
- }
-
-
- @Override
- protected Dialog onCreateDialog(int id) {
- Dialog dialog = null;
- AlertDialog.Builder builder;
- switch (id) {
- case DIALOG_SETUP_ACCOUNT: {
- builder = new AlertDialog.Builder(this);
- builder.setTitle(R.string.main_tit_accsetup);
- builder.setMessage(R.string.main_wrn_accsetup);
- builder.setCancelable(false);
- builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- createFirstAccount();
- dialog.dismiss();
- }
- });
- String message = String.format(getString(R.string.common_exit), getString(R.string.app_name));
- builder.setNegativeButton(message, new OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- finish();
- }
- });
- //builder.setNegativeButton(android.R.string.cancel, this);
- dialog = builder.create();
- break;
- }
- case DIALOG_ABOUT_APP: {
- builder = new AlertDialog.Builder(this);
- builder.setTitle(getString(R.string.about_title));
- PackageInfo pkg;
- try {
- pkg = getPackageManager().getPackageInfo(getPackageName(), 0);
- builder.setMessage(String.format(getString(R.string.about_message), getString(R.string.app_name), pkg.versionName));
- builder.setIcon(android.R.drawable.ic_menu_info_details);
- dialog = builder.create();
- } catch (NameNotFoundException e) {
- builder = null;
- dialog = null;
- Log.e(TAG, "Error while showing about dialog", e);
- }
- break;
- }
- case DIALOG_CREATE_DIR: {
- builder = new Builder(this);
- final EditText dirNameInput = new EditText(getBaseContext());
- builder.setView(dirNameInput);
- builder.setTitle(R.string.uploader_info_dirname);
- int typed_color = getResources().getColor(R.color.setup_text_typed);
- dirNameInput.setTextColor(typed_color);
- builder.setPositiveButton(android.R.string.ok,
- new OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- String directoryName = dirNameInput.getText().toString();
- if (directoryName.trim().length() == 0) {
- dialog.cancel();
- return;
- }
-
- // Figure out the path where the dir needs to be created
- String path;
- if (mCurrentDir == null) {
- // this is just a patch; we should ensure that mCurrentDir never is null
- if (!mStorageManager.fileExists(OCFile.PATH_SEPARATOR)) {
- OCFile file = new OCFile(OCFile.PATH_SEPARATOR);
- mStorageManager.saveFile(file);
- }
- mCurrentDir = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR);
- }
- path = FileDisplayActivity.this.mCurrentDir.getRemotePath();
-
- // Create directory
- path += directoryName + OCFile.PATH_SEPARATOR;
- Thread thread = new Thread(new DirectoryCreator(path, AccountUtils.getCurrentOwnCloudAccount(FileDisplayActivity.this), new Handler()));
- thread.start();
-
- dialog.dismiss();
-
- showDialog(DIALOG_SHORT_WAIT);
- }
- });
- builder.setNegativeButton(R.string.common_cancel,
- new OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- dialog.cancel();
- }
- });
- dialog = builder.create();
- break;
- }
- case DIALOG_SHORT_WAIT: {
- ProgressDialog working_dialog = new ProgressDialog(this);
- working_dialog.setMessage(getResources().getString(
- R.string.wait_a_moment));
- working_dialog.setIndeterminate(true);
- working_dialog.setCancelable(false);
- dialog = working_dialog;
- break;
- }
- case DIALOG_CHOOSE_UPLOAD_SOURCE: {
- final String [] items = { getString(R.string.actionbar_upload_files),
- getString(R.string.actionbar_upload_from_apps) };
- builder = new AlertDialog.Builder(this);
- builder.setTitle(R.string.actionbar_upload);
- builder.setItems(items, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int item) {
- if (item == 0) {
- //if (!mDualPane) {
- Intent action = new Intent(FileDisplayActivity.this, UploadFilesActivity.class);
- action.putExtra(UploadFilesActivity.EXTRA_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(FileDisplayActivity.this));
- startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES);
- //} else {
- // TODO create and handle new fragment LocalFileListFragment
- //}
- } else if (item == 1) {
- Intent action = new Intent(Intent.ACTION_GET_CONTENT);
- action = action.setType("*/*")
- .addCategory(Intent.CATEGORY_OPENABLE);
- startActivityForResult(
- Intent.createChooser(action, getString(R.string.upload_chooser_title)),
- ACTION_SELECT_CONTENT_FROM_APPS);
- }
- }
- });
- dialog = builder.create();
- break;
- }
- case DIALOG_SSL_VALIDATOR: {
- dialog = SslValidatorDialog.newInstance(this, mLastSslUntrustedServerResult, this);
- break;
- }
- case DIALOG_CERT_NOT_SAVED: {
- builder = new AlertDialog.Builder(this);
- builder.setMessage(getResources().getString(R.string.ssl_validator_not_saved));
- builder.setCancelable(false);
- builder.setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- dialog.dismiss();
- };
- });
- dialog = builder.create();
- break;
- }
- default:
- dialog = null;
- }
-
- return dialog;
- }
-
-
- /**
- * Translates a content URI of an image to a physical path
- * on the disk
- * @param uri The URI to resolve
- * @return The path to the image or null if it could not be found
- */
- public String getPath(Uri uri) {
- String[] projection = { MediaStore.Images.Media.DATA };
- Cursor cursor = managedQuery(uri, projection, null, null, null);
- if (cursor != null) {
- int column_index = cursor
- .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
- cursor.moveToFirst();
- return cursor.getString(column_index);
- }
- return null;
- }
-
- /**
- * Pushes a directory to the drop down list
- * @param directory to push
- * @throws IllegalArgumentException If the {@link OCFile#isDirectory()} returns false.
- */
- public void pushDirname(OCFile directory) {
- if(!directory.isDirectory()){
- throw new IllegalArgumentException("Only directories may be pushed!");
- }
- mDirectories.insert(directory.getFileName(), 0);
- mCurrentDir = directory;
- }
-
- /**
- * Pops a directory name from the drop down list
- * @return True, unless the stack is empty
- */
- public boolean popDirname() {
- mDirectories.remove(mDirectories.getItem(0));
- return !mDirectories.isEmpty();
- }
-
- private class DirectoryCreator implements Runnable {
- private String mTargetPath;
- private Account mAccount;
- private Handler mHandler;
-
- public DirectoryCreator(String targetPath, Account account, Handler handler) {
- mTargetPath = targetPath;
- mAccount = account;
- mHandler = handler;
- }
-
- @Override
- public void run() {
- WebdavClient wdc = OwnCloudClientUtils.createOwnCloudClient(mAccount, getApplicationContext());
- boolean created = wdc.createDirectory(mTargetPath);
- if (created) {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- dismissDialog(DIALOG_SHORT_WAIT);
-
- // Save new directory in local database
- OCFile newDir = new OCFile(mTargetPath);
- newDir.setMimetype("DIR");
- newDir.setParentId(mCurrentDir.getFileId());
- mStorageManager.saveFile(newDir);
-
- // Display the new folder right away
- mFileList.listDirectory();
- }
- });
-
- } else {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- dismissDialog(DIALOG_SHORT_WAIT);
- try {
- Toast msg = Toast.makeText(FileDisplayActivity.this, R.string.create_dir_fail_msg, Toast.LENGTH_LONG);
- msg.show();
-
- } catch (NotFoundException e) {
- Log.e(TAG, "Error while trying to show fail message " , e);
- }
- }
- });
- }
- }
-
- }
-
- // Custom array adapter to override text colors
- private class CustomArrayAdapter extends ArrayAdapter {
-
- public CustomArrayAdapter(FileDisplayActivity ctx, int view) {
- super(ctx, view);
- }
-
- public View getView(int position, View convertView, ViewGroup parent) {
- View v = super.getView(position, convertView, parent);
-
- ((TextView) v).setTextColor(getResources().getColorStateList(
- android.R.color.white));
- return v;
- }
-
- public View getDropDownView(int position, View convertView,
- ViewGroup parent) {
- View v = super.getDropDownView(position, convertView, parent);
-
- ((TextView) v).setTextColor(getResources().getColorStateList(
- android.R.color.white));
-
- return v;
- }
-
- }
-
- private class SyncBroadcastReceiver extends BroadcastReceiver {
-
- /**
- * {@link BroadcastReceiver} to enable syncing feedback in UI
- */
- @Override
- public void onReceive(Context context, Intent intent) {
- boolean inProgress = intent.getBooleanExtra(
- FileSyncService.IN_PROGRESS, false);
- String accountName = intent
- .getStringExtra(FileSyncService.ACCOUNT_NAME);
-
- Log.d("FileDisplay", "sync of account " + accountName
- + " is in_progress: " + inProgress);
-
- if (accountName.equals(AccountUtils.getCurrentOwnCloudAccount(context).name)) {
-
- String synchFolderRemotePath = intent.getStringExtra(FileSyncService.SYNC_FOLDER_REMOTE_PATH);
-
- boolean fillBlankRoot = false;
- if (mCurrentDir == null) {
- mCurrentDir = mStorageManager.getFileByPath("/");
- fillBlankRoot = (mCurrentDir != null);
- }
-
- if ((synchFolderRemotePath != null && mCurrentDir != null && (mCurrentDir.getRemotePath().equals(synchFolderRemotePath)))
- || fillBlankRoot ) {
- if (!fillBlankRoot)
- mCurrentDir = getStorageManager().getFileByPath(synchFolderRemotePath);
- OCFileListFragment fileListFragment = (OCFileListFragment) getSupportFragmentManager()
- .findFragmentById(R.id.fileList);
- if (fileListFragment != null) {
- fileListFragment.listDirectory(mCurrentDir);
- }
- }
-
- setSupportProgressBarIndeterminateVisibility(inProgress);
- removeStickyBroadcast(intent);
-
- }
-
- RemoteOperationResult synchResult = (RemoteOperationResult)intent.getSerializableExtra(FileSyncService.SYNC_RESULT);
- if (synchResult != null) {
- if (synchResult.getCode().equals(RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) {
- mLastSslUntrustedServerResult = synchResult;
- showDialog(DIALOG_SSL_VALIDATOR);
- }
- }
- }
- }
-
-
- private class UploadFinishReceiver extends BroadcastReceiver {
- /**
- * Once the file upload has finished -> update view
- * @author David A. Velasco
- * {@link BroadcastReceiver} to enable upload feedback in UI
- */
- @Override
- public void onReceive(Context context, Intent intent) {
- String uploadedRemotePath = intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH);
- String accountName = intent.getStringExtra(FileUploader.ACCOUNT_NAME);
- boolean sameAccount = accountName.equals(AccountUtils.getCurrentOwnCloudAccount(context).name);
- boolean isDescendant = (mCurrentDir != null) && (uploadedRemotePath != null) && (uploadedRemotePath.startsWith(mCurrentDir.getRemotePath()));
- if (sameAccount && isDescendant) {
- OCFileListFragment fileListFragment = (OCFileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList);
- if (fileListFragment != null) {
- fileListFragment.listDirectory();
- }
- }
- }
-
- }
-
-
- /**
- * Once the file download has finished -> update view
- */
- private class DownloadFinishReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- String downloadedRemotePath = intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH);
- String accountName = intent.getStringExtra(FileDownloader.ACCOUNT_NAME);
- boolean sameAccount = accountName.equals(AccountUtils.getCurrentOwnCloudAccount(context).name);
- boolean isDescendant = (mCurrentDir != null) && (downloadedRemotePath != null) && (downloadedRemotePath.startsWith(mCurrentDir.getRemotePath()));
- if (sameAccount && isDescendant) {
- OCFileListFragment fileListFragment = (OCFileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList);
- if (fileListFragment != null) {
- fileListFragment.listDirectory();
- }
- }
- }
- }
-
-
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public DataStorageManager getStorageManager() {
- return mStorageManager;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onDirectoryClick(OCFile directory) {
- pushDirname(directory);
- ActionBar actionBar = getSupportActionBar();
- actionBar.setDisplayHomeAsUpEnabled(true);
-
- if (mDualPane) {
- // Resets the FileDetailsFragment on Tablets so that it always displays
- FileDetailFragment fileDetails = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
- if (fileDetails != null && !fileDetails.isEmpty()) {
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- transaction.remove(fileDetails);
- transaction.add(R.id.file_details_container, new FileDetailFragment(null, null), FileDetailFragment.FTAG);
- transaction.commit();
- }
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onFileClick(OCFile file) {
-
- // If we are on a large device -> update fragment
- if (mDualPane) {
- // buttons in the details view are problematic when trying to reuse an existing fragment; create always a new one solves some of them, BUT no all; downloads are 'dangerous'
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- transaction.replace(R.id.file_details_container, new FileDetailFragment(file, AccountUtils.getCurrentOwnCloudAccount(this)), FileDetailFragment.FTAG);
- transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
- transaction.commit();
-
- } else { // small or medium screen device -> new Activity
- Intent showDetailsIntent = new Intent(this, FileDetailActivity.class);
- showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, file);
- showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this));
- startActivity(showDetailsIntent);
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public OCFile getInitialDirectory() {
- return mCurrentDir;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onFileStateChanged() {
- OCFileListFragment fileListFragment = (OCFileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList);
- if (fileListFragment != null) {
- fileListFragment.listDirectory();
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public FileDownloaderBinder getFileDownloaderBinder() {
- return mDownloaderBinder;
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public FileUploaderBinder getFileUploaderBinder() {
- return mUploaderBinder;
- }
-
-
- /** Defines callbacks for service binding, passed to bindService() */
- private class ListServiceConnection implements ServiceConnection {
-
- @Override
- public void onServiceConnected(ComponentName component, IBinder service) {
- if (component.equals(new ComponentName(FileDisplayActivity.this, FileDownloader.class))) {
- Log.d(TAG, "Download service connected");
- mDownloaderBinder = (FileDownloaderBinder) service;
- } else if (component.equals(new ComponentName(FileDisplayActivity.this, FileUploader.class))) {
- Log.d(TAG, "Upload service connected");
- mUploaderBinder = (FileUploaderBinder) service;
- } else {
- return;
- }
- // a new chance to get the mDownloadBinder through getFileDownloadBinder() - THIS IS A MESS
- if (mFileList != null)
- mFileList.listDirectory();
- if (mDualPane) {
- FileDetailFragment fragment = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
- if (fragment != null)
- fragment.updateFileDetails(false);
- }
- }
-
- @Override
- public void onServiceDisconnected(ComponentName component) {
- if (component.equals(new ComponentName(FileDisplayActivity.this, FileDownloader.class))) {
- Log.d(TAG, "Download service disconnected");
- mDownloaderBinder = null;
- } else if (component.equals(new ComponentName(FileDisplayActivity.this, FileUploader.class))) {
- Log.d(TAG, "Upload service disconnected");
- mUploaderBinder = null;
- }
- }
- };
-
-
-
- /**
- * Launch an intent to request the PIN code to the user before letting him use the app
- */
- private void requestPinCode() {
- boolean pinStart = false;
- SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
- pinStart = appPrefs.getBoolean("set_pincode", false);
- if (pinStart) {
- Intent i = new Intent(getApplicationContext(), PinCodeActivity.class);
- i.putExtra(PinCodeActivity.EXTRA_ACTIVITY, "FileDisplayActivity");
- startActivity(i);
- }
- }
-
-
- @Override
- public void onSavedCertificate() {
- startSynchronization();
- }
-
-
- @Override
- public void onFailedSavingCertificate() {
- showDialog(DIALOG_CERT_NOT_SAVED);
- }
-
-
- /**
- * Updates the view associated to the activity after the finish of some operation over files
- * in the current account.
- *
- * @param operation Removal operation performed.
- * @param result Result of the removal.
- */
- @Override
- public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
- if (operation instanceof RemoveFileOperation) {
- onRemoveFileOperationFinish((RemoveFileOperation)operation, result);
-
- } else if (operation instanceof RenameFileOperation) {
- onRenameFileOperationFinish((RenameFileOperation)operation, result);
-
- } else if (operation instanceof SynchronizeFileOperation) {
- onSynchronizeFileOperationFinish((SynchronizeFileOperation)operation, result);
- }
- }
-
-
- /**
- * Updates the view associated to the activity after the finish of an operation trying to remove a
- * file.
- *
- * @param operation Removal operation performed.
- * @param result Result of the removal.
- */
- private void onRemoveFileOperationFinish(RemoveFileOperation operation, RemoteOperationResult result) {
- dismissDialog(DIALOG_SHORT_WAIT);
- if (result.isSuccess()) {
- Toast msg = Toast.makeText(this, R.string.remove_success_msg, Toast.LENGTH_LONG);
- msg.show();
- OCFile removedFile = operation.getFile();
- if (mDualPane) {
- FileDetailFragment details = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
- if (details != null && removedFile.equals(details.getDisplayedFile()) ) {
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
- transaction.replace(R.id.file_details_container, new FileDetailFragment(null, null)); // empty FileDetailFragment
- transaction.commit();
- }
- }
- if (mStorageManager.getFileById(removedFile.getParentId()).equals(mCurrentDir)) {
- mFileList.listDirectory();
- }
-
- } else {
- Toast msg = Toast.makeText(this, R.string.remove_fail_msg, Toast.LENGTH_LONG);
- msg.show();
- if (result.isSslRecoverableException()) {
- mLastSslUntrustedServerResult = result;
- showDialog(DIALOG_SSL_VALIDATOR);
- }
- }
- }
-
- /**
- * Updates the view associated to the activity after the finish of an operation trying to rename a
- * file.
- *
- * @param operation Renaming operation performed.
- * @param result Result of the renaming.
- */
- private void onRenameFileOperationFinish(RenameFileOperation operation, RemoteOperationResult result) {
- dismissDialog(DIALOG_SHORT_WAIT);
- OCFile renamedFile = operation.getFile();
- if (result.isSuccess()) {
- if (mDualPane) {
- FileDetailFragment details = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
- if (details != null && renamedFile.equals(details.getDisplayedFile()) ) {
- details.updateFileDetails(renamedFile, AccountUtils.getCurrentOwnCloudAccount(this));
- }
- }
- if (mStorageManager.getFileById(renamedFile.getParentId()).equals(mCurrentDir)) {
- mFileList.listDirectory();
- }
-
- } else {
- if (result.getCode().equals(ResultCode.INVALID_LOCAL_FILE_NAME)) {
- Toast msg = Toast.makeText(this, R.string.rename_local_fail_msg, Toast.LENGTH_LONG);
- msg.show();
- // TODO throw again the new rename dialog
- } else {
- Toast msg = Toast.makeText(this, R.string.rename_server_fail_msg, Toast.LENGTH_LONG);
- msg.show();
- if (result.isSslRecoverableException()) {
- mLastSslUntrustedServerResult = result;
- showDialog(DIALOG_SSL_VALIDATOR);
- }
- }
- }
- }
-
-
- private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation, RemoteOperationResult result) {
- dismissDialog(DIALOG_SHORT_WAIT);
- OCFile syncedFile = operation.getLocalFile();
- if (!result.isSuccess()) {
- if (result.getCode() == ResultCode.SYNC_CONFLICT) {
- Intent i = new Intent(this, ConflictsResolveActivity.class);
- i.putExtra(ConflictsResolveActivity.EXTRA_FILE, syncedFile);
- i.putExtra(ConflictsResolveActivity.EXTRA_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this));
- startActivity(i);
-
- } else {
- Toast msg = Toast.makeText(this, R.string.sync_file_fail_msg, Toast.LENGTH_LONG);
- msg.show();
- }
-
- } else {
- if (operation.transferWasRequested()) {
- mFileList.listDirectory();
- onTransferStateChanged(syncedFile, true, true);
-
- } else {
- Toast msg = Toast.makeText(this, R.string.sync_file_nothing_to_do_msg, Toast.LENGTH_LONG);
- msg.show();
- }
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading) {
- /*OCFileListFragment fileListFragment = (OCFileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList);
- if (fileListFragment != null) {
- fileListFragment.listDirectory();
- }*/
- if (mDualPane) {
- FileDetailFragment details = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
- if (details != null && file.equals(details.getDisplayedFile()) ) {
- if (downloading || uploading) {
- details.updateFileDetails(file, AccountUtils.getCurrentOwnCloudAccount(this));
- } else {
- details.updateFileDetails(downloading || uploading);
- }
- }
- }
- }
-
-
-
-
-
-}
+/* ownCloud Android client application
+ * Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
+ *
+ * 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, see .
+ *
+ */
+
+package com.owncloud.android.ui.activity;
+
+import java.io.File;
+
+import android.accounts.Account;
+import android.app.AlertDialog;
+import android.app.AlertDialog.Builder;
+import android.app.Dialog;
+import android.app.ProgressDialog;
+import android.content.BroadcastReceiver;
+import android.content.ComponentName;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.ServiceConnection;
+import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Resources.NotFoundException;
+import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.graphics.drawable.BitmapDrawable;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.IBinder;
+import android.preference.PreferenceManager;
+import android.provider.MediaStore;
+import android.support.v4.app.FragmentTransaction;
+import android.util.Log;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
+import com.actionbarsherlock.app.SherlockFragmentActivity;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuInflater;
+import com.actionbarsherlock.view.MenuItem;
+import com.actionbarsherlock.view.Window;
+import com.owncloud.android.AccountUtils;
+import com.owncloud.android.R;
+import com.owncloud.android.authenticator.AccountAuthenticator;
+import com.owncloud.android.datamodel.DataStorageManager;
+import com.owncloud.android.datamodel.FileDataStorageManager;
+import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.files.services.FileDownloader;
+import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
+import com.owncloud.android.files.services.FileObserverService;
+import com.owncloud.android.files.services.FileUploader;
+import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
+import com.owncloud.android.network.OwnCloudClientUtils;
+import com.owncloud.android.operations.OnRemoteOperationListener;
+import com.owncloud.android.operations.RemoteOperation;
+import com.owncloud.android.operations.RemoteOperationResult;
+import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.operations.RemoveFileOperation;
+import com.owncloud.android.operations.RenameFileOperation;
+import com.owncloud.android.operations.SynchronizeFileOperation;
+import com.owncloud.android.syncadapter.FileSyncService;
+import com.owncloud.android.ui.dialog.ChangelogDialog;
+import com.owncloud.android.ui.dialog.SslValidatorDialog;
+import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener;
+import com.owncloud.android.ui.fragment.FileDetailFragment;
+import com.owncloud.android.ui.fragment.OCFileListFragment;
+
+import eu.alefzero.webdav.WebdavClient;
+
+/**
+ * Displays, what files the user has available in his ownCloud.
+ *
+ * @author Bartek Przybylski
+ *
+ */
+
+public class FileDisplayActivity extends SherlockFragmentActivity implements OCFileListFragment.ContainerActivity,
+ FileDetailFragment.ContainerActivity, OnNavigationListener, OnSslValidatorListener, OnRemoteOperationListener {
+
+ private ArrayAdapter mDirectories;
+ private OCFile mCurrentDir = null;
+ private OCFile mCurrentFile = null;
+
+ private DataStorageManager mStorageManager;
+ private SyncBroadcastReceiver mSyncBroadcastReceiver;
+ private UploadFinishReceiver mUploadFinishReceiver;
+ private DownloadFinishReceiver mDownloadFinishReceiver;
+ private FileDownloaderBinder mDownloaderBinder = null;
+ private FileUploaderBinder mUploaderBinder = null;
+ private ServiceConnection mDownloadConnection = null, mUploadConnection = null;
+ private RemoteOperationResult mLastSslUntrustedServerResult = null;
+
+ private OCFileListFragment mFileList;
+
+ private boolean mDualPane;
+
+ private static final int DIALOG_SETUP_ACCOUNT = 0;
+ private static final int DIALOG_CREATE_DIR = 1;
+ private static final int DIALOG_ABOUT_APP = 2;
+ public static final int DIALOG_SHORT_WAIT = 3;
+ private static final int DIALOG_CHOOSE_UPLOAD_SOURCE = 4;
+ private static final int DIALOG_SSL_VALIDATOR = 5;
+ private static final int DIALOG_CERT_NOT_SAVED = 6;
+ private static final String DIALOG_CHANGELOG_TAG = "DIALOG_CHANGELOG";
+
+
+ private static final int ACTION_SELECT_CONTENT_FROM_APPS = 1;
+ private static final int ACTION_SELECT_MULTIPLE_FILES = 2;
+ private static final int ACTION_SELECT_FAILED_INSTANT_UPLOAD = 2;
+
+ private static final String TAG = "FileDisplayActivity";
+
+ private static int[] mMenuIdentifiersToPatch = {R.id.about_app};
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ Log.d(getClass().toString(), "onCreate() start");
+ super.onCreate(savedInstanceState);
+
+ /// Load of parameters from received intent
+ mCurrentDir = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_FILE); // no check necessary, mCurrenDir == null if the parameter is not in the intent
+ Account account = getIntent().getParcelableExtra(FileDetailFragment.EXTRA_ACCOUNT);
+ if (account != null)
+ AccountUtils.setCurrentOwnCloudAccount(this, account.name);
+
+ /// Load of saved instance state: keep this always before initDataFromCurrentAccount()
+ if(savedInstanceState != null) {
+ // TODO - test if savedInstanceState should take precedence over file in the intent ALWAYS (now), NEVER, or SOME TIMES
+ mCurrentDir = savedInstanceState.getParcelable(FileDetailFragment.EXTRA_FILE);
+ }
+
+ if (!AccountUtils.accountsAreSetup(this)) {
+ /// no account available: FORCE ACCOUNT CREATION
+ mStorageManager = null;
+ createFirstAccount();
+
+ } else { // / at least an account is available
+
+ initDataFromCurrentAccount(); // it checks mCurrentDir and
+ // mCurrentFile with the current
+ // account
+
+ }
+
+ mUploadConnection = new ListServiceConnection();
+ mDownloadConnection = new ListServiceConnection();
+ bindService(new Intent(this, FileUploader.class), mUploadConnection, Context.BIND_AUTO_CREATE);
+ bindService(new Intent(this, FileDownloader.class), mDownloadConnection, Context.BIND_AUTO_CREATE);
+
+ // PIN CODE request ; best location is to decide, let's try this first
+ if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_MAIN) && savedInstanceState == null) {
+ requestPinCode();
+ }
+
+ // file observer
+ Intent observer_intent = new Intent(this, FileObserverService.class);
+ observer_intent.putExtra(FileObserverService.KEY_FILE_CMD, FileObserverService.CMD_INIT_OBSERVED_LIST);
+ startService(observer_intent);
+
+
+ /// USER INTERFACE
+ requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
+
+ // Drop-down navigation
+ mDirectories = new CustomArrayAdapter(this, R.layout.sherlock_spinner_dropdown_item);
+ OCFile currFile = mCurrentDir;
+ while (currFile != null && currFile.getFileName() != OCFile.PATH_SEPARATOR) {
+ mDirectories.add(currFile.getFileName());
+ currFile = mStorageManager.getFileById(currFile.getParentId());
+ }
+ mDirectories.add(OCFile.PATH_SEPARATOR);
+
+ // Inflate and set the layout view
+ setContentView(R.layout.files);
+ mFileList = (OCFileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList);
+ mDualPane = (findViewById(R.id.file_details_container) != null);
+ if (mDualPane) {
+ initFileDetailsInDualPane();
+ }
+
+ // Action bar setup
+ ActionBar actionBar = getSupportActionBar();
+ actionBar.setHomeButtonEnabled(true); // mandatory since Android ICS, according to the official documentation
+ actionBar.setDisplayHomeAsUpEnabled(mCurrentDir != null && mCurrentDir.getParentId() != 0);
+ actionBar.setDisplayShowTitleEnabled(false);
+ actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
+ actionBar.setListNavigationCallbacks(mDirectories, this);
+ setSupportProgressBarIndeterminateVisibility(false); // always AFTER setContentView(...) ; to workaround bug in its implementation
+
+
+ // show changelog, if needed
+ showChangeLog();
+
+ Log.d(getClass().toString(), "onCreate() end");
+ }
+
+
+ /**
+ * Shows a dialog with the change log of the current version after each app update
+ *
+ * TODO make it permanent; by now, only to advice the workaround app for 4.1.x
+ */
+ private void showChangeLog() {
+ if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.JELLY_BEAN) {
+ final String KEY_VERSION = "version";
+ SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ int currentVersionNumber = 0;
+ int savedVersionNumber = sharedPref.getInt(KEY_VERSION, 0);
+ try {
+ PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0);
+ currentVersionNumber = pi.versionCode;
+ } catch (Exception e) {}
+
+ if (currentVersionNumber > savedVersionNumber) {
+ ChangelogDialog.newInstance(true).show(getSupportFragmentManager(), DIALOG_CHANGELOG_TAG);
+ Editor editor = sharedPref.edit();
+ editor.putInt(KEY_VERSION, currentVersionNumber);
+ editor.commit();
+ }
+ }
+ }
+
+
+ /**
+ * Launches the account creation activity. To use when no ownCloud account is available
+ */
+ private void createFirstAccount() {
+ Intent intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);
+ intent.putExtra(android.provider.Settings.EXTRA_AUTHORITIES, new String[] { AccountAuthenticator.AUTH_TOKEN_TYPE });
+ startActivity(intent); // the new activity won't be created until this.onStart() and this.onResume() are finished;
+ }
+
+
+ /**
+ * Load of state dependent of the existence of an ownCloud account
+ */
+ private void initDataFromCurrentAccount() {
+ /// Storage manager initialization - access to local database
+ mStorageManager = new FileDataStorageManager(
+ AccountUtils.getCurrentOwnCloudAccount(this),
+ getContentResolver());
+
+ /// Check if mCurrentDir is a directory
+ if(mCurrentDir != null && !mCurrentDir.isDirectory()) {
+ mCurrentFile = mCurrentDir;
+ mCurrentDir = mStorageManager.getFileById(mCurrentDir.getParentId());
+ }
+
+ /// Check if mCurrentDir and mCurrentFile are in the current account, and update them
+ if (mCurrentDir != null) {
+ mCurrentDir = mStorageManager.getFileByPath(mCurrentDir.getRemotePath()); // mCurrentDir == null if it is not in the current account
+ }
+ if (mCurrentFile != null) {
+ if (mCurrentFile.fileExists()) {
+ mCurrentFile = mStorageManager.getFileByPath(mCurrentFile.getRemotePath()); // mCurrentFile == null if it is not in the current account
+ } // else : keep mCurrentFile with the received value; this is currently the case of an upload in progress, when the user presses the status notification in a landscape tablet
+ }
+
+ /// Default to root if mCurrentDir was not found
+ if (mCurrentDir == null) {
+ mCurrentDir = mStorageManager.getFileByPath("/"); // will be NULL if the database was never synchronized
+ }
+ }
+
+
+ private void initFileDetailsInDualPane() {
+ if (mDualPane && getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG) == null) {
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ if (mCurrentFile != null) {
+ transaction.replace(R.id.file_details_container,
+ new FileDetailFragment(mCurrentFile, AccountUtils.getCurrentOwnCloudAccount(this)),
+ FileDetailFragment.FTAG); // empty FileDetailFragment
+ mCurrentFile = null;
+ } else {
+ transaction.replace(R.id.file_details_container, new FileDetailFragment(null, null),
+ FileDetailFragment.FTAG); // empty FileDetailFragment
+ }
+ transaction.commit();
+ }
+ }
+
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ if (mDownloadConnection != null)
+ unbindService(mDownloadConnection);
+ if (mUploadConnection != null)
+ unbindService(mUploadConnection);
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getSherlock().getMenuInflater();
+ inflater.inflate(R.menu.menu, menu);
+
+ patchHiddenAccents(menu);
+
+ return true;
+ }
+
+ /**
+ * Workaround for this: http://code.google.com/p/android/issues/detail?id=3974
+ *
+ * @param menu Menu to patch
+ */
+ private void patchHiddenAccents(Menu menu) {
+ for (int i = 0; i < mMenuIdentifiersToPatch.length ; i++) {
+ MenuItem aboutItem = menu.findItem(mMenuIdentifiersToPatch[i]);
+ if (aboutItem != null && aboutItem.getIcon() instanceof BitmapDrawable) {
+ // Clip off the bottom three (density independent) pixels of transparent padding
+ Bitmap original = ((BitmapDrawable) aboutItem.getIcon()).getBitmap();
+ float scale = getResources().getDisplayMetrics().density;
+ int clippedHeight = (int) (original.getHeight() - (3 * scale));
+ Bitmap scaled = Bitmap.createBitmap(original, 0, 0, original.getWidth(), clippedHeight);
+ aboutItem.setIcon(new BitmapDrawable(getResources(), scaled));
+ }
+ }
+ }
+
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ boolean retval = true;
+ switch (item.getItemId()) {
+ case R.id.createDirectoryItem: {
+ showDialog(DIALOG_CREATE_DIR);
+ break;
+ }
+ case R.id.startSync: {
+ startSynchronization();
+ break;
+ }
+ case R.id.action_upload: {
+ showDialog(DIALOG_CHOOSE_UPLOAD_SOURCE);
+ break;
+ }
+ case R.id.action_settings: {
+ Intent settingsIntent = new Intent(this, Preferences.class);
+ startActivity(settingsIntent);
+ break;
+ }
+ case R.id.about_app: {
+ showDialog(DIALOG_ABOUT_APP);
+ break;
+ }
+ case android.R.id.home: {
+ if (mCurrentDir != null && mCurrentDir.getParentId() != 0) {
+ onBackPressed();
+ }
+ break;
+ }
+ default:
+ retval = super.onOptionsItemSelected(item);
+ }
+ return retval;
+ }
+
+ private void startSynchronization() {
+ ContentResolver.cancelSync(null, AccountAuthenticator.AUTH_TOKEN_TYPE); // cancel the current synchronizations of any ownCloud account
+ Bundle bundle = new Bundle();
+ bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
+ ContentResolver.requestSync(
+ AccountUtils.getCurrentOwnCloudAccount(this),
+ AccountAuthenticator.AUTH_TOKEN_TYPE, bundle);
+ }
+
+
+ @Override
+ public boolean onNavigationItemSelected(int itemPosition, long itemId) {
+ int i = itemPosition;
+ while (i-- != 0) {
+ onBackPressed();
+ }
+ // the next operation triggers a new call to this method, but it's necessary to
+ // ensure that the name exposed in the action bar is the current directory when the
+ // user selected it in the navigation list
+ if (itemPosition != 0)
+ getSupportActionBar().setSelectedNavigationItem(0);
+ return true;
+ }
+
+ /**
+ * Called, when the user selected something for uploading
+ */
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+
+ if (requestCode == ACTION_SELECT_CONTENT_FROM_APPS
+ && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
+ requestSimpleUpload(data, resultCode);
+
+ } else if (requestCode == ACTION_SELECT_MULTIPLE_FILES
+ && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) {
+ requestMultipleUpload(data, resultCode);
+
+ }
+ }
+
+ private void requestMultipleUpload(Intent data, int resultCode) {
+ String[] filePaths = data.getStringArrayExtra(UploadFilesActivity.EXTRA_CHOSEN_FILES);
+ if (filePaths != null) {
+ String[] remotePaths = new String[filePaths.length];
+ String remotePathBase = "";
+ for (int j = mDirectories.getCount() - 2; j >= 0; --j) {
+ remotePathBase += OCFile.PATH_SEPARATOR + mDirectories.getItem(j);
+ }
+ if (!remotePathBase.endsWith(OCFile.PATH_SEPARATOR))
+ remotePathBase += OCFile.PATH_SEPARATOR;
+ for (int j = 0; j < remotePaths.length; j++) {
+ remotePaths[j] = remotePathBase + (new File(filePaths[j])).getName();
+ }
+
+ Intent i = new Intent(this, FileUploader.class);
+ i.putExtra(FileUploader.KEY_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this));
+ i.putExtra(FileUploader.KEY_LOCAL_FILE, filePaths);
+ i.putExtra(FileUploader.KEY_REMOTE_FILE, remotePaths);
+ i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_MULTIPLE_FILES);
+ if (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)
+ i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE);
+ startService(i);
+
+ } else {
+ Log.d("FileDisplay", "User clicked on 'Update' with no selection");
+ Toast t = Toast.makeText(this, getString(R.string.filedisplay_no_file_selected), Toast.LENGTH_LONG);
+ t.show();
+ return;
+ }
+ }
+
+
+ private void requestSimpleUpload(Intent data, int resultCode) {
+ String filepath = null;
+ try {
+ Uri selectedImageUri = data.getData();
+
+ String filemanagerstring = selectedImageUri.getPath();
+ String selectedImagePath = getPath(selectedImageUri);
+
+ if (selectedImagePath != null)
+ filepath = selectedImagePath;
+ else
+ filepath = filemanagerstring;
+
+ } catch (Exception e) {
+ Log.e("FileDisplay", "Unexpected exception when trying to read the result of Intent.ACTION_GET_CONTENT", e);
+ e.printStackTrace();
+
+ } finally {
+ if (filepath == null) {
+ Log.e("FileDisplay", "Couldnt resolve path to file");
+ Toast t = Toast.makeText(this, getString(R.string.filedisplay_unexpected_bad_get_content), Toast.LENGTH_LONG);
+ t.show();
+ return;
+ }
+ }
+
+ Intent i = new Intent(this, FileUploader.class);
+ i.putExtra(FileUploader.KEY_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this));
+ String remotepath = new String();
+ for (int j = mDirectories.getCount() - 2; j >= 0; --j) {
+ remotepath += OCFile.PATH_SEPARATOR + mDirectories.getItem(j);
+ }
+ if (!remotepath.endsWith(OCFile.PATH_SEPARATOR))
+ remotepath += OCFile.PATH_SEPARATOR;
+ remotepath += new File(filepath).getName();
+
+ i.putExtra(FileUploader.KEY_LOCAL_FILE, filepath);
+ i.putExtra(FileUploader.KEY_REMOTE_FILE, remotepath);
+ i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);
+ if (resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)
+ i.putExtra(FileUploader.KEY_LOCAL_BEHAVIOUR, FileUploader.LOCAL_BEHAVIOUR_MOVE);
+ startService(i);
+ }
+
+
+ @Override
+ public void onBackPressed() {
+ if (mDirectories.getCount() <= 1) {
+ finish();
+ return;
+ }
+ popDirname();
+ mFileList.onNavigateUp();
+ mCurrentDir = mFileList.getCurrentFile();
+
+ if (mDualPane) {
+ // Resets the FileDetailsFragment on Tablets so that it always
+ // displays
+ FileDetailFragment fileDetails = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(
+ FileDetailFragment.FTAG);
+ if (fileDetails != null && !fileDetails.isEmpty()) {
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ transaction.remove(fileDetails);
+ transaction.add(R.id.file_details_container, new FileDetailFragment(null, null),
+ FileDetailFragment.FTAG);
+ transaction.commit();
+ }
+ }
+
+ if (mCurrentDir.getParentId() == 0) {
+ ActionBar actionBar = getSupportActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(false);
+ }
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ // responsibility of restore is preferred in onCreate() before than in onRestoreInstanceState when there are Fragments involved
+ Log.d(getClass().toString(), "onSaveInstanceState() start");
+ super.onSaveInstanceState(outState);
+ outState.putParcelable(FileDetailFragment.EXTRA_FILE, mCurrentDir);
+ if (mDualPane) {
+ FileDetailFragment fragment = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
+ if (fragment != null) {
+ OCFile file = fragment.getDisplayedFile();
+ if (file != null) {
+ outState.putParcelable(FileDetailFragment.EXTRA_FILE, file);
+ }
+ }
+ }
+ Log.d(getClass().toString(), "onSaveInstanceState() end");
+ }
+
+ @Override
+ protected void onResume() {
+ Log.d(getClass().toString(), "onResume() start");
+ super.onResume();
+
+ if (AccountUtils.accountsAreSetup(this)) {
+
+ if (mStorageManager == null) {
+ // this is necessary for handling the come back to FileDisplayActivity when the first ownCloud account is created
+ initDataFromCurrentAccount();
+ if (mDualPane) {
+ initFileDetailsInDualPane();
+ }
+ }
+
+ // Listen for sync messages
+ IntentFilter syncIntentFilter = new IntentFilter(FileSyncService.SYNC_MESSAGE);
+ mSyncBroadcastReceiver = new SyncBroadcastReceiver();
+ registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
+
+ // Listen for upload messages
+ IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.UPLOAD_FINISH_MESSAGE);
+ mUploadFinishReceiver = new UploadFinishReceiver();
+ registerReceiver(mUploadFinishReceiver, uploadIntentFilter);
+
+ // Listen for download messages
+ IntentFilter downloadIntentFilter = new IntentFilter(FileDownloader.DOWNLOAD_FINISH_MESSAGE);
+ mDownloadFinishReceiver = new DownloadFinishReceiver();
+ registerReceiver(mDownloadFinishReceiver, downloadIntentFilter);
+
+ // List current directory
+ mFileList.listDirectory(mCurrentDir); // TODO we should find the way to avoid the need of this (maybe it's not necessary yet; to check)
+
+ } else {
+
+ mStorageManager = null; // an invalid object will be there if all the ownCloud accounts are removed
+ showDialog(DIALOG_SETUP_ACCOUNT);
+
+ }
+ Log.d(getClass().toString(), "onResume() end");
+ }
+
+
+ @Override
+ protected void onPause() {
+ Log.d(getClass().toString(), "onPause() start");
+ super.onPause();
+ if (mSyncBroadcastReceiver != null) {
+ unregisterReceiver(mSyncBroadcastReceiver);
+ mSyncBroadcastReceiver = null;
+ }
+ if (mUploadFinishReceiver != null) {
+ unregisterReceiver(mUploadFinishReceiver);
+ mUploadFinishReceiver = null;
+ }
+ if (mDownloadFinishReceiver != null) {
+ unregisterReceiver(mDownloadFinishReceiver);
+ mDownloadFinishReceiver = null;
+ }
+ if (!AccountUtils.accountsAreSetup(this)) {
+ dismissDialog(DIALOG_SETUP_ACCOUNT);
+ }
+
+ Log.d(getClass().toString(), "onPause() end");
+ }
+
+
+ @Override
+ protected void onPrepareDialog(int id, Dialog dialog, Bundle args) {
+ if (id == DIALOG_SSL_VALIDATOR && mLastSslUntrustedServerResult != null) {
+ ((SslValidatorDialog)dialog).updateResult(mLastSslUntrustedServerResult);
+ }
+ }
+
+
+ @Override
+ protected Dialog onCreateDialog(int id) {
+ Dialog dialog = null;
+ AlertDialog.Builder builder;
+ switch (id) {
+ case DIALOG_SETUP_ACCOUNT: {
+ builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.main_tit_accsetup);
+ builder.setMessage(R.string.main_wrn_accsetup);
+ builder.setCancelable(false);
+ builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ createFirstAccount();
+ dialog.dismiss();
+ }
+ });
+ String message = String.format(getString(R.string.common_exit), getString(R.string.app_name));
+ builder.setNegativeButton(message, new OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ finish();
+ }
+ });
+ //builder.setNegativeButton(android.R.string.cancel, this);
+ dialog = builder.create();
+ break;
+ }
+ case DIALOG_ABOUT_APP: {
+ builder = new AlertDialog.Builder(this);
+ builder.setTitle(getString(R.string.about_title));
+ PackageInfo pkg;
+ try {
+ pkg = getPackageManager().getPackageInfo(getPackageName(), 0);
+ builder.setMessage(String.format(getString(R.string.about_message), getString(R.string.app_name), pkg.versionName));
+ builder.setIcon(android.R.drawable.ic_menu_info_details);
+ dialog = builder.create();
+ } catch (NameNotFoundException e) {
+ builder = null;
+ dialog = null;
+ Log.e(TAG, "Error while showing about dialog", e);
+ }
+ break;
+ }
+ case DIALOG_CREATE_DIR: {
+ builder = new Builder(this);
+ final EditText dirNameInput = new EditText(getBaseContext());
+ builder.setView(dirNameInput);
+ builder.setTitle(R.string.uploader_info_dirname);
+ int typed_color = getResources().getColor(R.color.setup_text_typed);
+ dirNameInput.setTextColor(typed_color);
+ builder.setPositiveButton(android.R.string.ok, new OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ String directoryName = dirNameInput.getText().toString();
+ if (directoryName.trim().length() == 0) {
+ dialog.cancel();
+ return;
+ }
+
+ // Figure out the path where the dir needs to be created
+ String path;
+ if (mCurrentDir == null) {
+ // this is just a patch; we should ensure that
+ // mCurrentDir never is null
+ if (!mStorageManager.fileExists(OCFile.PATH_SEPARATOR)) {
+ OCFile file = new OCFile(OCFile.PATH_SEPARATOR);
+ mStorageManager.saveFile(file);
+ }
+ mCurrentDir = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR);
+ }
+ path = FileDisplayActivity.this.mCurrentDir.getRemotePath();
+
+ // Create directory
+ path += directoryName + OCFile.PATH_SEPARATOR;
+ Thread thread = new Thread(new DirectoryCreator(path, AccountUtils
+ .getCurrentOwnCloudAccount(FileDisplayActivity.this), new Handler()));
+ thread.start();
+
+ dialog.dismiss();
+
+ showDialog(DIALOG_SHORT_WAIT);
+ }
+ });
+ builder.setNegativeButton(R.string.common_cancel, new OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+ dialog = builder.create();
+ break;
+ }
+ case DIALOG_SHORT_WAIT: {
+ ProgressDialog working_dialog = new ProgressDialog(this);
+ working_dialog.setMessage(getResources().getString(R.string.wait_a_moment));
+ working_dialog.setIndeterminate(true);
+ working_dialog.setCancelable(false);
+ dialog = working_dialog;
+ break;
+ }
+ case DIALOG_CHOOSE_UPLOAD_SOURCE: {
+ final String[] items = { getString(R.string.actionbar_upload_files),
+ getString(R.string.actionbar_upload_from_apps), getString(R.string.actionbar_failed_instant_upload) };
+ builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.actionbar_upload);
+ builder.setItems(items, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int item) {
+ if (item == 0) {
+ // if (!mDualPane) {
+ Intent action = new Intent(FileDisplayActivity.this, UploadFilesActivity.class);
+ action.putExtra(UploadFilesActivity.EXTRA_ACCOUNT,
+ AccountUtils.getCurrentOwnCloudAccount(FileDisplayActivity.this));
+ startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES);
+ // } else {
+ // TODO create and handle new fragment
+ // LocalFileListFragment
+ // }
+ } else if (item == 1) {
+ Intent action = new Intent(Intent.ACTION_GET_CONTENT);
+ action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE);
+ startActivityForResult(Intent.createChooser(action, getString(R.string.upload_chooser_title)),
+ ACTION_SELECT_CONTENT_FROM_APPS);
+ } else if (item == 2) {
+ Account account = AccountUtils.getCurrentOwnCloudAccount(FileDisplayActivity.this);
+ Intent action = new Intent(FileDisplayActivity.this, InstantUploadActivity.class);
+ action.putExtra(FileUploader.KEY_ACCOUNT, account);
+ startActivity(action);
+ }
+ }
+ });
+ dialog = builder.create();
+ break;
+ }
+ case DIALOG_SSL_VALIDATOR: {
+ dialog = SslValidatorDialog.newInstance(this, mLastSslUntrustedServerResult, this);
+ break;
+ }
+ case DIALOG_CERT_NOT_SAVED: {
+ builder = new AlertDialog.Builder(this);
+ builder.setMessage(getResources().getString(R.string.ssl_validator_not_saved));
+ builder.setCancelable(false);
+ builder.setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ };
+ });
+ dialog = builder.create();
+ break;
+ }
+ default:
+ dialog = null;
+ }
+
+ return dialog;
+ }
+
+
+ /**
+ * Translates a content URI of an image to a physical path
+ * on the disk
+ * @param uri The URI to resolve
+ * @return The path to the image or null if it could not be found
+ */
+ public String getPath(Uri uri) {
+ String[] projection = { MediaStore.Images.Media.DATA };
+ Cursor cursor = managedQuery(uri, projection, null, null, null);
+ if (cursor != null) {
+ int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
+ cursor.moveToFirst();
+ return cursor.getString(column_index);
+ }
+ return null;
+ }
+
+ /**
+ * Pushes a directory to the drop down list
+ * @param directory to push
+ * @throws IllegalArgumentException If the {@link OCFile#isDirectory()} returns false.
+ */
+ public void pushDirname(OCFile directory) {
+ if(!directory.isDirectory()){
+ throw new IllegalArgumentException("Only directories may be pushed!");
+ }
+ mDirectories.insert(directory.getFileName(), 0);
+ mCurrentDir = directory;
+ }
+
+ /**
+ * Pops a directory name from the drop down list
+ * @return True, unless the stack is empty
+ */
+ public boolean popDirname() {
+ mDirectories.remove(mDirectories.getItem(0));
+ return !mDirectories.isEmpty();
+ }
+
+ private class DirectoryCreator implements Runnable {
+ private String mTargetPath;
+ private Account mAccount;
+ private Handler mHandler;
+
+ public DirectoryCreator(String targetPath, Account account, Handler handler) {
+ mTargetPath = targetPath;
+ mAccount = account;
+ mHandler = handler;
+ }
+
+ @Override
+ public void run() {
+ WebdavClient wdc = OwnCloudClientUtils.createOwnCloudClient(mAccount, getApplicationContext());
+ boolean created = wdc.createDirectory(mTargetPath);
+ if (created) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ dismissDialog(DIALOG_SHORT_WAIT);
+
+ // Save new directory in local database
+ OCFile newDir = new OCFile(mTargetPath);
+ newDir.setMimetype("DIR");
+ newDir.setParentId(mCurrentDir.getFileId());
+ mStorageManager.saveFile(newDir);
+
+ // Display the new folder right away
+ mFileList.listDirectory();
+ }
+ });
+
+ } else {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ dismissDialog(DIALOG_SHORT_WAIT);
+ try {
+ Toast msg = Toast.makeText(FileDisplayActivity.this, R.string.create_dir_fail_msg,
+ Toast.LENGTH_LONG);
+ msg.show();
+
+ } catch (NotFoundException e) {
+ Log.e(TAG, "Error while trying to show fail message ", e);
+ }
+ }
+ });
+ }
+ }
+
+ }
+
+ // Custom array adapter to override text colors
+ private class CustomArrayAdapter extends ArrayAdapter {
+
+ public CustomArrayAdapter(FileDisplayActivity ctx, int view) {
+ super(ctx, view);
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ View v = super.getView(position, convertView, parent);
+
+ ((TextView) v).setTextColor(getResources().getColorStateList(android.R.color.white));
+ return v;
+ }
+
+ public View getDropDownView(int position, View convertView, ViewGroup parent) {
+ View v = super.getDropDownView(position, convertView, parent);
+
+ ((TextView) v).setTextColor(getResources().getColorStateList(android.R.color.white));
+
+ return v;
+ }
+
+ }
+
+ private class SyncBroadcastReceiver extends BroadcastReceiver {
+
+ /**
+ * {@link BroadcastReceiver} to enable syncing feedback in UI
+ */
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ boolean inProgress = intent.getBooleanExtra(FileSyncService.IN_PROGRESS, false);
+ String accountName = intent.getStringExtra(FileSyncService.ACCOUNT_NAME);
+
+ Log.d("FileDisplay", "sync of account " + accountName + " is in_progress: " + inProgress);
+
+ if (accountName.equals(AccountUtils.getCurrentOwnCloudAccount(context).name)) {
+
+ String synchFolderRemotePath = intent.getStringExtra(FileSyncService.SYNC_FOLDER_REMOTE_PATH);
+
+ boolean fillBlankRoot = false;
+ if (mCurrentDir == null) {
+ mCurrentDir = mStorageManager.getFileByPath("/");
+ fillBlankRoot = (mCurrentDir != null);
+ }
+
+ if ((synchFolderRemotePath != null && mCurrentDir != null && (mCurrentDir.getRemotePath()
+ .equals(synchFolderRemotePath))) || fillBlankRoot) {
+ if (!fillBlankRoot)
+ mCurrentDir = getStorageManager().getFileByPath(synchFolderRemotePath);
+ OCFileListFragment fileListFragment = (OCFileListFragment) getSupportFragmentManager()
+ .findFragmentById(R.id.fileList);
+ if (fileListFragment != null) {
+ fileListFragment.listDirectory(mCurrentDir);
+ }
+ }
+
+ setSupportProgressBarIndeterminateVisibility(inProgress);
+ removeStickyBroadcast(intent);
+
+ }
+
+ RemoteOperationResult synchResult = (RemoteOperationResult) intent
+ .getSerializableExtra(FileSyncService.SYNC_RESULT);
+ if (synchResult != null) {
+ if (synchResult.getCode().equals(RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) {
+ mLastSslUntrustedServerResult = synchResult;
+ showDialog(DIALOG_SSL_VALIDATOR);
+ }
+ }
+ }
+ }
+
+
+ private class UploadFinishReceiver extends BroadcastReceiver {
+ /**
+ * Once the file upload has finished -> update view
+ * @author David A. Velasco
+ * {@link BroadcastReceiver} to enable upload feedback in UI
+ */
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String uploadedRemotePath = intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH);
+ String accountName = intent.getStringExtra(FileUploader.ACCOUNT_NAME);
+ boolean sameAccount = accountName.equals(AccountUtils.getCurrentOwnCloudAccount(context).name);
+ boolean isDescendant = (mCurrentDir != null) && (uploadedRemotePath != null)
+ && (uploadedRemotePath.startsWith(mCurrentDir.getRemotePath()));
+ if (sameAccount && isDescendant) {
+ OCFileListFragment fileListFragment = (OCFileListFragment) getSupportFragmentManager()
+ .findFragmentById(R.id.fileList);
+ if (fileListFragment != null) {
+ fileListFragment.listDirectory();
+ }
+ }
+ }
+
+ }
+
+
+ /**
+ * Once the file download has finished -> update view
+ */
+ private class DownloadFinishReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String downloadedRemotePath = intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH);
+ String accountName = intent.getStringExtra(FileDownloader.ACCOUNT_NAME);
+ boolean sameAccount = accountName.equals(AccountUtils.getCurrentOwnCloudAccount(context).name);
+ boolean isDescendant = (mCurrentDir != null) && (downloadedRemotePath != null)
+ && (downloadedRemotePath.startsWith(mCurrentDir.getRemotePath()));
+ if (sameAccount && isDescendant) {
+ OCFileListFragment fileListFragment = (OCFileListFragment) getSupportFragmentManager()
+ .findFragmentById(R.id.fileList);
+ if (fileListFragment != null) {
+ fileListFragment.listDirectory();
+ }
+ }
+ }
+ }
+
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public DataStorageManager getStorageManager() {
+ return mStorageManager;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onDirectoryClick(OCFile directory) {
+ pushDirname(directory);
+ ActionBar actionBar = getSupportActionBar();
+ actionBar.setDisplayHomeAsUpEnabled(true);
+
+ if (mDualPane) {
+ // Resets the FileDetailsFragment on Tablets so that it always displays
+ FileDetailFragment fileDetails = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
+ if (fileDetails != null && !fileDetails.isEmpty()) {
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ transaction.remove(fileDetails);
+ transaction.add(R.id.file_details_container, new FileDetailFragment(null, null),
+ FileDetailFragment.FTAG);
+ transaction.commit();
+ }
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onFileClick(OCFile file) {
+
+ // If we are on a large device -> update fragment
+ if (mDualPane) {
+ // buttons in the details view are problematic when trying to reuse an existing fragment; create always a new one solves some of them, BUT no all; downloads are 'dangerous'
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ transaction
+ .replace(R.id.file_details_container,
+ new FileDetailFragment(file, AccountUtils.getCurrentOwnCloudAccount(this)),
+ FileDetailFragment.FTAG);
+ transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
+ transaction.commit();
+
+ } else { // small or medium screen device -> new Activity
+ Intent showDetailsIntent = new Intent(this, FileDetailActivity.class);
+ showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, file);
+ showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this));
+ startActivity(showDetailsIntent);
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public OCFile getInitialDirectory() {
+ return mCurrentDir;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onFileStateChanged() {
+ OCFileListFragment fileListFragment = (OCFileListFragment) getSupportFragmentManager().findFragmentById(
+ R.id.fileList);
+ if (fileListFragment != null) {
+ fileListFragment.listDirectory();
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public FileDownloaderBinder getFileDownloaderBinder() {
+ return mDownloaderBinder;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public FileUploaderBinder getFileUploaderBinder() {
+ return mUploaderBinder;
+ }
+
+
+ /** Defines callbacks for service binding, passed to bindService() */
+ private class ListServiceConnection implements ServiceConnection {
+
+ @Override
+ public void onServiceConnected(ComponentName component, IBinder service) {
+ if (component.equals(new ComponentName(FileDisplayActivity.this, FileDownloader.class))) {
+ Log.d(TAG, "Download service connected");
+ mDownloaderBinder = (FileDownloaderBinder) service;
+ } else if (component.equals(new ComponentName(FileDisplayActivity.this, FileUploader.class))) {
+ Log.d(TAG, "Upload service connected");
+ mUploaderBinder = (FileUploaderBinder) service;
+ } else {
+ return;
+ }
+ // a new chance to get the mDownloadBinder through getFileDownloadBinder() - THIS IS A MESS
+ if (mFileList != null)
+ mFileList.listDirectory();
+ if (mDualPane) {
+ FileDetailFragment fragment = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(
+ FileDetailFragment.FTAG);
+ if (fragment != null)
+ fragment.updateFileDetails(false);
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName component) {
+ if (component.equals(new ComponentName(FileDisplayActivity.this, FileDownloader.class))) {
+ Log.d(TAG, "Download service disconnected");
+ mDownloaderBinder = null;
+ } else if (component.equals(new ComponentName(FileDisplayActivity.this, FileUploader.class))) {
+ Log.d(TAG, "Upload service disconnected");
+ mUploaderBinder = null;
+ }
+ }
+ };
+
+
+
+ /**
+ * Launch an intent to request the PIN code to the user before letting him use the app
+ */
+ private void requestPinCode() {
+ boolean pinStart = false;
+ SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ pinStart = appPrefs.getBoolean("set_pincode", false);
+ if (pinStart) {
+ Intent i = new Intent(getApplicationContext(), PinCodeActivity.class);
+ i.putExtra(PinCodeActivity.EXTRA_ACTIVITY, "FileDisplayActivity");
+ startActivity(i);
+ }
+ }
+
+
+ @Override
+ public void onSavedCertificate() {
+ startSynchronization();
+ }
+
+ @Override
+ public void onFailedSavingCertificate() {
+ showDialog(DIALOG_CERT_NOT_SAVED);
+ }
+
+
+ /**
+ * Updates the view associated to the activity after the finish of some operation over files
+ * in the current account.
+ *
+ * @param operation Removal operation performed.
+ * @param result Result of the removal.
+ */
+ @Override
+ public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
+ if (operation instanceof RemoveFileOperation) {
+ onRemoveFileOperationFinish((RemoveFileOperation) operation, result);
+
+ } else if (operation instanceof RenameFileOperation) {
+ onRenameFileOperationFinish((RenameFileOperation) operation, result);
+
+ } else if (operation instanceof SynchronizeFileOperation) {
+ onSynchronizeFileOperationFinish((SynchronizeFileOperation) operation, result);
+ }
+ }
+
+
+ /**
+ * Updates the view associated to the activity after the finish of an operation trying to remove a
+ * file.
+ *
+ * @param operation Removal operation performed.
+ * @param result Result of the removal.
+ */
+ private void onRemoveFileOperationFinish(RemoveFileOperation operation, RemoteOperationResult result) {
+ dismissDialog(DIALOG_SHORT_WAIT);
+ if (result.isSuccess()) {
+ Toast msg = Toast.makeText(this, R.string.remove_success_msg, Toast.LENGTH_LONG);
+ msg.show();
+ OCFile removedFile = operation.getFile();
+ if (mDualPane) {
+ FileDetailFragment details = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(
+ FileDetailFragment.FTAG);
+ if (details != null && removedFile.equals(details.getDisplayedFile())) {
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ transaction.replace(R.id.file_details_container, new FileDetailFragment(null, null)); // empty
+ // FileDetailFragment
+ transaction.commit();
+ }
+ }
+ if (mStorageManager.getFileById(removedFile.getParentId()).equals(mCurrentDir)) {
+ mFileList.listDirectory();
+ }
+
+ } else {
+ Toast msg = Toast.makeText(this, R.string.remove_fail_msg, Toast.LENGTH_LONG);
+ msg.show();
+ if (result.isSslRecoverableException()) {
+ mLastSslUntrustedServerResult = result;
+ showDialog(DIALOG_SSL_VALIDATOR);
+ }
+ }
+ }
+
+ /**
+ * Updates the view associated to the activity after the finish of an operation trying to rename a
+ * file.
+ *
+ * @param operation Renaming operation performed.
+ * @param result Result of the renaming.
+ */
+ private void onRenameFileOperationFinish(RenameFileOperation operation, RemoteOperationResult result) {
+ dismissDialog(DIALOG_SHORT_WAIT);
+ OCFile renamedFile = operation.getFile();
+ if (result.isSuccess()) {
+ if (mDualPane) {
+ FileDetailFragment details = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(
+ FileDetailFragment.FTAG);
+ if (details != null && renamedFile.equals(details.getDisplayedFile())) {
+ details.updateFileDetails(renamedFile, AccountUtils.getCurrentOwnCloudAccount(this));
+ }
+ }
+ if (mStorageManager.getFileById(renamedFile.getParentId()).equals(mCurrentDir)) {
+ mFileList.listDirectory();
+ }
+
+ } else {
+ if (result.getCode().equals(ResultCode.INVALID_LOCAL_FILE_NAME)) {
+ Toast msg = Toast.makeText(this, R.string.rename_local_fail_msg, Toast.LENGTH_LONG);
+ msg.show();
+ // TODO throw again the new rename dialog
+ } else {
+ Toast msg = Toast.makeText(this, R.string.rename_server_fail_msg, Toast.LENGTH_LONG);
+ msg.show();
+ if (result.isSslRecoverableException()) {
+ mLastSslUntrustedServerResult = result;
+ showDialog(DIALOG_SSL_VALIDATOR);
+ }
+ }
+ }
+ }
+
+ private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation, RemoteOperationResult result) {
+ dismissDialog(DIALOG_SHORT_WAIT);
+ OCFile syncedFile = operation.getLocalFile();
+ if (!result.isSuccess()) {
+ if (result.getCode() == ResultCode.SYNC_CONFLICT) {
+ Intent i = new Intent(this, ConflictsResolveActivity.class);
+ i.putExtra(ConflictsResolveActivity.EXTRA_FILE, syncedFile);
+ i.putExtra(ConflictsResolveActivity.EXTRA_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this));
+ startActivity(i);
+
+ } else {
+ Toast msg = Toast.makeText(this, R.string.sync_file_fail_msg, Toast.LENGTH_LONG);
+ msg.show();
+ }
+
+ } else {
+ if (operation.transferWasRequested()) {
+ mFileList.listDirectory();
+ onTransferStateChanged(syncedFile, true, true);
+
+ } else {
+ Toast msg = Toast.makeText(this, R.string.sync_file_nothing_to_do_msg, Toast.LENGTH_LONG);
+ msg.show();
+ }
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading) {
+ /*OCFileListFragment fileListFragment = (OCFileListFragment) getSupportFragmentManager().findFragmentById(R.id.fileList);
+ if (fileListFragment != null) {
+ fileListFragment.listDirectory();
+ }*/
+ if (mDualPane) {
+ FileDetailFragment details = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(
+ FileDetailFragment.FTAG);
+ if (details != null && file.equals(details.getDisplayedFile())) {
+ if (downloading || uploading) {
+ details.updateFileDetails(file, AccountUtils.getCurrentOwnCloudAccount(this));
+ } else {
+ details.updateFileDetails(downloading || uploading);
+ }
+ }
+ }
+ }
+
+
+
+
+
+}
diff --git a/src/com/owncloud/android/ui/activity/GenericExplanationActivity.java b/src/com/owncloud/android/ui/activity/GenericExplanationActivity.java
index a45383f3..8a46a001 100644
--- a/src/com/owncloud/android/ui/activity/GenericExplanationActivity.java
+++ b/src/com/owncloud/android/ui/activity/GenericExplanationActivity.java
@@ -1,3 +1,21 @@
+/* ownCloud Android client application
+ * Copyright (C) 2012-2013 ownCloud Inc.
+ *
+ * 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, see .
+ *
+ */
+
package com.owncloud.android.ui.activity;
import java.util.ArrayList;
diff --git a/src/com/owncloud/android/ui/activity/InstantUploadActivity.java b/src/com/owncloud/android/ui/activity/InstantUploadActivity.java
new file mode 100644
index 00000000..4325b8ab
--- /dev/null
+++ b/src/com/owncloud/android/ui/activity/InstantUploadActivity.java
@@ -0,0 +1,436 @@
+/* ownCloud Android client application
+ * Copyright (C) 2012-2013 ownCloud Inc.
+ *
+ * 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 3 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, see .
+ *
+ */
+package com.owncloud.android.ui.activity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import android.accounts.Account;
+import android.app.Activity;
+import android.content.Intent;
+import android.database.Cursor;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.os.Bundle;
+import android.util.Log;
+import android.util.SparseArray;
+import android.view.Gravity;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.CompoundButton.OnCheckedChangeListener;
+import android.widget.ImageButton;
+import android.widget.LinearLayout;
+import android.widget.Toast;
+
+import com.owncloud.android.AccountUtils;
+import com.owncloud.android.R;
+import com.owncloud.android.db.DbHandler;
+import com.owncloud.android.files.InstantUploadBroadcastReceiver;
+import com.owncloud.android.files.services.FileUploader;
+import com.owncloud.android.files.services.InstantUploadService;
+
+/**
+ * This Activity is used to display a list with images they could not be
+ * uploaded instantly. The images can be selected for delete or for a try again
+ * upload
+ *
+ * The entrypoint for this activity is the 'Failed upload Notification" and a
+ * submenue underneath the 'Upload' menuentry
+ *
+ * @author andomaex / Matthias Baumann
+ *
+ * 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 3 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 de/
+ */
+public class InstantUploadActivity extends Activity {
+
+ private static final String LOG_TAG = InstantUploadActivity.class.getSimpleName();
+ private LinearLayout listView;
+ private static final String retry_chexbox_tag = "retry_chexbox_tag";
+ private static int MAX_LOAD_IMAGES = 5;
+ private int lastLoadImageIdx = 0;
+
+ private SparseArray fileList = null;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.failed_upload_files);
+
+ Button delete_all_btn = (Button) findViewById(R.id.failed_upload_delete_all_btn);
+ delete_all_btn.setOnClickListener(getDeleteListner());
+ Button retry_all_btn = (Button) findViewById(R.id.failed_upload_retry_all_btn);
+ retry_all_btn.setOnClickListener(getRetryListner());
+ CheckBox failed_upload_all_cb = (CheckBox) findViewById(R.id.failed_upload_headline_cb);
+ failed_upload_all_cb.setOnCheckedChangeListener(getCheckAllListener());
+ listView = (LinearLayout) findViewById(R.id.failed_upload_scrollviewlayout);
+
+ loadListView(true);
+
+ }
+
+ /**
+ * init the listview with ImageButtons, checkboxes and filename for every
+ * Image that was not successfully uploaded
+ *
+ * this method is call at Activity creation and on delete one ore more
+ * list-entry an on retry the upload by clicking the ImageButton or by click
+ * to the 'retry all' button
+ *
+ */
+ private void loadListView(boolean reset) {
+ DbHandler db = new DbHandler(getApplicationContext());
+ Cursor c = db.getFailedFiles();
+
+ if (reset) {
+ fileList = new SparseArray();
+ listView.removeAllViews();
+ lastLoadImageIdx = 0;
+ }
+ if (c != null) {
+ try {
+ c.moveToPosition(lastLoadImageIdx);
+
+ while (c.moveToNext()) {
+
+ lastLoadImageIdx++;
+ String imp_path = c.getString(1);
+ fileList.put(lastLoadImageIdx, imp_path);
+ LinearLayout rowLayout = getLinearLayout(lastLoadImageIdx);
+ rowLayout.addView(getFileCheckbox(lastLoadImageIdx));
+ rowLayout.addView(getImageButton(imp_path, lastLoadImageIdx));
+ rowLayout.addView(getFileButton(imp_path, lastLoadImageIdx));
+ listView.addView(rowLayout);
+ Log.d(LOG_TAG, imp_path + " on idx: " + lastLoadImageIdx);
+ if (lastLoadImageIdx % MAX_LOAD_IMAGES == 0) {
+ break;
+ }
+ }
+ if (lastLoadImageIdx > 0) {
+ addLoadMoreButton(listView);
+ }
+ } finally {
+ db.close();
+ }
+ }
+ }
+
+ private void addLoadMoreButton(LinearLayout listView) {
+ if (listView != null) {
+ Button loadmoreBtn = null;
+ View oldButton = listView.findViewById(42);
+ if (oldButton != null) {
+ // remove existing button
+ listView.removeView(oldButton);
+ // to add the button at the end
+ loadmoreBtn = (Button) oldButton;
+ } else {
+ // create a new button to add to the scoll view
+ loadmoreBtn = new Button(this);
+ loadmoreBtn.setId(42);
+ loadmoreBtn.setText(getString(R.string.failed_upload_load_more_images));
+ loadmoreBtn.setBackgroundResource(R.color.owncloud_white);
+ loadmoreBtn.setTextSize(12);
+ loadmoreBtn.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ loadListView(false);
+ }
+
+ });
+ }
+ listView.addView(loadmoreBtn);
+ }
+ }
+
+ /**
+ * provide a list of CheckBox instances, looked up from parent listview this
+ * list ist used to select/deselect all checkboxes at the list
+ *
+ * @return List
+ */
+ private List getCheckboxList() {
+ List list = new ArrayList();
+ for (int i = 0; i < listView.getChildCount(); i++) {
+ Log.d(LOG_TAG, "ListView has Childs: " + listView.getChildCount());
+ View childView = listView.getChildAt(i);
+ if (childView != null && childView instanceof ViewGroup) {
+ View checkboxView = getChildViews((ViewGroup) childView);
+ if (checkboxView != null && checkboxView instanceof CheckBox) {
+ Log.d(LOG_TAG, "found Child: " + checkboxView.getId() + " " + checkboxView.getClass());
+ list.add((CheckBox) checkboxView);
+ }
+ }
+ }
+ return list;
+ }
+
+ /**
+ * recursive called method, used from getCheckboxList method
+ *
+ * @param View
+ * @return View
+ */
+ private View getChildViews(ViewGroup view) {
+ if (view != null) {
+ for (int i = 0; i < view.getChildCount(); i++) {
+ View cb = view.getChildAt(i);
+ if (cb != null && cb instanceof ViewGroup) {
+ return getChildViews((ViewGroup) cb);
+ } else if (cb instanceof CheckBox) {
+ return cb;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * create a new OnCheckedChangeListener for the 'check all' checkbox *
+ *
+ * @return OnCheckedChangeListener to select all checkboxes at the list
+ */
+ private OnCheckedChangeListener getCheckAllListener() {
+ return new OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ List list = getCheckboxList();
+ for (CheckBox checkbox : list) {
+ ((CheckBox) checkbox).setChecked(isChecked);
+ }
+ }
+
+ };
+ }
+
+ /**
+ * Button click Listener for the retry button at the headline
+ *
+ * @return a Listener to perform a retry for all selected images
+ */
+ private OnClickListener getRetryListner() {
+ return new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+
+ try {
+ List list = getCheckboxList();
+ for (CheckBox checkbox : list) {
+ boolean to_retry = checkbox.isChecked();
+
+ Log.d(LOG_TAG, "Checkbox for " + checkbox.getId() + " was checked: " + to_retry);
+ String img_path = fileList.get(checkbox.getId());
+ if (to_retry) {
+
+ final String msg = "Image-Path " + checkbox.getId() + " was checked: " + img_path;
+ Log.d(LOG_TAG, msg);
+ startUpload(img_path);
+ }
+
+ }
+ } finally {
+ // refresh the List
+ listView.removeAllViews();
+ loadListView(true);
+ }
+
+ }
+ };
+ }
+
+ /**
+ * Button click Listener for the delete button at the headline
+ *
+ * @return a Listener to perform a delete for all selected images
+ */
+ private OnClickListener getDeleteListner() {
+
+ return new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ final DbHandler dbh = new DbHandler(getApplicationContext());
+ try {
+ List list = getCheckboxList();
+ for (CheckBox checkbox : list) {
+ boolean to_be_delete = checkbox.isChecked();
+
+ Log.d(LOG_TAG, "Checkbox for " + checkbox.getId() + " was checked: " + to_be_delete);
+ String img_path = fileList.get(checkbox.getId());
+ Log.d(LOG_TAG, "Image-Path " + checkbox.getId() + " was checked: " + img_path);
+ if (to_be_delete) {
+ boolean deleted = dbh.removeIUPendingFile(img_path);
+ Log.d(LOG_TAG, "removing " + checkbox.getId() + " was : " + deleted);
+
+ }
+
+ }
+ } finally {
+ dbh.close();
+ // refresh the List
+ listView.removeAllViews();
+ loadListView(true);
+ }
+
+ }
+ };
+ }
+
+ private LinearLayout getLinearLayout(int id) {
+ LinearLayout linearLayout = new LinearLayout(getApplicationContext());
+ linearLayout.setId(id);
+ linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
+ LinearLayout.LayoutParams.MATCH_PARENT));
+ linearLayout.setGravity(Gravity.RIGHT);
+ linearLayout.setOrientation(LinearLayout.HORIZONTAL);
+ return linearLayout;
+ }
+
+ private Button getFileButton(final String img_path, int id) {
+ Button retryButton = new Button(this);
+ retryButton.setId(id);
+ retryButton.setText(img_path);
+ retryButton.setBackgroundResource(R.color.owncloud_white);
+ retryButton.setTextSize(8);
+ retryButton.setOnClickListener(getImageButtonOnClickListener(img_path));
+ return retryButton;
+ }
+
+ private CheckBox getFileCheckbox(int id) {
+ CheckBox retryCB = new CheckBox(this);
+ retryCB.setId(id);
+ retryCB.setBackgroundResource(R.color.owncloud_white);
+ retryCB.setTextSize(8);
+ retryCB.setTag(retry_chexbox_tag);
+ return retryCB;
+ }
+
+ private ImageButton getImageButton(String img_path, int id) {
+ ImageButton imageButton = new ImageButton(this);
+ imageButton.setId(id);
+ imageButton.setClickable(true);
+ imageButton.setOnClickListener(getImageButtonOnClickListener(img_path));
+
+ // scale and add a thumbnail to the imagebutton
+ int base_scale_size = 32;
+ if (img_path != null) {
+ Log.d(LOG_TAG, "add " + img_path + " to Image Button");
+ BitmapFactory.Options options = new BitmapFactory.Options();
+ options.inJustDecodeBounds = true;
+ Bitmap bitmap = BitmapFactory.decodeFile(img_path, options);
+ int width_tpm = options.outWidth, height_tmp = options.outHeight;
+ int scale = 3;
+ while (true) {
+ if (width_tpm / 2 < base_scale_size || height_tmp / 2 < base_scale_size) {
+ break;
+ }
+ width_tpm /= 2;
+ height_tmp /= 2;
+ scale++;
+ }
+
+ Log.d(LOG_TAG, "scale Imgae with: " + scale);
+ BitmapFactory.Options options2 = new BitmapFactory.Options();
+ options2.inSampleSize = scale;
+ bitmap = BitmapFactory.decodeFile(img_path, options2);
+
+ if (bitmap != null) {
+ Log.d(LOG_TAG, "loaded Bitmap Bytes: " + bitmap.getRowBytes());
+ imageButton.setImageBitmap(bitmap);
+ } else {
+ Log.d(LOG_TAG, "could not load imgage: " + img_path);
+ }
+ }
+ return imageButton;
+ }
+
+ private OnClickListener getImageButtonOnClickListener(final String img_path) {
+ return new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ startUpload(img_path);
+ loadListView(true);
+ }
+
+ };
+ }
+
+ /**
+ * start uploading a file to the INSTANT_UPLOD_DIR
+ *
+ * @param img_path
+ */
+ private void startUpload(String img_path) {
+ // extract filename
+ String filename = img_path.substring(img_path.lastIndexOf('/'), img_path.length());
+ if (canInstantUpload()) {
+ Account account = AccountUtils.getCurrentOwnCloudAccount(InstantUploadActivity.this);
+ // add file again to upload queue
+ DbHandler db = new DbHandler(InstantUploadActivity.this);
+ try {
+ db.updateFileState(img_path, DbHandler.UPLOAD_STATUS_UPLOAD_LATER);
+ } finally {
+ db.close();
+ }
+
+ Intent i = new Intent(InstantUploadActivity.this, FileUploader.class);
+ i.putExtra(FileUploader.KEY_ACCOUNT, account);
+ i.putExtra(FileUploader.KEY_LOCAL_FILE, img_path);
+ i.putExtra(FileUploader.KEY_REMOTE_FILE, InstantUploadService.INSTANT_UPLOAD_DIR + "/" + filename);
+ i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);
+ i.putExtra(com.owncloud.android.files.services.FileUploader.KEY_INSTANT_UPLOAD, true);
+
+ final String msg = "try to upload file with name :" + filename;
+ Log.d(LOG_TAG, msg);
+ Toast toast = Toast.makeText(InstantUploadActivity.this, getString(R.string.failed_upload_retry_text)
+ + filename, Toast.LENGTH_LONG);
+ toast.show();
+
+ startService(i);
+ } else {
+ Toast toast = Toast.makeText(InstantUploadActivity.this,
+ getString(R.string.failed_upload_retry_do_nothing_text) + filename, Toast.LENGTH_LONG);
+ toast.show();
+ }
+ }
+
+ private boolean canInstantUpload() {
+
+ if (!InstantUploadBroadcastReceiver.isOnline(this)
+ || (InstantUploadBroadcastReceiver.instantUploadViaWiFiOnly(this) && !InstantUploadBroadcastReceiver
+ .isConnectedViaWiFi(this))) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/src/com/owncloud/android/ui/activity/LandingActivity.java b/src/com/owncloud/android/ui/activity/LandingActivity.java
index 3af64853..32fae223 100644
--- a/src/com/owncloud/android/ui/activity/LandingActivity.java
+++ b/src/com/owncloud/android/ui/activity/LandingActivity.java
@@ -3,7 +3,7 @@
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/activity/PinCodeActivity.java b/src/com/owncloud/android/ui/activity/PinCodeActivity.java
index ea22268b..4ad0e57a 100644
--- a/src/com/owncloud/android/ui/activity/PinCodeActivity.java
+++ b/src/com/owncloud/android/ui/activity/PinCodeActivity.java
@@ -3,7 +3,7 @@
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/activity/Preferences.java b/src/com/owncloud/android/ui/activity/Preferences.java
index 9dfce138..460c5e0c 100644
--- a/src/com/owncloud/android/ui/activity/Preferences.java
+++ b/src/com/owncloud/android/ui/activity/Preferences.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/activity/PreferencesNewSession.java b/src/com/owncloud/android/ui/activity/PreferencesNewSession.java
index cafb86c6..211cce5f 100644
--- a/src/com/owncloud/android/ui/activity/PreferencesNewSession.java
+++ b/src/com/owncloud/android/ui/activity/PreferencesNewSession.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/activity/TransferServiceGetter.java b/src/com/owncloud/android/ui/activity/TransferServiceGetter.java
index 332976a3..0160f7e5 100644
--- a/src/com/owncloud/android/ui/activity/TransferServiceGetter.java
+++ b/src/com/owncloud/android/ui/activity/TransferServiceGetter.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/activity/UploadFilesActivity.java b/src/com/owncloud/android/ui/activity/UploadFilesActivity.java
index f2c36afb..a6d61d18 100644
--- a/src/com/owncloud/android/ui/activity/UploadFilesActivity.java
+++ b/src/com/owncloud/android/ui/activity/UploadFilesActivity.java
@@ -1,9 +1,9 @@
/* ownCloud Android client application
- * Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/adapter/FileListActionListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListActionListAdapter.java
index f4393b58..ac7aa90f 100644
--- a/src/com/owncloud/android/ui/adapter/FileListActionListAdapter.java
+++ b/src/com/owncloud/android/ui/adapter/FileListActionListAdapter.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java
index b924cc8c..8d879935 100644
--- a/src/com/owncloud/android/ui/adapter/FileListListAdapter.java
+++ b/src/com/owncloud/android/ui/adapter/FileListListAdapter.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/adapter/LandingScreenAdapter.java b/src/com/owncloud/android/ui/adapter/LandingScreenAdapter.java
index 8bc56754..1f588c48 100644
--- a/src/com/owncloud/android/ui/adapter/LandingScreenAdapter.java
+++ b/src/com/owncloud/android/ui/adapter/LandingScreenAdapter.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java b/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java
index 82031542..d55eb3f6 100644
--- a/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java
+++ b/src/com/owncloud/android/ui/adapter/LocalFileListAdapter.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/dialog/ChangelogDialog.java b/src/com/owncloud/android/ui/dialog/ChangelogDialog.java
index 6330da74..ab0e0a7b 100644
--- a/src/com/owncloud/android/ui/dialog/ChangelogDialog.java
+++ b/src/com/owncloud/android/ui/dialog/ChangelogDialog.java
@@ -1,9 +1,9 @@
/* ownCloud Android client application
- * Copyright (C) 2013 ownCloud Inc.
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
@@ -15,6 +15,7 @@
* along with this program. If not, see .
*
*/
+
package com.owncloud.android.ui.dialog;
import java.io.InputStream;
diff --git a/src/com/owncloud/android/ui/dialog/ConflictsResolveDialog.java b/src/com/owncloud/android/ui/dialog/ConflictsResolveDialog.java
index 1c89790c..6a3fa219 100644
--- a/src/com/owncloud/android/ui/dialog/ConflictsResolveDialog.java
+++ b/src/com/owncloud/android/ui/dialog/ConflictsResolveDialog.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/dialog/EditNameDialog.java b/src/com/owncloud/android/ui/dialog/EditNameDialog.java
index 41d65d4d..069eedb7 100644
--- a/src/com/owncloud/android/ui/dialog/EditNameDialog.java
+++ b/src/com/owncloud/android/ui/dialog/EditNameDialog.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
@@ -16,7 +17,6 @@
*
*/
-
package com.owncloud.android.ui.dialog;
import android.app.AlertDialog;
diff --git a/src/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.java b/src/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.java
index 4f9305b0..c7796232 100644
--- a/src/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.java
+++ b/src/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.java
@@ -1,3 +1,21 @@
+/* ownCloud Android client application
+ * Copyright (C) 2012-2013 ownCloud Inc.
+ *
+ * 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, see .
+ *
+ */
+
package com.owncloud.android.ui.dialog;
import android.app.Dialog;
diff --git a/src/com/owncloud/android/ui/dialog/SslValidatorDialog.java b/src/com/owncloud/android/ui/dialog/SslValidatorDialog.java
index f67968ad..2143e9a9 100644
--- a/src/com/owncloud/android/ui/dialog/SslValidatorDialog.java
+++ b/src/com/owncloud/android/ui/dialog/SslValidatorDialog.java
@@ -1,9 +1,9 @@
/* ownCloud Android client application
- * Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
@@ -15,6 +15,7 @@
* along with this program. If not, see .
*
*/
+
package com.owncloud.android.ui.dialog;
import java.io.IOException;
diff --git a/src/com/owncloud/android/ui/fragment/AuthenticatorAccountDetailsFragment.java b/src/com/owncloud/android/ui/fragment/AuthenticatorAccountDetailsFragment.java
index 2a3b331c..265bb1dd 100644
--- a/src/com/owncloud/android/ui/fragment/AuthenticatorAccountDetailsFragment.java
+++ b/src/com/owncloud/android/ui/fragment/AuthenticatorAccountDetailsFragment.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/fragment/AuthenticatorGetStartedFragment.java b/src/com/owncloud/android/ui/fragment/AuthenticatorGetStartedFragment.java
index 860eb5b0..5ddee243 100644
--- a/src/com/owncloud/android/ui/fragment/AuthenticatorGetStartedFragment.java
+++ b/src/com/owncloud/android/ui/fragment/AuthenticatorGetStartedFragment.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/fragment/ConfirmationDialogFragment.java b/src/com/owncloud/android/ui/fragment/ConfirmationDialogFragment.java
index 7cf45538..e527d31e 100644
--- a/src/com/owncloud/android/ui/fragment/ConfirmationDialogFragment.java
+++ b/src/com/owncloud/android/ui/fragment/ConfirmationDialogFragment.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java
index fc6f1672..2d46a55c 100644
--- a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java
+++ b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/fragment/LandingPageFragment.java b/src/com/owncloud/android/ui/fragment/LandingPageFragment.java
index a021afbf..ab584638 100644
--- a/src/com/owncloud/android/ui/fragment/LandingPageFragment.java
+++ b/src/com/owncloud/android/ui/fragment/LandingPageFragment.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/fragment/LocalFileListFragment.java b/src/com/owncloud/android/ui/fragment/LocalFileListFragment.java
index 18266ab6..51f78b70 100644
--- a/src/com/owncloud/android/ui/fragment/LocalFileListFragment.java
+++ b/src/com/owncloud/android/ui/fragment/LocalFileListFragment.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java
index 117b0b2d..34e156d3 100644
--- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java
+++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/utils/FileStorageUtils.java b/src/com/owncloud/android/utils/FileStorageUtils.java
index 63aee6b5..5406cb5a 100644
--- a/src/com/owncloud/android/utils/FileStorageUtils.java
+++ b/src/com/owncloud/android/utils/FileStorageUtils.java
@@ -1,9 +1,9 @@
/* ownCloud Android client application
- * Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
@@ -27,6 +27,11 @@ import android.os.StatFs;
import com.owncloud.android.datamodel.OCFile;
+/**
+ * Static methods to help in access to local file system.
+ *
+ * @author David A. Velasco
+ */
public class FileStorageUtils {
public static final String getSavePath(String accountName) {
diff --git a/src/com/owncloud/android/utils/OwnCloudVersion.java b/src/com/owncloud/android/utils/OwnCloudVersion.java
index 43ea9838..8bba93f0 100644
--- a/src/com/owncloud/android/utils/OwnCloudVersion.java
+++ b/src/com/owncloud/android/utils/OwnCloudVersion.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
@@ -33,7 +34,7 @@ public class OwnCloudVersion implements Comparable {
// format is in version
// 0xAABBCC
// for version AA.BB.CC
- // ie version 3.0.3 will be stored as 0x030003
+ // ie version 2.0.3 will be stored as 0x030003
private int mVersion;
private boolean mIsValid;
diff --git a/src/com/owncloud/android/utils/RecursiveFileObserver.java b/src/com/owncloud/android/utils/RecursiveFileObserver.java
index aac34eb3..3ce88534 100644
--- a/src/com/owncloud/android/utils/RecursiveFileObserver.java
+++ b/src/com/owncloud/android/utils/RecursiveFileObserver.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/com/owncloud/android/widgets/ActionEditText.java b/src/com/owncloud/android/widgets/ActionEditText.java
index a4f5527f..d77a825a 100644
--- a/src/com/owncloud/android/widgets/ActionEditText.java
+++ b/src/com/owncloud/android/widgets/ActionEditText.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/eu/alefzero/webdav/ChunkFromFileChannelRequestEntity.java b/src/eu/alefzero/webdav/ChunkFromFileChannelRequestEntity.java
index 1316315d..d39f8ce7 100644
--- a/src/eu/alefzero/webdav/ChunkFromFileChannelRequestEntity.java
+++ b/src/eu/alefzero/webdav/ChunkFromFileChannelRequestEntity.java
@@ -1,9 +1,9 @@
/* ownCloud Android client application
- * Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/eu/alefzero/webdav/FileRequestEntity.java b/src/eu/alefzero/webdav/FileRequestEntity.java
index 292d88bf..3adaa3a8 100644
--- a/src/eu/alefzero/webdav/FileRequestEntity.java
+++ b/src/eu/alefzero/webdav/FileRequestEntity.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/eu/alefzero/webdav/OnDatatransferProgressListener.java b/src/eu/alefzero/webdav/OnDatatransferProgressListener.java
index 5469f88c..a8c84b12 100644
--- a/src/eu/alefzero/webdav/OnDatatransferProgressListener.java
+++ b/src/eu/alefzero/webdav/OnDatatransferProgressListener.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/eu/alefzero/webdav/WebdavClient.java b/src/eu/alefzero/webdav/WebdavClient.java
index 61f16605..1319a2b0 100644
--- a/src/eu/alefzero/webdav/WebdavClient.java
+++ b/src/eu/alefzero/webdav/WebdavClient.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2011 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/eu/alefzero/webdav/WebdavEntry.java b/src/eu/alefzero/webdav/WebdavEntry.java
index 30b5660f..f76ee697 100644
--- a/src/eu/alefzero/webdav/WebdavEntry.java
+++ b/src/eu/alefzero/webdav/WebdavEntry.java
@@ -3,7 +3,7 @@
*
* 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 3 of the License, or
+ * 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,
diff --git a/src/eu/alefzero/webdav/WebdavUtils.java b/src/eu/alefzero/webdav/WebdavUtils.java
index a42b9024..7e2d6840 100644
--- a/src/eu/alefzero/webdav/WebdavUtils.java
+++ b/src/eu/alefzero/webdav/WebdavUtils.java
@@ -1,9 +1,10 @@
/* ownCloud Android client application
* Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
*
* 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 3 of the License, or
+ * 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,
diff --git a/tests/src/com/owncloud/android/test/AccountUtilsTest.java b/tests/src/com/owncloud/android/test/AccountUtilsTest.java
index 3c04ad22..528392a4 100644
--- a/tests/src/com/owncloud/android/test/AccountUtilsTest.java
+++ b/tests/src/com/owncloud/android/test/AccountUtilsTest.java
@@ -1,3 +1,22 @@
+/* ownCloud Android client application
+ * Copyright (C) 2012 Bartek Przybylski
+ * Copyright (C) 2012-2013 ownCloud Inc.
+ *
+ * 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, see .
+ *
+ */
+
package com.owncloud.android.test;
import android.test.AndroidTestCase;