Merge remote-tracking branch 'remotes/upstream/setAsWallpaper' into beta
authortobiasKaminsky <tobias@kaminsky.me>
Sat, 21 Nov 2015 09:03:07 +0000 (10:03 +0100)
committertobiasKaminsky <tobias@kaminsky.me>
Sat, 21 Nov 2015 09:03:07 +0000 (10:03 +0100)
1  2 
res/values/strings.xml
src/com/owncloud/android/files/FileOperationsHelper.java

diff --combined res/values/strings.xml
@@@ -23,7 -23,8 +23,7 @@@
      <!-- TODO re-enable when "Accounts" is available in Navigation Drawer -->
      <!--<string name="drawer_item_accounts">Accounts</string>-->
      <string name="drawer_item_all_files">All files</string>
 -    <!-- TODO re-enable when "On Device" is available
 -    <string name="drawer_item_on_device">On device</string>-->
 +    <string name="drawer_item_on_device">On device</string>
      <string name="drawer_item_settings">Settings</string>
      <string name="drawer_item_logs">Logs</string>
        <string name="drawer_close">Close</string>
@@@ -61,7 -62,7 +61,7 @@@
      <string name="setup_btn_connect">Connect</string>
      <string name="uploader_btn_upload_text">Upload</string>
      <string name="uploader_btn_new_folder_text">New folder</string>
 -    <string name="uploader_top_message">Choose upload folder:</string>
 +    <string name="uploader_top_message">Choose upload folder</string>
      <string name="uploader_wrn_no_account_title">No account found</string>
      <string name="uploader_wrn_no_account_text">There are no %1$s accounts on your device. Please setup an account first.</string>
      <string name="uploader_wrn_no_account_setup_btn_text">Setup</string>
@@@ -86,7 -87,6 +86,7 @@@
      <string name="list_layout">List Layout</string>
      <string name="action_share_file">Share link</string>
      <string name="action_unshare_file">Unshare link</string>
 +    <string name="action_share_with_users">Share with users</string>
      <string name="common_yes">Yes</string>
      <string name="common_no">No</string>
      <string name="common_ok">OK</string>
      <string name="unfavorite">Unfavorite</string>
      <string name="common_rename">Rename</string>
      <string name="common_remove">Remove</string>
 -    <string name="confirmation_remove_alert">"Do you really want to remove %1$s?"</string>
 +    <string name="confirmation_remove_file_alert">"Do you really want to remove %1$s?"</string>
      <string name="confirmation_remove_folder_alert">"Do you really want to remove %1$s and its contents?"</string>
      <string name="confirmation_remove_local">Local only</string>
      <string name="confirmation_remove_folder_local">Local only</string>
 -    <string name="confirmation_remove_remote">From server</string>
 +    <string name="confirmation_remove_file_remote">From server</string>
      <string name="confirmation_remove_remote_and_local">Remote &amp; local</string>
      <string name="remove_success_msg">"Removal succeeded"</string>
      <string name="remove_fail_msg">"Removal failed"</string>
      <string name="ssl_validator_label_validity_to">To:</string>
      <string name="ssl_validator_label_signature">Signature:</string>
      <string name="ssl_validator_label_signature_algorithm">Algorithm:</string>
 +    <string name="digest_algorithm_not_available">This digest algorithm is not available on your phone.</string>
 +    <string name="ssl_validator_label_certificate_fingerprint">Fingerprint:</string>
 +    <string name="certificate_load_problem">There is a problem loading the certificate.</string>
      <string name="ssl_validator_null_cert">The certificate could not be shown.</string>
      <string name="ssl_validator_no_info_about_error">- No information about the error</string>
  
      <string name="placeholder_filesize">389 KB</string>
      <string name="placeholder_timestamp">2012/05/18 12:23 PM</string>
      <string name="placeholder_media_time">12:23:45</string>
 -
 -    <string name="instant_upload_on_wifi">Upload pictures via WiFi only</string>
 -    <string name="instant_video_upload_on_wifi">Upload videos via WiFi only</string>
 +    
 +    <string name="instant_upload_on_wifi">Upload pictures via wifi only</string>
 +    <string name="instant_upload_on_charging">Upload when charging only</string>
 +    <string name="instant_video_upload_on_wifi">Upload videos via wifi only</string>
 +    <string name="instant_video_upload_on_charging">Upload when charging only</string>
      <string name="instant_upload_path">/InstantUpload</string>
      <string name="conflict_title">File conflict</string>
      <string name="conflict_message">Which files do you want to keep? If you select both versions, the local file will have a number added to its name.</string>
      <string name="preview_image_error_unknown_format">This image cannot be shown</string>
  
      <string name="error__upload__local_file_not_copied">%1$s could not be copied to %2$s local folder</string>
 -    <string name="prefs_instant_upload_path_title">Upload Path</string>
 +    <string name="prefs_instant_upload_path_title">Upload path</string>
  
        <string name="share_link_no_support_share_api">Sorry, sharing is not enabled on your server. Please contact your
                administrator.</string>
      <string name="uploader_upload_forbidden_permissions">to upload in this folder</string>
      <string name="downloader_download_file_not_found">The file is no longer available on the server</string>
  
 +    <string name="file_migration_finish_button">Finish</string>
 +    <string name="file_migration_preparing">Preparing for migration...</string>
 +    <string name="file_migration_checking_destination">Checking destination...</string>
 +    <string name="file_migration_saving_accounts_configuration">Saving accounts configuration...</string>
 +    <string name="file_migration_waiting_for_unfinished_sync">Waiting for unfinished synchronizations...</string>
 +    <string name="file_migration_migrating">Moving data...</string>
 +    <string name="file_migration_updating_index">Updating index...</string>
 +    <string name="file_migration_cleaning">Cleaning...</string>
 +    <string name="file_migration_restoring_accounts_configuration">Restoring accounts configuration...</string>
 +    <string name="file_migration_ok_finished">Finished</string>
 +    <string name="file_migration_failed_not_enough_space">ERROR: Not enough space</string>
 +    <string name="file_migration_failed_not_writable">ERROR: File is not writable</string>
 +    <string name="file_migration_failed_not_readable">ERROR: File is not readable</string>
 +    <string name="file_migration_failed_dir_already_exists">ERROR: owncloud directory already exists</string>
 +    <string name="file_migration_failed_while_coping">ERROR: While migrating</string>
 +    <string name="file_migration_failed_while_updating_index">ERROR: While updating index</string>
 +
      <string name="prefs_category_accounts">Accounts</string>
      <string name="prefs_add_account">Add account</string>
      <string name="auth_redirect_non_secure_connection_title">Secure connection is redirected through an unsecured route.</string>
      <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>
      
 -      <string name="subject_token">%1$s shared \"%2$s\" with you</string>
 -    <string name="saml_subject_token">\"%1$s\" has been shared with you</string>
 +      <string name="subject_user_shared_with_you">%1$s shared \"%2$s\" with you</string>
 +    <string name="subject_shared_with_you">\"%1$s\" has been shared with you</string>
  
      <string name="auth_refresh_button">Refresh connection</string>
      <string name="auth_host_address">Server address</string>
      <string name="file_list__footer__files">%1$d files</string>
      <string name="file_list__footer__files_and_folder">%1$d files, 1 folder</string>
      <string name="file_list__footer__files_and_folders">%1$d files, %2$d folders</string>
 +    <string name="action_switch_grid_view">Switch to grid view</string>
 +    <string name="action_switch_list_view">Switch to list view</string>
 +    <string name="common_category">Common</string>
 +    <string name="pref_cache_size">Cache size</string>
 +    <string name="prefs_instant_behaviour_dialogTitle">Upload file to server and ...</string>
 +    <string name="prefs_instant_behaviour_title">Behaviour</string>
 +    <string name="upload_copy_files">Copy file</string>
 +    <string name="upload_move_files">Move file</string>
 +    <string name="prefs_storage_path">Storage path</string>
 +    <string name="prefs_common">Common</string>
 +
 +    <string name="pref_behaviour_entries_do_nothing">do nothing</string>
 +    <string name="pref_behaviour_entries_copy">copy file to OC folder</string>
 +    <string name="pref_behaviour_entries_move">move file to OC folder</string>
 +    <string name="pref_behaviour_entries_delete">delete origin file</string>
 +    <string name="confirmation_remove_files_alert">Do you really want to remove selected items?</string>
 +    <string name="confirmation_remove_folders_alert">Do you really want to remove a folder and its content?</string>
 +    <string name="confirmation_remove_files">selected items</string>
 +    <string name="error_log_exit">Exit</string>
 +    <string name="error_log_send">Send Log</string>
 +    <string name="error_log_title">Error Log</string>
 +    <string name="action_stream_file">Stream file with external player</string>
 +    <string name="stream_expose_password">Do you want to stream this file with an external app?\n\nCAUTION: This may expose your password!</string>
      <string name="set_picture_as">Set picture as</string>
+     <string name="set_as">Set As</string>
  
 +    <string name="share_dialog_title">Sharing</string>
 +    <string name="share_with_user_section_title">Share with Users and Groups</string>
 +    <string name="share_no_users">No data shared with users yet</string>
 +    <string name="share_add_user_or_group">Add User or Group</string>
 +    <string name="share_search">Search</string>
 +
 +    <string name="search_users_and_groups_hint">Search users and groups</string>
 +    <string name="share_group_clarification">%1$s (group)</string>
 +
 +    <string name="share_sharee_unavailable">Sorry, your server version does not allow share with users within clients.
 +        \nPlease contact your administrator</string>
 +    <string name="changelog">https://github.com/owncloud/android/raw/beta/CHANGELOG.md</string>
 +
  </resources>
@@@ -25,31 -25,24 +25,31 @@@ import android.accounts.Account
  import android.content.ActivityNotFoundException;
  import android.content.Context;
  import android.content.Intent;
 +import android.graphics.Bitmap;
  import android.content.pm.PackageManager;
  import android.content.pm.ResolveInfo;
 +import android.graphics.Bitmap;
  import android.net.Uri;
  import android.support.v4.app.DialogFragment;
  import android.webkit.MimeTypeMap;
  import android.widget.Toast;
  
 +import com.owncloud.android.MainApp;
  import com.owncloud.android.R;
  import com.owncloud.android.authentication.AccountUtils;
  import com.owncloud.android.datamodel.OCFile;
 +import com.owncloud.android.datamodel.ThumbnailsCacheManager;
  import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
  import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
  import com.owncloud.android.lib.common.network.WebdavUtils;
  import com.owncloud.android.lib.common.utils.Log_OC;
 +import com.owncloud.android.lib.resources.shares.ShareType;
  import com.owncloud.android.lib.resources.status.OwnCloudVersion;
  import com.owncloud.android.services.OperationsService;
  import com.owncloud.android.services.observer.FileObserverService;
  import com.owncloud.android.ui.activity.FileActivity;
 +import com.owncloud.android.ui.adapter.DiskLruImageCacheFileProvider;
 +import com.owncloud.android.ui.activity.ShareActivity;
  import com.owncloud.android.ui.dialog.ShareLinkToDialog;
  
  import org.apache.http.protocol.HTTP;
  import java.io.File;
  import java.util.List;
  
 +import java.io.ByteArrayOutputStream;
 +import java.io.File;
 +import java.io.FileNotFoundException;
 +import java.io.FileOutputStream;
 +import java.io.IOException;
 +
 +import org.apache.http.protocol.HTTP;
 +
 +import java.util.ArrayList;
 +import java.util.List;
 +
  /**
   *
   */
@@@ -93,8 -75,7 +93,8 @@@ public class FileOperationsHelper 
              String encodedStoragePath = WebdavUtils.encodePath(storagePath);
  
              Intent intentForSavedMimeType = new Intent(Intent.ACTION_VIEW);
 -            intentForSavedMimeType.setDataAndType(Uri.parse("file://"+ encodedStoragePath), file.getMimetype());
 +            intentForSavedMimeType.setDataAndType(Uri.parse("file://"+ encodedStoragePath),
 +                    file.getMimetype());
              intentForSavedMimeType.setFlags(
                      Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
              );
                  );
                  if (guessedMimeType != null && !guessedMimeType.equals(file.getMimetype())) {
                      intentForGuessedMimeType = new Intent(Intent.ACTION_VIEW);
 -                    intentForGuessedMimeType.setDataAndType(Uri.parse("file://"+ encodedStoragePath), guessedMimeType);
 +                    intentForGuessedMimeType.
 +                            setDataAndType(Uri.parse("file://"+ encodedStoragePath),
 +                                    guessedMimeType);
                      intentForGuessedMimeType.setFlags(
 -                            Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION
 +                            Intent.FLAG_GRANT_READ_URI_PERMISSION |
 +                                    Intent.FLAG_GRANT_WRITE_URI_PERMISSION
                      );
                  }
              }
                  String link = "https://fake.url";
                  Intent intent = createShareWithLinkIntent(link);
                  String[] packagesToExclude = new String[]{mFileActivity.getPackageName()};
 -                DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intent, packagesToExclude, file);
 +                DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intent,
 +                        packagesToExclude, file);
                  chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
  
              } else {
          } else {
              // Show a Message
              Toast t = Toast.makeText(
 -                    mFileActivity, mFileActivity.getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG
 +                    mFileActivity, mFileActivity.getString(R.string.share_link_no_support_share_api),
 +                    Toast.LENGTH_LONG
              );
              t.show();
          }
      public void shareFileWithLinkToApp(OCFile file, String password, Intent sendIntent) {
          
          if (file != null) {
 -            mFileActivity.showLoadingDialog();
 +            mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
 +                    getString(R.string.wait_a_moment));
  
              Intent service = new Intent(mFileActivity, OperationsService.class);
 -            service.setAction(OperationsService.ACTION_CREATE_SHARE);
 +            service.setAction(OperationsService.ACTION_CREATE_SHARE_VIA_LINK);
              service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
              service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
              service.putExtra(OperationsService.EXTRA_PASSWORD_SHARE, password);
  
  
      /**
 +     * Helper method to share a file with a know sharee. Starts a request to do it in {@link OperationsService}
 +     *
 +     * @param file          The file to share.
 +     * @param shareeName    Name (user name or group name) of the target sharee.
 +     * @param shareType     The share type determines the sharee type.
 +     */
 +    public void shareFileWithSharee(OCFile file, String shareeName, ShareType shareType) {
 +        if (file != null) {
 +            // TODO check capability?
 +            mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
 +                    getString(R.string.wait_a_moment));
 +
 +            Intent service = new Intent(mFileActivity, OperationsService.class);
 +            service.setAction(OperationsService.ACTION_CREATE_SHARE_WITH_SHAREE);
 +            service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
 +            service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
 +            service.putExtra(OperationsService.EXTRA_SHARE_WITH, shareeName);
 +            service.putExtra(OperationsService.EXTRA_SHARE_TYPE, shareType);
 +            mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
 +
 +        } else {
 +            Log_OC.wtf(TAG, "Trying to share a NULL OCFile");
 +        }
 +    }
 +
 +
 +    /**
       * @return 'True' if the server supports the Share API
       */
      public boolean isSharedSupported() {
  
      public void unshareFileWithLink(OCFile file) {
  
 +        // Unshare the file: Create the intent
 +        Intent unshareService = new Intent(mFileActivity, OperationsService.class);
 +        unshareService.setAction(OperationsService.ACTION_UNSHARE);
 +        unshareService.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
 +        unshareService.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
 +        unshareService.putExtra(OperationsService.EXTRA_SHARE_TYPE, ShareType.PUBLIC_LINK);
 +        unshareService.putExtra(OperationsService.EXTRA_SHARE_WITH, "");
 +
 +        unshareFile(unshareService);
 +    }
 +
 +    public void unshareFileWithUserOrGroup(OCFile file, ShareType shareType, String userOrGroup){
 +
 +        // Unshare the file: Create the intent
 +        Intent unshareService = new Intent(mFileActivity, OperationsService.class);
 +        unshareService.setAction(OperationsService.ACTION_UNSHARE);
 +        unshareService.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
 +        unshareService.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
 +        unshareService.putExtra(OperationsService.EXTRA_SHARE_TYPE, shareType);
 +        unshareService.putExtra(OperationsService.EXTRA_SHARE_WITH, userOrGroup);
 +
 +        unshareFile(unshareService);
 +    }
 +
 +
 +    private void unshareFile(Intent unshareService){
          if (isSharedSupported()) {
              // Unshare the file
 -            Intent service = new Intent(mFileActivity, OperationsService.class);
 -            service.setAction(OperationsService.ACTION_UNSHARE);
 -            service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
 -            service.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
 -            mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
 -            
 -            mFileActivity.showLoadingDialog();
 +            mWaitingForOpId = mFileActivity.getOperationsServiceBinder().
 +                    queueNewOperation(unshareService);
 +
 +            mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
 +                    getString(R.string.wait_a_moment));
  
          } else {
              // Show a Message
 -            Toast t = Toast.makeText(mFileActivity, mFileActivity.getString(R.string.share_link_no_support_share_api), Toast.LENGTH_LONG);
 +            Toast t = Toast.makeText(mFileActivity,
 +                    mFileActivity.getString(R.string.share_link_no_support_share_api),
 +                    Toast.LENGTH_LONG);
              t.show();
  
          }
      }
  
 +    /**
 +     * Show an instance of {@link ShareType} for sharing or unsharing the {@OCFile} received as parameter.
 +     *
 +     * @param file  File to share or unshare.
 +     */
 +    public void showShareFile(OCFile file){
 +        Intent intent = new Intent(mFileActivity, ShareActivity.class);
 +        intent.putExtra(mFileActivity.EXTRA_FILE, file);
 +        intent.putExtra(mFileActivity.EXTRA_ACCOUNT, mFileActivity.getAccount());
 +        mFileActivity.startActivity(intent);
 +
 +    }
 +
 +
 +    /**
 +     * @return 'True' if the server supports the Search Users API
 +     */
 +    public boolean isSearchUsersSupportedSupported() {
 +        if (mFileActivity.getAccount() != null) {
 +            OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mFileActivity.getAccount());
 +            return (serverVersion != null && serverVersion.isSearchUsersSupported());
 +        }
 +        return false;
 +    }
 +
      public void sendDownloadedFile(OCFile file) {
          if (file != null) {
              String storagePath = file.getStoragePath();
  
              // Show dialog, without the own app
              String[] packagesToExclude = new String[]{mFileActivity.getPackageName()};
 -            DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude, file);
 +            DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent,
 +                    packagesToExclude, file);
              chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
  
          } else {
                  Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
                  intent.setDataAndType(sendUri, file.getMimetype());
                  intent.putExtra("mimeType", file.getMimetype());
-                 mFileActivity.startActivityForResult(Intent.createChooser(intent, "Set As"), 200);
+                 mFileActivity.startActivityForResult(Intent.createChooser(intent,
+                                                     mFileActivity.getString(R.string.set_as)), 200);
              } else {
 -//                 TODO re-enable after resized images is available
 -//                Uri sendUri = Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + file.getRemotePath());
 -//                Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
 -//                intent.setDataAndType(sendUri, file.getMimetype());
 -//                intent.putExtra("mimeType", file.getMimetype());
 -//                mFileActivity.startActivityForResult(Intent.createChooser(intent, "Set As"), 200);
 +                // TODO re-enable after resized images is available
 +                Uri sendUri = Uri.parse("content://" + DiskLruImageCacheFileProvider.AUTHORITY + file.getRemotePath());
 +                Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
 +                intent.setDataAndType(sendUri, file.getMimetype());
 +                intent.putExtra("mimeType", file.getMimetype());
 +                mFileActivity.startActivityForResult(Intent.createChooser(intent, "Set As"), 200);
 +
 +//                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 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.
       *
              intent.putExtra(OperationsService.EXTRA_REMOTE_PATH, file.getRemotePath());
              intent.putExtra(OperationsService.EXTRA_SYNC_FILE_CONTENTS, true);
              mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(intent);
 -            mFileActivity.showLoadingDialog();
 +            mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
 +                    getString(R.string.wait_a_moment));
              
          } else {
              Intent intent = new Intent(mFileActivity, OperationsService.class);
          }
      }
  
 +    public void toggleFavorites(ArrayList<OCFile> files, boolean isFavorite){
 +        for (OCFile file: files) {
 +            toggleFavorite(file, isFavorite);
 +        }
 +    }
 +
      public void toggleFavorite(OCFile file, boolean isFavorite) {
          file.setFavorite(isFavorite);
          mFileActivity.getStorageManager().saveFile(file);
          service.putExtra(OperationsService.EXTRA_NEWNAME, newFilename);
          mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
          
 -        mFileActivity.showLoadingDialog();
 +        mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
 +                getString(R.string.wait_a_moment));
      }
  
  
          service.putExtra(OperationsService.EXTRA_REMOVE_ONLY_LOCAL, onlyLocalCopy);
          mWaitingForOpId =  mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
          
 -        mFileActivity.showLoadingDialog();
 +        mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
 +                getString(R.string.wait_a_moment));
      }
  
  
          service.putExtra(OperationsService.EXTRA_CREATE_FULL_PATH, createFullPath);
          mWaitingForOpId =  mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
          
 -        mFileActivity.showLoadingDialog();
 +        mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
 +                getString(R.string.wait_a_moment));
      }
  
      /**
      public void cancelTransference(OCFile file) {
          Account account = mFileActivity.getAccount();
          if (file.isFolder()) {
 -            OperationsService.OperationsServiceBinder opsBinder = mFileActivity.getOperationsServiceBinder();
 +            OperationsService.OperationsServiceBinder opsBinder =
 +                    mFileActivity.getOperationsServiceBinder();
              if (opsBinder != null) {
                  opsBinder.cancel(account, file);
              }
          service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
          mWaitingForOpId =  mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
  
 -        mFileActivity.showLoadingDialog();
 +        // TODO Tobi loading dialog?
 +//        mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
 +//                getString(R.string.wait_a_moment));
      }
  
      /**
          service.putExtra(OperationsService.EXTRA_ACCOUNT, mFileActivity.getAccount());
          mWaitingForOpId = mFileActivity.getOperationsServiceBinder().queueNewOperation(service);
  
 -        mFileActivity.showLoadingDialog();
 +        mFileActivity.showLoadingDialog(mFileActivity.getApplicationContext().
 +                getString(R.string.wait_a_moment));
      }
  
      public long getOpIdWaitingFor() {
       */
      public boolean isVersionWithForbiddenCharacters() {
          if (mFileActivity.getAccount() != null) {
 -            OwnCloudVersion serverVersion = AccountUtils.getServerVersion(mFileActivity.getAccount());
 +            OwnCloudVersion serverVersion =
 +                    AccountUtils.getServerVersion(mFileActivity.getAccount());
              return (serverVersion != null && serverVersion.isVersionWithForbiddenCharacters());
          }
          return false;