// remove successfull uploading, ignore rest for reupload on reconnect
if (intent.getBooleanExtra(FileUploader.EXTRA_UPLOAD_RESULT, false)) {
DbHandler db = new DbHandler(context);
- String localPath = intent.getStringExtra(FileUploader.EXTRA_FILE_PATH);
+ String localPath = intent.getStringExtra(FileUploader.EXTRA_OLD_FILE_PATH);
if (!db.removeIUPendingFile(localPath,
intent.getStringExtra(FileUploader.ACCOUNT_NAME))) {
Log.w(TAG, "Tried to remove non existing instant upload file " + localPath);
public static final String EXTRA_UPLOAD_RESULT = "RESULT";
public static final String EXTRA_REMOTE_PATH = "REMOTE_PATH";
public static final String EXTRA_OLD_REMOTE_PATH = "OLD_REMOTE_PATH";
- public static final String EXTRA_FILE_PATH = "FILE_PATH";
+ public static final String EXTRA_OLD_FILE_PATH = "OLD_FILE_PATH";
public static final String ACCOUNT_NAME = "ACCOUNT_NAME";
public static final String KEY_FILE = "FILE";
mDefaultNotificationContentView = mNotification.contentView;
mNotification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.progressbar_layout);
mNotification.contentView.setProgressBar(R.id.status_progress, 100, 0, false);
- mNotification.contentView.setTextViewText(R.id.status_text, String.format(getString(R.string.uploader_upload_in_progress_content), 0, new File(upload.getStoragePath()).getName()));
+ mNotification.contentView.setTextViewText(R.id.status_text, String.format(getString(R.string.uploader_upload_in_progress_content), 0, upload.getFileName()));
mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);
/// includes a pending intent in the notification showing the details view of the file
mNotification.setLatestEventInfo( getApplicationContext(),
getString(R.string.uploader_upload_succeeded_ticker),
- String.format(getString(R.string.uploader_upload_succeeded_content_single), (new File(upload.getStoragePath())).getName()),
+ String.format(getString(R.string.uploader_upload_succeeded_content_single), upload.getFileName()),
mNotification.contentIntent);
mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotification); // NOT AN ERROR; uploader_upload_in_progress_ticker is the target, not a new notification
if (uploadResult.getCode() == ResultCode.LOCAL_STORAGE_FULL ||
uploadResult.getCode() == ResultCode.LOCAL_STORAGE_NOT_COPIED) {
// TODO we need a class to provide error messages for the users from a RemoteOperationResult and a RemoteOperation
- content = String.format(getString(R.string.error__upload__local_file_not_copied), (new File(upload.getStoragePath())).getName(), getString(R.string.app_name));
+ content = String.format(getString(R.string.error__upload__local_file_not_copied), upload.getFileName(), getString(R.string.app_name));
} else {
- content = String.format(getString(R.string.uploader_upload_failed_content_single), (new File(upload.getStoragePath())).getName());
+ content = String.format(getString(R.string.uploader_upload_failed_content_single), upload.getFileName());
}
finalNotification.setLatestEventInfo( getApplicationContext(),
getString(R.string.uploader_upload_failed_ticker),
if (upload.wasRenamed()) {
end.putExtra(EXTRA_OLD_REMOTE_PATH, upload.getOldFile().getRemotePath());
}
- end.putExtra(EXTRA_FILE_PATH, upload.getStoragePath());
+ end.putExtra(EXTRA_OLD_FILE_PATH, upload.getOriginalStoragePath());
end.putExtra(ACCOUNT_NAME, upload.getAccount().name);
end.putExtra(EXTRA_UPLOAD_RESULT, uploadResult.isSuccess());
sendStickyBroadcast(end);
private boolean mForceOverwrite = false;
private int mLocalBehaviour = FileUploader.LOCAL_BEHAVIOUR_COPY;
private boolean mWasRenamed = false;
+ private String mOriginalFileName = null;
+ private String mOriginalStoragePath = null;
PutMethod mPutMethod = null;
private Set<OnDatatransferProgressListener> mDataTransferListeners = new HashSet<OnDatatransferProgressListener>();
private final AtomicBoolean mCancellationRequested = new AtomicBoolean(false);
mIsInstant = isInstant;
mForceOverwrite = forceOverwrite;
mLocalBehaviour = localBehaviour;
+ mOriginalStoragePath = mFile.getStoragePath();
+ mOriginalFileName = mFile.getFileName();
}
return mAccount;
}
+ public String getFileName() {
+ return mOriginalFileName;
+ }
+
public OCFile getFile() {
return mFile;
}
return mOldFile;
}
+ public String getOriginalStoragePath() {
+ return mOriginalStoragePath;
+ }
+
public String getStoragePath() {
return mFile.getStoragePath();
}
protected RemoteOperationResult run(WebdavClient client) {
RemoteOperationResult result = null;
boolean localCopyPassed = false, nameCheckPassed = false;
- String originalStoragePath = mFile.getStoragePath();
- File temporalFile = null, originalFile = new File(originalStoragePath), expectedFile = null;
+ File temporalFile = null, originalFile = new File(mOriginalStoragePath), expectedFile = null;
try {
/// rename the file to upload, if necessary
if (!mForceOverwrite) {
expectedFile = new File(expectedPath);
/// check location of local file; if not the expected, copy to a temporal file before upload (if COPY is the expected behaviour)
- if (!originalStoragePath.equals(expectedPath) && mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_COPY) {
+ if (!mOriginalStoragePath.equals(expectedPath) && mLocalBehaviour == FileUploader.LOCAL_BEHAVIOUR_COPY) {
if (FileStorageUtils.getUsableSpace(mAccount.name) < originalFile.length()) {
result = new RemoteOperationResult(ResultCode.LOCAL_STORAGE_FULL);
String temporalPath = FileStorageUtils.getTemporalPath(mAccount.name) + mFile.getRemotePath();
mFile.setStoragePath(temporalPath);
temporalFile = new File(temporalPath);
- if (!originalStoragePath.equals(temporalPath)) { // preventing weird but possible situation
+ if (!mOriginalStoragePath.equals(temporalPath)) { // preventing weird but possible situation
InputStream in = null;
OutputStream out = null;
try {
try {
if (in != null) in.close();
} catch (Exception e) {
- Log.d(TAG, "Weird exception while closing input stream for " + originalStoragePath + " (ignoring)", e);
+ Log.d(TAG, "Weird exception while closing input stream for " + mOriginalStoragePath + " (ignoring)", e);
}
try {
if (out != null) out.close();
} else { // FileUploader.LOCAL_BEHAVIOUR_MOVE
fileToMove = originalFile;
}
- expectedFile = new File(mFile.getStoragePath());
if (!expectedFile.equals(fileToMove) && !fileToMove.renameTo(expectedFile)) {
mFile.setStoragePath(null); // forget the local file
// by now, treat this as a success; the file was uploaded; the user won't like that the local file is not linked, but this should be a veeery rare fail;
temporalFile.delete();
}
if (result.isSuccess()) {
- Log.i(TAG, "Upload of " + originalStoragePath + " to " + mRemotePath + ": " + result.getLogMessage());
+ Log.i(TAG, "Upload of " + mOriginalStoragePath + " to " + mRemotePath + ": " + result.getLogMessage());
} else {
if (result.getException() != null) {
} else if (!localCopyPassed) {
complement = " (while copying local file to " + FileStorageUtils.getSavePath(mAccount.name) + ")";
}
- Log.e(TAG, "Upload of " + originalStoragePath + " to " + mRemotePath + ": " + result.getLogMessage() + complement, result.getException());
+ Log.e(TAG, "Upload of " + mOriginalStoragePath + " to " + mRemotePath + ": " + result.getLogMessage() + complement, result.getException());
} else {
- Log.e(TAG, "Upload of " + originalStoragePath + " to " + mRemotePath + ": " + result.getLogMessage());
+ Log.e(TAG, "Upload of " + mOriginalStoragePath + " to " + mRemotePath + ": " + result.getLogMessage());
}
}
}
setResult(RESULT_OK_AND_MOVE, data);
finish();
}
- //mCurrentDialog.dismiss();
+ mCurrentDialog.dismiss();
mCurrentDialog = null;
}
@Override
public void onNeutral(String callerTag) {
Log.d(TAG, "Phantom neutral button in dialog was clicked; dialog tag is " + callerTag);
- //mCurrentDialog.dismiss();
+ mCurrentDialog.dismiss();
mCurrentDialog = null;
}
public void onCancel(String callerTag) {
/// nothing to do; don't finish, let the user change the selection
Log.d(TAG, "Negative button in dialog was clicked; dialog tag is " + callerTag);
- //mCurrentDialog.dismiss();
+ mCurrentDialog.dismiss();
mCurrentDialog = null;
}
import android.os.AsyncTask;\r
import android.os.Bundle;\r
import android.os.Handler;\r
+import android.support.v4.app.DialogFragment;\r
import android.support.v4.app.FragmentTransaction;\r
import android.util.Log;\r
import android.view.Display;\r
\r
private Handler mHandler;\r
private RemoteOperation mLastRemoteOperation;\r
+ private DialogFragment mCurrentDialog;\r
\r
private static final String TAG = FileDetailFragment.class.getSimpleName();\r
public static final String FTAG = "FileDetails"; \r
mFile.isDown() ? R.string.confirmation_remove_local : -1,\r
R.string.common_cancel);\r
confDialog.setOnConfirmationListener(this);\r
- confDialog.show(getFragmentManager(), FTAG_CONFIRMATION);\r
+ mCurrentDialog = confDialog;\r
+ mCurrentDialog.show(getFragmentManager(), FTAG_CONFIRMATION);\r
break;\r
}\r
case R.id.fdOpenBtn: {\r
getActivity().showDialog((inDisplayActivity)? FileDisplayActivity.DIALOG_SHORT_WAIT : FileDetailActivity.DIALOG_SHORT_WAIT);\r
}\r
}\r
+ mCurrentDialog.dismiss();\r
+ mCurrentDialog = null;\r
}\r
\r
@Override\r
mStorageManager.saveFile(mFile);\r
updateFileDetails(mFile, mAccount);\r
}\r
+ mCurrentDialog.dismiss();\r
+ mCurrentDialog = null;\r
}\r
\r
@Override\r
public void onCancel(String callerTag) {\r
Log.d(TAG, "REMOVAL CANCELED");\r
+ mCurrentDialog.dismiss();\r
+ mCurrentDialog = null;\r
}\r
\r
\r
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
+import android.support.v4.app.DialogFragment;
import android.util.Log;
import android.view.ContextMenu;
import android.view.MenuInflater;
private Handler mHandler;
private OCFile mTargetFile;
-
+
+ private DialogFragment mCurrentDialog;
/**
* {@inheritDoc}
neuBtnStringId,
R.string.common_cancel);
confDialog.setOnConfirmationListener(this);
- confDialog.show(getFragmentManager(), FileDetailFragment.FTAG_CONFIRMATION);
+ mCurrentDialog = confDialog;
+ mCurrentDialog.show(getFragmentManager(), FileDetailFragment.FTAG_CONFIRMATION);
return true;
}
case R.id.open_file_item: {
getActivity().showDialog(FileDisplayActivity.DIALOG_SHORT_WAIT);
}
+ mCurrentDialog.dismiss();
+ mCurrentDialog = null;
}
}
mTargetFile.setStoragePath(null);
mContainerActivity.getStorageManager().saveFile(mTargetFile);
}
+ mCurrentDialog.dismiss();
+ mCurrentDialog = null;
listDirectory();
mContainerActivity.onTransferStateChanged(mTargetFile, false, false);
}
@Override
public void onCancel(String callerTag) {
Log.d(TAG, "REMOVAL CANCELED");
+ mCurrentDialog.dismiss();
+ mCurrentDialog = null;
}