Merge branch 'develop' into send_file_pr311_with_develop
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / fragment / OCFileListFragment.java
index 87fd686..a4919ca 100644 (file)
@@ -44,8 +44,6 @@ import com.owncloud.android.utils.Log_OC;
 
 import android.accounts.Account;
 import android.app.Activity;
-import android.content.Intent;
-import android.net.Uri;
 import android.os.Bundle;
 import android.os.Handler;
 import android.view.ContextMenu;
@@ -222,7 +220,7 @@ public class OCFileListFragment extends ExtendedListFragment implements EditName
             toHide.add(R.id.action_cancel_upload);
             toHide.add(R.id.action_sync_file);
             toHide.add(R.id.action_see_details);
-            toHide.add(R.id.action_share_file);
+            toHide.add(R.id.action_send_file);
             if (    mContainerActivity.getFileDownloaderBinder().isDownloading(AccountUtils.getCurrentOwnCloudAccount(getActivity()), targetFile) ||
                     mContainerActivity.getFileUploaderBinder().isUploading(AccountUtils.getCurrentOwnCloudAccount(getActivity()), targetFile)           ) {
                 toDisable.add(R.id.action_rename_file);
@@ -362,11 +360,17 @@ public class OCFileListFragment extends ExtendedListFragment implements EditName
                 return true;
             }
             case R.id.action_send_file: {
-                Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
-                // set MimeType
-                sharingIntent.setType(mTargetFile.getMimetype());
-                sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+mTargetFile.getStoragePath()));
-                startActivity(Intent.createChooser(sharingIntent, "Share via")); 
+                // Obtain the file
+                if (!mTargetFile.isDown()) {  // Download the file
+                    ((FileDisplayActivity) getSherlockActivity()).showLoadingDialog();
+                    Log_OC.d(TAG, mTargetFile.getRemotePath() + " : File must be downloaded");
+                    mContainerActivity.startDownloadForSending(mTargetFile);
+                    
+                } else {
+                
+                    FileDisplayActivity activity = (FileDisplayActivity) getSherlockActivity();
+                    activity.getFileOperationsHelper().sendDownloadedFile(mTargetFile, activity);
+                }
                 return true;
             }
             default:
@@ -473,6 +477,8 @@ public class OCFileListFragment extends ExtendedListFragment implements EditName
          * @param uploading     Flag signaling if the file is now uploading.
          */
         public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading);
+
+        void startDownloadForSending(OCFile file);
         
     }