-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Added pending uploads screen #5752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
13b4987
474c3bc
771f889
cd11e1c
ecb934c
1286a8d
a6c9752
d825cd7
51bdd2b
6cf975f
517e0ca
c3b8f6a
520baed
3b660da
7a1e381
ea48335
28ac25f
0b5fb6d
1e032e6
04c102d
c98ae7e
0b75774
9cbf988
5c71ca6
de0dc45
45681f7
81de2ed
0051dcc
ca1bf88
33897bb
91affcf
926ef27
ea693b3
efa7ae7
72500b2
4005a51
64ad6ca
a01263a
170d0b1
9f77fbb
283e2c0
b8723ad
5b57c25
7255c99
368d3bb
4eaad5a
7d56b31
aeb49cd
ae00a9d
e96cc8b
9a3acdc
4a2570c
71c3e81
f1deb7b
4ea3698
34930f1
9a4e87b
a9d26bb
07021a2
45f2359
35eadf3
dc37060
8ed879f
c12c7f0
a416222
5ed0650
31f45d8
b5f537f
e855a2c
49859e3
e846004
8b6af52
a8a9c30
031d355
17305b4
ff27796
63f5a9f
1308546
31f6b3d
51e9489
c02a453
b3bc1b8
29183df
e3fb9fa
bd3924f
edf83b6
0972d11
982b0b2
a112f48
b8063a5
56ccc48
2ca0c72
960ce5e
3b13eda
971c426
6c97917
a14256b
973627c
1d94aa9
c7390c4
70a4e1d
97bceba
7998f36
4d8767a
4a10b08
a9e70ab
312ebb9
0809732
ea86184
ef0512f
c686ec8
f23cd7f
083cabd
d776522
9e28cfd
01b5c7d
61375da
eebfdef
cb8640a
ae3df4b
e1e8443
4b02dd7
6e56f07
42a629f
63d260d
dd77937
5b234de
a79642b
efe13d5
04539e0
810d86c
cdac03c
7f6fb0b
2d59c3b
6028812
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,6 @@ data class StashUploadResult( | |
enum class StashUploadState { | ||
SUCCESS, | ||
PAUSED, | ||
FAILED | ||
FAILED, | ||
CANCELLED | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,15 +78,23 @@ class UploadClient @Inject constructor( | |
compositeDisposable.add( | ||
Observable.fromIterable(fileChunks).forEach { chunkFile: File -> | ||
if (canProcess(contribution, failures)) { | ||
processChunk( | ||
filename, contribution, notificationUpdater, chunkFile, | ||
failures, chunkInfo, index, errorMessage, mediaType!!, file!!, fileChunks.size | ||
) | ||
if (CommonsApplication.cancelledUploads.contains(contribution.pageId)) { | ||
compositeDisposable.clear() | ||
return@forEach | ||
}else{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, we still don't have a linter on our repository. Would you mind making the spaces around if-else blocks more consistent? We follow the Java style guide. |
||
processChunk( | ||
filename, contribution, notificationUpdater, chunkFile, | ||
failures, chunkInfo, index, errorMessage, mediaType!!, file!!, fileChunks.size | ||
) | ||
} | ||
} | ||
} | ||
) | ||
|
||
return when { | ||
CommonsApplication.cancelledUploads.contains(contribution.pageId) -> { | ||
return Observable.just(StashUploadResult(StashUploadState.CANCELLED, null, "Upload cancelled")) | ||
} | ||
contribution.isPaused() -> { | ||
Timber.d("Upload stash paused %s", contribution.pageId) | ||
Observable.just(StashUploadResult(StashUploadState.PAUSED, null, null)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,7 +189,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | |
.blockingGet() | ||
//Showing initial notification for the number of uploads being processed | ||
|
||
Timber.e("Queued Contributions: " + queuedContributions.size) | ||
Timber.tag("PRINT").e("Queued Contributions: " + queuedContributions.size) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we're planning to club the log messages together, then I would suggest using a more specific name. |
||
|
||
processingUploads.setContentTitle(appContext.getString(R.string.starting_uploads)) | ||
processingUploads.setContentText( | ||
|
@@ -344,7 +344,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | |
).onErrorReturn{ | ||
return@onErrorReturn StashUploadResult(StashUploadState.FAILED,fileKey = null,errorMessage = it.message) | ||
}.blockingSingle() | ||
|
||
Timber.tag("PRINT").e("-- "+stashUploadResult.state) | ||
when (stashUploadResult.state) { | ||
StashUploadState.SUCCESS -> { | ||
//If the stash upload succeeds | ||
|
@@ -404,6 +404,9 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | |
contribution.state = Contribution.STATE_PAUSED | ||
contributionDao.saveSynchronous(contribution) | ||
} | ||
StashUploadState.CANCELLED -> { | ||
showCancelledNotification(contribution) | ||
} | ||
else -> { | ||
Timber.e("""upload file to stash failed with status: ${stashUploadResult.state}""") | ||
showInvalidLoginNotification(contribution) | ||
|
@@ -622,6 +625,25 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) : | |
) | ||
} | ||
|
||
/** | ||
* Notify that the current upload is cancelled | ||
* @param contribution | ||
*/ | ||
private fun showCancelledNotification(contribution: Contribution) { | ||
val displayTitle = contribution.media.displayTitle | ||
curentNotification.setContentIntent(getPendingIntent(UploadProgressActivity::class.java)) | ||
curentNotification.setContentTitle( | ||
displayTitle | ||
) | ||
.setContentText("Upload has been cancelled!") | ||
.setProgress(0, 0, false) | ||
.setOngoing(false) | ||
notificationManager!!.notify( | ||
currentNotificationTag, currentNotificationID, | ||
curentNotification.build() | ||
) | ||
} | ||
|
||
/** | ||
* Method used to get Pending intent for opening different screen after clicking on notification | ||
* @param toClass | ||
|
Uh oh!
There was an error while loading. Please reload this page.