5136: Fix retried uploads stuck in queued state (#5272)

* fix stuck uploads

* automate retries for failed uploads once the user returns to the app

* UploadWorker: modify PendingIntent flag and Android version code

* MainActivity: remove automatic retry logic

* Revert "MainActivity: remove automatic retry logic"

* set work request as expedited

* handle notification for foreground service on older versions of Android

* set backoff criteria for work requests

* enqueue failed uploads for a retry

* revert "enqueue failed uploads for a retry"

* limit the number of retries for a failed upload

* add a popup that suggests users to switch to unrestricted battery usage mode

* take users to the battery settings page on the first big upload

* take users to battery optimisation settings page using the standard intent

* add instructions to the battery optimisation settings popup

* remove the first usage of fr.free.nrw.commons from the popup

* comply with the wording in the OS settings

* modify battery optimisation popup instructions, add comments and rename firstBigUploadSet

* add filename to the retry log statement

* update database version

* make battery optimisation dialog appear only on Android 6 and above

* use foreground service instead of setting work request as expedited

* fix retried uploads stuck in queued state

* use MIN_BACKOFF_MILLIS constant instead of using the number 10 and add comments

* factorise the creation of the new OneTimeWorkRequest at one place

* ensure work requests are in accordance with the unit tests

* forbid retries for images which have got uploaded without caption

* add a TODO for the suggestion related to retries

* revert "forbid retries for images which have got uploaded without caption"
This commit is contained in:
Ritika Pahwa 2023-09-09 22:46:13 +05:30 committed by GitHub
parent 4540f54d59
commit 81030d1e78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 200 additions and 47 deletions

View file

@ -62,6 +62,7 @@
<string name="bullet">&#8226;</string>
<string name="menu_settings">Settings</string>
<string name="intent_share_upload_label">Upload to Commons</string>
<string name="upload_in_progress">Upload in progress</string>
<string name="username">Username</string>
<string name="password">Password</string>
<string name="login_credential">Log in to your Commons Beta account</string>
@ -75,6 +76,9 @@
<string name="login_success">Login success!</string>
<string name="login_failed">Login failed!</string>
<string name="upload_failed">File not found. Please try another file.</string>
<string name="retry_limit_reached">Maximum retry limit reached! Please cancel the upload and try again</string>
<string name="unrestricted_battery_mode">Turn battery optimization off?</string>
<string name="suggest_unrestricted_mode">Uploading more than 3 images works more reliably when the battery optimization is turned off. Please turn battery optimization off for the Commons app from the settings for a smooth upload experience. \n\nPossible steps to turn battery optimization off:\n\nStep 1: Tap on the \'Settings\' button below.\n\nStep 2: Switch from \'Not optimized\' to \'All apps\'.\n\nStep 3: Search for \"Commons\" or \"fr.free.nrw.commons\".\n\nStep 4: Tap it and select \'Don\'t optimize\'.\n\nStep 5: Press \'Done\'.</string>
<string name="authentication_failed">Authentication failed, please login again</string>
<string name="uploading_started">Upload started!</string>
<string name="uploading_queued">Upload queued (limited connection mode enabled)</string>