From: MMMarcy Date: Fri, 17 Oct 2014 12:58:27 +0000 (+0200) Subject: Merge remote-tracking branch 'theirs/develop' into gradleWithInternalDependency X-Git-Tag: oc-android-1.7.0_signed~69^2~10^2~1 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/d8d75623e49a10942c5d02137032c40984c674ea?ds=inline;hp=-c Merge remote-tracking branch 'theirs/develop' into gradleWithInternalDependency Conflicts: owncloud-android-library pom.xml --- d8d75623e49a10942c5d02137032c40984c674ea diff --combined owncloud-android-library index 19d453dd,c29631b8..00000000 deleted file mode 160000,160000 --- a/owncloud-android-library +++ /dev/null @@@ -1,1 -1,1 +1,0 @@@ - Subproject commit 19d453dd55233d689754335af641e77087a1c431 -Subproject commit c29631b8bfea22e5f0b448aab8ffff959ae4de66 diff --combined pom.xml index 36c5d944,6a8cf6a7..538df03c --- a/pom.xml +++ b/pom.xml @@@ -1,7 -1,6 +1,7 @@@ - + 4.0.0 com.owncloud.android @@@ -14,7 -13,7 +14,7 @@@ 1.5.1-SNAPSHOT 1.6 - 4.4.2_r3 + 4.4.2_r4 19 4.2.0 @@@ -27,29 -26,24 +27,40 @@@ scm:git:git@github.com:owncloud/android.git https://github.com/owncloud/android - + + + + + + + + + + - - - - - + + + touch-image-view.jar + touch-image-view.jar + 1.0 + system + ${basedir}/libs/touch-image-view.jar + + + + + + + + com.jakewharton + disklrucache + 2.0.2 + + android-support-v4.jar android-support-v4.jar @@@ -57,35 -51,34 +68,35 @@@ system ${basedir}/third_party/android-support-library/android-support-v4.jar - - - android - android - ${google.android-version} - provided - + com.actionbarsherlock - actionbarsherlock + library ${actionbarsherlock-version} - provided + apklib - com.actionbarsherlock - actionbarsherlock - ${actionbarsherlock-version} - apklib + android + android + ${google.android-version} + provided + + + + + + + - com.owncloud.android - owncloud-android-library - ${owncloud.version} - + com.owncloud.android + owncloud-android-library + ${owncloud.version} + @@@ -99,7 -92,7 +110,7 @@@ org.apache.maven.plugins maven-compiler-plugin - 3.0 + 3.1 ${java-version} ${java-version} @@@ -109,7 -102,7 +120,7 @@@ com.jayway.maven.plugins.android.generation2 android-maven-plugin - 3.8.0 + 3.8.2 ${env.ANDROID_HOME} diff --combined src/com/owncloud/android/datamodel/FileDataStorageManager.java index 26c14554,795004a1..7fb1604b --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@@ -27,11 -27,11 +27,11 @@@ import java.util.Vector import com.owncloud.android.MainApp; import com.owncloud.android.db.ProviderMeta.ProviderTableMeta; + import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.shares.OCShare; import com.owncloud.android.lib.resources.shares.ShareType; import com.owncloud.android.lib.resources.files.FileUtils; import com.owncloud.android.utils.FileStorageUtils; - import com.owncloud.android.utils.Log_OC; import android.accounts.Account; @@@ -188,6 -188,7 +188,7 @@@ public class FileDataStorageManager cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink()); cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions()); cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId()); + cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.needsUpdateThumbnail()); boolean sameRemotePath = fileExists(file.getRemotePath()); if (sameRemotePath || @@@ -612,6 -613,126 +613,126 @@@ } + public void moveLocalFile(OCFile file, String targetPath, String targetParentPath) { + + if (file != null && file.fileExists() && !OCFile.ROOT_PATH.equals(file.getFileName())) { + + OCFile targetParent = getFileByPath(targetParentPath); + if (targetParent == null) { + // TODO panic + } + + /// 1. get all the descendants of the moved element in a single QUERY + Cursor c = null; + if (getContentProviderClient() != null) { + try { + c = getContentProviderClient().query( + ProviderTableMeta.CONTENT_URI, + null, + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + + ProviderTableMeta.FILE_PATH + " LIKE ? ", + new String[] { + mAccount.name, + file.getRemotePath() + "%" + }, + ProviderTableMeta.FILE_PATH + " ASC " + ); + } catch (RemoteException e) { + Log_OC.e(TAG, e.getMessage()); + } + + } else { + c = getContentResolver().query( + ProviderTableMeta.CONTENT_URI, + null, + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=? AND " + + ProviderTableMeta.FILE_PATH + " LIKE ? ", + new String[] { + mAccount.name, + file.getRemotePath() + "%" + }, + ProviderTableMeta.FILE_PATH + " ASC " + ); + } + + /// 2. prepare a batch of update operations to change all the descendants + ArrayList operations = + new ArrayList(c.getCount()); + String defaultSavePath = FileStorageUtils.getSavePath(mAccount.name); + if (c.moveToFirst()) { + int lengthOfOldPath = file.getRemotePath().length(); + int lengthOfOldStoragePath = defaultSavePath.length() + lengthOfOldPath; + do { + ContentValues cv = new ContentValues(); // keep construction in the loop + OCFile child = createFileInstance(c); + cv.put( + ProviderTableMeta.FILE_PATH, + targetPath + child.getRemotePath().substring(lengthOfOldPath) + ); + if (child.getStoragePath() != null && + child.getStoragePath().startsWith(defaultSavePath)) { + // update link to downloaded content - but local move is not done here! + cv.put( + ProviderTableMeta.FILE_STORAGE_PATH, + defaultSavePath + targetPath + + child.getStoragePath().substring(lengthOfOldStoragePath) + ); + } + if (child.getRemotePath().equals(file.getRemotePath())) { + cv.put( + ProviderTableMeta.FILE_PARENT, + targetParent.getFileId() + ); + } + operations.add( + ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI). + withValues(cv). + withSelection( + ProviderTableMeta._ID + "=?", + new String[] { String.valueOf(child.getFileId()) } + ) + .build()); + + } while (c.moveToNext()); + } + c.close(); + + /// 3. apply updates in batch + try { + if (getContentResolver() != null) { + getContentResolver().applyBatch(MainApp.getAuthority(), operations); + + } else { + getContentProviderClient().applyBatch(operations); + } + + } catch (Exception e) { + Log_OC.e( + TAG, + "Fail to update " + file.getFileId() + " and descendants in database", + e + ); + } + + /// 4. move in local file system + String localPath = FileStorageUtils.getDefaultSavePathFor(mAccount.name, file); + File localFile = new File(localPath); + boolean renamed = false; + if (localFile.exists()) { + File targetFile = new File(defaultSavePath + targetPath); + File targetFolder = targetFile.getParentFile(); + if (!targetFolder.exists()) { + targetFolder.mkdirs(); + } + renamed = localFile.renameTo(targetFile); + } + Log_OC.d(TAG, "Local file RENAMED : " + renamed); + + } + + } + + private Vector getFolderContent(long parentId) { Vector ret = new Vector(); @@@ -758,6 -879,8 +879,8 @@@ file.setPublicLink(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PUBLIC_LINK))); file.setPermissions(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_PERMISSIONS))); file.setRemoteId(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_REMOTE_ID))); + file.setNeedsUpdateThumbnail(c.getInt( + c.getColumnIndex(ProviderTableMeta.FILE_UPDATE_THUMBNAIL)) == 1 ? true : false); } return file; @@@ -1102,6 -1225,7 +1225,7 @@@ cv.put(ProviderTableMeta.FILE_PUBLIC_LINK, file.getPublicLink()); cv.put(ProviderTableMeta.FILE_PERMISSIONS, file.getPermissions()); cv.put(ProviderTableMeta.FILE_REMOTE_ID, file.getRemoteId()); + cv.put(ProviderTableMeta.FILE_UPDATE_THUMBNAIL, file.needsUpdateThumbnail() ? 1 : 0); boolean existsByPath = fileExists(file.getRemotePath()); if (existsByPath || fileExists(file.getFileId())) { @@@ -1169,7 -1293,7 +1293,7 @@@ path = path + FileUtils.PATH_SEPARATOR; } - // Update OCFile with data from share: ShareByLink ¿and publicLink? + // Update OCFile with data from share: ShareByLink and publicLink OCFile file = getFileByPath(path); if (file != null) { if (share.getShareType().equals(ShareType.PUBLIC_LINK)) { @@@ -1302,4 -1426,5 +1426,5 @@@ */ //} } + } diff --combined src/com/owncloud/android/operations/CreateShareOperation.java index a85f8d4c,c32c4771..b563790f --- a/src/com/owncloud/android/operations/CreateShareOperation.java +++ b/src/com/owncloud/android/operations/CreateShareOperation.java @@@ -32,12 -32,12 +32,12 @@@ import com.owncloud.android.lib.common. import com.owncloud.android.lib.resources.shares.OCShare; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; + import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation; import com.owncloud.android.lib.resources.shares.ShareType; import com.owncloud.android.lib.resources.shares.CreateRemoteShareOperation; import com.owncloud.android.lib.resources.files.FileUtils; import com.owncloud.android.operations.common.SyncOperation; - import com.owncloud.android.utils.Log_OC; public class CreateShareOperation extends SyncOperation { @@@ -57,20 -57,20 +57,20 @@@ /** * Constructor * @param path Full path of the file/folder being shared. Mandatory argument - * @param shareType ‘0’ = user, ‘1’ = group, ‘3’ = Public link. Mandatory argument + * @param shareType 0 = user, 1 = group, 3 = Public link. Mandatory argument * @param shareWith User/group ID with who the file should be shared. This is mandatory for shareType of 0 or 1 - * @param publicUpload If ‘false’ (default) public cannot upload to a public shared folder. - * If ‘true’ public can upload to a shared folder. Only available for public link shares + * @param publicUpload If false (default) public cannot upload to a public shared folder. + * If true public can upload to a shared folder. Only available for public link shares * @param password Password to protect a public link share. Only available for public link shares - * @param permissions 1 - Read only – Default for “public” shares + * @param permissions 1 - Read only - Default for public shares * 2 - Update * 4 - Create * 8 - Delete * 16- Re-share - * 31- All above – Default for “private” shares + * 31- All above - Default for private shares * For user or group shares. * To obtain combinations, add the desired values together. - * For instance, for “Re-Share”, “delete”, “read”, “update”, add 16+8+2+1 = 27. + * For instance, for Re-Share, delete, read, update, add 16+8+2+1 = 27. */ public CreateShareOperation(String path, ShareType shareType, String shareWith, boolean publicUpload, String password, int permissions, Intent sendIntent) { diff --combined src/com/owncloud/android/operations/GetSharesForFileOperation.java index 9416999d,c319d620..649437d2 --- a/src/com/owncloud/android/operations/GetSharesForFileOperation.java +++ b/src/com/owncloud/android/operations/GetSharesForFileOperation.java @@@ -23,9 -23,9 +23,9 @@@ import java.util.ArrayList import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.resources.shares.OCShare; import com.owncloud.android.lib.common.operations.RemoteOperationResult; + import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation; import com.owncloud.android.operations.common.SyncOperation; - import com.owncloud.android.utils.Log_OC; /** * Provide a list shares for a specific file. @@@ -45,10 -45,10 +45,10 @@@ public class GetSharesForFileOperation * Constructor * * @param path Path to file or folder - * @param reshares If set to ‘false’ (default), only shares from the current user are returned - * If set to ‘true’, all shares from the given file are returned - * @param subfiles If set to ‘false’ (default), lists only the folder being shared - * If set to ‘true’, all shared files within the folder are returned. + * @param reshares If set to false (default), only shares from the current user are returned + * If set to true, all shares from the given file are returned + * @param subfiles If set to false (default), lists only the folder being shared + * If set to true, all shared files within the folder are returned. */ public GetSharesForFileOperation(String path, boolean reshares, boolean subfiles) { mPath = path;