From: David A. Velasco Date: Mon, 2 Jul 2012 08:41:56 +0000 (+0200) Subject: Download failures not treated as successes X-Git-Tag: oc-android-1.4.3~323^2~5 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/41f2cf116916d7fd8e2adbe3b513713fed02eefa?ds=inline Download failures not treated as successes --- diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 4e9ca6f2..0a1bac7a 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -18,7 +18,7 @@ --> + android:versionName="0.1.141B" xmlns:android="http://schemas.android.com/apk/res/android"> diff --git a/res/values/strings.xml b/res/values/strings.xml index 5e21f88e..4624a7dc 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -69,6 +69,7 @@ Uploading completed successfully Upload failed: files uploaded + Download could not be completed Choose account Contacts Use Secure Connection diff --git a/src/eu/alefzero/owncloud/files/services/FileDownloader.java b/src/eu/alefzero/owncloud/files/services/FileDownloader.java index 323faf46..734359ed 100644 --- a/src/eu/alefzero/owncloud/files/services/FileDownloader.java +++ b/src/eu/alefzero/owncloud/files/services/FileDownloader.java @@ -33,6 +33,7 @@ import eu.alefzero.webdav.WebdavClient; public class FileDownloader extends Service implements OnDatatransferProgressListener { public static final String DOWNLOAD_FINISH_MESSAGE = "DOWNLOAD_FINISH"; + public static final String BAD_DOWNLOAD_MESSAGE = "BAD_DOWNLOAD"; public static final String EXTRA_ACCOUNT = "ACCOUNT"; public static final String EXTRA_FILE_PATH = "FILE_PATH"; public static final String EXTRA_REMOTE_PATH = "REMOTE_PATH"; @@ -144,6 +145,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis Log.e(TAG, file.getAbsolutePath() + " " + oc_url.toString()); Log.e(TAG, mFilePath+""); + String message; if (wdc.downloadFile(mRemotePath, file)) { ContentValues cv = new ContentValues(); cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getAbsolutePath()); @@ -155,9 +157,13 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis new String[] { mFilePath.substring(mFilePath.lastIndexOf('/') + 1), mAccount.name }); + message = DOWNLOAD_FINISH_MESSAGE; + } else { + message = BAD_DOWNLOAD_MESSAGE; } + mNotificationMngr.cancel(1); - Intent end = new Intent(DOWNLOAD_FINISH_MESSAGE); + Intent end = new Intent(message); end.putExtra(EXTRA_FILE_PATH, file.getAbsolutePath()); sendBroadcast(end); } diff --git a/src/eu/alefzero/owncloud/files/services/FileUploader.java b/src/eu/alefzero/owncloud/files/services/FileUploader.java index 23e24c4d..1e688b5e 100644 --- a/src/eu/alefzero/owncloud/files/services/FileUploader.java +++ b/src/eu/alefzero/owncloud/files/services/FileUploader.java @@ -129,7 +129,6 @@ public class FileUploader extends Service implements OnDatatransferProgressListe 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(); } diff --git a/src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java b/src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java index 39a88317..230d3a75 100644 --- a/src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java +++ b/src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java @@ -70,7 +70,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { Log.d(TAG, "syncing owncloud account " + account.name); - sendStickyBroadcast(true, -1); // starting message to the main IU + sendStickyBroadcast(true, -1); // starting message to UI PropFindMethod query; try { @@ -131,7 +131,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter { getStorageManager().removeFile(file); } - // synched folder -> notice to main thread + // synched folder -> notice to IU sendStickyBroadcast(true, parentId); // recursive fetch diff --git a/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java b/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java index 657d6df9..beb9f666 100644 --- a/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java +++ b/src/eu/alefzero/owncloud/ui/activity/FileDisplayActivity.java @@ -147,7 +147,6 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements case R.id.startSync: { Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); - bundle.putString("PROBANDO", "PARAMETRO PASADO AL SYNC"); ContentResolver.requestSync( AccountUtils.getCurrentOwnCloudAccount(this), "org.owncloud", bundle); diff --git a/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java b/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java index 2badae1d..c9863caf 100644 --- a/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java +++ b/src/eu/alefzero/owncloud/ui/fragment/FileDetailFragment.java @@ -373,8 +373,13 @@ public class FileDetailFragment extends SherlockFragment implements private class DownloadFinishReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - ((OCFile)mIntent.getParcelableExtra(EXTRA_FILE)).setStoragePath(intent.getStringExtra(FileDownloader.EXTRA_FILE_PATH)); - updateFileDetails(mIntent); + if (intent.getAction().equals(FileDownloader.BAD_DOWNLOAD_MESSAGE)) { + Toast.makeText(context, R.string.downloader_download_failed , Toast.LENGTH_SHORT).show(); + + } else if (intent.getAction().equals(FileDownloader.DOWNLOAD_FINISH_MESSAGE)) { + ((OCFile)mIntent.getParcelableExtra(EXTRA_FILE)).setStoragePath(intent.getStringExtra(FileDownloader.EXTRA_FILE_PATH)); + updateFileDetails(mIntent); + } } }