Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 5f20afb

Browse files
Sam1301kunall17
authored andcommitted
Add support for multiple upload notifications.
1 parent 5f6ffea commit 5f20afb

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

app/src/main/java/com/zulip/android/activities/ZulipActivity.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,16 +1094,15 @@ private void startFileUpload() {
10941094
}
10951095

10961096
@NonNull
1097-
private MultipartBody.Part prepareFilePart(String partName, File file) {
1097+
private MultipartBody.Part prepareFilePart(String partName, File file, int notificationId) {
10981098
// create UploadProgressRequest instance from file
1099-
// TODO: change for multiple uploads
11001099
UploadProgressRequest request = new UploadProgressRequest(file, new UploadProgressRequest.UploadCallbacks() {
11011100
@Override
11021101
public void onProgressUpdate(int percentage, String progress, int notificationId) {
11031102
// update notification
11041103
progressNotification(notificationId, percentage, progress);
11051104
}
1106-
}, 100);
1105+
}, notificationId);
11071106

11081107
// MultipartBody.Part is used to send also the actual file name
11091108
return MultipartBody.Part.createFormData(partName, file.getName(), request);
@@ -1175,15 +1174,15 @@ private void endNotification(int notificationId, String content) {
11751174
* @param file on local storage
11761175
*/
11771176
private void uploadFile(final File file) {
1177+
final int notifId = (int) ((new Date().getTime() / 1000L) % Integer.MAX_VALUE);
11781178

11791179
// MultipartBody.Part is used to send also the actual file name
1180-
MultipartBody.Part body = prepareFilePart("file", file);
1180+
MultipartBody.Part body = prepareFilePart("file", file, notifId);
11811181

11821182
final String loadingMsg = getResources().getString(R.string.uploading_message);
11831183

11841184
// start notification
1185-
// TODO: handle different notif ids
1186-
setNotification(100, getString(R.string.init_notif_title));
1185+
setNotification(notifId, getString(R.string.init_notif_title));
11871186

11881187
// finally, execute the request
11891188
// create upload service client
@@ -1195,7 +1194,7 @@ public void onSuccess(Call<UploadResponse> call, Response<UploadResponse> respon
11951194
UploadResponse uploadResponse = response.body();
11961195
filePathOnServer = uploadResponse.getUri();
11971196
if (!filePathOnServer.equals("")) {
1198-
endNotification(100, getString(R.string.finish_notif_title));
1197+
endNotification(notifId, getString(R.string.finish_notif_title));
11991198
// remove loading message from the screen
12001199
sendingMessage(false, loadingMsg);
12011200

app/src/main/res/values/strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,9 @@
171171
<string name="notif_title">Upload to Zulip</string>
172172
<string name="init_notif_title">Starting upload</string>
173173
<string name="finish_notif_title">Complete</string>
174+
<string name="upload_big_file">Yowza, that’s a big file.</string>
175+
<string name="photo_dialog">Take photo</string>
176+
<string name="pick_dialog">Pick a file</string>
177+
<string name="to_string">" to "</string>
178+
<string name="upload_started_str">Upload started</string>
174179
</resources>

0 commit comments

Comments
 (0)