mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 07:05:49 +03:00
Rebase master
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
47099dec72
commit
ce4f5c2901
2 changed files with 37 additions and 51 deletions
|
@ -71,7 +71,6 @@ class FilesUploadWorker(
|
|||
private val notificationManager = UploadNotificationManager(context, viewThemeUtils)
|
||||
private val intents = FileUploaderIntents(context)
|
||||
private val fileUploaderDelegate = FileUploaderDelegate()
|
||||
private val helper = FilesUploadHelper()
|
||||
|
||||
override fun doWork(): Result {
|
||||
backgroundJobManager.logStartOfWorker(BackgroundJobManagerImpl.formatClassTag(this::class))
|
||||
|
|
|
@ -95,6 +95,8 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|||
private final ViewThemeUtils viewThemeUtils;
|
||||
private NotificationManager mNotificationManager;
|
||||
|
||||
private final FilesUploadHelper uploadHelper = new FilesUploadHelper();
|
||||
|
||||
@Override
|
||||
public int getSectionCount() {
|
||||
return uploadGroups.length;
|
||||
|
@ -126,21 +128,17 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|||
headerViewHolder.binding.uploadListAction.setOnClickListener(v -> {
|
||||
switch (group.type) {
|
||||
case CURRENT -> {
|
||||
FilesUploadHelper uploadHelper = parentActivity.getFileUploaderHelper();
|
||||
if (uploadHelper != null) {
|
||||
for (OCUpload upload : group.getItems()) {
|
||||
uploadHelper.cancelFileUpload(upload.getRemotePath(), upload.getAccountName());
|
||||
}
|
||||
}
|
||||
}
|
||||
case FINISHED -> uploadsStorageManager.clearSuccessfulUploads();
|
||||
case FAILED -> new Thread(() -> FilesUploadWorker.Companion.retryFailedUploads(
|
||||
parentActivity,
|
||||
uploadsStorageManager,
|
||||
connectivityService,
|
||||
accountManager,
|
||||
powerManagementService
|
||||
)).start();
|
||||
powerManagementService)).start();
|
||||
default -> {
|
||||
}
|
||||
// do nothing
|
||||
|
@ -270,8 +268,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|||
viewThemeUtils.platform.themeHorizontalProgressBar(itemViewHolder.binding.uploadProgressBar);
|
||||
itemViewHolder.binding.uploadProgressBar.setProgress(0);
|
||||
itemViewHolder.binding.uploadProgressBar.setVisibility(View.VISIBLE);
|
||||
FilesUploadHelper uploadHelper = parentActivity.getFileUploaderHelper();
|
||||
if (uploadHelper != null) {
|
||||
|
||||
if (uploadHelper.isUploadingNow(item)) {
|
||||
// really uploading, so...
|
||||
// ... unbind the old progress bar, if any; ...
|
||||
|
@ -305,9 +302,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|||
progressListener = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log_OC.w(TAG, "FileUploaderBinder not ready yet for upload " + item.getRemotePath());
|
||||
}
|
||||
|
||||
itemViewHolder.binding.uploadDate.setVisibility(View.GONE);
|
||||
itemViewHolder.binding.uploadFileSize.setVisibility(View.GONE);
|
||||
itemViewHolder.binding.uploadProgressBar.invalidate();
|
||||
|
@ -323,11 +318,8 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|||
itemViewHolder.binding.uploadRightButton.setImageResource(R.drawable.ic_action_cancel_grey);
|
||||
itemViewHolder.binding.uploadRightButton.setVisibility(View.VISIBLE);
|
||||
itemViewHolder.binding.uploadRightButton.setOnClickListener(v -> {
|
||||
FilesUploadHelper uploadHelper = parentActivity.getFileUploaderHelper();
|
||||
if (uploadHelper != null) {
|
||||
uploadHelper.cancelFileUpload(item.getRemotePath(), item.getAccountName());
|
||||
loadUploadItemsFromDb();
|
||||
}
|
||||
});
|
||||
|
||||
} else if (item.getUploadStatus() == UploadStatus.UPLOAD_FAILED) {
|
||||
|
@ -374,7 +366,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|||
File file = new File(item.getLocalPath());
|
||||
Optional<User> user = accountManager.getUser(item.getAccountName());
|
||||
if (file.exists() && user.isPresent()) {
|
||||
new FilesUploadHelper().retryUpload(item, user.get());
|
||||
uploadHelper.retryUpload(item, user.get());
|
||||
loadUploadItemsFromDb();
|
||||
} else {
|
||||
DisplayUtils.showSnackMessage(
|
||||
|
@ -619,14 +611,11 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|||
* @return Text describing the status of the given upload.
|
||||
*/
|
||||
private String getStatusText(OCUpload upload) {
|
||||
|
||||
String status;
|
||||
switch (upload.getUploadStatus()) {
|
||||
|
||||
case UPLOAD_IN_PROGRESS:
|
||||
status = parentActivity.getString(R.string.uploads_view_later_waiting_to_upload);
|
||||
FilesUploadHelper uploadHelper = parentActivity.getFileUploaderHelper();
|
||||
if (uploadHelper != null && uploadHelper.isUploadingNow(upload)) {
|
||||
if (uploadHelper.isUploadingNow(upload)) {
|
||||
// really uploading, bind the progress bar to listen for progress updates
|
||||
status = parentActivity.getString(R.string.uploader_upload_in_progress_ticker);
|
||||
}
|
||||
|
@ -873,8 +862,6 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|||
}
|
||||
|
||||
void fixAndSortItems(OCUpload... array) {
|
||||
FilesUploadHelper uploadHelper = parentActivity.getFileUploaderHelper();
|
||||
|
||||
for (OCUpload upload : array) {
|
||||
upload.setDataFixed(uploadHelper);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue