mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Improved error notification
This commit is contained in:
parent
ea483354eb
commit
28ac25fdb0
1 changed files with 20 additions and 1 deletions
|
|
@ -408,13 +408,14 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
Timber.e("""upload file to stash failed with status: ${stashUploadResult.state}""")
|
Timber.e("""upload file to stash failed with status: ${stashUploadResult.state}""")
|
||||||
showInvalidLoginNotification(contribution)
|
|
||||||
contribution.state = Contribution.STATE_FAILED
|
contribution.state = Contribution.STATE_FAILED
|
||||||
contribution.chunkInfo = null
|
contribution.chunkInfo = null
|
||||||
contribution.errorInfo = stashUploadResult.errorMessage
|
contribution.errorInfo = stashUploadResult.errorMessage
|
||||||
|
showErrorNotification(contribution)
|
||||||
contributionDao.saveSynchronous(contribution)
|
contributionDao.saveSynchronous(contribution)
|
||||||
if (stashUploadResult.errorMessage.equals(CsrfTokenClient.INVALID_TOKEN_ERROR_MESSAGE)) {
|
if (stashUploadResult.errorMessage.equals(CsrfTokenClient.INVALID_TOKEN_ERROR_MESSAGE)) {
|
||||||
Timber.e("Invalid Login, logging out")
|
Timber.e("Invalid Login, logging out")
|
||||||
|
showInvalidLoginNotification(contribution)
|
||||||
val username = sessionManager.userName
|
val username = sessionManager.userName
|
||||||
var logoutListener = CommonsApplication.BaseLogoutListener(
|
var logoutListener = CommonsApplication.BaseLogoutListener(
|
||||||
appContext,
|
appContext,
|
||||||
|
|
@ -603,6 +604,24 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("StringFormatInvalid")
|
||||||
|
private fun showErrorNotification(contribution: Contribution) {
|
||||||
|
val displayTitle = contribution.media.displayTitle
|
||||||
|
curentNotification.setContentTitle(
|
||||||
|
appContext.getString(
|
||||||
|
R.string.upload_failed_notification_title,
|
||||||
|
displayTitle
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.setContentText(contribution.errorInfo)
|
||||||
|
.setProgress(0, 0, false)
|
||||||
|
.setOngoing(false)
|
||||||
|
notificationManager?.notify(
|
||||||
|
currentNotificationTag, currentNotificationID,
|
||||||
|
curentNotification.build()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify that the current upload is paused
|
* Notify that the current upload is paused
|
||||||
* @param contribution
|
* @param contribution
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue