From: Jorge Antonio Diaz-Benito Soriano Date: Thu, 23 Oct 2014 20:34:42 +0000 (+0200) Subject: Added copy action X-Git-Tag: oc-android-1.8~22^2~11 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/ccf8741fab3c7fe8c6468679ed736b65833225e1?ds=inline;hp=--cc Added copy action --- ccf8741fab3c7fe8c6468679ed736b65833225e1 diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index febb3b69..10b7698c 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -158,7 +158,7 @@ public class FileDataStorageManager { } } - + public Vector getFolderImages(OCFile folder/*, boolean onlyOnDevice*/) { Vector ret = new Vector(); if (folder != null) { @@ -206,8 +206,7 @@ public class FileDataStorageManager { cv.put(ProviderTableMeta.FILE_IS_DOWNLOADING, file.isDownloading()); boolean sameRemotePath = fileExists(file.getRemotePath()); - if (sameRemotePath || - fileExists(file.getFileId()) ) { // for renamed files + if (sameRemotePath || fileExists(file.getFileId())) { // for renamed files; no more delete and create OCFile oldFile = null; if (sameRemotePath) { @@ -357,7 +356,7 @@ public class FileDataStorageManager { ProviderTableMeta.CONTENT_URI_FILE, file.getFileId() ) ).withSelection(where, whereArgs).build()); - + if (file.isDown()) { String path = file.getStoragePath(); new File(path).delete(); @@ -480,13 +479,10 @@ public class FileDataStorageManager { } else { if (removeDBData) { - Uri file_uri = ContentUris.withAppendedId( - ProviderTableMeta.CONTENT_URI_FILE, - file.getFileId() - ); - String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?" + " AND " + - ProviderTableMeta.FILE_PATH + "=?"; - String [] whereArgs = new String[]{mAccount.name, file.getRemotePath()}; + //Uri file_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, ""+file.getFileId()); + Uri file_uri = ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_FILE, file.getFileId()); + String where = ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?" + " AND " + ProviderTableMeta.FILE_PATH + "=?"; + String[] whereArgs = new String[]{mAccount.name, file.getRemotePath()}; int deleted = 0; if (getContentProviderClient() != null) { try { @@ -1006,8 +1002,7 @@ public class FileDataStorageManager { cv.put(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED, share.getIdRemoteShared()); cv.put(ProviderTableMeta.OCSHARES_ACCOUNT_OWNER, mAccount.name); - if (shareExists(share.getIdRemoteShared())) { // for renamed files - + if (shareExists(share.getIdRemoteShared())) { // for renamed files; no more delete and create overriden = true; if (getContentResolver() != null) { getContentResolver().update(ProviderTableMeta.CONTENT_URI_SHARE, cv, @@ -1106,12 +1101,9 @@ public class FileDataStorageManager { share.setSharedWithDisplayName(c.getString(c .getColumnIndex(ProviderTableMeta.OCSHARES_SHARE_WITH_DISPLAY_NAME))); share.setIsFolder(c.getInt( - c.getColumnIndex(ProviderTableMeta.OCSHARES_IS_DIRECTORY)) == 1 ? true : false); + c.getColumnIndex(ProviderTableMeta.OCSHARES_IS_DIRECTORY)) == 1); share.setUserId(c.getLong(c.getColumnIndex(ProviderTableMeta.OCSHARES_USER_ID))); - share.setIdRemoteShared( - c.getLong(c.getColumnIndex(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED)) - ); - + share.setIdRemoteShared(c.getLong(c.getColumnIndex(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED))); } return share; } @@ -1162,10 +1154,7 @@ public class FileDataStorageManager { } else { try { - getContentProviderClient().update( - ProviderTableMeta.CONTENT_URI, cv, where, whereArgs - ); - + getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs); } catch (RemoteException e) { Log_OC.e(TAG, "Exception in cleanSharedFiles" + e.getMessage()); } @@ -1185,10 +1174,7 @@ public class FileDataStorageManager { } else { try { - getContentProviderClient().update( - ProviderTableMeta.CONTENT_URI, cv, where, whereArgs - ); - + getContentProviderClient().update(ProviderTableMeta.CONTENT_URI, cv, where, whereArgs); } catch (RemoteException e) { Log_OC.e(TAG, "Exception in cleanSharedFilesInFolder " + e.getMessage()); } @@ -1204,10 +1190,7 @@ public class FileDataStorageManager { } else { try { - getContentProviderClient().delete( - ProviderTableMeta.CONTENT_URI_SHARE, where, whereArgs - ); - + getContentProviderClient().delete(ProviderTableMeta.CONTENT_URI_SHARE, where, whereArgs); } catch (RemoteException e) { Log_OC.e(TAG, "Exception in cleanShares" + e.getMessage()); } @@ -1246,13 +1229,9 @@ public class FileDataStorageManager { operations.add( ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI_SHARE). withValues(cv). - withSelection( - ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED + "=?", - new String[] { String.valueOf(share.getIdRemoteShared()) } - ). - build() - ); - + withSelection(ProviderTableMeta.OCSHARES_ID_REMOTE_SHARED + "=?", + new String[]{String.valueOf(share.getIdRemoteShared())}) + .build()); } else { // adding a new file operations.add( @@ -1271,10 +1250,7 @@ public class FileDataStorageManager { " operations to FileContentProvider"); try { if (getContentResolver() != null) { - results = getContentResolver().applyBatch( - MainApp.getAuthority(), operations - ); - + results = getContentResolver().applyBatch(MainApp.getAuthority(), operations); } else { results = getContentProviderClient().applyBatch(operations); } @@ -1341,11 +1317,9 @@ public class FileDataStorageManager { operations.add( ContentProviderOperation.newUpdate(ProviderTableMeta.CONTENT_URI). withValues(cv). - withSelection( - ProviderTableMeta._ID + "=?", - new String[] { String.valueOf(file.getFileId()) } - ).build() - ); + withSelection(ProviderTableMeta._ID + "=?", + new String[]{String.valueOf(file.getFileId())}) + .build()); } else { // adding a new file @@ -1365,10 +1339,7 @@ public class FileDataStorageManager { " operations to FileContentProvider"); try { if (getContentResolver() != null) { - results = getContentResolver().applyBatch( - MainApp.getAuthority(), operations - ); - + results = getContentResolver().applyBatch(MainApp.getAuthority(), operations); } else { results = getContentProviderClient().applyBatch(operations); } diff --git a/src/com/owncloud/android/files/FileOperationsHelper.java b/src/com/owncloud/android/files/FileOperationsHelper.java index 57b766ec..22370289 100644 --- a/src/com/owncloud/android/files/FileOperationsHelper.java +++ b/src/com/owncloud/android/files/FileOperationsHelper.java @@ -125,7 +125,7 @@ public class FileOperationsHelper { } } - + public void shareFileWithLinkToApp(OCFile file, String password, Intent sendIntent) { if (file != null) { diff --git a/src/com/owncloud/android/services/OperationsService.java b/src/com/owncloud/android/services/OperationsService.java index 90fc2f00..099bd087 100644 --- a/src/com/owncloud/android/services/OperationsService.java +++ b/src/com/owncloud/android/services/OperationsService.java @@ -256,14 +256,14 @@ public class OperationsService extends Service { */ public class OperationsServiceBinder extends Binder /* implements OnRemoteOperationListener */ { - /** + /** * Map of listeners that will be reported about the end of operations from a * {@link OperationsServiceBinder} instance */ private final ConcurrentMap mBoundListeners = new ConcurrentHashMap(); - private ServiceHandler mServiceHandler = null; + private ServiceHandler mServiceHandler = null; public OperationsServiceBinder(ServiceHandler serviceHandler) { mServiceHandler = serviceHandler; @@ -290,7 +290,7 @@ public class OperationsService extends Service { /** * Adds a listener interested in being reported about the end of operations. * - * @param listener Object to notify about the end of operations. + * @param listener Object to notify about the end of operations. * @param callbackHandler {@link Handler} to access the listener without * breaking Android threading protection. */ @@ -317,7 +317,7 @@ public class OperationsService extends Service { /** * TODO - IMPORTANT: update implementation when more operations are moved into the service - * + * * @return 'True' when an operation that enforces the user to wait for completion is * in process. */ @@ -346,7 +346,7 @@ public class OperationsService extends Service { } } - + public boolean dispatchResultIfFinished(int operationId, OnRemoteOperationListener listener) { Pair undispatched = @@ -381,7 +381,7 @@ public class OperationsService extends Service { /** * Operations worker. Performs the pending operations in the order they were requested. - * + * * Created with the Looper of a new thread, started in {@link OperationsService#onCreate()}. */ private static class ServiceHandler extends Handler { @@ -391,7 +391,7 @@ public class OperationsService extends Service { OperationsService mService; - + private ConcurrentLinkedQueue> mPendingOperations = new ConcurrentLinkedQueue>(); private RemoteOperation mCurrentOperation = null; @@ -477,7 +477,7 @@ public class OperationsService extends Service { } else { result = mCurrentOperation.execute(mOwnCloudClient); } - + } catch (AccountsException e) { if (mLastTarget.mAccount == null) { Log_OC.e(TAG, "Error while trying to get authorization for a NULL account", diff --git a/src/com/owncloud/android/ui/activity/FileActivity.java b/src/com/owncloud/android/ui/activity/FileActivity.java index 63f700c3..e2667e8c 100644 --- a/src/com/owncloud/android/ui/activity/FileActivity.java +++ b/src/com/owncloud/android/ui/activity/FileActivity.java @@ -709,6 +709,7 @@ public class FileActivity extends ActionBarActivity } + private void onCreateShareOperationFinish(CreateShareOperation operation, RemoteOperationResult result) { dismissLoadingDialog();