import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.content.SyncRequest;
+import android.content.res.Configuration;
import android.content.res.Resources.NotFoundException;
import android.database.Cursor;
import android.net.Uri;
private static final String KEY_WAITING_TO_PREVIEW = "WAITING_TO_PREVIEW";
private static final String KEY_SYNC_IN_PROGRESS = "SYNC_IN_PROGRESS";
//private static final String KEY_REFRESH_SHARES_IN_PROGRESS = "SHARES_IN_PROGRESS";
+ private static final String KEY_WAITING_TO_SEND = "WAITING_TO_SEND";
public static final int DIALOG_SHORT_WAIT = 0;
private static final int DIALOG_CHOOSE_UPLOAD_SOURCE = 1;
private boolean mSyncInProgress = false;
//private boolean mRefreshSharesInProgress = false;
+ private OCFile mWaitingToSend;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
Log_OC.d(TAG, "onCreate() start");
mWaitingToPreview = (OCFile) savedInstanceState.getParcelable(FileDisplayActivity.KEY_WAITING_TO_PREVIEW);
mSyncInProgress = savedInstanceState.getBoolean(KEY_SYNC_IN_PROGRESS);
//mRefreshSharesInProgress = savedInstanceState.getBoolean(KEY_REFRESH_SHARES_IN_PROGRESS);
+ mWaitingToSend = (OCFile) savedInstanceState.getParcelable(FileDisplayActivity.KEY_WAITING_TO_SEND);
} else {
mWaitingToPreview = null;
mSyncInProgress = false;
//mRefreshSharesInProgress = false;
+ mWaitingToSend = null;
}
/// USER INTERFACE
unbindService(mUploadConnection);
}
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ }
/**
* Called when the ownCloud {@link Account} associated to the Activity was just updated.
outState.putParcelable(FileDisplayActivity.KEY_WAITING_TO_PREVIEW, mWaitingToPreview);
outState.putBoolean(FileDisplayActivity.KEY_SYNC_IN_PROGRESS, mSyncInProgress);
//outState.putBoolean(FileDisplayActivity.KEY_REFRESH_SHARES_IN_PROGRESS, mRefreshSharesInProgress);
+ outState.putParcelable(FileDisplayActivity.KEY_WAITING_TO_SEND, mWaitingToSend);
Log_OC.d(TAG, "onSaveInstanceState() end");
}
refreshSecondFragment(intent.getAction(), downloadedRemotePath, intent.getBooleanExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, false));
}
+ if (mWaitingToSend != null) {
+ mWaitingToSend = getStorageManager().getFileByPath(mWaitingToSend.getRemotePath()); // Update the file to send
+ if (mWaitingToSend.isDown() && mWaitingToSend.getStoragePath()!=null) {
+ 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);
+ boolean hasSecondFragment = (getSecondFragment()!= null);
+ updateFragmentsVisibility(hasSecondFragment);
+ }
+
+ 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;
+ }
+
}