Merge pull request #284 from owncloud/setup_app_name
authorDavid A. Velasco <dvelasco@owncloud.com>
Tue, 22 Oct 2013 12:15:21 +0000 (05:15 -0700)
committerDavid A. Velasco <dvelasco@owncloud.com>
Tue, 22 Oct 2013 12:15:21 +0000 (05:15 -0700)
Setup app name, optional settings, and availability of multiple accounts.

19 files changed:
.gitignore
AndroidManifest.xml
SETUP.md
oc_jb_workaround/AndroidManifest.xml
pom.xml
res/drawable-hdpi/icon.png
res/drawable-hdpi/logo.png
res/drawable-ldpi/icon.png
res/drawable-ldpi/logo.png
res/drawable-mdpi/icon.png
res/drawable-mdpi/logo.png
res/layout/media_control.xml
src/com/owncloud/android/files/services/FileUploader.java
src/com/owncloud/android/operations/RemoteOperationResult.java
src/com/owncloud/android/operations/SynchronizeFileOperation.java
src/com/owncloud/android/operations/SynchronizeFolderOperation.java
src/com/owncloud/android/ui/activity/FileDisplayActivity.java
src/com/owncloud/android/ui/fragment/FileDetailFragment.java
src/com/owncloud/android/ui/preview/PreviewImageActivity.java

index 7a3b836..ac30011 100644 (file)
@@ -18,3 +18,13 @@ local.properties
 
 # Mac .DS_Store files
 .DS_Store
+
+# These files are created automatically by Eclipse:
+tests/proguard-project.txt
+tests/project.properties
+tests/ant.properties
+tests/build.xml
+proguard-project.txt
+
+# Should not be commited inside this repo:
+actionbarsherlock/
\ No newline at end of file
index 0acd29f..ac8c150 100644 (file)
@@ -18,8 +18,8 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
  -->
 <manifest package="com.owncloud.android"
-    android:versionCode="104005"
-    android:versionName="1.4.5" xmlns:android="http://schemas.android.com/apk/res/android">
+    android:versionCode="104006"
+    android:versionName="1.4.6" xmlns:android="http://schemas.android.com/apk/res/android">
 
     <uses-permission android:name="android.permission.GET_ACCOUNTS" />
     <uses-permission android:name="android.permission.USE_CREDENTIALS" />
index 8c1ebd9..cd67a80 100644 (file)
--- a/SETUP.md
+++ b/SETUP.md
@@ -2,27 +2,44 @@
   If you want to start development of ownCloud first download required files, then compile using console or Eclipse, finally create pull request:
   
   1. Fork and download android/develop repository:
-  
+
+  -  NOTE: You must have git in your enviroment path
   -  Navigate to https://github.com/owncloud/android, click fork.
   -  Clone your new repo: "git clone git@github.com:YOURGITHUBNAME/android.git"
+  -  "cd android"
   -  Checkout remote develop branch: "git checkout -b develop remotes/origin/develop"
+  -  Pull changes from your develop branch: "git pull origin develop"
+  -  Make sure to get the latest changes from official android/develop branch:
+  -  Make official owncloud repo known as upstream: "git remote add upstream git@github.com:owncloud/android.git"
+  -  Pull latest changes from upstream: "git pull upstream develop"
 
-  2. Building with console:
+  2. Building with console/maven:
 
-  -  Use setup_env.sh or setup_env.bat
-  -  NOTE: You must have mvn, git, ant/bin, android/tools, and 'platforms-tools' in your enviroment path
+  -  OPTIONAL, CONTINUE WITH STEP 3 IF NOT REQUIRED!
+  -  NOTE: You must have mvn in your enviroment path
+  -  Download/install Android plugin for Maven, then build ownCloud with mvn:
+  -  "cd .."
+  -  "git clone https://github.com/mosabua/maven-android-sdk-deployer.git"
+  -  "cd maven-android-sdk-deployer"
+  -  "mvn -pl com.simpligility.android.sdk-deployer:android-17 -am install"
+  -  "cd ../android"
   -  Now you can create APK using "mvn package"
-  
-  3. Building with eclipse:
 
-  -  Open Eclipse and create new "Android Project from Existing Code". As root choose *actionbarsherlock/library*
-  -  Increase Android API level until project compiles. 14 should work. bin/library.jar needs to be created!
+  3. Building with Eclipse:
+
+  -  NOTE: You must have android/tools, and 'platforms-tools' in your enviroment path
+  -  Prepare building with Eclipse:
+  -  "setup_env.bat" or "./setup_env.sh"
+  -  Open Eclipse and create new "Android Project from Existing Code". As root choose android/actionbarsherlock/library
+  -  Increase Android API level until project compiles. 14 should work. 
+  -  Clean project and compile.
+  -  Make sure android/actionbarsherlock/library/bin/library.jar was created!
   -  Import OwnCloud Android project.
   -  Increase Android API level to 17.
-  -  Clean all projects.
+  -  Clean project and compile.
   -  After those actions you should be good to go. HAVE FUN!
-  -  TODO: How to build for older devices?
-  
+  -  NOTE: Even though API level is set to 17, APK also runs on older devices because in AndroidManifest.xml minSdkVersion is set to 8.
+
   4. Create pull request:
   
   -  Commit your changes locally: "git commit -a"
index cdb77bc..c987c82 100644 (file)
@@ -1,14 +1,12 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.owncloud.android.workaround.accounts"
-    android:versionCode="0100007"
-    android:versionName="1.0.7" >
+    android:versionCode="0100008"
+    android:versionName="1.0.8" >
 
     <uses-sdk
         android:minSdkVersion="16"
-        android:targetSdkVersion="16" 
-        android:maxSdkVersion="17"
-        />
+        android:targetSdkVersion="16" />
 
     <application
         android:allowBackup="false"
diff --git a/pom.xml b/pom.xml
index 2726333..a55a77a 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -11,8 +11,7 @@
 
     <properties>
         <java-version>1.6</java-version>
-        <google.android-version>4.1.1.4</google.android-version>
-        <google.android.support-version>r7</google.android.support-version>
+        <google.android-version>4.2.2_r2</google.android-version>
         <actionbarsherlock-version>4.2.0</actionbarsherlock-version>
     </properties>
 
     <dependencies>
 
         <dependency>
-            <groupId>com.google.android</groupId>
+            <groupId>android</groupId>
             <artifactId>android</artifactId>
             <version>${google.android-version}</version>
             <scope>provided</scope>
         </dependency>
 
         <dependency>
-            <groupId>com.google.android</groupId>
-            <artifactId>support-v4</artifactId>
-            <version>${google.android.support-version}</version>
-        </dependency>
-
-        <dependency>
             <groupId>com.actionbarsherlock</groupId>
             <artifactId>actionbarsherlock</artifactId>
             <version>${actionbarsherlock-version}</version>
index e388c7b..8a2fe19 100644 (file)
Binary files a/res/drawable-hdpi/icon.png and b/res/drawable-hdpi/icon.png differ
index ecea3b0..a920912 100644 (file)
Binary files a/res/drawable-hdpi/logo.png and b/res/drawable-hdpi/logo.png differ
index 11cf0ab..f8f54b7 100644 (file)
Binary files a/res/drawable-ldpi/icon.png and b/res/drawable-ldpi/icon.png differ
index 62dff25..7de7cb8 100644 (file)
Binary files a/res/drawable-ldpi/logo.png and b/res/drawable-ldpi/logo.png differ
index 6997c7e..42bbaad 100644 (file)
Binary files a/res/drawable-mdpi/icon.png and b/res/drawable-mdpi/icon.png differ
index ecea3b0..a920912 100644 (file)
Binary files a/res/drawable-mdpi/logo.png and b/res/drawable-mdpi/logo.png differ
index 489c997..f308edc 100644 (file)
@@ -27,7 +27,7 @@
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:gravity="center"
-        android:paddingTop="4dip"
+        android:paddingTop="4dp"
         android:orientation="horizontal"
         >
 
             android:id="@+id/currentTimeText"
             android:textSize="14sp"
             android:textStyle="bold"
-            android:paddingTop="4dip"
-            android:paddingStart="4dip"
+            android:paddingTop="4dp"
+            android:paddingStart="4dp"
             android:layout_gravity="center_horizontal"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:paddingEnd="4dip"
+            android:paddingEnd="4dp"
             android:text="@string/placeholder_media_time"
             />
 
         <SeekBar
             android:id="@+id/progressBar"
             style="?android:attr/progressBarStyleHorizontal"
-            android:layout_width="0dip"
+            android:layout_width="0dp"
             android:layout_weight="1"
-            android:layout_height="32dip"
+            android:layout_height="32dp"
             android:layout_alignParentStart="true"
             android:layout_alignParentEnd="true" />
 
         <TextView android:id="@+id/totalTimeText"
             android:textSize="14sp"
             android:textStyle="bold"
-            android:paddingTop="4dip"
-            android:paddingEnd="4dip"
+            android:paddingTop="4dp"
+            android:paddingEnd="4dp"
             android:layout_gravity="center_horizontal"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:paddingStart="4dip"
+            android:paddingStart="4dp"
             android:text="@string/placeholder_media_time"
             />
         
index 55aefbd..e738a27 100644 (file)
@@ -29,6 +29,7 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
 import org.apache.http.HttpStatus;
+import org.apache.jackrabbit.webdav.DavConstants;
 import org.apache.jackrabbit.webdav.MultiStatus;
 import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
 
@@ -535,6 +536,11 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
                     mPendingUploads.remove(uploadKey);
                     Log_OC.i(TAG, "Remove CurrentUploadItem from pending upload Item Map.");
                 }
+                if (uploadResult.isException()) {
+                    // enforce the creation of a new client object for next uploads; this grant that a new socket will 
+                    // be created in the future if the current exception is due to an abrupt lose of network connection
+                    mUploadClient = null;
+                }
             }
             
             /// notify result
@@ -617,8 +623,9 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
         PropFindMethod propfind = null;
         RemoteOperationResult result = null;
         try {
-            propfind = new PropFindMethod(mUploadClient.getBaseUri()
-                    + WebdavUtils.encodePath(mCurrentUpload.getRemotePath()));
+            propfind = new PropFindMethod(mUploadClient.getBaseUri() + WebdavUtils.encodePath(mCurrentUpload.getRemotePath()),
+                    DavConstants.PROPFIND_ALL_PROP,
+                    DavConstants.DEPTH_0);
             int status = mUploadClient.executeMethod(propfind);
             boolean isMultiStatus = (status == HttpStatus.SC_MULTI_STATUS);
             if (isMultiStatus) {
@@ -723,12 +730,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
         mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);
         
         /// includes a pending intent in the notification showing the details view of the file
-        Intent showDetailsIntent = null;
-        if (PreviewImageFragment.canBePreviewed(upload.getFile())) {
-            showDetailsIntent = new Intent(this, PreviewImageActivity.class);
-        } else {
-            showDetailsIntent = new Intent(this, FileDisplayActivity.class);
-        }
+        Intent showDetailsIntent = new Intent(this, FileDisplayActivity.class);
         showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, upload.getFile());
         showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, upload.getAccount());
         showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
index 999974c..4e137c4 100644 (file)
@@ -52,6 +52,7 @@ public class RemoteOperationResult implements Serializable {
 
     /** Generated - should be refreshed every time the class changes!! */
     private static final long serialVersionUID = -4415103901492836870L;
+    
 
     
     private static final String TAG = "RemoteOperationResult";
index 5be116b..7a81b84 100644 (file)
@@ -19,6 +19,7 @@
 package com.owncloud.android.operations;
 
 import org.apache.http.HttpStatus;
+import org.apache.jackrabbit.webdav.DavConstants;
 import org.apache.jackrabbit.webdav.MultiStatus;
 import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
 
@@ -89,7 +90,9 @@ public class SynchronizeFileOperation extends RemoteOperation {
                 
                 if (mServerFile == null) {
                     /// take the duty of check the server for the current state of the file there
-                    propfind = new PropFindMethod(client.getBaseUri() + WebdavUtils.encodePath(mLocalFile.getRemotePath()));
+                    propfind = new PropFindMethod(client.getBaseUri() + WebdavUtils.encodePath(mLocalFile.getRemotePath()),
+                            DavConstants.PROPFIND_ALL_PROP,
+                            DavConstants.DEPTH_0);
                     int status = client.executeMethod(propfind, SYNC_READ_TIMEOUT, SYNC_CONNECTION_TIMEOUT);
                     boolean isMultiStatus = status == HttpStatus.SC_MULTI_STATUS;
                     if (isMultiStatus) {
index 0236a13..3295668 100644 (file)
@@ -29,6 +29,7 @@ import java.util.Map;
 import java.util.Vector;
 
 import org.apache.http.HttpStatus;
+import org.apache.jackrabbit.webdav.DavConstants;
 import org.apache.jackrabbit.webdav.MultiStatus;
 import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
 
@@ -134,7 +135,9 @@ public class SynchronizeFolderOperation extends RemoteOperation {
             Log_OC.d(TAG, "Synchronizing " + mAccount.name + ", fetching files in " + mRemotePath);
             
             // remote request 
-            query = new PropFindMethod(client.getBaseUri() + WebdavUtils.encodePath(mRemotePath));
+            query = new PropFindMethod(client.getBaseUri() + WebdavUtils.encodePath(mRemotePath),
+                    DavConstants.PROPFIND_ALL_PROP,
+                    DavConstants.DEPTH_1);
             int status = client.executeMethod(query);
             
             // check and process response   - /// TODO take into account all the possible status per child-resource
index e66ab60..7721133 100644 (file)
@@ -86,6 +86,7 @@ import com.owncloud.android.ui.fragment.FileDetailFragment;
 import com.owncloud.android.ui.fragment.FileFragment;
 import com.owncloud.android.ui.fragment.OCFileListFragment;
 import com.owncloud.android.ui.preview.PreviewImageActivity;
+import com.owncloud.android.ui.preview.PreviewImageFragment;
 import com.owncloud.android.ui.preview.PreviewMediaFragment;
 import com.owncloud.android.ui.preview.PreviewVideoActivity;
 
@@ -220,12 +221,15 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
 
             /// Check whether the 'main' OCFile handled by the Activity is contained in the current Account
             OCFile file = getFile();
+            // get parent from path
+            String parentPath = "";
             if (file != null) {
                 if (file.isDown() && file.getLastSyncDateForProperties() == 0) {
                     // upload in progress - right now, files are not inserted in the local cache until the upload is successful
-                    if (mStorageManager.getFileById(file.getParentId()) == null) {
-                        file = null;    // not able to know the directory where the file is uploading
-                    }
+                    // get parent from path
+                    parentPath = file.getRemotePath().substring(0, file.getRemotePath().lastIndexOf(file.getFileName()));
+                    if (mStorageManager.getFileByPath(parentPath) ==  null)
+                        file = null; // not able to know the directory where the file is uploading
                 } else {
                     file = mStorageManager.getFileByPath(file.getRemotePath());   // currentDir = null if not in the current Account
                 }
@@ -241,7 +245,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
                 if (fileIt.isDirectory()) {
                     mDirectories.add(fileIt.getFileName());
                 }
-                fileIt = mStorageManager.getFileById(fileIt.getParentId());
+                // get parent from path
+                parentPath = fileIt.getRemotePath().substring(0, fileIt.getRemotePath().lastIndexOf(fileIt.getFileName()));
+                fileIt = mStorageManager.getFileByPath(parentPath);
             }
             mDirectories.add(OCFile.PATH_SEPARATOR);
             if (!stateWasRecovered) {
@@ -867,7 +873,9 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
 
             Log_OC.d(TAG, "sync of account " + accountName + " is in_progress: " + inProgress);
 
-            if (getAccount() != null && accountName.equals(getAccount().name)) {  
+            if (getAccount() != null && accountName.equals(getAccount().name)
+                    && mStorageManager != null
+                    ) {  
 
                 String synchFolderRemotePath = intent.getStringExtra(FileSyncService.SYNC_FOLDER_REMOTE_PATH); 
 
@@ -881,7 +889,7 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
                 if ((synchFolderRemotePath != null && currentDir != null && (currentDir.getRemotePath().equals(synchFolderRemotePath)))
                         || fillBlankRoot ) {
                     if (!fillBlankRoot) 
-                        currentDir = getStorageManager().getFileByPath(synchFolderRemotePath);
+                        currentDir = mStorageManager.getFileByPath(synchFolderRemotePath);
                     OCFileListFragment fileListFragment = getListOfFilesFragment();
                     if (fileListFragment != null) {
                         fileListFragment.listDirectory(currentDir);
@@ -1370,7 +1378,8 @@ OCFileListFragment.ContainerActivity, FileDetailFragment.ContainerActivity, OnNa
             if (file.isDirectory()) {
                 return file;
             } else if (mStorageManager != null) {
-                return mStorageManager.getFileById(file.getParentId());
+                String parentPath = file.getRemotePath().substring(0, file.getRemotePath().lastIndexOf(file.getFileName()));
+                return mStorageManager.getFileByPath(parentPath);
             }
         }
         return null;
index 07f274e..944decf 100644 (file)
@@ -64,6 +64,7 @@ import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDisplayActivity;
 import com.owncloud.android.ui.dialog.EditNameDialog;
 import com.owncloud.android.ui.dialog.EditNameDialog.EditNameDialogListener;
+import com.owncloud.android.ui.preview.PreviewImageFragment;
 
 import eu.alefzero.webdav.OnDatatransferProgressListener;
 
@@ -742,7 +743,13 @@ public class FileDetailFragment extends FileFragment implements
                         msg.show();
                     }
                     getSherlockActivity().removeStickyBroadcast(intent);    // not the best place to do this; a small refactorization of BroadcastReceivers should be done
+                    
                     updateFileDetails(false, false);    // it updates the buttons; must be called although !uploadWasFine; interrupted uploads still leave an incomplete file in the server
+                   
+                    // Force the preview if the file is an image
+                    if (uploadWasFine && PreviewImageFragment.canBePreviewed(getFile())) {
+                        ((FileDisplayActivity) mContainerActivity).startImagePreview(getFile());
+                    } 
                 }
             }
         }
index 7c9ccd6..6a80ffb 100644 (file)
@@ -110,7 +110,10 @@ public class PreviewImageActivity extends FileActivity implements FileFragment.C
     }
 
     private void initViewPager() {
-        OCFile parentFolder = mStorageManager.getFileById(getFile().getParentId());
+        // get parent from path
+        String parentPath = getFile().getRemotePath().substring(0, getFile().getRemotePath().lastIndexOf(getFile().getFileName()));
+        OCFile parentFolder = mStorageManager.getFileByPath(parentPath);
+        //OCFile parentFolder = mStorageManager.getFileById(getFile().getParentId());
         if (parentFolder == null) {
             // should not be necessary
             parentFolder = mStorageManager.getFileByPath(OCFile.PATH_SEPARATOR);
@@ -158,7 +161,7 @@ public class PreviewImageActivity extends FileActivity implements FileFragment.C
                     Log_OC.d(TAG, "Simulating reselection of current page after connection of download binder");
                     onPageSelected(mViewPager.getCurrentItem());
                 }
-                    
+
             } else if (component.equals(new ComponentName(PreviewImageActivity.this, FileUploader.class))) {
                 Log_OC.d(TAG, "Upload service connected");
                 mUploaderBinder = (FileUploaderBinder) service;
@@ -436,8 +439,12 @@ public class PreviewImageActivity extends FileActivity implements FileFragment.C
             if (!file.isImage()) {
                 throw new IllegalArgumentException("Non-image file passed as argument");
             }
-            mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
-            file = mStorageManager.getFileById(file.getFileId()); 
+            mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());            
+            
+            // Update file according to DB file, if it is possible
+            if (file.getFileId() > DataStorageManager.ROOT_PARENT_ID)            
+                file = mStorageManager.getFileById(file.getFileId());
+            
             if (file != null) {
                 /// Refresh the activity according to the Account and OCFile set
                 setFile(file);  // reset after getting it fresh from mStorageManager