Fixes the last reported bugs
authorJorge Antonio Diaz-Benito Soriano <jorge.diazbenitosoriano@gmail.com>
Mon, 17 Aug 2015 16:10:21 +0000 (18:10 +0200)
committerDavid A. Velasco <dvelasco@solidgear.es>
Tue, 18 Aug 2015 16:05:20 +0000 (18:05 +0200)
src/com/owncloud/android/files/FileMenuFilter.java
src/com/owncloud/android/operations/CopyFileOperation.java
src/com/owncloud/android/ui/fragment/FileDetailFragment.java
src/com/owncloud/android/ui/preview/FileDownloadFragment.java
src/com/owncloud/android/ui/preview/PreviewImageFragment.java
src/com/owncloud/android/ui/preview/PreviewMediaFragment.java
src/com/owncloud/android/utils/ErrorMessageAdapter.java

index 2c2754c..f7fee62 100644 (file)
@@ -39,7 +39,7 @@ import com.owncloud.android.services.OperationsService.OperationsServiceBinder;
 import com.owncloud.android.ui.activity.ComponentsGetter;
 
 /**
 import com.owncloud.android.ui.activity.ComponentsGetter;
 
 /**
- * Filters out the file actions available in a given {@link Menu} for a given {@link OCFile} 
+ * Filters out the file actions available in a given {@link Menu} for a given {@link OCFile}
  * according to the current state of the latest. 
  */
 public class FileMenuFilter {
  * according to the current state of the latest. 
  */
 public class FileMenuFilter {
@@ -48,10 +48,10 @@ public class FileMenuFilter {
     private ComponentsGetter mComponentsGetter;
     private Account mAccount;
     private Context mContext;
     private ComponentsGetter mComponentsGetter;
     private Account mAccount;
     private Context mContext;
-    
+
     /**
      * Constructor
     /**
      * Constructor
-     * 
+     *
      * @param targetFile        {@link OCFile} target of the action to filter in the {@link Menu}.
      * @param account           ownCloud {@link Account} holding targetFile.
      * @param cg                Accessor to app components, needed to access the
      * @param targetFile        {@link OCFile} target of the action to filter in the {@link Menu}.
      * @param account           ownCloud {@link Account} holding targetFile.
      * @param cg                Accessor to app components, needed to access the
@@ -64,20 +64,20 @@ public class FileMenuFilter {
         mComponentsGetter = cg;
         mContext = context;
     }
         mComponentsGetter = cg;
         mContext = context;
     }
-    
-    
+
+
     /**
      * Filters out the file actions available in the passed {@link Menu} taken into account
      * the state of the {@link OCFile} held by the filter.
     /**
      * Filters out the file actions available in the passed {@link Menu} taken into account
      * the state of the {@link OCFile} held by the filter.
-     *  
+     *
      * @param menu              Options or context menu to filter.
      */
     public void filter(Menu menu) {
      * @param menu              Options or context menu to filter.
      */
     public void filter(Menu menu) {
-        List<Integer> toShow = new ArrayList<Integer>();  
-        List<Integer> toHide = new ArrayList<Integer>();    
-        
+        List<Integer> toShow = new ArrayList<Integer>();
+        List<Integer> toHide = new ArrayList<Integer>();
+
         filter(toShow, toHide);
         filter(toShow, toHide);
-        
+
         MenuItem item = null;
         for (int i : toShow) {
             item = menu.findItem(i);
         MenuItem item = null;
         for (int i : toShow) {
             item = menu.findItem(i);
@@ -86,7 +86,7 @@ public class FileMenuFilter {
                 item.setEnabled(true);
             }
         }
                 item.setEnabled(true);
             }
         }
-        
+
         for (int i : toHide) {
             item = menu.findItem(i);
             if (item != null) {
         for (int i : toHide) {
             item = menu.findItem(i);
             if (item != null) {
@@ -99,10 +99,10 @@ public class FileMenuFilter {
 
     /**
      * Performs the real filtering, to be applied in the {@link Menu} by the caller methods.
 
     /**
      * Performs the real filtering, to be applied in the {@link Menu} by the caller methods.
-     * 
+     *
      * Decides what actions must be shown and hidden.
      * Decides what actions must be shown and hidden.
-     *  
-     * @param toShow            List to save the options that must be shown in the menu. 
+     *
+     * @param toShow            List to save the options that must be shown in the menu.
      * @param toHide            List to save the options that must be shown in the menu.
      */
     private void filter(List<Integer> toShow, List <Integer> toHide) {
      * @param toHide            List to save the options that must be shown in the menu.
      */
     private void filter(List<Integer> toShow, List <Integer> toHide) {
@@ -116,71 +116,72 @@ public class FileMenuFilter {
             FileUploaderBinder uploaderBinder = mComponentsGetter.getFileUploaderBinder();
             uploading = (uploaderBinder != null && uploaderBinder.isUploading(mAccount, mFile));
         }
             FileUploaderBinder uploaderBinder = mComponentsGetter.getFileUploaderBinder();
             uploading = (uploaderBinder != null && uploaderBinder.isUploading(mAccount, mFile));
         }
-        
+
         /// decision is taken for each possible action on a file in the menu
         /// decision is taken for each possible action on a file in the menu
-        
+
         // DOWNLOAD 
         if (mFile == null || mFile.isDown() || downloading || uploading) {
             toHide.add(R.id.action_download_file);
         // DOWNLOAD 
         if (mFile == null || mFile.isDown() || downloading || uploading) {
             toHide.add(R.id.action_download_file);
-            
+
         } else {
             toShow.add(R.id.action_download_file);
         }
         } else {
             toShow.add(R.id.action_download_file);
         }
-        
+
         // RENAME
         if (mFile == null || downloading || uploading) {
             toHide.add(R.id.action_rename_file);
         // RENAME
         if (mFile == null || downloading || uploading) {
             toHide.add(R.id.action_rename_file);
-            
+
         } else {
             toShow.add(R.id.action_rename_file);
         }
 
         } else {
             toShow.add(R.id.action_rename_file);
         }
 
-        // MOVE
+        // MOVE & COPY
         if (mFile == null || downloading || uploading) {
             toHide.add(R.id.action_move);
         if (mFile == null || downloading || uploading) {
             toHide.add(R.id.action_move);
-
+            toHide.add(R.id.action_copy);
         } else {
             toShow.add(R.id.action_move);
         } else {
             toShow.add(R.id.action_move);
+            toShow.add(R.id.action_copy);
         }
         }
-        
+
         // REMOVE
         if (mFile == null || downloading || uploading) {
             toHide.add(R.id.action_remove_file);
         // REMOVE
         if (mFile == null || downloading || uploading) {
             toHide.add(R.id.action_remove_file);
-            
+
         } else {
             toShow.add(R.id.action_remove_file);
         }
         } else {
             toShow.add(R.id.action_remove_file);
         }
-        
+
         // OPEN WITH (different to preview!)
         if (mFile == null || mFile.isFolder() || !mFile.isDown() || downloading || uploading) {
             toHide.add(R.id.action_open_file_with);
         // OPEN WITH (different to preview!)
         if (mFile == null || mFile.isFolder() || !mFile.isDown() || downloading || uploading) {
             toHide.add(R.id.action_open_file_with);
-            
+
         } else {
             toShow.add(R.id.action_open_file_with);
         }
         } else {
             toShow.add(R.id.action_open_file_with);
         }
-        
-        
+
+
         // CANCEL DOWNLOAD
         if (mFile == null || !downloading) {
             toHide.add(R.id.action_cancel_download);
         } else {
             toShow.add(R.id.action_cancel_download);
         }
         // CANCEL DOWNLOAD
         if (mFile == null || !downloading) {
             toHide.add(R.id.action_cancel_download);
         } else {
             toShow.add(R.id.action_cancel_download);
         }
-        
+
         // CANCEL UPLOAD
         if (mFile == null || !uploading || mFile.isFolder()) {
             toHide.add(R.id.action_cancel_upload);
         } else {
             toShow.add(R.id.action_cancel_upload);
         }
         // CANCEL UPLOAD
         if (mFile == null || !uploading || mFile.isFolder()) {
             toHide.add(R.id.action_cancel_upload);
         } else {
             toShow.add(R.id.action_cancel_upload);
         }
-        
+
         // SYNC FILE CONTENTS
         if (mFile == null || mFile.isFolder() || !mFile.isDown() || downloading || uploading) {
             toHide.add(R.id.action_sync_file);
         } else {
             toShow.add(R.id.action_sync_file);
         }
         // SYNC FILE CONTENTS
         if (mFile == null || mFile.isFolder() || !mFile.isDown() || downloading || uploading) {
             toHide.add(R.id.action_sync_file);
         } else {
             toShow.add(R.id.action_sync_file);
         }
-        
+
         // SHARE FILE 
         // TODO add check on SHARE available on server side?
         boolean shareAllowed = (mContext != null  &&
         // SHARE FILE 
         // TODO add check on SHARE available on server side?
         boolean shareAllowed = (mContext != null  &&
@@ -190,7 +191,7 @@ public class FileMenuFilter {
         } else {
             toShow.add(R.id.action_share_file);
         }
         } else {
             toShow.add(R.id.action_share_file);
         }
-        
+
         // UNSHARE FILE  
         // TODO add check on SHARE available on server side?
         if ( !shareAllowed || (mFile == null || !mFile.isShareByLink())) {
         // UNSHARE FILE  
         // TODO add check on SHARE available on server side?
         if ( !shareAllowed || (mFile == null || !mFile.isShareByLink())) {
@@ -205,7 +206,7 @@ public class FileMenuFilter {
         } else {
             toShow.add(R.id.action_see_details);
         }
         } else {
             toShow.add(R.id.action_see_details);
         }
-        
+
         // SEND
         boolean sendAllowed = (mContext != null &&
                 mContext.getString(R.string.send_files_to_other_apps).equalsIgnoreCase("on"));
         // SEND
         boolean sendAllowed = (mContext != null &&
                 mContext.getString(R.string.send_files_to_other_apps).equalsIgnoreCase("on"));
index 77d2458..77a9a07 100644 (file)
@@ -71,7 +71,7 @@ public class CopyFileOperation extends SyncOperation {
 
         /// 1. check copy validity
         if (mTargetParentPath.startsWith(mSrcPath)) {
 
         /// 1. check copy validity
         if (mTargetParentPath.startsWith(mSrcPath)) {
-            return new RemoteOperationResult(ResultCode.INVALID_MOVE_INTO_DESCENDANT);
+            return new RemoteOperationResult(ResultCode.INVALID_COPY_INTO_DESCENDANT);
         }
         mFile = getStorageManager().getFileByPath(mSrcPath);
         if (mFile == null) {
         }
         mFile = getStorageManager().getFileByPath(mSrcPath);
         if (mFile == null) {
index 9916a3d..b5fce44 100644 (file)
  */
 package com.owncloud.android.ui.fragment;
 
  */
 package com.owncloud.android.ui.fragment;
 
-import java.lang.ref.WeakReference;
-
 import android.accounts.Account;
 import android.accounts.Account;
-import android.content.Intent;
 import android.os.Bundle;
 import android.view.LayoutInflater;
 import android.view.Menu;
 import android.os.Bundle;
 import android.view.LayoutInflater;
 import android.view.Menu;
@@ -46,13 +43,14 @@ import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
 import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
 import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
 import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
 import com.owncloud.android.lib.common.utils.Log_OC;
-import com.owncloud.android.services.observer.FileObserverService;
 import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDisplayActivity;
 import com.owncloud.android.ui.dialog.RemoveFileDialogFragment;
 import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
 import com.owncloud.android.utils.DisplayUtils;
 
 import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDisplayActivity;
 import com.owncloud.android.ui.dialog.RemoveFileDialogFragment;
 import com.owncloud.android.ui.dialog.RenameFileDialogFragment;
 import com.owncloud.android.utils.DisplayUtils;
 
+import java.lang.ref.WeakReference;
+
 
 /**
  * This Fragment is used to display the details about a file.
 
 /**
  * This Fragment is used to display the details about a file.
@@ -62,9 +60,9 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
     private int mLayout;
     private View mView;
     private Account mAccount;
     private int mLayout;
     private View mView;
     private Account mAccount;
-    
+
     public ProgressListener mProgressListener;
     public ProgressListener mProgressListener;
-    
+
     private static final String TAG = FileDetailFragment.class.getSimpleName();
     public static final String FTAG_CONFIRMATION = "REMOVE_CONFIRMATION_FRAGMENT";
     public static final String FTAG_RENAME_FILE = "RENAME_FILE_FRAGMENT";
     private static final String TAG = FileDetailFragment.class.getSimpleName();
     public static final String FTAG_CONFIRMATION = "REMOVE_CONFIRMATION_FRAGMENT";
     public static final String FTAG_RENAME_FILE = "RENAME_FILE_FRAGMENT";
@@ -103,14 +101,14 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
         mLayout = R.layout.file_details_empty;
         mProgressListener = null;
     }
         mLayout = R.layout.file_details_empty;
         mProgressListener = null;
     }
-    
+
 
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setHasOptionsMenu(true);
     }
 
     @Override
     public void onActivityCreated(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setHasOptionsMenu(true);
     }
-    
+
 
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
 
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -120,14 +118,14 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
         mAccount = getArguments().getParcelable(ARG_ACCOUNT);
 
         if (savedInstanceState != null) {
         mAccount = getArguments().getParcelable(ARG_ACCOUNT);
 
         if (savedInstanceState != null) {
-            setFile((OCFile)savedInstanceState.getParcelable(FileActivity.EXTRA_FILE));
+            setFile((OCFile) savedInstanceState.getParcelable(FileActivity.EXTRA_FILE));
             mAccount = savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT);
         }
             mAccount = savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT);
         }
-        
-        if(getFile() != null && mAccount != null) {
+
+        if (getFile() != null && mAccount != null) {
             mLayout = R.layout.file_details_fragment;
         }
             mLayout = R.layout.file_details_fragment;
         }
-        
+
         mView = inflater.inflate(mLayout, null);
         
         if (mLayout == R.layout.file_details_fragment) {
         mView = inflater.inflate(mLayout, null);
         
         if (mLayout == R.layout.file_details_fragment) {
@@ -153,20 +151,20 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
         super.onStart();
         listenForTransferProgress();
     }
         super.onStart();
         listenForTransferProgress();
     }
-    
+
     @Override
     public void onStop() {
         leaveTransferProgress();
         super.onStop();
     }
 
     @Override
     public void onStop() {
         leaveTransferProgress();
         super.onStop();
     }
 
-    
+
     @Override
     public View getView() {
         return super.getView() == null ? mView : super.getView();
     }
 
     @Override
     public View getView() {
         return super.getView() == null ? mView : super.getView();
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
     /**
      * {@inheritDoc}
      */
@@ -174,16 +172,16 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
         super.onCreateOptionsMenu(menu, inflater);
         inflater.inflate(R.menu.file_actions_menu, menu);
     public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
         super.onCreateOptionsMenu(menu, inflater);
         inflater.inflate(R.menu.file_actions_menu, menu);
-   }
+    }
+
 
 
-    
     /**
      * {@inheritDoc}
      */
     @Override
     /**
      * {@inheritDoc}
      */
     @Override
-    public void onPrepareOptionsMenu (Menu menu) {
+    public void onPrepareOptionsMenu(Menu menu) {
         super.onPrepareOptionsMenu(menu);
         super.onPrepareOptionsMenu(menu);
-        
+
         if (mContainerActivity.getStorageManager() != null) {
             FileMenuFilter mf = new FileMenuFilter(
                 getFile(),
         if (mContainerActivity.getStorageManager() != null) {
             FileMenuFilter mf = new FileMenuFilter(
                 getFile(),
@@ -193,7 +191,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
             );
             mf.filter(menu);
         }
             );
             mf.filter(menu);
         }
-        
+
         // additional restriction for this fragment 
         MenuItem item = menu.findItem(R.id.action_see_details);
         if (item != null) {
         // additional restriction for this fragment 
         MenuItem item = menu.findItem(R.id.action_see_details);
         if (item != null) {
@@ -207,9 +205,16 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
             item.setVisible(false);
             item.setEnabled(false);
         }
             item.setVisible(false);
             item.setEnabled(false);
         }
+
+        // additional restriction for this fragment
+        item = menu.findItem(R.id.action_copy);
+        if (item != null) {
+            item.setVisible(false);
+            item.setEnabled(false);
+        }
     }
 
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
     /**
      * {@inheritDoc}
      */
@@ -240,10 +245,10 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
             }
             case R.id.action_cancel_download:
             case R.id.action_cancel_upload: {
             }
             case R.id.action_cancel_download:
             case R.id.action_cancel_upload: {
-                ((FileDisplayActivity)mContainerActivity).cancelTransference(getFile());
+                ((FileDisplayActivity) mContainerActivity).cancelTransference(getFile());
                 return true;
             }
                 return true;
             }
-            case R.id.action_download_file: 
+            case R.id.action_download_file:
             case R.id.action_sync_file: {
                 mContainerActivity.getFileOperationsHelper().syncFile(getFile());
                 return true;
             case R.id.action_sync_file: {
                 mContainerActivity.getFileOperationsHelper().syncFile(getFile());
                 return true;
@@ -252,9 +257,10 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
                 // Obtain the file
                 if (!getFile().isDown()) {  // Download the file                    
                     Log_OC.d(TAG, getFile().getRemotePath() + " : File must be downloaded");
                 // Obtain the file
                 if (!getFile().isDown()) {  // Download the file                    
                     Log_OC.d(TAG, getFile().getRemotePath() + " : File must be downloaded");
-                    ((FileDisplayActivity)mContainerActivity).startDownloadForSending(getFile());
-                    
-                } else {
+                    ((FileDisplayActivity) mContainerActivity).startDownloadForSending(getFile());
+
+                }
+                else {
                     mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile());
                 }
                 return true;
                     mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile());
                 }
                 return true;
@@ -281,7 +287,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
                 break;
             }
             case R.id.fdCancelBtn: {
                 break;
             }
             case R.id.fdCancelBtn: {
-                ((FileDisplayActivity)mContainerActivity).cancelTransference(getFile());
+                ((FileDisplayActivity) mContainerActivity).cancelTransference(getFile());
                 break;
             }
             default:
                 break;
             }
             default:
@@ -292,17 +298,17 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
 
     /**
      * Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be replaced.
 
     /**
      * Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be replaced.
-     * 
-     * @return  True when the fragment was created with the empty layout.
+     *
+     * @return True when the fragment was created with the empty layout.
      */
     public boolean isEmpty() {
         return (mLayout == R.layout.file_details_empty || getFile() == null || mAccount == null);
     }
 
      */
     public boolean isEmpty() {
         return (mLayout == R.layout.file_details_empty || getFile() == null || mAccount == null);
     }
 
-    
+
     /**
      * Use this method to signal this Activity that it shall update its view.
     /**
      * Use this method to signal this Activity that it shall update its view.
-     * 
+     *
      * @param file : An {@link OCFile}
      */
     public void updateFileDetails(OCFile file, Account ocAccount) {
      * @param file : An {@link OCFile}
      */
     public void updateFileDetails(OCFile file, Account ocAccount) {
@@ -313,14 +319,13 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
 
     /**
      * Updates the view with all relevant details about that file.
 
     /**
      * Updates the view with all relevant details about that file.
+     * <p/>
+     * TODO Remove parameter when the transferring state of files is kept in database.
      *
      *
-     * TODO Remove parameter when the transferring state of files is kept in database. 
-     * 
-     * @param transferring      Flag signaling if the file should be considered as downloading or uploading, 
-     *                          although {@link FileDownloaderBinder#isDownloading(Account, OCFile)}  and 
-     *                          {@link FileUploaderBinder#isUploading(Account, OCFile)} return false.
-     *                          
-     * @param refresh           If 'true', try to refresh the whole file from the database
+     * @param transferring Flag signaling if the file should be considered as downloading or uploading,
+     *                     although {@link FileDownloaderBinder#isDownloading(Account, OCFile)}  and
+     *                     {@link FileUploaderBinder#isUploading(Account, OCFile)} return false.
+     * @param refresh      If 'true', try to refresh the whole file from the database
      */
     public void updateFileDetails(boolean transferring, boolean refresh) {
         if (readyToShow()) {
      */
     public void updateFileDetails(boolean transferring, boolean refresh) {
         if (readyToShow()) {
@@ -329,7 +334,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
                 setFile(storageManager.getFileByPath(getFile().getRemotePath()));
             }
             OCFile file = getFile();
                 setFile(storageManager.getFileByPath(getFile().getRemotePath()));
             }
             OCFile file = getFile();
-            
+
             // set file details
             setFilename(file.getFileName());
             setFiletype(file.getMimetype(), file.getFileName());
             // set file details
             setFilename(file.getFileName());
             setFiletype(file.getMimetype(), file.getFileName());
@@ -348,7 +353,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
                     (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file))
                     ) {
                 setButtonsForTransferring();
                     (uploaderBinder != null && uploaderBinder.isUploading(mAccount, file))
                     ) {
                 setButtonsForTransferring();
-                
+
             } else if (file.isDown()) {
                 
                 setButtonsForDown();
             } else if (file.isDown()) {
                 
                 setButtonsForDown();
@@ -361,25 +366,27 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
         }
         getView().invalidate();
     }
         }
         getView().invalidate();
     }
-    
+
     /**
      * Checks if the fragment is ready to show details of a OCFile
     /**
      * Checks if the fragment is ready to show details of a OCFile
-     *  
-     * @return  'True' when the fragment is ready to show details of a file
+     *
+     * @return 'True' when the fragment is ready to show details of a file
      */
     private boolean readyToShow() {
      */
     private boolean readyToShow() {
-        return (getFile() != null && mAccount != null && mLayout == R.layout.file_details_fragment);        
+        return (getFile() != null && mAccount != null && mLayout == R.layout.file_details_fragment);
     }
 
 
     /**
      * Updates the filename in view
     }
 
 
     /**
      * Updates the filename in view
+     *
      * @param filename to set
      */
     private void setFilename(String filename) {
         TextView tv = (TextView) getView().findViewById(R.id.fdFilename);
      * @param filename to set
      */
     private void setFilename(String filename) {
         TextView tv = (TextView) getView().findViewById(R.id.fdFilename);
-        if (tv != null)
+        if (tv != null) {
             tv.setText(filename);
             tv.setText(filename);
+        }
     }
 
     /**
     }
 
     /**
@@ -401,25 +408,28 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
 
     /**
      * Updates the file size in view
 
     /**
      * Updates the file size in view
+     *
      * @param filesize in bytes to set
      */
     private void setFilesize(long filesize) {
         TextView tv = (TextView) getView().findViewById(R.id.fdSize);
      * @param filesize in bytes to set
      */
     private void setFilesize(long filesize) {
         TextView tv = (TextView) getView().findViewById(R.id.fdSize);
-        if (tv != null)
+        if (tv != null) {
             tv.setText(DisplayUtils.bytesToHumanReadable(filesize));
             tv.setText(DisplayUtils.bytesToHumanReadable(filesize));
+        }
     }
     }
-    
+
     /**
      * Updates the time that the file was last modified
     /**
      * Updates the time that the file was last modified
+     *
      * @param milliseconds Unix time to set
      */
      * @param milliseconds Unix time to set
      */
-    private void setTimeModified(long milliseconds){
+    private void setTimeModified(long milliseconds) {
         TextView tv = (TextView) getView().findViewById(R.id.fdModified);
         TextView tv = (TextView) getView().findViewById(R.id.fdModified);
-        if(tv != null){
+        if (tv != null) {
             tv.setText(DisplayUtils.unixTimeToHumanReadable(milliseconds));
         }
     }
             tv.setText(DisplayUtils.unixTimeToHumanReadable(milliseconds));
         }
     }
-    
+
     /**
      * Enables or disables buttons for a file being downloaded
      */
     /**
      * Enables or disables buttons for a file being downloaded
      */
@@ -430,21 +440,24 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
             
             // show the progress bar for the transfer
             getView().findViewById(R.id.fdProgressBlock).setVisibility(View.VISIBLE);
             
             // show the progress bar for the transfer
             getView().findViewById(R.id.fdProgressBlock).setVisibility(View.VISIBLE);
-            TextView progressText = (TextView)getView().findViewById(R.id.fdProgressText);
+            TextView progressText = (TextView) getView().findViewById(R.id.fdProgressText);
             progressText.setVisibility(View.VISIBLE);
             FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
             FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
             //if (getFile().isDownloading()) {
             if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, getFile())) {
                 progressText.setText(R.string.downloader_download_in_progress_ticker);
             progressText.setVisibility(View.VISIBLE);
             FileDownloaderBinder downloaderBinder = mContainerActivity.getFileDownloaderBinder();
             FileUploaderBinder uploaderBinder = mContainerActivity.getFileUploaderBinder();
             //if (getFile().isDownloading()) {
             if (downloaderBinder != null && downloaderBinder.isDownloading(mAccount, getFile())) {
                 progressText.setText(R.string.downloader_download_in_progress_ticker);
-            } else if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, getFile())) {
-                progressText.setText(R.string.uploader_upload_in_progress_ticker);
+            }
+            else {
+                if (uploaderBinder != null && uploaderBinder.isUploading(mAccount, getFile())) {
+                    progressText.setText(R.string.uploader_upload_in_progress_ticker);
+                }
             }
         }
     }
 
     /**
             }
         }
     }
 
     /**
-     * Enables or disables buttons for a file locally available 
+     * Enables or disables buttons for a file locally available
      */
     private void setButtonsForDown() {
         if (!isEmpty()) {
      */
     private void setButtonsForDown() {
         if (!isEmpty()) {
@@ -452,13 +465,13 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
             
             // hides the progress bar
             getView().findViewById(R.id.fdProgressBlock).setVisibility(View.GONE);
             
             // hides the progress bar
             getView().findViewById(R.id.fdProgressBlock).setVisibility(View.GONE);
-            TextView progressText = (TextView)getView().findViewById(R.id.fdProgressText);
+            TextView progressText = (TextView) getView().findViewById(R.id.fdProgressText);
             progressText.setVisibility(View.GONE);
         }
     }
 
     /**
             progressText.setVisibility(View.GONE);
         }
     }
 
     /**
-     * Enables or disables buttons for a file not locally available 
+     * Enables or disables buttons for a file not locally available
      */
     private void setButtonsForRemote() {
         if (!isEmpty()) {
      */
     private void setButtonsForRemote() {
         if (!isEmpty()) {
@@ -466,11 +479,11 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
             
             // hides the progress bar
             getView().findViewById(R.id.fdProgressBlock).setVisibility(View.GONE);
             
             // hides the progress bar
             getView().findViewById(R.id.fdProgressBlock).setVisibility(View.GONE);
-            TextView progressText = (TextView)getView().findViewById(R.id.fdProgressText);
+            TextView progressText = (TextView) getView().findViewById(R.id.fdProgressText);
             progressText.setVisibility(View.GONE);
         }
     }
             progressText.setVisibility(View.GONE);
         }
     }
-    
+
 
     public void listenForTransferProgress() {
         if (mProgressListener != null) {
 
     public void listenForTransferProgress() {
         if (mProgressListener != null) {
@@ -484,8 +497,8 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
             }
         }
     }
             }
         }
     }
-    
-    
+
+
     public void leaveTransferProgress() {
         if (mProgressListener != null) {
             if (mContainerActivity.getFileDownloaderBinder() != null) {
     public void leaveTransferProgress() {
         if (mProgressListener != null) {
             if (mContainerActivity.getFileDownloaderBinder() != null) {
@@ -500,7 +513,6 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
     }
 
 
     }
 
 
-    
     /**
      * Helper class responsible for updating the progress bar shown for file uploading or
      * downloading
     /**
      * Helper class responsible for updating the progress bar shown for file uploading or
      * downloading
@@ -508,11 +520,11 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
     private class ProgressListener implements OnDatatransferProgressListener {
         int mLastPercent = 0;
         WeakReference<ProgressBar> mProgressBar = null;
     private class ProgressListener implements OnDatatransferProgressListener {
         int mLastPercent = 0;
         WeakReference<ProgressBar> mProgressBar = null;
-        
+
         ProgressListener(ProgressBar progressBar) {
             mProgressBar = new WeakReference<ProgressBar>(progressBar);
         }
         ProgressListener(ProgressBar progressBar) {
             mProgressBar = new WeakReference<ProgressBar>(progressBar);
         }
-        
+
         @Override
         public void onTransferProgress(long progressRate, long totalTransferredSoFar,
                                        long totalToTransfer, String filename) {
         @Override
         public void onTransferProgress(long progressRate, long totalTransferredSoFar,
                                        long totalToTransfer, String filename) {
index 631a836..957d338 100644 (file)
@@ -36,8 +36,13 @@ import android.view.ViewGroup;
 import android.widget.ProgressBar;
 import android.widget.TextView;
 
 import android.widget.ProgressBar;
 import android.widget.TextView;
 
+import com.owncloud.android.R;
+import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
 import com.owncloud.android.lib.common.utils.Log_OC;
 import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
 import com.owncloud.android.lib.common.utils.Log_OC;
+import com.owncloud.android.ui.fragment.FileFragment;
+
+import java.lang.ref.WeakReference;
 
 
 /**
 
 
 /**
@@ -58,9 +63,9 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
 
     public ProgressListener mProgressListener;
     private boolean mListening;
 
     public ProgressListener mProgressListener;
     private boolean mListening;
-    
+
     private static final String TAG = FileDownloadFragment.class.getSimpleName();
     private static final String TAG = FileDownloadFragment.class.getSimpleName();
-    
+
     private boolean mIgnoreFirstSavedState;
     private boolean mError;
 
     private boolean mIgnoreFirstSavedState;
     private boolean mError;
 
@@ -117,30 +122,31 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
         mIgnoreFirstSavedState = args.getBoolean(ARG_IGNORE_FIRST);
         mAccount = args.getParcelable(ARG_ACCOUNT);
     }
         mIgnoreFirstSavedState = args.getBoolean(ARG_IGNORE_FIRST);
         mAccount = args.getParcelable(ARG_ACCOUNT);
     }
-    
+
 
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
 
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
-            Bundle savedInstanceState) {
+                             Bundle savedInstanceState) {
         super.onCreateView(inflater, container, savedInstanceState);
         super.onCreateView(inflater, container, savedInstanceState);
-        
+
         if (savedInstanceState != null) {
             if (!mIgnoreFirstSavedState) {
         if (savedInstanceState != null) {
             if (!mIgnoreFirstSavedState) {
-                setFile((OCFile)savedInstanceState.getParcelable(FileDownloadFragment.EXTRA_FILE));
+                setFile((OCFile) savedInstanceState.getParcelable(FileDownloadFragment.EXTRA_FILE));
                 mAccount = savedInstanceState.getParcelable(FileDownloadFragment.EXTRA_ACCOUNT);
                 mError = savedInstanceState.getBoolean(FileDownloadFragment.EXTRA_ERROR);
                 mAccount = savedInstanceState.getParcelable(FileDownloadFragment.EXTRA_ACCOUNT);
                 mError = savedInstanceState.getBoolean(FileDownloadFragment.EXTRA_ERROR);
-            } else {
+            }
+            else {
                 mIgnoreFirstSavedState = false;
             }
         }
                 mIgnoreFirstSavedState = false;
             }
         }
-        
+
         View view = null;
         view = inflater.inflate(R.layout.file_download_fragment, container, false);
         mView = view;
         View view = null;
         view = inflater.inflate(R.layout.file_download_fragment, container, false);
         mView = view;
-        
-        ProgressBar progressBar = (ProgressBar)mView.findViewById(R.id.progressBar);
+
+        ProgressBar progressBar = (ProgressBar) mView.findViewById(R.id.progressBar);
         mProgressListener = new ProgressListener(progressBar);
         mProgressListener = new ProgressListener(progressBar);
-        
+
         (mView.findViewById(R.id.cancelBtn)).setOnClickListener(this);
         
         (mView.findViewById(R.id.fileDownloadLL)).setOnClickListener(new OnClickListener() {
         (mView.findViewById(R.id.cancelBtn)).setOnClickListener(this);
         
         (mView.findViewById(R.id.fileDownloadLL)).setOnClickListener(new OnClickListener() {
@@ -152,13 +158,14 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
 
         if (mError) {
             setButtonsForRemote();
 
         if (mError) {
             setButtonsForRemote();
-        } else {
+        }
+        else {
             setButtonsForTransferring();
         }
             setButtonsForTransferring();
         }
-        
+
         return view;
     }
         return view;
     }
-    
+
 
     @Override
     public void onSaveInstanceState(Bundle outState) {
 
     @Override
     public void onSaveInstanceState(Bundle outState) {
@@ -173,7 +180,7 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
         super.onStart();
         listenForTransferProgress();
     }
         super.onStart();
         listenForTransferProgress();
     }
-    
+
     @Override
     public void onResume() {
         super.onResume();
     @Override
     public void onResume() {
         super.onResume();
@@ -185,19 +192,19 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
         super.onPause();
     }
 
         super.onPause();
     }
 
-    
+
     @Override
     public void onStop() {
         leaveTransferProgress();
         super.onStop();
     }
     @Override
     public void onStop() {
         leaveTransferProgress();
         super.onStop();
     }
-    
+
     @Override
     public void onDestroy() {
         super.onDestroy();
     }
     @Override
     public void onDestroy() {
         super.onDestroy();
     }
-    
-    
+
+
     @Override
     public View getView() {
         if (!mListening) {
     @Override
     public View getView() {
         if (!mListening) {
@@ -206,7 +213,7 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
         return super.getView() == null ? mView : super.getView();
     }
 
         return super.getView() == null ? mView : super.getView();
     }
 
-    
+
     @Override
     public void onClick(View v) {
         switch (v.getId()) {
     @Override
     public void onClick(View v) {
         switch (v.getId()) {
@@ -220,53 +227,52 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
         }
     }
 
         }
     }
 
-    
+
     /**
      * Enables or disables buttons for a file being downloaded
      */
     private void setButtonsForTransferring() {
         getView().findViewById(R.id.cancelBtn).setVisibility(View.VISIBLE);
     /**
      * Enables or disables buttons for a file being downloaded
      */
     private void setButtonsForTransferring() {
         getView().findViewById(R.id.cancelBtn).setVisibility(View.VISIBLE);
-    
+
         // show the progress bar for the transfer
         getView().findViewById(R.id.progressBar).setVisibility(View.VISIBLE);
         // show the progress bar for the transfer
         getView().findViewById(R.id.progressBar).setVisibility(View.VISIBLE);
-        TextView progressText = (TextView)getView().findViewById(R.id.progressText);
+        TextView progressText = (TextView) getView().findViewById(R.id.progressText);
         progressText.setText(R.string.downloader_download_in_progress_ticker);
         progressText.setVisibility(View.VISIBLE);
         progressText.setText(R.string.downloader_download_in_progress_ticker);
         progressText.setVisibility(View.VISIBLE);
-                
+
         // hides the error icon
         getView().findViewById(R.id.errorText).setVisibility(View.GONE);
         getView().findViewById(R.id.error_image).setVisibility(View.GONE);
     }
         // hides the error icon
         getView().findViewById(R.id.errorText).setVisibility(View.GONE);
         getView().findViewById(R.id.error_image).setVisibility(View.GONE);
     }
-    
 
     /**
 
     /**
-     * Enables or disables buttons for a file locally available 
+     * Enables or disables buttons for a file locally available
      */
     private void setButtonsForDown() {
         getView().findViewById(R.id.cancelBtn).setVisibility(View.GONE);
      */
     private void setButtonsForDown() {
         getView().findViewById(R.id.cancelBtn).setVisibility(View.GONE);
-    
+
         // hides the progress bar
         getView().findViewById(R.id.progressBar).setVisibility(View.GONE);
         // hides the progress bar
         getView().findViewById(R.id.progressBar).setVisibility(View.GONE);
-        
+
         // updates the text message
         // updates the text message
-        TextView progressText = (TextView)getView().findViewById(R.id.progressText);
+        TextView progressText = (TextView) getView().findViewById(R.id.progressText);
         progressText.setText(R.string.common_loading);
         progressText.setVisibility(View.VISIBLE);
         progressText.setText(R.string.common_loading);
         progressText.setVisibility(View.VISIBLE);
-        
+
         // hides the error icon
         getView().findViewById(R.id.errorText).setVisibility(View.GONE);
         getView().findViewById(R.id.error_image).setVisibility(View.GONE);
     }
 
         // hides the error icon
         getView().findViewById(R.id.errorText).setVisibility(View.GONE);
         getView().findViewById(R.id.error_image).setVisibility(View.GONE);
     }
 
-    
+
     /**
     /**
-     * Enables or disables buttons for a file not locally available 
-     * 
+     * Enables or disables buttons for a file not locally available
+     * <p/>
      * Currently, this is only used when a download was failed
      */
     private void setButtonsForRemote() {
         getView().findViewById(R.id.cancelBtn).setVisibility(View.GONE);
      * Currently, this is only used when a download was failed
      */
     private void setButtonsForRemote() {
         getView().findViewById(R.id.cancelBtn).setVisibility(View.GONE);
-        
+
         // hides the progress bar and message
         getView().findViewById(R.id.progressBar).setVisibility(View.GONE);
         getView().findViewById(R.id.progressText).setVisibility(View.GONE);
         // hides the progress bar and message
         getView().findViewById(R.id.progressBar).setVisibility(View.GONE);
         getView().findViewById(R.id.progressText).setVisibility(View.GONE);
@@ -275,7 +281,7 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
         getView().findViewById(R.id.errorText).setVisibility(View.VISIBLE);
         getView().findViewById(R.id.error_image).setVisibility(View.VISIBLE);
     }
         getView().findViewById(R.id.errorText).setVisibility(View.VISIBLE);
         getView().findViewById(R.id.error_image).setVisibility(View.VISIBLE);
     }
-    
+
 
     public void listenForTransferProgress() {
         if (mProgressListener != null && !mListening) {
 
     public void listenForTransferProgress() {
         if (mProgressListener != null && !mListening) {
@@ -288,8 +294,8 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
             }
         }
     }
             }
         }
     }
-    
-    
+
+
     public void leaveTransferProgress() {
         if (mProgressListener != null) {
             if (mContainerActivity.getFileDownloaderBinder() != null) {
     public void leaveTransferProgress() {
         if (mProgressListener != null) {
             if (mContainerActivity.getFileDownloaderBinder() != null) {
@@ -308,11 +314,11 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
     private class ProgressListener implements OnDatatransferProgressListener {
         int mLastPercent = 0;
         WeakReference<ProgressBar> mProgressBar = null;
     private class ProgressListener implements OnDatatransferProgressListener {
         int mLastPercent = 0;
         WeakReference<ProgressBar> mProgressBar = null;
-        
+
         ProgressListener(ProgressBar progressBar) {
             mProgressBar = new WeakReference<ProgressBar>(progressBar);
         }
         ProgressListener(ProgressBar progressBar) {
             mProgressBar = new WeakReference<ProgressBar>(progressBar);
         }
-        
+
         @Override
         public void onTransferProgress(
                 long progressRate, long totalTransferredSoFar, long totalToTransfer, String filename
         @Override
         public void onTransferProgress(
                 long progressRate, long totalTransferredSoFar, long totalToTransfer, String filename
@@ -333,8 +339,9 @@ public class FileDownloadFragment extends FileFragment implements OnClickListene
 
     public void setError(boolean error) {
         mError = error;
 
     public void setError(boolean error) {
         mError = error;
-    };
-    
+    }
+
+    ;
 
 
 }
 
 
 }
index 7ca1cfb..6dd1865 100644 (file)
@@ -74,11 +74,11 @@ public class PreviewImageFragment extends FileFragment {
     private ProgressBar mProgressWheel;
 
     public Bitmap mBitmap = null;
     private ProgressBar mProgressWheel;
 
     public Bitmap mBitmap = null;
-    
+
     private static final String TAG = PreviewImageFragment.class.getSimpleName();
 
     private boolean mIgnoreFirstSavedState;
     private static final String TAG = PreviewImageFragment.class.getSimpleName();
 
     private boolean mIgnoreFirstSavedState;
-    
+
     private LoadBitmapTask mLoadBitmapTask = null;
 
 
     private LoadBitmapTask mLoadBitmapTask = null;
 
 
@@ -105,7 +105,7 @@ public class PreviewImageFragment extends FileFragment {
         return frag;
     }
 
         return frag;
     }
 
-    
+
     
     /**
      *  Creates an empty fragment for image previews.
     
     /**
      *  Creates an empty fragment for image previews.
@@ -119,8 +119,8 @@ public class PreviewImageFragment extends FileFragment {
     public PreviewImageFragment() {
         mIgnoreFirstSavedState = false;
     }
     public PreviewImageFragment() {
         mIgnoreFirstSavedState = false;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
     /**
      * {@inheritDoc}
      */
@@ -135,14 +135,14 @@ public class PreviewImageFragment extends FileFragment {
         mIgnoreFirstSavedState = args.getBoolean(ARG_IGNORE_FIRST);
         setHasOptionsMenu(true);
     }
         mIgnoreFirstSavedState = args.getBoolean(ARG_IGNORE_FIRST);
         setHasOptionsMenu(true);
     }
-    
+
 
     /**
      * {@inheritDoc}
      */
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
 
     /**
      * {@inheritDoc}
      */
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
-            Bundle savedInstanceState) {
+                             Bundle savedInstanceState) {
         super.onCreateView(inflater, container, savedInstanceState);
         View view = inflater.inflate(R.layout.preview_image_fragment, container, false);
         mImageView = (TouchImageViewCustom) view.findViewById(R.id.image);
         super.onCreateView(inflater, container, savedInstanceState);
         View view = inflater.inflate(R.layout.preview_image_fragment, container, false);
         mImageView = (TouchImageViewCustom) view.findViewById(R.id.image);
@@ -182,7 +182,7 @@ public class PreviewImageFragment extends FileFragment {
             throw new IllegalStateException("There is no local file to preview");
         }
     }
             throw new IllegalStateException("There is no local file to preview");
         }
     }
-        
+
 
     /**
      * {@inheritDoc}
 
     /**
      * {@inheritDoc}
@@ -192,7 +192,7 @@ public class PreviewImageFragment extends FileFragment {
         super.onSaveInstanceState(outState);
         outState.putParcelable(PreviewImageFragment.EXTRA_FILE, getFile());
     }
         super.onSaveInstanceState(outState);
         outState.putParcelable(PreviewImageFragment.EXTRA_FILE, getFile());
     }
-    
+
 
     @Override
     public void onStart() {
 
     @Override
     public void onStart() {
@@ -203,8 +203,8 @@ public class PreviewImageFragment extends FileFragment {
             mLoadBitmapTask.execute(getFile().getStoragePath());
         }
     }
             mLoadBitmapTask.execute(getFile().getStoragePath());
         }
     }
-    
-    
+
+
     @Override
     public void onStop() {
         Log_OC.d(TAG, "onStop starts");
     @Override
     public void onStop() {
         Log_OC.d(TAG, "onStop starts");
@@ -214,7 +214,7 @@ public class PreviewImageFragment extends FileFragment {
         }
         super.onStop();
     }
         }
         super.onStop();
     }
-    
+
     /**
      * {@inheritDoc}
      */
     /**
      * {@inheritDoc}
      */
@@ -230,11 +230,11 @@ public class PreviewImageFragment extends FileFragment {
     @Override
     public void onPrepareOptionsMenu(Menu menu) {
         super.onPrepareOptionsMenu(menu);
     @Override
     public void onPrepareOptionsMenu(Menu menu) {
         super.onPrepareOptionsMenu(menu);
-        
+
         if (mContainerActivity.getStorageManager() != null) {
             // Update the file
             setFile(mContainerActivity.getStorageManager().getFileById(getFile().getFileId()));
         if (mContainerActivity.getStorageManager() != null) {
             // Update the file
             setFile(mContainerActivity.getStorageManager().getFileById(getFile().getFileId()));
-            
+
             FileMenuFilter mf = new FileMenuFilter(
                 getFile(),
                 mContainerActivity.getStorageManager().getAccount(),
             FileMenuFilter mf = new FileMenuFilter(
                 getFile(),
                 mContainerActivity.getStorageManager().getAccount(),
@@ -243,7 +243,7 @@ public class PreviewImageFragment extends FileFragment {
             );
             mf.filter(menu);
         }
             );
             mf.filter(menu);
         }
-        
+
         // additional restriction for this fragment 
         // TODO allow renaming in PreviewImageFragment
         MenuItem item = menu.findItem(R.id.action_rename_file);
         // additional restriction for this fragment 
         // TODO allow renaming in PreviewImageFragment
         MenuItem item = menu.findItem(R.id.action_rename_file);
@@ -251,7 +251,7 @@ public class PreviewImageFragment extends FileFragment {
             item.setVisible(false);
             item.setEnabled(false);
         }
             item.setVisible(false);
             item.setEnabled(false);
         }
-        
+
         // additional restriction for this fragment 
         // TODO allow refresh file in PreviewImageFragment
         item = menu.findItem(R.id.action_sync_file);
         // additional restriction for this fragment 
         // TODO allow refresh file in PreviewImageFragment
         item = menu.findItem(R.id.action_sync_file);
@@ -266,11 +266,17 @@ public class PreviewImageFragment extends FileFragment {
             item.setVisible(false);
             item.setEnabled(false);
         }
             item.setVisible(false);
             item.setEnabled(false);
         }
-        
+
+        // additional restriction for this fragment
+        item = menu.findItem(R.id.action_copy);
+        if (item != null) {
+            item.setVisible(false);
+            item.setEnabled(false);
+        }
+
     }
 
     }
 
-    
-    
+
     /**
      * {@inheritDoc}
      */
     /**
      * {@inheritDoc}
      */
@@ -318,10 +324,10 @@ public class PreviewImageFragment extends FileFragment {
                 return false;
         }
     }
                 return false;
         }
     }
-    
+
 
     private void seeDetails() {
 
     private void seeDetails() {
-        mContainerActivity.showDetails(getFile());        
+        mContainerActivity.showDetails(getFile());
     }
 
 
     }
 
 
@@ -348,7 +354,7 @@ public class PreviewImageFragment extends FileFragment {
         super.onDestroy();
     }
 
         super.onDestroy();
     }
 
-    
+
     /**
      * Opens the previewed image with an external application.
      */
     /**
      * Opens the previewed image with an external application.
      */
@@ -356,8 +362,8 @@ public class PreviewImageFragment extends FileFragment {
         mContainerActivity.getFileOperationsHelper().openFile(getFile());
         finish();
     }
         mContainerActivity.getFileOperationsHelper().openFile(getFile());
         finish();
     }
-    
-    
+
+
     private class LoadBitmapTask extends AsyncTask<String, Void, Bitmap> {
 
         /**
     private class LoadBitmapTask extends AsyncTask<String, Void, Bitmap> {
 
         /**
@@ -376,7 +382,7 @@ public class PreviewImageFragment extends FileFragment {
          */
         private final WeakReference<TextView> mMessageViewRef;
 
          */
         private final WeakReference<TextView> mMessageViewRef;
 
-        
+
         /**
          * Weak reference to the target {@link ProgressBar} shown while the load is in progress.
          * 
         /**
          * Weak reference to the target {@link ProgressBar} shown while the load is in progress.
          * 
@@ -385,17 +391,17 @@ public class PreviewImageFragment extends FileFragment {
          */
         private final WeakReference<ProgressBar> mProgressWheelRef;
 
          */
         private final WeakReference<ProgressBar> mProgressWheelRef;
 
-        
+
         /**
         /**
-         * Error message to show when a load fails 
+         * Error message to show when a load fails
          */
         private int mErrorMessageId;
          */
         private int mErrorMessageId;
-        
-        
+
+
         /**
          * Constructor.
         /**
          * Constructor.
-         * 
-         * @param imageView     Target {@link ImageView} where the bitmap will be loaded into.
+         *
+         * @param imageView Target {@link ImageView} where the bitmap will be loaded into.
          */
         public LoadBitmapTask(ImageViewCustom imageView, TextView messageView,
                               ProgressBar progressWheel) {
          */
         public LoadBitmapTask(ImageViewCustom imageView, TextView messageView,
                               ProgressBar progressWheel) {
@@ -403,8 +409,8 @@ public class PreviewImageFragment extends FileFragment {
             mMessageViewRef = new WeakReference<TextView>(messageView);
             mProgressWheelRef = new WeakReference<ProgressBar>(progressWheel);
         }
             mMessageViewRef = new WeakReference<TextView>(messageView);
             mProgressWheelRef = new WeakReference<ProgressBar>(progressWheel);
         }
-        
-        
+
+
         @Override
         protected Bitmap doInBackground(String... params) {
             Bitmap result = null;
         @Override
         protected Bitmap doInBackground(String... params) {
             Bitmap result = null;
@@ -454,18 +460,18 @@ public class PreviewImageFragment extends FileFragment {
 
             } catch (NoSuchFieldError e) {
                 mErrorMessageId = R.string.common_error_unknown;
 
             } catch (NoSuchFieldError e) {
                 mErrorMessageId = R.string.common_error_unknown;
-                Log_OC.e(TAG, "Error from access to unexisting field despite protection; file " 
-                                + storagePath, e);
-                    
+                Log_OC.e(TAG, "Error from access to unexisting field despite protection; file "
+                        + storagePath, e);
+
             } catch (Throwable t) {
                 mErrorMessageId = R.string.common_error_unknown;
                 Log_OC.e(TAG, "Unexpected error loading " + getFile().getStoragePath(), t);
             } catch (Throwable t) {
                 mErrorMessageId = R.string.common_error_unknown;
                 Log_OC.e(TAG, "Unexpected error loading " + getFile().getStoragePath(), t);
-                
+
             }
             }
-            
+
             return result;
         }
             return result;
         }
-        
+
         @Override
         protected void onCancelled(Bitmap result) {
             if (result != null) {
         @Override
         protected void onCancelled(Bitmap result) {
             if (result != null) {
@@ -478,7 +484,8 @@ public class PreviewImageFragment extends FileFragment {
             hideProgressWheel();
             if (result != null) {
                 showLoadedImage(result);
             hideProgressWheel();
             if (result != null) {
                 showLoadedImage(result);
-            } else {
+            }
+            else {
                 showErrorMessage();
             }
             if (result != null && mBitmap != result)  {
                 showErrorMessage();
             }
             if (result != null && mBitmap != result)  {
@@ -486,7 +493,7 @@ public class PreviewImageFragment extends FileFragment {
                 result.recycle();
             }
         }
                 result.recycle();
             }
         }
-        
+
         @SuppressLint("InlinedApi")
         private void showLoadedImage(Bitmap result) {
             final ImageViewCustom imageView = mImageViewRef.get();
         @SuppressLint("InlinedApi")
         private void showLoadedImage(Bitmap result) {
             final ImageViewCustom imageView = mImageViewRef.get();
@@ -503,7 +510,7 @@ public class PreviewImageFragment extends FileFragment {
                 messageView.setVisibility(View.GONE);
             } // else , silently finish, the fragment was destroyed
         }
                 messageView.setVisibility(View.GONE);
             } // else , silently finish, the fragment was destroyed
         }
-        
+
         private void showErrorMessage() {
             final ImageView imageView = mImageViewRef.get();
             if (imageView != null) {
         private void showErrorMessage() {
             final ImageView imageView = mImageViewRef.get();
             if (imageView != null) {
@@ -517,14 +524,14 @@ public class PreviewImageFragment extends FileFragment {
                 messageView.setVisibility(View.VISIBLE);
             } // else , silently finish, the fragment was destroyed
         }
                 messageView.setVisibility(View.VISIBLE);
             } // else , silently finish, the fragment was destroyed
         }
-        
+
         private void hideProgressWheel() {
             final ProgressBar progressWheel = mProgressWheelRef.get();
             if (progressWheel != null) {
                 progressWheel.setVisibility(View.GONE);
             }
         }
         private void hideProgressWheel() {
             final ProgressBar progressWheel = mProgressWheelRef.get();
             if (progressWheel != null) {
                 progressWheel.setVisibility(View.GONE);
             }
         }
-        
+
     }
 
     /**
     }
 
     /**
@@ -538,7 +545,7 @@ public class PreviewImageFragment extends FileFragment {
         return (file != null && file.isImage());
     }
 
         return (file != null && file.isImage());
     }
 
-    
+
     /**
      * Finishes the preview
      */
     /**
      * Finishes the preview
      */
@@ -546,7 +553,7 @@ public class PreviewImageFragment extends FileFragment {
         Activity container = getActivity();
         container.finish();
     }
         Activity container = getActivity();
         container.finish();
     }
-    
+
     public TouchImageViewCustom getImageView() {
         return mImageView;
     }
     public TouchImageViewCustom getImageView() {
         return mImageView;
     }
index d87b82c..02aebd0 100644 (file)
@@ -64,7 +64,7 @@ import com.owncloud.android.ui.fragment.FileFragment;
 
 /**
  * This fragment shows a preview of a downloaded media file (audio or video).
 
 /**
  * This fragment shows a preview of a downloaded media file (audio or video).
- * 
+ *
  * Trying to get an instance with NULL {@link OCFile} or ownCloud {@link Account} values will
  * produce an {@link IllegalStateException}.
  * 
  * Trying to get an instance with NULL {@link OCFile} or ownCloud {@link Account} values will
  * produce an {@link IllegalStateException}.
  * 
@@ -84,46 +84,46 @@ public class PreviewMediaFragment extends FileFragment implements
     private ImageView mImagePreview;
     private VideoView mVideoPreview;
     private int mSavedPlaybackPosition;
     private ImageView mImagePreview;
     private VideoView mVideoPreview;
     private int mSavedPlaybackPosition;
-    
+
     private MediaServiceBinder mMediaServiceBinder = null;
     private MediaControlView mMediaController = null;
     private MediaServiceConnection mMediaServiceConnection = null;
     private VideoHelper mVideoHelper;
     private boolean mAutoplay;
     public boolean mPrepared;
     private MediaServiceBinder mMediaServiceBinder = null;
     private MediaControlView mMediaController = null;
     private MediaServiceConnection mMediaServiceConnection = null;
     private VideoHelper mVideoHelper;
     private boolean mAutoplay;
     public boolean mPrepared;
-    
+
     private static final String TAG = PreviewMediaFragment.class.getSimpleName();
 
     private static final String TAG = PreviewMediaFragment.class.getSimpleName();
 
-    
+
     /**
      * Creates a fragment to preview a file.
     /**
      * Creates a fragment to preview a file.
-     * 
+     * <p/>
      * When 'fileToDetail' or 'ocAccount' are null
      * When 'fileToDetail' or 'ocAccount' are null
-     * 
-     * @param fileToDetail      An {@link OCFile} to preview in the fragment
-     * @param ocAccount         An ownCloud account; needed to start downloads
+     *
+     * @param fileToDetail An {@link OCFile} to preview in the fragment
+     * @param ocAccount    An ownCloud account; needed to start downloads
      */
     public PreviewMediaFragment(
      */
     public PreviewMediaFragment(
-            OCFile fileToDetail, 
-            Account ocAccount, 
-            int startPlaybackPosition, 
+            OCFile fileToDetail,
+            Account ocAccount,
+            int startPlaybackPosition,
             boolean autoplay) {
             boolean autoplay) {
-        
+
         super(fileToDetail);
         mAccount = ocAccount;
         mSavedPlaybackPosition = startPlaybackPosition;
         mAutoplay = autoplay;
     }
         super(fileToDetail);
         mAccount = ocAccount;
         mSavedPlaybackPosition = startPlaybackPosition;
         mAutoplay = autoplay;
     }
-    
-    
+
+
     /**
     /**
-     *  Creates an empty fragment for previews.
-     * 
-     *  MUST BE KEPT: the system uses it when tries to reinstantiate a fragment automatically 
-     *  (for instance, when the device is turned a aside).
-     * 
-     *  DO NOT CALL IT: an {@link OCFile} and {@link Account} must be provided for a successful 
-     *  construction 
+     * Creates an empty fragment for previews.
+     * <p/>
+     * MUST BE KEPT: the system uses it when tries to reinstantiate a fragment automatically
+     * (for instance, when the device is turned a aside).
+     * <p/>
+     * DO NOT CALL IT: an {@link OCFile} and {@link Account} must be provided for a successful
+     * construction
      */
     public PreviewMediaFragment() {
         super();
      */
     public PreviewMediaFragment() {
         super();
@@ -131,8 +131,8 @@ public class PreviewMediaFragment extends FileFragment implements
         mSavedPlaybackPosition = 0;
         mAutoplay = true;
     }
         mSavedPlaybackPosition = 0;
         mAutoplay = true;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
     /**
      * {@inheritDoc}
      */
@@ -141,29 +141,29 @@ public class PreviewMediaFragment extends FileFragment implements
         super.onCreate(savedInstanceState);
         setHasOptionsMenu(true);
     }
         super.onCreate(savedInstanceState);
         setHasOptionsMenu(true);
     }
-    
+
 
     /**
      * {@inheritDoc}
      */
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
 
     /**
      * {@inheritDoc}
      */
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
-            Bundle savedInstanceState) {
+                             Bundle savedInstanceState) {
         super.onCreateView(inflater, container, savedInstanceState);
         Log_OC.e(TAG, "onCreateView");
 
         super.onCreateView(inflater, container, savedInstanceState);
         Log_OC.e(TAG, "onCreateView");
 
-        
+
         mView = inflater.inflate(R.layout.file_preview, container, false);
         mView = inflater.inflate(R.layout.file_preview, container, false);
-        
-        mImagePreview = (ImageView)mView.findViewById(R.id.image_preview);
-        mVideoPreview = (VideoView)mView.findViewById(R.id.video_preview);
+
+        mImagePreview = (ImageView) mView.findViewById(R.id.image_preview);
+        mVideoPreview = (VideoView) mView.findViewById(R.id.video_preview);
         mVideoPreview.setOnTouchListener(this);
         mVideoPreview.setOnTouchListener(this);
-        
-        mMediaController = (MediaControlView)mView.findViewById(R.id.media_controller);
-        
+
+        mMediaController = (MediaControlView) mView.findViewById(R.id.media_controller);
+
         return mView;
     }
         return mView;
     }
-    
+
 
     /**
      * {@inheritDoc}
 
     /**
      * {@inheritDoc}
@@ -184,30 +184,32 @@ public class PreviewMediaFragment extends FileFragment implements
             if (!file.isDown()) {
                 throw new IllegalStateException("There is no local file to preview");
             }
             if (!file.isDown()) {
                 throw new IllegalStateException("There is no local file to preview");
             }
-            
-        } else {
-            file = (OCFile)savedInstanceState.getParcelable(PreviewMediaFragment.EXTRA_FILE);
+
+        }
+        else {
+            file = (OCFile) savedInstanceState.getParcelable(PreviewMediaFragment.EXTRA_FILE);
             setFile(file);
             mAccount = savedInstanceState.getParcelable(PreviewMediaFragment.EXTRA_ACCOUNT);
             setFile(file);
             mAccount = savedInstanceState.getParcelable(PreviewMediaFragment.EXTRA_ACCOUNT);
-            mSavedPlaybackPosition = 
+            mSavedPlaybackPosition =
                     savedInstanceState.getInt(PreviewMediaFragment.EXTRA_PLAY_POSITION);
             mAutoplay = savedInstanceState.getBoolean(PreviewMediaFragment.EXTRA_PLAYING);
                     savedInstanceState.getInt(PreviewMediaFragment.EXTRA_PLAY_POSITION);
             mAutoplay = savedInstanceState.getBoolean(PreviewMediaFragment.EXTRA_PLAYING);
-            
+
         }
         if (file != null && file.isDown()) {
             if (file.isVideo()) {
                 mVideoPreview.setVisibility(View.VISIBLE);
                 mImagePreview.setVisibility(View.GONE);
                 prepareVideo();
         }
         if (file != null && file.isDown()) {
             if (file.isVideo()) {
                 mVideoPreview.setVisibility(View.VISIBLE);
                 mImagePreview.setVisibility(View.GONE);
                 prepareVideo();
-            
-            } else {
+
+            }
+            else {
                 mVideoPreview.setVisibility(View.GONE);
                 mImagePreview.setVisibility(View.VISIBLE);
             }
         }
                 mVideoPreview.setVisibility(View.GONE);
                 mImagePreview.setVisibility(View.VISIBLE);
             }
         }
-        
+
     }
     }
-        
+
 
     /**
      * {@inheritDoc}
 
     /**
      * {@inheritDoc}
@@ -216,24 +218,25 @@ public class PreviewMediaFragment extends FileFragment implements
     public void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
         Log_OC.e(TAG, "onSaveInstanceState");
     public void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
         Log_OC.e(TAG, "onSaveInstanceState");
-        
+
         outState.putParcelable(PreviewMediaFragment.EXTRA_FILE, getFile());
         outState.putParcelable(PreviewMediaFragment.EXTRA_ACCOUNT, mAccount);
         outState.putParcelable(PreviewMediaFragment.EXTRA_FILE, getFile());
         outState.putParcelable(PreviewMediaFragment.EXTRA_ACCOUNT, mAccount);
-        
+
         if (getFile().isVideo()) {
             mSavedPlaybackPosition = mVideoPreview.getCurrentPosition();
             mAutoplay = mVideoPreview.isPlaying();
         if (getFile().isVideo()) {
             mSavedPlaybackPosition = mVideoPreview.getCurrentPosition();
             mAutoplay = mVideoPreview.isPlaying();
-            outState.putInt(PreviewMediaFragment.EXTRA_PLAY_POSITION , mSavedPlaybackPosition);
-            outState.putBoolean(PreviewMediaFragment.EXTRA_PLAYING , mAutoplay);
-        } else {
+            outState.putInt(PreviewMediaFragment.EXTRA_PLAY_POSITION, mSavedPlaybackPosition);
+            outState.putBoolean(PreviewMediaFragment.EXTRA_PLAYING, mAutoplay);
+        }
+        else {
             outState.putInt(
             outState.putInt(
-                    PreviewMediaFragment.EXTRA_PLAY_POSITION , 
+                    PreviewMediaFragment.EXTRA_PLAY_POSITION,
                     mMediaServiceBinder.getCurrentPosition());
             outState.putBoolean(
                     mMediaServiceBinder.getCurrentPosition());
             outState.putBoolean(
-                    PreviewMediaFragment.EXTRA_PLAYING , mMediaServiceBinder.isPlaying());
+                    PreviewMediaFragment.EXTRA_PLAYING, mMediaServiceBinder.isPlaying());
         }
     }
         }
     }
-    
+
 
     @Override
     public void onStart() {
 
     @Override
     public void onStart() {
@@ -242,17 +245,20 @@ public class PreviewMediaFragment extends FileFragment implements
 
         OCFile file = getFile();
         if (file != null && file.isDown()) {
 
         OCFile file = getFile();
         if (file != null && file.isDown()) {
-           if (file.isAudio()) {
-               bindMediaService();
-               
-           } else if (file.isVideo()) {
-               stopAudio();
-               playVideo(); 
-           }
+            if (file.isAudio()) {
+                bindMediaService();
+
+            }
+            else {
+                if (file.isVideo()) {
+                    stopAudio();
+                    playVideo();
+                }
+            }
         }
     }
         }
     }
-    
-    
+
+
     private void stopAudio() {
         Intent i = new Intent(getActivity(), MediaService.class);
         i.setAction(MediaService.ACTION_STOP_ALL);
     private void stopAudio() {
         Intent i = new Intent(getActivity(), MediaService.class);
         i.setAction(MediaService.ACTION_STOP_ALL);
@@ -276,7 +282,7 @@ public class PreviewMediaFragment extends FileFragment implements
     @Override
     public void onPrepareOptionsMenu(Menu menu) {
         super.onPrepareOptionsMenu(menu);
     @Override
     public void onPrepareOptionsMenu(Menu menu) {
         super.onPrepareOptionsMenu(menu);
-        
+
         if (mContainerActivity.getStorageManager() != null) {
             FileMenuFilter mf = new FileMenuFilter(
                 getFile(),
         if (mContainerActivity.getStorageManager() != null) {
             FileMenuFilter mf = new FileMenuFilter(
                 getFile(),
@@ -301,9 +307,16 @@ public class PreviewMediaFragment extends FileFragment implements
             item.setVisible(false);
             item.setEnabled(false);
         }
             item.setVisible(false);
             item.setEnabled(false);
         }
+
+        // additional restriction for this fragment
+        item = menu.findItem(R.id.action_copy);
+        if (item != null) {
+            item.setVisible(false);
+            item.setEnabled(false);
+        }
     }
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
     /**
      * {@inheritDoc}
      */
@@ -353,26 +366,26 @@ public class PreviewMediaFragment extends FileFragment implements
                 return false;
         }
     }
                 return false;
         }
     }
-    
 
 
     /**
      * Update the file of the fragment with file value
 
 
     /**
      * Update the file of the fragment with file value
+     *
      * @param file
      */
      * @param file
      */
-    public void updateFile(OCFile file){
+    public void updateFile(OCFile file) {
         setFile(file);
     }
         setFile(file);
     }
-    
+
     private void sendFile() {
         stopPreview(false);
         mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile());
     private void sendFile() {
         stopPreview(false);
         mContainerActivity.getFileOperationsHelper().sendDownloadedFile(getFile());
-        
+
     }
 
     private void seeDetails() {
         stopPreview(false);
     }
 
     private void seeDetails() {
         stopPreview(false);
-        mContainerActivity.showDetails(getFile());        
+        mContainerActivity.showDetails(getFile());
     }
 
 
     }
 
 
@@ -383,77 +396,80 @@ public class PreviewMediaFragment extends FileFragment implements
         mVideoPreview.setOnCompletionListener(mVideoHelper);
         mVideoPreview.setOnErrorListener(mVideoHelper);
     }
         mVideoPreview.setOnCompletionListener(mVideoHelper);
         mVideoPreview.setOnErrorListener(mVideoHelper);
     }
-    
+
     @SuppressWarnings("static-access")
     private void playVideo() {
         // create and prepare control panel for the user
         mMediaController.setMediaPlayer(mVideoPreview);
     @SuppressWarnings("static-access")
     private void playVideo() {
         // create and prepare control panel for the user
         mMediaController.setMediaPlayer(mVideoPreview);
-        
+
         // load the video file in the video player ; 
         // when done, VideoHelper#onPrepared() will be called
         Uri uri = Uri.parse(getFile().getStoragePath());
         mVideoPreview.setVideoPath(uri.encode(getFile().getStoragePath()));
     }
         // load the video file in the video player ; 
         // when done, VideoHelper#onPrepared() will be called
         Uri uri = Uri.parse(getFile().getStoragePath());
         mVideoPreview.setVideoPath(uri.encode(getFile().getStoragePath()));
     }
-    
+
 
     private class VideoHelper implements OnCompletionListener, OnPreparedListener, OnErrorListener {
 
     private class VideoHelper implements OnCompletionListener, OnPreparedListener, OnErrorListener {
-        
-        /** 
+
+        /**
          * Called when the file is ready to be played.
          * Called when the file is ready to be played.
-         * 
+         * <p/>
          * Just starts the playback.
          * Just starts the playback.
-         * 
+         *
          * @param   vp    {@link MediaPlayer} instance performing the playback.
          */
         @Override
         public void onPrepared(MediaPlayer vp) {
             Log_OC.e(TAG, "onPrepared");
             mVideoPreview.seekTo(mSavedPlaybackPosition);
          * @param   vp    {@link MediaPlayer} instance performing the playback.
          */
         @Override
         public void onPrepared(MediaPlayer vp) {
             Log_OC.e(TAG, "onPrepared");
             mVideoPreview.seekTo(mSavedPlaybackPosition);
-            if (mAutoplay) { 
+            if (mAutoplay) {
                 mVideoPreview.start();
             }
             mMediaController.setEnabled(true);
             mMediaController.updatePausePlay();
             mPrepared = true;
         }
                 mVideoPreview.start();
             }
             mMediaController.setEnabled(true);
             mMediaController.updatePausePlay();
             mPrepared = true;
         }
-        
-        
+
+
         /**
          * Called when the file is finished playing.
         /**
          * Called when the file is finished playing.
-         *  
+         * <p/>
          * Finishes the activity.
          * Finishes the activity.
-         * 
-         * @param   mp    {@link MediaPlayer} instance performing the playback.
+         *
+         * @param mp {@link MediaPlayer} instance performing the playback.
          */
         @Override
          */
         @Override
-        public void onCompletion(MediaPlayer  mp) {
+        public void onCompletion(MediaPlayer mp) {
             Log_OC.e(TAG, "completed");
             if (mp != null) {
                 mVideoPreview.seekTo(0);
                 // next lines are necessary to work around undesired video loops
                 if (Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD) {
             Log_OC.e(TAG, "completed");
             if (mp != null) {
                 mVideoPreview.seekTo(0);
                 // next lines are necessary to work around undesired video loops
                 if (Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD) {
-                    mVideoPreview.pause();   
-                    
-                } else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD_MR1) {
-                    // mVideePreview.pause() is not enough
-                    
-                    mMediaController.setEnabled(false);
-                    mVideoPreview.stopPlayback();
-                    mAutoplay = false;
-                    mSavedPlaybackPosition = 0;
-                    mVideoPreview.setVideoPath(getFile().getStoragePath());
+                    mVideoPreview.pause();
+
+                }
+                else {
+                    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD_MR1) {
+                        // mVideePreview.pause() is not enough
+
+                        mMediaController.setEnabled(false);
+                        mVideoPreview.stopPlayback();
+                        mAutoplay = false;
+                        mSavedPlaybackPosition = 0;
+                        mVideoPreview.setVideoPath(getFile().getStoragePath());
+                    }
                 }
             } // else : called from onError()
             mMediaController.updatePausePlay();
         }
                 }
             } // else : called from onError()
             mMediaController.updatePausePlay();
         }
-        
-        
+
+
         /**
          * Called when an error in playback occurs.
         /**
          * Called when an error in playback occurs.
-         * 
-         * @param   mp      {@link MediaPlayer} instance performing the playback.
-         * @param   what    Type of error
-         * @param   extra   Extra code specific to the error
+         *
+         * @param mp    {@link MediaPlayer} instance performing the playback.
+         * @param what  Type of error
+         * @param extra Extra code specific to the error
          */
         @Override
         public boolean onError(MediaPlayer mp, int what, int extra) {
          */
         @Override
         public boolean onError(MediaPlayer mp, int what, int extra) {
@@ -474,28 +490,28 @@ public class PreviewMediaFragment extends FileFragment implements
             }
             return true;
         }
             }
             return true;
         }
-        
+
     }
 
     }
 
-    
+
     @Override
     public void onPause() {
         Log_OC.e(TAG, "onPause");
         super.onPause();
     }
     @Override
     public void onPause() {
         Log_OC.e(TAG, "onPause");
         super.onPause();
     }
-    
+
     @Override
     public void onResume() {
         super.onResume();
         Log_OC.e(TAG, "onResume");
     }
     @Override
     public void onResume() {
         super.onResume();
         Log_OC.e(TAG, "onResume");
     }
-    
+
     @Override
     public void onDestroy() {
         Log_OC.e(TAG, "onDestroy");
         super.onDestroy();
     }
     @Override
     public void onDestroy() {
         Log_OC.e(TAG, "onDestroy");
         super.onDestroy();
     }
-    
+
     @Override
     public void onStop() {
         Log_OC.e(TAG, "onStop");
     @Override
     public void onStop() {
         Log_OC.e(TAG, "onStop");
@@ -510,10 +526,10 @@ public class PreviewMediaFragment extends FileFragment implements
             mMediaServiceConnection = null;
             mMediaServiceBinder = null;
         }
             mMediaServiceConnection = null;
             mMediaServiceBinder = null;
         }
-        
+
         super.onStop();
     }
         super.onStop();
     }
-    
+
     @Override
     public boolean onTouch(View v, MotionEvent event) {
         if (event.getAction() == MotionEvent.ACTION_DOWN && v == mVideoPreview) {
     @Override
     public boolean onTouch(View v, MotionEvent event) {
         if (event.getAction() == MotionEvent.ACTION_DOWN && v == mVideoPreview) {
@@ -526,7 +542,7 @@ public class PreviewMediaFragment extends FileFragment implements
         return false;
     }
 
         return false;
     }
 
-    
+
     private void startFullScreenVideo() {
         Intent i = new Intent(getActivity(), PreviewVideoActivity.class);
         i.putExtra(FileActivity.EXTRA_ACCOUNT, mAccount);
     private void startFullScreenVideo() {
         Intent i = new Intent(getActivity(), PreviewVideoActivity.class);
         i.putExtra(FileActivity.EXTRA_ACCOUNT, mAccount);
@@ -538,29 +554,30 @@ public class PreviewMediaFragment extends FileFragment implements
     }
 
     @Override
     }
 
     @Override
-    public void onConfigurationChanged (Configuration newConfig) {
+    public void onConfigurationChanged(Configuration newConfig) {
         Log_OC.e(TAG, "onConfigurationChanged " + this);
     }
         Log_OC.e(TAG, "onConfigurationChanged " + this);
     }
-    
+
     @Override
     @Override
-    public void onActivityResult (int requestCode, int resultCode, Intent data) {
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
         Log_OC.e(TAG, "onActivityResult " + this);
         super.onActivityResult(requestCode, resultCode, data);
         if (resultCode == Activity.RESULT_OK) {
             mSavedPlaybackPosition = data.getExtras().getInt(
                     PreviewVideoActivity.EXTRA_START_POSITION);
         Log_OC.e(TAG, "onActivityResult " + this);
         super.onActivityResult(requestCode, resultCode, data);
         if (resultCode == Activity.RESULT_OK) {
             mSavedPlaybackPosition = data.getExtras().getInt(
                     PreviewVideoActivity.EXTRA_START_POSITION);
-            mAutoplay = data.getExtras().getBoolean(PreviewVideoActivity.EXTRA_AUTOPLAY); 
+            mAutoplay = data.getExtras().getBoolean(PreviewVideoActivity.EXTRA_AUTOPLAY);
         }
     }
         }
     }
-    
+
 
     private void playAudio() {
         OCFile file = getFile();
         if (!mMediaServiceBinder.isPlaying(file)) {
             Log_OC.d(TAG, "starting playback of " + file.getStoragePath());
             mMediaServiceBinder.start(mAccount, file, mAutoplay, mSavedPlaybackPosition);
 
     private void playAudio() {
         OCFile file = getFile();
         if (!mMediaServiceBinder.isPlaying(file)) {
             Log_OC.d(TAG, "starting playback of " + file.getStoragePath());
             mMediaServiceBinder.start(mAccount, file, mAutoplay, mSavedPlaybackPosition);
-            
-        } else {
+
+        }
+        else {
             if (!mMediaServiceBinder.isPlaying() && mAutoplay) {
                 mMediaServiceBinder.start();
                 mMediaController.updatePausePlay();
             if (!mMediaServiceBinder.isPlaying() && mAutoplay) {
                 mMediaServiceBinder.start();
                 mMediaController.updatePausePlay();
@@ -597,7 +614,8 @@ public class PreviewMediaFragment extends FileFragment implements
 
                         Log_OC.d(TAG, "Successfully bound to MediaService, MediaController ready");
 
 
                         Log_OC.d(TAG, "Successfully bound to MediaService, MediaController ready");
 
-                    } else {
+                    }
+                    else {
                         Log_OC.e(TAG, "Unexpected response from MediaService while binding");
                     }
                 }
                         Log_OC.e(TAG, "Unexpected response from MediaService while binding");
                     }
                 }
@@ -619,7 +637,8 @@ public class PreviewMediaFragment extends FileFragment implements
                 Log_OC.e(TAG, "Media service suddenly disconnected");
                 if (mMediaController != null) {
                     mMediaController.setMediaPlayer(null);
                 Log_OC.e(TAG, "Media service suddenly disconnected");
                 if (mMediaController != null) {
                     mMediaController.setMediaPlayer(null);
-                } else {
+                }
+                else {
                     Toast.makeText(
                             getActivity(),
                             "No media controller to release when disconnected from media service", 
                     Toast.makeText(
                             getActivity(),
                             "No media controller to release when disconnected from media service", 
@@ -629,9 +648,8 @@ public class PreviewMediaFragment extends FileFragment implements
                 mMediaServiceConnection = null;
             }
         }
                 mMediaServiceConnection = null;
             }
         }
-    }    
+    }
 
 
-    
 
     /**
      * Opens the previewed file with an external application.
 
     /**
      * Opens the previewed file with an external application.
@@ -641,31 +659,33 @@ public class PreviewMediaFragment extends FileFragment implements
         mContainerActivity.getFileOperationsHelper().openFile(getFile());
         finish();
     }
         mContainerActivity.getFileOperationsHelper().openFile(getFile());
         finish();
     }
-    
+
     /**
      * Helper method to test if an {@link OCFile} can be passed to a {@link PreviewMediaFragment}
     /**
      * Helper method to test if an {@link OCFile} can be passed to a {@link PreviewMediaFragment}
-     *  to be previewed.
-     * 
-     * @param file      File to test if can be previewed.
-     * @return          'True' if the file can be handled by the fragment.
+     * to be previewed.
+     *
+     * @param file File to test if can be previewed.
+     * @return 'True' if the file can be handled by the fragment.
      */
     public static boolean canBePreviewed(OCFile file) {
         return (file != null && (file.isAudio() || file.isVideo()));
     }
      */
     public static boolean canBePreviewed(OCFile file) {
         return (file != null && (file.isAudio() || file.isVideo()));
     }
-    
+
 
     public void stopPreview(boolean stopAudio) {
         OCFile file = getFile();
         if (file.isAudio() && stopAudio) {
             mMediaServiceBinder.pause();
 
     public void stopPreview(boolean stopAudio) {
         OCFile file = getFile();
         if (file.isAudio() && stopAudio) {
             mMediaServiceBinder.pause();
-            
-        } else if (file.isVideo()) {
-            mVideoPreview.stopPlayback();
+
+        }
+        else {
+            if (file.isVideo()) {
+                mVideoPreview.stopPlayback();
+            }
         }
     }
 
 
         }
     }
 
 
-
     /**
      * Finishes the preview
      */
     /**
      * Finishes the preview
      */
@@ -681,12 +701,12 @@ public class PreviewMediaFragment extends FileFragment implements
         Log_OC.e(TAG, "getting position: " + mSavedPlaybackPosition);
         return mSavedPlaybackPosition;
     }
         Log_OC.e(TAG, "getting position: " + mSavedPlaybackPosition);
         return mSavedPlaybackPosition;
     }
-    
+
     public boolean isPlaying() {
         if (mPrepared) {
             mAutoplay = mVideoPreview.isPlaying();
         }
         return mAutoplay;
     }
     public boolean isPlaying() {
         if (mPrepared) {
             mAutoplay = mVideoPreview.isPlaying();
         }
         return mAutoplay;
     }
-    
+
 }
 }
index c86346b..b80cc57 100644 (file)
@@ -206,9 +206,10 @@ public class ErrorMessageAdapter {
             }
         } else if (operation instanceof MoveFileOperation) {
 
             }
         } else if (operation instanceof MoveFileOperation) {
 
-            if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
+            if(isNetworkError(result.getCode())){
+                message = getErrorMessage(result, res);
+            } else if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
                 message = res.getString(R.string.move_file_not_found);
                 message = res.getString(R.string.move_file_not_found);
-
             } else if (result.getCode() == ResultCode.INVALID_MOVE_INTO_DESCENDANT) {
                 message = res.getString(R.string.move_file_invalid_into_descendent);
 
             } else if (result.getCode() == ResultCode.INVALID_MOVE_INTO_DESCENDANT) {
                 message = res.getString(R.string.move_file_invalid_into_descendent);
 
@@ -242,11 +243,11 @@ public class ErrorMessageAdapter {
                 }
             }
         } else if (operation instanceof CopyFileOperation) {
                 }
             }
         } else if (operation instanceof CopyFileOperation) {
-
-            if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
+            if(isNetworkError(result.getCode())){
+                message = getErrorMessage(result, res);
+            } else if (result.getCode() == ResultCode.FILE_NOT_FOUND) {
                 message = res.getString(R.string.copy_file_not_found);
                 message = res.getString(R.string.copy_file_not_found);
-
-            } else if (result.getCode() == ResultCode.INVALID_MOVE_INTO_DESCENDANT) {
+            } else if (result.getCode() == ResultCode.INVALID_COPY_INTO_DESCENDANT) {
                 message = res.getString(R.string.copy_file_invalid_into_descendent);
 
             } else if (result.getCode() == ResultCode.INVALID_OVERWRITE) {
                 message = res.getString(R.string.copy_file_invalid_into_descendent);
 
             } else if (result.getCode() == ResultCode.INVALID_OVERWRITE) {