X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/c9ce39241ea7e20a791dcd2ba8a8ca8b8bed3c1b..1caeb59e9dd66e7c4cd0ca1b254d54509ae929a8:/src/com/owncloud/android/files/services/FileDownloader.java diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index 1c53bea4..ba9824ad 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -36,6 +36,8 @@ import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.network.OnDatatransferProgressListener; import com.owncloud.android.lib.common.OwnCloudClientFactory; import com.owncloud.android.lib.common.OwnCloudClient; +import com.owncloud.android.notifications.NotificationBuilderWithProgressBar; +import com.owncloud.android.notifications.NotificationDelayer; import com.owncloud.android.operations.DownloadFileOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; @@ -46,7 +48,6 @@ import com.owncloud.android.ui.preview.PreviewImageActivity; import com.owncloud.android.ui.preview.PreviewImageFragment; import com.owncloud.android.utils.ErrorMessageAdapter; import com.owncloud.android.utils.Log_OC; -import com.owncloud.android.utils.NotificationBuilderWithProgressBar; import android.accounts.Account; import android.accounts.AccountsException; @@ -461,8 +462,9 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis */ private void notifyDownloadResult(DownloadFileOperation download, RemoteOperationResult downloadResult) { mNotificationManager.cancel(R.string.downloader_download_in_progress_ticker); - if (!downloadResult.isCancelled() && !downloadResult.isSuccess()) { - int tickerId = R.string.downloader_download_failed_ticker; + if (!downloadResult.isCancelled()) { + int tickerId = (downloadResult.isSuccess()) ? R.string.downloader_download_succeeded_ticker : + R.string.downloader_download_failed_ticker; boolean needsToUpdateCredentials = (downloadResult.getCode() == ResultCode.UNAUTHORIZED || (downloadResult.isIdPRedirection() @@ -501,8 +503,26 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis } mNotificationBuilder.setContentText(ErrorMessageAdapter.getErrorCauseMessage(downloadResult, download, getResources())); - mNotificationManager.notify(tickerId, mNotificationBuilder.build()); + + // Remove success notification + if (downloadResult.isSuccess()) { + // Sleep 2 seconds, so show the notification before remove it + NotificationDelayer.cancelWithDelay( + mNotificationManager, + R.string.downloader_download_succeeded_ticker, + 2000); + /* + Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + public void run() { + mNotificationManager.cancel(R.string.downloader_download_succeeded_ticker); + } + }, 2000); + */ + + } + } }