Browse Source

Minor uploads cleanup

pull/63/head
Ezerous 5 years ago
parent
commit
0137f5b651
No known key found for this signature in database GPG Key ID: 262B2954BBA319E3
  1. 4
      app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java
  2. 17
      app/src/main/java/gr/thmmy/mthmmy/services/UploadsReceiver.java
  3. 7
      app/src/main/res/values/strings.xml

4
app/src/main/java/gr/thmmy/mthmmy/activities/upload/UploadActivity.java

@ -710,13 +710,13 @@ public class UploadActivity extends BaseActivity {
uploadNotificationConfig.getProgress().actions.add(new UploadNotificationAction( uploadNotificationConfig.getProgress().actions.add(new UploadNotificationAction(
R.drawable.ic_cancel_accent_24dp, R.drawable.ic_cancel_accent_24dp,
context.getString(R.string.upload_notification_cancel), context.getString(R.string.upload_cancel),
PendingIntent.getBroadcast(context, 0, cancelIntent, PendingIntent.getBroadcast(context, 0, cancelIntent,
PendingIntent.FLAG_UPDATE_CURRENT) PendingIntent.FLAG_UPDATE_CURRENT)
)); ));
uploadNotificationConfig.getError().actions.add(new UploadNotificationAction( uploadNotificationConfig.getError().actions.add(new UploadNotificationAction(
R.drawable.ic_notification, R.drawable.ic_notification,
context.getString(R.string.upload_notification_retry), context.getString(R.string.upload_retry),
PendingIntent.getBroadcast(context, 0, retryIntent, PendingIntent.getBroadcast(context, 0, retryIntent,
PendingIntent.FLAG_UPDATE_CURRENT) PendingIntent.FLAG_UPDATE_CURRENT)
)); ));

17
app/src/main/java/gr/thmmy/mthmmy/services/UploadsReceiver.java

@ -90,11 +90,11 @@ public class UploadsReceiver extends UploadServiceBroadcastReceiver {
uploadInfo.getUploadId().equals(dialogUploadID) && uploadInfo.getUploadId().equals(dialogUploadID) &&
uploadProgressDialog != null) { uploadProgressDialog != null) {
Button alertDialogNeutral = uploadProgressDialog.getButton(AlertDialog.BUTTON_NEUTRAL); Button alertDialogNeutral = uploadProgressDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
alertDialogNeutral.setText("Resume on background"); alertDialogNeutral.setText(R.string.upload_resume_in_background);
alertDialogNeutral.setOnClickListener(v -> uploadProgressDialog.dismiss()); alertDialogNeutral.setOnClickListener(v -> uploadProgressDialog.dismiss());
Button alertDialogNegative = uploadProgressDialog.getButton(AlertDialog.BUTTON_NEGATIVE); Button alertDialogNegative = uploadProgressDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
alertDialogNegative.setText("Cancel"); alertDialogNegative.setText(R.string.upload_cancel);
alertDialogNegative.setOnClickListener(v -> { alertDialogNegative.setOnClickListener(v -> {
UploadService.stopUpload(dialogUploadID); UploadService.stopUpload(dialogUploadID);
uploadProgressDialog.dismiss(); uploadProgressDialog.dismiss();
@ -137,7 +137,7 @@ public class UploadsReceiver extends UploadServiceBroadcastReceiver {
});*/ });*/
Button alertDialogNegative = uploadProgressDialog.getButton(AlertDialog.BUTTON_NEGATIVE); Button alertDialogNegative = uploadProgressDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
alertDialogNegative.setText("Cancel"); alertDialogNegative.setText(R.string.upload_cancel);
alertDialogNegative.setOnClickListener(v -> { alertDialogNegative.setOnClickListener(v -> {
NotificationManager notificationManager = (NotificationManager) context.getApplicationContext(). NotificationManager notificationManager = (NotificationManager) context.getApplicationContext().
getSystemService(Context.NOTIFICATION_SERVICE); getSystemService(Context.NOTIFICATION_SERVICE);
@ -155,7 +155,7 @@ public class UploadsReceiver extends UploadServiceBroadcastReceiver {
TextView dialogProgressText = progressWindow.findViewById(R.id.dialog_upload_progress_text); TextView dialogProgressText = progressWindow.findViewById(R.id.dialog_upload_progress_text);
dialogProgressBar.setVisibility(View.GONE); dialogProgressBar.setVisibility(View.GONE);
dialogProgressText.setText("Upload failed"); dialogProgressText.setText(R.string.upload_failed);
} }
if (uploadInfo.getUploadedBytes() == uploadInfo.getTotalBytes()) { if (uploadInfo.getUploadedBytes() == uploadInfo.getTotalBytes()) {
@ -174,7 +174,7 @@ public class UploadsReceiver extends UploadServiceBroadcastReceiver {
context.sendBroadcast(combinedActionsIntent); context.sendBroadcast(combinedActionsIntent);
} }
Toast.makeText(context.getApplicationContext(), "Upload failed", Toast.LENGTH_SHORT).show(); Toast.makeText(context.getApplicationContext(), R.string.upload_failed, Toast.LENGTH_SHORT).show();
if (storage == null) { if (storage == null) {
storage = new Storage(context.getApplicationContext()); storage = new Storage(context.getApplicationContext());
} }
@ -193,8 +193,9 @@ public class UploadsReceiver extends UploadServiceBroadcastReceiver {
BaseApplication.getInstance().logFirebaseAnalyticsEvent("file_upload", null); BaseApplication.getInstance().logFirebaseAnalyticsEvent("file_upload", null);
} }
else { else {
Timber.e(new MultipartUploadException(response)); MultipartUploadException multipartUploadException = new MultipartUploadException(response);
onError(context,uploadInfo,serverResponse,new MultipartUploadException(response)); Timber.e(multipartUploadException);
onError(context,uploadInfo,serverResponse,multipartUploadException);
} }
if (storage == null) { if (storage == null) {
@ -211,7 +212,7 @@ public class UploadsReceiver extends UploadServiceBroadcastReceiver {
dialogUploadID = null; dialogUploadID = null;
} }
Toast.makeText(context.getApplicationContext(), "Upload canceled", Toast.LENGTH_SHORT).show(); Toast.makeText(context.getApplicationContext(), R.string.upload_canceled, Toast.LENGTH_SHORT).show();
if (storage == null) { if (storage == null) {
storage = new Storage(context.getApplicationContext()); storage = new Storage(context.getApplicationContext());
} }

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

@ -144,8 +144,11 @@
\nThis does not rename your local files.</string> \nThis does not rename your local files.</string>
<string name="upload_progress_dialog_title">Uploading</string> <string name="upload_progress_dialog_title">Uploading</string>
<string name="upload_progress_dialog_bytes_uploaded">Uploading: %1$.2f Kbit/s, %2$d/%3$d KBytes</string> <string name="upload_progress_dialog_bytes_uploaded">Uploading: %1$.2f Kbit/s, %2$d/%3$d KBytes</string>
<string name="upload_notification_cancel">"Cancel"</string> <string name="upload_failed">"Upload failed"</string>
<string name="upload_notification_retry">"Retry"</string> <string name="upload_canceled">"Upload canceled"</string>
<string name="upload_resume_in_background">"Resume in background"</string>
<string name="upload_cancel">"Cancel"</string>
<string name="upload_retry">"Retry"</string>
<!--Upload Fields Builder Activity--> <!--Upload Fields Builder Activity-->
<string name="upload_fields_builder_type_radio_buttons_title">Select type of upload</string> <string name="upload_fields_builder_type_radio_buttons_title">Select type of upload</string>

Loading…
Cancel
Save