Merge remote-tracking branch 'remotes/upstream/master' into beta
authortobiasKaminsky <tobias@kaminsky.me>
Sat, 31 Oct 2015 07:48:10 +0000 (08:48 +0100)
committertobiasKaminsky <tobias@kaminsky.me>
Sat, 31 Oct 2015 07:48:10 +0000 (08:48 +0100)
63 files changed:
1  2 
owncloud-android-library
res/menu/file_actions_menu.xml
res/values-ar/strings.xml
res/values-az/strings.xml
res/values-bg-rBG/strings.xml
res/values-bn-rBD/strings.xml
res/values-ca/strings.xml
res/values-cs-rCZ/strings.xml
res/values-da/strings.xml
res/values-de-rDE/strings.xml
res/values-de/strings.xml
res/values-el/strings.xml
res/values-en-rGB/strings.xml
res/values-eo/strings.xml
res/values-es-rAR/strings.xml
res/values-es-rCL/strings.xml
res/values-es/strings.xml
res/values-et-rEE/strings.xml
res/values-eu/strings.xml
res/values-fi-rFI/strings.xml
res/values-fr/strings.xml
res/values-gl/strings.xml
res/values-he/strings.xml
res/values-hu-rHU/strings.xml
res/values-id/strings.xml
res/values-it/strings.xml
res/values-ja-rJP/strings.xml
res/values-ko/strings.xml
res/values-lb/strings.xml
res/values-lt-rLT/strings.xml
res/values-mk/strings.xml
res/values-nb-rNO/strings.xml
res/values-nl/strings.xml
res/values-oc/strings.xml
res/values-pl/strings.xml
res/values-pt-rBR/strings.xml
res/values-pt-rPT/strings.xml
res/values-ro/strings.xml
res/values-ru/strings.xml
res/values-sk-rSK/strings.xml
res/values-sl/strings.xml
res/values-sr/strings.xml
res/values-sv/strings.xml
res/values-th-rTH/strings.xml
res/values-tr/strings.xml
res/values-uk/strings.xml
res/values-zh-rCN/strings.xml
res/values-zh-rTW/strings.xml
res/values/strings.xml
src/com/owncloud/android/datamodel/FileDataStorageManager.java
src/com/owncloud/android/datamodel/OCFile.java
src/com/owncloud/android/files/FileMenuFilter.java
src/com/owncloud/android/files/FileOperationsHelper.java
src/com/owncloud/android/files/services/FileUploader.java
src/com/owncloud/android/operations/RefreshFolderOperation.java
src/com/owncloud/android/operations/SynchronizeFolderOperation.java
src/com/owncloud/android/operations/UploadFileOperation.java
src/com/owncloud/android/ui/activity/FileDisplayActivity.java
src/com/owncloud/android/ui/adapter/FileListListAdapter.java
src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java
src/com/owncloud/android/ui/fragment/OCFileListFragment.java
src/com/owncloud/android/utils/DisplayUtils.java
src/com/owncloud/android/utils/FileStorageUtils.java

@@@ -1,1 -1,1 +1,1 @@@
- Subproject commit 652cd28bb15672eaedfe8c1d9a46cf293c909b89
 -Subproject commit f02dffb1d3c46305c70d246f696cde7b8c3b0971
++Subproject commit 59fb61601de4dd8bfcab1afb619e016e1a7b904d
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
      <string name="prefs_category_instant_uploading">Instant Uploads</string>
        <string name="prefs_category_security">Security</string>
  
 -      <string name="prefs_instant_video_upload_path_title">Upload Video Path</string>
 +      <string name="prefs_instant_video_upload_path_title">Upload video path</string>
 +    <string name="download_folder_failed_content">Download of %1$s folder could not be completed</string>
+     <string name="sync_folder_failed_content">Synchronization of %1$s folder could not be completed</string>
  
        <string name="shared_subject_header">shared</string>
        <string name="with_you_subject_header">with you</string>
@@@ -1485,47 -1414,9 +1409,9 @@@ 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());
-             } catch (RemoteException e) {
-                 Log_OC.e(TAG, "Exception in batch of operations  " + e.getMessage());
-             }
-         }            
-         */
-             
-             /*
-             if (getContentResolver() != null) {
-                 
-                 getContentResolver().delete(ProviderTableMeta.CONTENT_URI_SHARE, 
-                                             where,
-                                             whereArgs);
-             } else {
-                 try {
-                     getContentProviderClient().delete(  ProviderTableMeta.CONTENT_URI_SHARE, 
-                                                         where,
-                                                         whereArgs);
-                 } catch (RemoteException e) {
-                     Log_OC.e(TAG, "Exception deleting shares in a folder " + e.getMessage());
-                 }
-             }
-             */
-         //}
      }
  
 -    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);
@@@ -72,8 -74,8 +72,10 @@@ public class OCFile implements Parcelab
  
      private boolean mIsDownloading;
  
 +    private boolean mShowGridView;
 +
+     private String mEtagInConflict;    // Save file etag in the server, when there is a conflict. No conflict =  null
  
      /**
       * Create new {@link OCFile} with given path.
@@@ -248,32 -236,13 +248,37 @@@ public class FileOperationsHelper 
          }
      }
  
 +    public void sendCachedImage(OCFile file) {
 +        if (file != null) {
 +            Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
 +            // set MimeType
 +            sendIntent.setType(file.getMimetype());
 +//            sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + "/#" + file.getRemoteId() + "#" + file.getFileName()));
 +            sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + file.getRemotePath()));
 +            sendIntent.putExtra(Intent.ACTION_SEND, true);      // Send Action
 +
 +            // Show dialog, without the own app
 +            String[] packagesToExclude = new String[] { mFileActivity.getPackageName() };
 +            DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude, file);
 +            chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
 +        } else {
 +            Log_OC.wtf(TAG, "Trying to send a NULL OCFile");
 +        }
 +    }
 +
 +    public void syncFiles(ArrayList<OCFile> files) {
 +        for (OCFile file: files) {
 +            syncFile(file);
 +        }
 +    }
 +
+     /**
+      * Request the synchronization of a file or folder with the OC server, including its contents.
+      *
+      * @param file          The file or folder to synchronize
+      */
      public void syncFile(OCFile file) {
-         if (!file.isFolder()) {
+         if (!file.isFolder()){
              Intent intent = new Intent(mFileActivity, OperationsService.class);
              intent.setAction(OperationsService.ACTION_SYNC_FILE);
              intent.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
@@@ -201,8 -195,14 +195,14 @@@ public class RefreshFolderOperation ext
              if (mRemoteFolderChanged) {
                  result = fetchAndSyncRemoteFolder(client);
              } else {
 -                mChildren = mStorageManager.getFolderContent(mLocalFolder/*, false*/);
+                 fetchFavoritesToSyncFromLocalData();
 +                mChildren = mStorageManager.getFolderContent(mLocalFolder, false);
              }
+             if (result.isSuccess()) {
+                 // request for the synchronization of KEPT-IN-SYNC file contents
+                 startContentSynchronizations(mFilesToSyncContents, client);
+             }
          }
          
          if (!mSyncFullAccount) {            
                  + " changed - starting update of local data ");
          
          List<OCFile> updatedFiles = new Vector<OCFile>(folderAndFiles.size() - 1);
-         List<SynchronizeFileOperation> filesToSyncContents = new Vector<SynchronizeFileOperation>();
+         mFilesToSyncContents.clear();
  
          // get current data about local contents of the folder to synchronize
 -        // TODO Enable when "On Device" is recovered ?
 -        List<OCFile> localFiles = mStorageManager.getFolderContent(mLocalFolder/*, false*/);
 +        List<OCFile> localFiles = mStorageManager.getFolderContent(mLocalFolder, false);
          Map<String, OCFile> localFilesMap = new HashMap<String, OCFile>(localFiles.size());
          for (OCFile file : localFiles) {
              localFilesMap.put(file.getRemotePath(), file);
      }
  
  
-     public boolean getRemoteFolderChanged() {
-         return mRemoteFolderChanged;
+     private void fetchFavoritesToSyncFromLocalData() {
 -        List<OCFile> children = mStorageManager.getFolderContent(mLocalFolder);
++        List<OCFile> children = mStorageManager.getFolderContent(mLocalFolder, false);
+         for (OCFile child : children) {
+             if (!child.isFolder() && child.isFavorite()) {
+                 SynchronizeFileOperation operation = new SynchronizeFileOperation(
+                         child,
+                         child,  // cheating with the remote file to get an update to server; to refactor
+                         mAccount,
+                         true,
+                         mContext
+                 );
+                 mFilesToSyncContents.add(operation);
+             }
+         }
      }
  
  }
@@@ -322,47 -320,48 +321,50 @@@ 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 {
+                     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());
                  }
+             } else if (result.getHttpCode() == HttpStatus.SC_PRECONDITION_FAILED ) {
+                 result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT);
              }
  
          } catch (Exception e) {
@@@ -546,122 -334,85 +546,121 @@@ public class OCFileListFragment extend
          }
      }
  
 -    /**
 -     * {@inheritDoc}
 -     */
 -    @Override
 -    public boolean onFileActionChosen(int menuId, int filePosition) {
 -        mTargetFile = (OCFile) mAdapter.getItem(filePosition);
 -        switch (menuId) {
 -            case R.id.action_share_file: {
 -                mContainerActivity.getFileOperationsHelper().shareFileWithLink(mTargetFile);
 -                return true;
 -            }
 -            case R.id.action_open_file_with: {
 -                mContainerActivity.getFileOperationsHelper().openFile(mTargetFile);
 -                return true;
 -            }
 -            case R.id.action_unshare_file: {
 -                mContainerActivity.getFileOperationsHelper().unshareFileWithLink(mTargetFile);
 -                return true;
 -            }
 -            case R.id.action_rename_file: {
 -                RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(mTargetFile);
 -                dialog.show(getFragmentManager(), FileDetailFragment.FTAG_RENAME_FILE);
 -                return true;
 -            }
 -            case R.id.action_remove_file: {
 -                RemoveFileDialogFragment dialog = RemoveFileDialogFragment.newInstance(mTargetFile);
 -                dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
 -                return true;
 -            }
 -            case R.id.action_download_file:
 -            case R.id.action_sync_file: {
 -                mContainerActivity.getFileOperationsHelper().syncFile(mTargetFile);
 -                return true;
 -            }
 -            case R.id.action_cancel_sync: {
 -                ((FileDisplayActivity)mContainerActivity).cancelTransference(mTargetFile);
 -                return true;
 -            }
 -            case R.id.action_see_details: {
 -                mContainerActivity.showDetails(mTargetFile);
 -                return true;
 -            }
 -            case R.id.action_send_file: {
 -                // Obtain the file
 -                if (!mTargetFile.isDown()) {  // Download the file
 -                    Log_OC.d(TAG, mTargetFile.getRemotePath() + " : File must be downloaded");
 -                    ((FileDisplayActivity) mContainerActivity).startDownloadForSending(mTargetFile);
 +    public boolean onFileActionChosen(int menuId) {
 +        if (mAdapter.getCheckedItems().size() == 1){
 +            OCFile mTargetFile = mAdapter.getCheckedItems().get(0);
  
 -                } else {
 -                    mContainerActivity.getFileOperationsHelper().sendDownloadedFile(mTargetFile);
 +            switch (menuId) {
 +                case R.id.action_share_file: {
 +                    mContainerActivity.getFileOperationsHelper().shareFileWithLink(mTargetFile);
 +                    return true;
                  }
 -                return true;
 -            }
 -            case R.id.action_move: {
 -                Intent action = new Intent(getActivity(), FolderPickerActivity.class);
 +                case R.id.action_open_file_with: {
 +                    mContainerActivity.getFileOperationsHelper().openFile(mTargetFile);
 +                    return true;
 +                }
 +                case R.id.action_unshare_file: {
 +                    mContainerActivity.getFileOperationsHelper().unshareFileWithLink(mTargetFile);
 +                    return true;
 +                }
 +                case R.id.action_rename_file: {
 +                    RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(mTargetFile);
 +                    dialog.show(getFragmentManager(), FileDetailFragment.FTAG_RENAME_FILE);
 +                    return true;
 +                }
 +                case R.id.action_remove_file: {
 +                    RemoveFileDialogFragment dialog = RemoveFileDialogFragment.newInstance(mTargetFile);
 +                    dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
 +                    return true;
 +                }
 +                case R.id.action_download_file:
 +                case R.id.action_sync_file: {
 +                    mContainerActivity.getFileOperationsHelper().syncFile(mTargetFile);
 +                    return true;
 +                }
-                 case R.id.action_cancel_download:
-                 case R.id.action_cancel_upload: {
++                case R.id.action_cancel_sync: {
 +                    ((FileDisplayActivity) mContainerActivity).cancelTransference(mTargetFile);
 +                    return true;
 +                }
 +                case R.id.action_see_details: {
 +                    mContainerActivity.showDetails(mTargetFile);
 +                    return true;
 +                }
 +                case R.id.action_send_file: {
 +                    // Obtain the file
 +                    if (!mTargetFile.isDown()) {  // Download the file
 +                        Log_OC.d(TAG, mTargetFile.getRemotePath() + " : File must be downloaded");
 +                        ((FileDisplayActivity) mContainerActivity).startDownloadForSending(mTargetFile);
  
 -                // Pass mTargetFile that contains info of selected file/folder
 -                action.putExtra(FolderPickerActivity.EXTRA_FILE, mTargetFile);
 -                getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_MOVE_FILES);
 -                return true;
 -            }
 -            case R.id.action_favorite_file: {
 -                mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, true);
 -                return true;
 -            }
 -            case R.id.action_unfavorite_file: {
 -                mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, false);
 -                return true;
 +                    } else {
 +                        mContainerActivity.getFileOperationsHelper().sendDownloadedFile(mTargetFile);
 +                    }
 +                    return true;
 +                }
 +                case R.id.action_move: {
 +                    Intent action = new Intent(getActivity(), FolderPickerActivity.class);
 +                    ArrayList files = new ArrayList();
 +                    files.add(mTargetFile);
 +                    action.putParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES, files);
 +                    getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_MOVE_FILES);
 +                    return true;
 +                }
 +                case R.id.action_favorite_file: {
 +                    mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, true);
 +                    return true;
 +                }
 +                case R.id.action_unfavorite_file: {
 +                    mContainerActivity.getFileOperationsHelper().toggleFavorite(mTargetFile, false);
 +                    return true;
 +                }
 +                case R.id.action_copy:
 +                    Intent action = new Intent(getActivity(), FolderPickerActivity.class);
 +
 +                    // Pass mTargetFile that contains info of selected file/folder
 +                    action.putExtra(FolderPickerActivity.EXTRA_FILE, mTargetFile);
 +                    getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_COPY_FILES);
 +                    return true;
 +                default:
 +                    return false;
              }
 -            case R.id.action_copy:
 -                Intent action = new Intent(getActivity(), FolderPickerActivity.class);
 +        } else {
 +            ArrayList<OCFile> mTargetFiles = mAdapter.getCheckedItems();
  
 -                // Pass mTargetFile that contains info of selected file/folder
 -                action.putExtra(FolderPickerActivity.EXTRA_FILE, mTargetFile);
 -                getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_COPY_FILES);
 -                return true;
 -            default:
 -                return false;
 +            switch (menuId) {
 +                case R.id.action_remove_file: {
 +                    RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(mTargetFiles);
 +                    dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
 +                    return true;
 +                }
 +                case R.id.action_download_file:
 +                case R.id.action_sync_file: {
 +                    mContainerActivity.getFileOperationsHelper().syncFiles(mTargetFiles);
 +                    return true;
 +                }
 +                case R.id.action_move: {
 +                    Intent action = new Intent(getActivity(), FolderPickerActivity.class);
 +                    action.putParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES, mTargetFiles);
 +                    getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_MOVE_FILES);
 +                    return true;
 +                }
 +                case R.id.action_favorite_file: {
 +                    mContainerActivity.getFileOperationsHelper().toggleFavorites(mTargetFiles, true);
 +                    return true;
 +                }
 +                case R.id.action_unfavorite_file: {
 +                    mContainerActivity.getFileOperationsHelper().toggleFavorites(mTargetFiles, false);
 +                    return true;
 +                }
 +                case R.id.action_copy:
 +                    Intent action = new Intent(getActivity(), FolderPickerActivity.class);
 +                    action.putParcelableArrayListExtra(FolderPickerActivity.EXTRA_FILES, mTargetFiles);
 +                    getActivity().startActivityForResult(action, FileDisplayActivity.ACTION_COPY_FILES);
 +                    return true;
 +                default:
 +                    return false;
 +            }
          }
 +
      }
      
      /**