}
return false;
}
-
+
public void unshareFileWithLink(OCFile file, FileActivity callerActivity) {
}
}
+
+ public void sendFile(OCFile file, FileActivity callerActivity) {
+ // Obtain the file
+ if (!file.isDown()) { // Download the file
+ Log_OC.d(TAG, file.getRemotePath() + " : File must be downloaded");
+ } else {
+ sendDownloadedFile(file, callerActivity);
+ }
+
+
+ }
+
+ public void sendDownloadedFile(OCFile file, FileActivity callerActivity) {
+ Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
+ // set MimeType
+ sharingIntent.setType(file.getMimetype());
+ sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getStoragePath()));
+ callerActivity.startActivity(Intent.createChooser(sharingIntent, callerActivity.getString(R.string.send_file_title_intent)));
+ }
+
+
}
import com.owncloud.android.ui.fragment.FileFragment;
import com.owncloud.android.ui.fragment.OCFileListFragment;
import com.owncloud.android.ui.preview.PreviewImageActivity;
-import com.owncloud.android.ui.preview.PreviewImageFragment;
import com.owncloud.android.ui.preview.PreviewMediaFragment;
import com.owncloud.android.ui.preview.PreviewVideoActivity;
import com.owncloud.android.utils.DisplayUtils;
private boolean mSyncInProgress = false;
//private boolean mRefreshSharesInProgress = false;
+ private OCFile mWaitingToSend;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
Log_OC.d(TAG, "onCreate() start");
refreshSecondFragment(intent.getAction(), downloadedRemotePath, intent.getBooleanExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, false));
}
+ if (mWaitingToSend != null && mWaitingToSend.isDown()) {
+
+ sendDownloadedFile();
+
+ }
removeStickyBroadcast(intent);
}
}
*/
+ /**
+ * Requests the download of the received {@link OCFile} , updates the UI
+ * to monitor the download progress and prepares the activity to send the file
+ * when the download finishes.
+ *
+ * @param file {@link OCFile} to download and preview.
+ */
+ @Override
+ public void startDownloadForSending(OCFile file) {
+ mWaitingToSend = file;
+ requestForDownload(mWaitingToSend);
+ updateFragmentsVisibility(true);
+ }
+
+ private void requestForDownload(OCFile file) {
+ Account account = getAccount();
+ if (!mDownloaderBinder.isDownloading(account, file)) {
+ Intent i = new Intent(this, FileDownloader.class);
+ i.putExtra(FileDownloader.EXTRA_ACCOUNT, account);
+ i.putExtra(FileDownloader.EXTRA_FILE, file);
+ startService(i);
+ }
+ }
+
+ private void sendDownloadedFile(){
+ getFileOperationsHelper().sendDownloadedFile(mWaitingToSend, this);
+ mWaitingToSend = null;
+ }
+
}
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;
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, getResources().getString(R.string.send_file_title_intent)));
+ // Obtain the file
+ if (!mTargetFile.isDown()) { // Download the file
+ 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:
* @param uploading Flag signaling if the file is now uploading.
*/
public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading);
+
+ void startDownloadForSending(OCFile file);
}
return true;
}
case R.id.action_send_file: {
- sendFile();
+ FileActivity act = (FileActivity)getSherlockActivity();
+ act.getFileOperationsHelper().sendDownloadedFile(getFile(), act);
return true;
}
}
}
- private void sendFile(){
- Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
- // set MimeType
- sharingIntent.setType(getFile().getMimetype());
- sharingIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+getFile().getStoragePath()));
- startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.send_file_title_intent)));
- }
-
-
private void seeDetails() {
((FileFragment.ContainerActivity)getActivity()).showDetails(getFile());