Update branch with develop branch
authormasensio <masensio@solidgear.es>
Thu, 6 Jun 2013 15:22:25 +0000 (17:22 +0200)
committermasensio <masensio@solidgear.es>
Thu, 6 Jun 2013 15:22:25 +0000 (17:22 +0200)
.classpath
lint.xml [new file with mode: 0644]
oc_jb_workaround/.classpath
oc_jb_workaround/project.properties
src/com/owncloud/android/ui/adapter/FileListListAdapter.java
tests/.classpath
tests/.settings/org.eclipse.jdt.core.prefs
tests/project.properties

index f7b8a1f..cbaab1a 100644 (file)
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-       <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
-       <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="gen"/>
-       <classpathentry kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
+       <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
+       <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+       <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
        <classpathentry kind="output" path="bin/classes"/>
 </classpath>
diff --git a/lint.xml b/lint.xml
new file mode 100644 (file)
index 0000000..ee0eead
--- /dev/null
+++ b/lint.xml
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lint>
+</lint>
\ No newline at end of file
index d57ec02..96e9275 100644 (file)
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-       <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
-       <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="gen"/>
+       <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+       <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
        <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
        <classpathentry kind="output" path="bin/classes"/>
 </classpath>
index 9b84a6b..a3ee5ab 100644 (file)
@@ -11,4 +11,4 @@
 #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
 
 # Project target.
-target=android-16
+target=android-17
index 80f5358..907410f 100644 (file)
-/* ownCloud Android client application\r
- *   Copyright (C) 2011  Bartek Przybylski\r
- *   Copyright (C) 2012-2013 ownCloud Inc.\r
- *\r
- *   This program is free software: you can redistribute it and/or modify\r
- *   it under the terms of the GNU General Public License version 2,\r
- *   as published by the Free Software Foundation.\r
- *\r
- *   This program is distributed in the hope that it will be useful,\r
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
- *   GNU General Public License for more details.\r
- *\r
- *   You should have received a copy of the GNU General Public License\r
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.\r
- *\r
- */\r
-package com.owncloud.android.ui.adapter;\r
-\r
-import java.util.Vector;\r
-\r
-import com.owncloud.android.AccountUtils;\r
-import com.owncloud.android.DisplayUtils;\r
-import com.owncloud.android.datamodel.DataStorageManager;\r
-import com.owncloud.android.datamodel.OCFile;\r
-import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;\r
-import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;\r
-import com.owncloud.android.ui.activity.TransferServiceGetter;\r
-\r
-import com.owncloud.android.R;\r
-\r
-import android.accounts.Account;\r
-import android.content.Context;\r
-import android.view.LayoutInflater;\r
-import android.view.View;\r
-import android.view.ViewGroup;\r
-import android.widget.BaseAdapter;\r
-import android.widget.ImageView;\r
-import android.widget.ListAdapter;\r
-import android.widget.ListView;\r
-import android.widget.TextView;\r
-\r
-/**\r
- * This Adapter populates a ListView with all files and folders in an ownCloud\r
- * instance.\r
- * \r
- * @author Bartek Przybylski\r
- * \r
- */\r
-public class FileListListAdapter extends BaseAdapter implements ListAdapter {\r
-    private Context mContext;\r
-    private OCFile mFile = null;\r
-    private Vector<OCFile> mFiles = null;\r
-    private DataStorageManager mStorageManager;\r
-    private Account mAccount;\r
-    private TransferServiceGetter mTransferServiceGetter;\r
-\r
-    public FileListListAdapter(OCFile file, DataStorageManager storage_man,\r
-            Context context, TransferServiceGetter transferServiceGetter) {\r
-        mStorageManager = storage_man;\r
-        mContext = context;\r
-        mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);\r
-        mTransferServiceGetter = transferServiceGetter;\r
-        swapDirectory(file, mStorageManager);\r
-        /*mFile = file;\r
-        mFiles = mStorageManager.getDirectoryContent(mFile);*/\r
-    }\r
-\r
-    @Override\r
-    public boolean areAllItemsEnabled() {\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public boolean isEnabled(int position) {\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public int getCount() {\r
-        return mFiles != null ? mFiles.size() : 0;\r
-    }\r
-\r
-    @Override\r
-    public Object getItem(int position) {\r
-        if (mFiles == null || mFiles.size() <= position)\r
-            return null;\r
-        return mFiles.get(position);\r
-    }\r
-\r
-    @Override\r
-    public long getItemId(int position) {\r
-        if (mFiles == null || mFiles.size() <= position)\r
-            return 0;\r
-        return mFiles.get(position).getFileId();\r
-    }\r
-\r
-    @Override\r
-    public int getItemViewType(int position) {\r
-        return 0;\r
-    }\r
-\r
-    @Override\r
-    public View getView(int position, View convertView, ViewGroup parent) {\r
-        View view = convertView;\r
-        if (view == null) {\r
-            LayoutInflater inflator = (LayoutInflater) mContext\r
-                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);\r
-            view = inflator.inflate(R.layout.list_item, null);\r
-        }\r
-        if (mFiles != null && mFiles.size() > position) {\r
-            OCFile file = mFiles.get(position);\r
-            TextView fileName = (TextView) view.findViewById(R.id.Filename);\r
-            String name = file.getFileName();\r
-\r
-            fileName.setText(name);\r
-            ImageView fileIcon = (ImageView) view.findViewById(R.id.imageView1);\r
-            fileIcon.setImageResource(DisplayUtils.getResourceId(file.getMimetype()));\r
-            ImageView localStateView = (ImageView) view.findViewById(R.id.imageView2);\r
-            FileDownloaderBinder downloaderBinder = mTransferServiceGetter.getFileDownloaderBinder();\r
-            FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();\r
-            if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) {\r
-                localStateView.setImageResource(R.drawable.downloading_file_indicator);\r
-                localStateView.setVisibility(View.VISIBLE);\r
-            } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {\r
-                localStateView.setImageResource(R.drawable.uploading_file_indicator);\r
-                localStateView.setVisibility(View.VISIBLE);\r
-            } else if (file.isDown()) {\r
-                localStateView.setImageResource(R.drawable.local_file_indicator);\r
-                localStateView.setVisibility(View.VISIBLE);\r
-            } else {\r
-                localStateView.setVisibility(View.INVISIBLE);\r
-            }\r
-\r
-            \r
-            TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);\r
-            TextView lastModV = (TextView) view.findViewById(R.id.last_mod);\r
-            ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);\r
-            \r
-            if (!file.isDirectory()) {\r
-                fileSizeV.setVisibility(View.VISIBLE);\r
-                fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));\r
-                lastModV.setVisibility(View.VISIBLE);\r
-                lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));\r
-                // this if-else is needed even thoe fav icon is visible by default\r
-                // because android reuses views in listview\r
-                if (!file.keepInSync()) {\r
-                    view.findViewById(R.id.imageView3).setVisibility(View.GONE);\r
-                } else {\r
-                    view.findViewById(R.id.imageView3).setVisibility(View.VISIBLE);\r
-                }\r
-                \r
-                ListView parentList = (ListView)parent;\r
-                if (parentList.getChoiceMode() == ListView.CHOICE_MODE_NONE) { \r
-                    checkBoxV.setVisibility(View.GONE);\r
-                } else {\r
-                    if (parentList.isItemChecked(position)) {\r
-                        checkBoxV.setImageResource(android.R.drawable.checkbox_on_background);\r
-                    } else {\r
-                        checkBoxV.setImageResource(android.R.drawable.checkbox_off_background);\r
-                    }\r
-                    checkBoxV.setVisibility(View.VISIBLE);\r
-                }\r
-                \r
-            } else {\r
-               fileSizeV.setVisibility(View.GONE);\r
-               lastModV.setVisibility(View.GONE);\r
-               checkBoxV.setVisibility(View.GONE);\r
-               view.findViewById(R.id.imageView3).setVisibility(View.GONE);\r
-            }\r
-        }\r
-\r
-        return view;\r
-    }\r
-\r
-    @Override\r
-    public int getViewTypeCount() {\r
-        return 1;\r
-    }\r
-\r
-    @Override\r
-    public boolean hasStableIds() {\r
-        return true;\r
-    }\r
-\r
-    @Override\r
-    public boolean isEmpty() {\r
-        return (mFiles == null || mFiles.isEmpty());\r
-    }\r
-\r
-    /**\r
-     * Change the adapted directory for a new one\r
-     * @param directory                 New file to adapt. Can be NULL, meaning "no content to adapt".\r
-     * @param updatedStorageManager     Optional updated storage manager; used to replace mStorageManager if is different (and not NULL)\r
-     */\r
-    public void swapDirectory(OCFile directory, DataStorageManager updatedStorageManager) {\r
-        mFile = directory;\r
-        if (updatedStorageManager != null && updatedStorageManager != mStorageManager) {\r
-            mStorageManager = updatedStorageManager;\r
-            mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);\r
-        }\r
-        if (mStorageManager != null) {\r
-            mFiles = mStorageManager.getDirectoryContent(mFile);\r
-        } else {\r
-            mFiles = null;\r
-        }\r
-        notifyDataSetChanged();\r
-    }\r
-    \r
-}\r
+
+/* 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 <http://www.gnu.org/licenses/>.
+ *
+ */
+package com.owncloud.android.ui.adapter;
+
+import java.util.Vector;
+
+import android.accounts.Account;
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageView;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import com.owncloud.android.AccountUtils;
+import com.owncloud.android.DisplayUtils;
+import com.owncloud.android.R;
+import com.owncloud.android.datamodel.DataStorageManager;
+import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
+import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
+import com.owncloud.android.ui.activity.TransferServiceGetter;
+
+/**
+ * This Adapter populates a ListView with all files and folders in an ownCloud
+ * instance.
+ * 
+ * @author Bartek Przybylski
+ * 
+ */
+public class FileListListAdapter extends BaseAdapter implements ListAdapter {
+    private Context mContext;
+    private OCFile mFile = null;
+    private Vector<OCFile> mFiles = null;
+    private DataStorageManager mStorageManager;
+    private Account mAccount;
+    private TransferServiceGetter mTransferServiceGetter;
+    //total size of a directory (recursive)
+    private Long totalSizeOfDirectoriesRecursive = null;
+    private Long lastModifiedOfAllSubdirectories = null;
+    
+    public FileListListAdapter(OCFile file, DataStorageManager storage_man,
+            Context context, TransferServiceGetter transferServiceGetter) {
+        mStorageManager = storage_man;
+        mContext = context;
+        mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
+        mTransferServiceGetter = transferServiceGetter;
+        swapDirectory(file, mStorageManager);
+        /*mFile = file;
+        mFiles = mStorageManager.getDirectoryContent(mFile);*/
+    }
+
+    @Override
+    public boolean areAllItemsEnabled() {
+        return true;
+    }
+
+    @Override
+    public boolean isEnabled(int position) {
+        return true;
+    }
+
+    @Override
+    public int getCount() {
+        return mFiles != null ? mFiles.size() : 0;
+    }
+
+    @Override
+    public Object getItem(int position) {
+        if (mFiles == null || mFiles.size() <= position)
+            return null;
+        return mFiles.get(position);
+    }
+
+    @Override
+    public long getItemId(int position) {
+        if (mFiles == null || mFiles.size() <= position)
+            return 0;
+        return mFiles.get(position).getFileId();
+    }
+
+    @Override
+    public int getItemViewType(int position) {
+        return 0;
+    }
+
+    @Override
+    public View getView(int position, View convertView, ViewGroup parent) {
+        View view = convertView;
+        if (view == null) {
+            LayoutInflater inflator = (LayoutInflater) mContext
+                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+            view = inflator.inflate(R.layout.list_item, null);
+        }
+        if (mFiles != null && mFiles.size() > position) {
+            OCFile file = mFiles.get(position);
+            TextView fileName = (TextView) view.findViewById(R.id.Filename);
+            String name = file.getFileName();
+
+            fileName.setText(name);
+            ImageView fileIcon = (ImageView) view.findViewById(R.id.imageView1);
+            fileIcon.setImageResource(DisplayUtils.getResourceId(file.getMimetype()));
+            ImageView localStateView = (ImageView) view.findViewById(R.id.imageView2);
+            FileDownloaderBinder downloaderBinder = mTransferServiceGetter.getFileDownloaderBinder();
+            FileUploaderBinder uploaderBinder = mTransferServiceGetter.getFileUploaderBinder();
+            if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, file)) {
+                localStateView.setImageResource(R.drawable.downloading_file_indicator);
+                localStateView.setVisibility(View.VISIBLE);
+            } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file)) {
+                localStateView.setImageResource(R.drawable.uploading_file_indicator);
+                localStateView.setVisibility(View.VISIBLE);
+            } else if (file.isDown()) {
+                localStateView.setImageResource(R.drawable.local_file_indicator);
+                localStateView.setVisibility(View.VISIBLE);
+            } else {
+                localStateView.setVisibility(View.INVISIBLE);
+            }
+
+            
+            TextView fileSizeV = (TextView) view.findViewById(R.id.file_size);
+            TextView lastModV = (TextView) view.findViewById(R.id.last_mod);
+            ImageView checkBoxV = (ImageView) view.findViewById(R.id.custom_checkbox);
+            
+            if (!file.isDirectory()) {
+                fileSizeV.setVisibility(View.VISIBLE);
+                fileSizeV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
+                lastModV.setVisibility(View.VISIBLE);
+                lastModV.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
+                // this if-else is needed even thoe fav icon is visible by default
+                // because android reuses views in listview
+                if (!file.keepInSync()) {
+                    view.findViewById(R.id.imageView3).setVisibility(View.GONE);
+                } else {
+                    view.findViewById(R.id.imageView3).setVisibility(View.VISIBLE);
+                }
+                
+                ListView parentList = (ListView)parent;
+                if (parentList.getChoiceMode() == ListView.CHOICE_MODE_NONE) { 
+                    checkBoxV.setVisibility(View.GONE);
+                } else {
+                    if (parentList.isItemChecked(position)) {
+                        checkBoxV.setImageResource(android.R.drawable.checkbox_on_background);
+                    } else {
+                        checkBoxV.setImageResource(android.R.drawable.checkbox_off_background);
+                    }
+                    checkBoxV.setVisibility(View.VISIBLE);
+                }
+                
+            } 
+            else {
+               
+               getDirectorySizeNumber(file,true);
+               if (lastModifiedOfAllSubdirectories == null)
+               {
+                   lastModV.setVisibility(View.GONE);
+                   fileSizeV.setVisibility(View.GONE);
+               }
+               else
+               {
+                   lastModV.setVisibility(View.VISIBLE);
+                   lastModV.setText(DisplayUtils.unixTimeToHumanReadable(lastModifiedOfAllSubdirectories));
+                   fileSizeV.setVisibility(View.VISIBLE);
+                   fileSizeV.setText(DisplayUtils.bytesToHumanReadable((totalSizeOfDirectoriesRecursive == null) ? 0 : totalSizeOfDirectoriesRecursive));
+               }
+               checkBoxV.setVisibility(View.GONE);
+               view.findViewById(R.id.imageView3).setVisibility(View.GONE);
+            }
+        }
+
+        return view;
+    }
+
+    
+    /**
+     * - This method counts recursively all subdirectories and their files from the root directory. 
+     * - It also shows a timestamp of the last modificated file inside the root directory
+     * 
+     *   @param OCFile  : startDirectory
+     *   @param boolean :  counting starts from here ?
+     */
+    private void getDirectorySizeNumber(OCFile directory,boolean startOfRecursive) {
+        if (startOfRecursive) {
+            totalSizeOfDirectoriesRecursive = null;
+        }
+        Vector<OCFile> files  = mStorageManager.getDirectoryContent(directory);
+        for (OCFile file : files) {
+            if(!file.isDirectory()) {
+                if (totalSizeOfDirectoriesRecursive == null) {
+                    totalSizeOfDirectoriesRecursive = file.getFileLength();
+                    lastModifiedOfAllSubdirectories = file.getModificationTimestamp();
+                    continue;
+                }
+                
+                totalSizeOfDirectoriesRecursive += file.getFileLength();
+                if (lastModifiedOfAllSubdirectories < file.getModificationTimestamp()) {
+                    lastModifiedOfAllSubdirectories = file.getModificationTimestamp();
+                }
+            }
+            else {
+                this.getDirectorySizeNumber(file, false);
+            }
+        }
+    }
+    
+    
+    @Override
+    public int getViewTypeCount() {
+        return 1;
+    }
+
+    @Override
+    public boolean hasStableIds() {
+        return true;
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return (mFiles == null || mFiles.isEmpty());
+    }
+
+    /**
+     * Change the adapted directory for a new one
+     * @param directory                 New file to adapt. Can be NULL, meaning "no content to adapt".
+     * @param updatedStorageManager     Optional updated storage manager; used to replace mStorageManager if is different (and not NULL)
+     */
+    public void swapDirectory(OCFile directory, DataStorageManager updatedStorageManager) {
+        mFile = directory;
+        if (updatedStorageManager != null && updatedStorageManager != mStorageManager) {
+            mStorageManager = updatedStorageManager;
+            mAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
+        }
+        if (mStorageManager != null) {
+            mFiles = mStorageManager.getDirectoryContent(mFile);
+        } else {
+            mFiles = null;
+        }
+        notifyDataSetChanged();
+    }
+    
+}
\ No newline at end of file
index 0331c0e..657a459 100644 (file)
@@ -1,11 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-       <classpathentry combineaccessrules="false" kind="src" path="/owncloud-android"/>
-       <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
-       <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
-       <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="gen"/>
+       <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+       <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
        <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
+       <classpathentry combineaccessrules="false" kind="src" path="/owncloud-android"/>
        <classpathentry kind="output" path="bin/classes"/>
 </classpath>
index 8000cd6..877df2d 100644 (file)
@@ -1,4 +1,8 @@
 eclipse.preferences.version=1
+<<<<<<< HEAD
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+=======
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
@@ -8,4 +12,5 @@ org.eclipse.jdt.core.compiler.debug.localVariable=generate
 org.eclipse.jdt.core.compiler.debug.sourceFile=generate
 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+>>>>>>> develop
 org.eclipse.jdt.core.compiler.source=1.6
index 8937e94..a3ee5ab 100644 (file)
@@ -11,4 +11,4 @@
 #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
 
 # Project target.
-target=android-14
+target=android-17