Merge branch 'develop' into send_file_pr311_with_develop
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / fragment / FileDetailFragment.java
index 310da9c..4d3b031 100644 (file)
@@ -186,6 +186,10 @@ public class FileDetailFragment extends FileFragment implements
         super.onActivityCreated(savedInstanceState);
         if (mAccount != null) {
             mStorageManager = new FileDataStorageManager(mAccount, getActivity().getApplicationContext().getContentResolver());
+            OCFile file = mStorageManager.getFileByPath(getFile().getRemotePath());
+            if (file != null) {
+                setFile(file);
+            }
         }
     }
         
@@ -314,6 +318,8 @@ public class FileDetailFragment extends FileFragment implements
         // Options shareLink
         if (!file.isShareByLink()) {
             toHide.add(R.id.action_unshare_file);
+        } else {
+            toShow.add(R.id.action_unshare_file);
         }
         
         MenuItem item = null;
@@ -370,6 +376,19 @@ public class FileDetailFragment extends FileFragment implements
                 synchronizeFile();
                 return true;
             }
+            case R.id.action_send_file: {
+                FileDisplayActivity activity = (FileDisplayActivity) getSherlockActivity();
+                // Obtain the file
+                if (!getFile().isDown()) {  // Download the file                    
+                    //activity.showLoadingDialog();
+                    Log_OC.d(TAG, getFile().getRemotePath() + " : File must be downloaded");
+                    activity.startDownloadForSending(getFile());
+                    
+                } else {
+                    activity.getFileOperationsHelper().sendDownloadedFile(getFile(), activity);
+                }
+                return true;
+            }
             default:
                 return false;
         }