From: tobiasKaminsky Date: Sat, 21 Nov 2015 07:48:40 +0000 (+0100) Subject: Merge remote-tracking branch 'remotes/upstream/master' into avoidDuplicateFiles_Master X-Git-Tag: beta-20151122~4^2 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/2aac1e527034960dde1910fa5eaa88bc13dc2ee7?ds=inline Merge remote-tracking branch 'remotes/upstream/master' into avoidDuplicateFiles_Master --- 2aac1e527034960dde1910fa5eaa88bc13dc2ee7 diff --cc res/values/strings.xml index 18e81c49,320eea1a..706baf05 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@@ -364,14 -368,17 +368,26 @@@ %1$d files %1$d files, 1 folder %1$d files, %2$d folders + Upload file to server and ... + Behaviour + Copy file + Move file + + do nothing + copy file to OC folder + move file to OC folder + delete origin file + Sharing + Share with Users and Groups + No data shared with users yet + Add User or Group + Search + + Search users and groups + %1$s (group) + + Sorry, your server version does not allow share with users within clients. + \nPlease contact your administrator + diff --cc src/com/owncloud/android/datamodel/FileDataStorageManager.java index b7485897,237c8469..5d49b2c5 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@@ -1490,47 -1497,67 +1497,67 @@@ public class FileDataStorageManager } } return preparedOperations; - - /* - if (operations.size() > 0) { - try { - if (getContentResolver() != null) { - getContentResolver().applyBatch(MainApp.getAuthority(), operations); - } else { - getContentProviderClient().applyBatch(operations); - } + } - } catch (OperationApplicationException e) { - Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); + private ArrayList prepareRemoveSharesInFile( + String filePath, ArrayList preparedOperations) { + + String where = ProviderTableMeta.OCSHARES_PATH + "=?" + " AND " + + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?"; + String[] whereArgs = new String[]{filePath, mAccount.name}; + + preparedOperations.add( + ContentProviderOperation.newDelete(ProviderTableMeta.CONTENT_URI_SHARE). + withSelection(where, whereArgs). + build() + ); + + return preparedOperations; + + } + + public ArrayList getSharesWithForAFile(String filePath, String accountName){ + // Condition + String where = ProviderTableMeta.OCSHARES_PATH + "=?" + " AND " + + ProviderTableMeta.OCSHARES_ACCOUNT_OWNER + "=?"+ "AND" + + " (" + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? OR " + + ProviderTableMeta.OCSHARES_SHARE_TYPE + "=? ) "; + String [] whereArgs = new String[]{ filePath, accountName , + Integer.toString(ShareType.USER.getValue()), + Integer.toString(ShareType.GROUP.getValue()) }; + + Cursor c = null; + if (getContentResolver() != null) { + c = getContentResolver().query( + ProviderTableMeta.CONTENT_URI_SHARE, + null, where, whereArgs, null); + } else { + try { + c = getContentProviderClient().query( + ProviderTableMeta.CONTENT_URI_SHARE, + null, where, whereArgs, null); } catch (RemoteException e) { - Log_OC.e(TAG, "Exception in batch of operations " + e.getMessage()); + Log_OC.e(TAG, "Could not get list of shares with: " + e.getMessage()); + c = null; } - } - */ - - /* - if (getContentResolver() != null) { - - getContentResolver().delete(ProviderTableMeta.CONTENT_URI_SHARE, - where, - whereArgs); - } else { - try { - getContentProviderClient().delete( ProviderTableMeta.CONTENT_URI_SHARE, - where, - whereArgs); + } + ArrayList shares = new ArrayList(); + OCShare share = null; + if (c.moveToFirst()) { + do { + share = createShareInstance(c); + shares.add(share); + // } + } while (c.moveToNext()); + } + c.close(); - } catch (RemoteException e) { - Log_OC.e(TAG, "Exception deleting shares in a folder " + e.getMessage()); - } - } - */ - //} + return shares; } - public void triggerMediaScan(String path) { + public static void triggerMediaScan(String path) { Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); intent.setData(Uri.fromFile(new File(path))); MainApp.getAppContext().sendBroadcast(intent); diff --cc src/com/owncloud/android/operations/UploadFileOperation.java index 6be2e0ae,ee9f7c88..ab74e792 --- a/src/com/owncloud/android/operations/UploadFileOperation.java +++ b/src/com/owncloud/android/operations/UploadFileOperation.java @@@ -322,47 -320,48 +321,49 @@@ public class UploadFileOperation extend while (listener.hasNext()) { mUploadOperation.addDatatransferProgressListener(listener.next()); } - if (!mCancellationRequested.get()) { - result = mUploadOperation.execute(client); - - /// move local temporal file or original file to its corresponding - // location in the ownCloud local folder - if (result.isSuccess()) { - if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_FORGET) { - mFile.setStoragePath(null); - } else if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_REMOVE){ - mFile.setStoragePath(null); - originalFile.delete(); - } else { - mFile.setStoragePath(expectedPath); - File fileToMove = null; - if (temporalFile != null) { // FileUploader.LOCAL_BEHAVIOUR_COPY - // ; see where temporalFile was - // set - fileToMove = temporalFile; - } else { // FileUploader.LOCAL_BEHAVIOUR_MOVE - fileToMove = originalFile; - } - if (!expectedFile.equals(fileToMove)) { - File expectedFolder = expectedFile.getParentFile(); - expectedFolder.mkdirs(); - if (!expectedFolder.isDirectory() || !fileToMove.renameTo(expectedFile)) { - mFile.setStoragePath(null); // forget the local file - // by now, treat this as a success; the file was - // uploaded; the user won't like that the local file - // is not linked, but this should be a very rare - // fail; - // the best option could be show a warning message - // (but not a fail) - // result = new - // RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_MOVED); - // return result; - } + if (mCancellationRequested.get()) { + throw new OperationCancelledException(); + } + - result = mUploadOperation.execute(client); - + /// move local temporal file or original file to its corresponding + // location in the ownCloud local folder + if (result.isSuccess()) { + if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_FORGET) { + mFile.setStoragePath(null); - ++ } else if (mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_REMOVE){ ++ mFile.setStoragePath(null); ++ originalFile.delete(); + } else { + mFile.setStoragePath(expectedPath); + File fileToMove = null; + if (temporalFile != null) { // FileUploader.LOCAL_BEHAVIOUR_COPY + // ; see where temporalFile was + // set + fileToMove = temporalFile; + } else { // FileUploader.LOCAL_BEHAVIOUR_MOVE + fileToMove = originalFile; + } + if (!expectedFile.equals(fileToMove)) { + File expectedFolder = expectedFile.getParentFile(); + expectedFolder.mkdirs(); + if (!expectedFolder.isDirectory() || !fileToMove.renameTo(expectedFile)) { + mFile.setStoragePath(null); // forget the local file + // by now, treat this as a success; the file was + // uploaded; the user won't like that the local file + // is not linked, but this should be a very rare + // fail; + // the best option could be show a warning message + // (but not a fail) + // result = new + // RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_MOVED); + // return result; } } - FileDataStorageManager.triggerMediaScan(originalFile.getAbsolutePath()); - FileDataStorageManager.triggerMediaScan(expectedFile.getAbsolutePath()); } - ++ FileDataStorageManager.triggerMediaScan(originalFile.getAbsolutePath()); ++ FileDataStorageManager.triggerMediaScan(expectedFile.getAbsolutePath()); + } else if (result.getHttpCode() == HttpStatus.SC_PRECONDITION_FAILED ) { + result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT); } } catch (Exception e) {