Update of messages when uploads finish

This commit is contained in:
David A. Velasco 2012-06-29 10:36:25 +02:00
parent 114e0c2521
commit 72141b60fb
3 changed files with 13 additions and 7 deletions

View file

@ -18,7 +18,7 @@
-->
<manifest package="eu.alefzero.owncloud"
android:versionCode="1"
android:versionName="0.1.138B" xmlns:android="http://schemas.android.com/apk/res/android">
android:versionName="0.1.139B" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />

View file

@ -68,6 +68,7 @@
<string name="uploader_info_dirname">Directory name</string>
<string name="uploader_upload_succeed">Uploading completed successfully</string>
<string name="uploader_upload_failed">Upload failed: </string>
<string name="uploader_files_uploaded_suffix"> files uploaded</string>
<string name="common_choose_account">Choose account</string>
<string name="sync_string_contacts">Contacts</string>
<string name="use_ssl">Use Secure Connection</string>

View file

@ -50,11 +50,11 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
private AccountManager mAccountManager;
private Account mAccount;
private String[] mLocalPaths, mRemotePaths;
private boolean mResult;
private int mUploadType;
private Notification mNotification;
private int mTotalDataToSend, mSendData;
private int mCurrentIndexUpload, mPreviousPercent;
private int mSuccessCounter;
@Override
public IBinder onBind(Intent arg0) {
@ -122,12 +122,16 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
}
public void run() {
if (mResult) {
Toast.makeText(this, "Upload successfull", Toast.LENGTH_SHORT)
.show();
String message;
if (mSuccessCounter == mLocalPaths.length) {
message = getString(R.string.uploader_upload_succeed);
} else {
message = getString(R.string.uploader_upload_failed);
if (mLocalPaths.length > 1)
message += " (" + mSuccessCounter + " / " + mLocalPaths.length + getString(R.string.uploader_files_uploaded_suffix) + ")";
Toast.makeText(this, "Upload could not be completed", Toast.LENGTH_SHORT).show();
}
Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
}
public void uploadFile() {
@ -169,6 +173,8 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
Log.d(TAG, "Will upload " + mTotalDataToSend + " bytes, with " + mLocalPaths.length + " files");
mSuccessCounter = 0;
for (int i = 0; i < mLocalPaths.length; ++i) {
String mimeType;
@ -182,10 +188,9 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
mimeType = "application/octet-stream";
}
mResult = false;
mCurrentIndexUpload = i;
if (wc.putFile(mLocalPaths[i], mRemotePaths[i], mimeType)) {
mResult |= true;
mSuccessCounter++;
OCFile new_file = new OCFile(mRemotePaths[i]);
new_file.setMimetype(mimeType);
new_file.setFileLength(new File(mLocalPaths[i]).length());