mirror of
https://github.com/nextcloud/android.git
synced 2024-11-29 18:59:18 +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 notificationManager = UploadNotificationManager(context, viewThemeUtils)
|
||||||
private val intents = FileUploaderIntents(context)
|
private val intents = FileUploaderIntents(context)
|
||||||
private val fileUploaderDelegate = FileUploaderDelegate()
|
private val fileUploaderDelegate = FileUploaderDelegate()
|
||||||
private val helper = FilesUploadHelper()
|
|
||||||
|
|
||||||
override fun doWork(): Result {
|
override fun doWork(): Result {
|
||||||
backgroundJobManager.logStartOfWorker(BackgroundJobManagerImpl.formatClassTag(this::class))
|
backgroundJobManager.logStartOfWorker(BackgroundJobManagerImpl.formatClassTag(this::class))
|
||||||
|
|
|
@ -95,6 +95,8 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
private final ViewThemeUtils viewThemeUtils;
|
private final ViewThemeUtils viewThemeUtils;
|
||||||
private NotificationManager mNotificationManager;
|
private NotificationManager mNotificationManager;
|
||||||
|
|
||||||
|
private final FilesUploadHelper uploadHelper = new FilesUploadHelper();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSectionCount() {
|
public int getSectionCount() {
|
||||||
return uploadGroups.length;
|
return uploadGroups.length;
|
||||||
|
@ -126,11 +128,8 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
headerViewHolder.binding.uploadListAction.setOnClickListener(v -> {
|
headerViewHolder.binding.uploadListAction.setOnClickListener(v -> {
|
||||||
switch (group.type) {
|
switch (group.type) {
|
||||||
case CURRENT -> {
|
case CURRENT -> {
|
||||||
FilesUploadHelper uploadHelper = parentActivity.getFileUploaderHelper();
|
for (OCUpload upload : group.getItems()) {
|
||||||
if (uploadHelper != null) {
|
uploadHelper.cancelFileUpload(upload.getRemotePath(), upload.getAccountName());
|
||||||
for (OCUpload upload : group.getItems()) {
|
|
||||||
uploadHelper.cancelFileUpload(upload.getRemotePath(), upload.getAccountName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case FINISHED -> uploadsStorageManager.clearSuccessfulUploads();
|
case FINISHED -> uploadsStorageManager.clearSuccessfulUploads();
|
||||||
|
@ -139,8 +138,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
uploadsStorageManager,
|
uploadsStorageManager,
|
||||||
connectivityService,
|
connectivityService,
|
||||||
accountManager,
|
accountManager,
|
||||||
powerManagementService
|
powerManagementService)).start();
|
||||||
)).start();
|
|
||||||
default -> {
|
default -> {
|
||||||
}
|
}
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -270,44 +268,41 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
viewThemeUtils.platform.themeHorizontalProgressBar(itemViewHolder.binding.uploadProgressBar);
|
viewThemeUtils.platform.themeHorizontalProgressBar(itemViewHolder.binding.uploadProgressBar);
|
||||||
itemViewHolder.binding.uploadProgressBar.setProgress(0);
|
itemViewHolder.binding.uploadProgressBar.setProgress(0);
|
||||||
itemViewHolder.binding.uploadProgressBar.setVisibility(View.VISIBLE);
|
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; ...
|
|
||||||
if (progressListener != null) {
|
|
||||||
OCUpload ocUpload = progressListener.getUpload();
|
|
||||||
|
|
||||||
if (ocUpload == null) {
|
if (uploadHelper.isUploadingNow(item)) {
|
||||||
return;
|
// really uploading, so...
|
||||||
}
|
// ... unbind the old progress bar, if any; ...
|
||||||
|
if (progressListener != null) {
|
||||||
|
OCUpload ocUpload = progressListener.getUpload();
|
||||||
|
|
||||||
String targetKey = FilesUploadHelper.Companion.buildRemoteName(ocUpload.getAccountName(), ocUpload.getRemotePath());
|
if (ocUpload == null) {
|
||||||
uploadHelper.removeUploadTransferProgressListener(progressListener, targetKey);
|
return;
|
||||||
}
|
}
|
||||||
// ... then, bind the current progress bar to listen for updates
|
|
||||||
progressListener = new ProgressListener(item, itemViewHolder.binding.uploadProgressBar);
|
|
||||||
String targetKey = FilesUploadHelper.Companion.buildRemoteName(item.getAccountName(), item.getRemotePath());
|
|
||||||
uploadHelper.addUploadTransferProgressListener(progressListener, targetKey);
|
|
||||||
} else {
|
|
||||||
// not really uploading; stop listening progress if view is reused!
|
|
||||||
if (progressListener != null &&
|
|
||||||
progressListener.isWrapping(itemViewHolder.binding.uploadProgressBar)) {
|
|
||||||
OCUpload ocUpload = progressListener.getUpload();
|
|
||||||
|
|
||||||
if (ocUpload == null) {
|
String targetKey = FilesUploadHelper.Companion.buildRemoteName(ocUpload.getAccountName(), ocUpload.getRemotePath());
|
||||||
return;
|
uploadHelper.removeUploadTransferProgressListener(progressListener, targetKey);
|
||||||
}
|
|
||||||
|
|
||||||
String targetKey = FilesUploadHelper.Companion.buildRemoteName(ocUpload.getAccountName(), ocUpload.getRemotePath());
|
|
||||||
|
|
||||||
uploadHelper.removeUploadTransferProgressListener(progressListener, targetKey);
|
|
||||||
progressListener = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// ... then, bind the current progress bar to listen for updates
|
||||||
|
progressListener = new ProgressListener(item, itemViewHolder.binding.uploadProgressBar);
|
||||||
|
String targetKey = FilesUploadHelper.Companion.buildRemoteName(item.getAccountName(), item.getRemotePath());
|
||||||
|
uploadHelper.addUploadTransferProgressListener(progressListener, targetKey);
|
||||||
} else {
|
} else {
|
||||||
Log_OC.w(TAG, "FileUploaderBinder not ready yet for upload " + item.getRemotePath());
|
// not really uploading; stop listening progress if view is reused!
|
||||||
|
if (progressListener != null &&
|
||||||
|
progressListener.isWrapping(itemViewHolder.binding.uploadProgressBar)) {
|
||||||
|
OCUpload ocUpload = progressListener.getUpload();
|
||||||
|
|
||||||
|
if (ocUpload == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String targetKey = FilesUploadHelper.Companion.buildRemoteName(ocUpload.getAccountName(), ocUpload.getRemotePath());
|
||||||
|
|
||||||
|
uploadHelper.removeUploadTransferProgressListener(progressListener, targetKey);
|
||||||
|
progressListener = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
itemViewHolder.binding.uploadDate.setVisibility(View.GONE);
|
itemViewHolder.binding.uploadDate.setVisibility(View.GONE);
|
||||||
itemViewHolder.binding.uploadFileSize.setVisibility(View.GONE);
|
itemViewHolder.binding.uploadFileSize.setVisibility(View.GONE);
|
||||||
itemViewHolder.binding.uploadProgressBar.invalidate();
|
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.setImageResource(R.drawable.ic_action_cancel_grey);
|
||||||
itemViewHolder.binding.uploadRightButton.setVisibility(View.VISIBLE);
|
itemViewHolder.binding.uploadRightButton.setVisibility(View.VISIBLE);
|
||||||
itemViewHolder.binding.uploadRightButton.setOnClickListener(v -> {
|
itemViewHolder.binding.uploadRightButton.setOnClickListener(v -> {
|
||||||
FilesUploadHelper uploadHelper = parentActivity.getFileUploaderHelper();
|
uploadHelper.cancelFileUpload(item.getRemotePath(), item.getAccountName());
|
||||||
if (uploadHelper != null) {
|
loadUploadItemsFromDb();
|
||||||
uploadHelper.cancelFileUpload(item.getRemotePath(), item.getAccountName());
|
|
||||||
loadUploadItemsFromDb();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
} else if (item.getUploadStatus() == UploadStatus.UPLOAD_FAILED) {
|
} else if (item.getUploadStatus() == UploadStatus.UPLOAD_FAILED) {
|
||||||
|
@ -374,7 +366,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
File file = new File(item.getLocalPath());
|
File file = new File(item.getLocalPath());
|
||||||
Optional<User> user = accountManager.getUser(item.getAccountName());
|
Optional<User> user = accountManager.getUser(item.getAccountName());
|
||||||
if (file.exists() && user.isPresent()) {
|
if (file.exists() && user.isPresent()) {
|
||||||
new FilesUploadHelper().retryUpload(item, user.get());
|
uploadHelper.retryUpload(item, user.get());
|
||||||
loadUploadItemsFromDb();
|
loadUploadItemsFromDb();
|
||||||
} else {
|
} else {
|
||||||
DisplayUtils.showSnackMessage(
|
DisplayUtils.showSnackMessage(
|
||||||
|
@ -619,14 +611,11 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
* @return Text describing the status of the given upload.
|
* @return Text describing the status of the given upload.
|
||||||
*/
|
*/
|
||||||
private String getStatusText(OCUpload upload) {
|
private String getStatusText(OCUpload upload) {
|
||||||
|
|
||||||
String status;
|
String status;
|
||||||
switch (upload.getUploadStatus()) {
|
switch (upload.getUploadStatus()) {
|
||||||
|
|
||||||
case UPLOAD_IN_PROGRESS:
|
case UPLOAD_IN_PROGRESS:
|
||||||
status = parentActivity.getString(R.string.uploads_view_later_waiting_to_upload);
|
status = parentActivity.getString(R.string.uploads_view_later_waiting_to_upload);
|
||||||
FilesUploadHelper uploadHelper = parentActivity.getFileUploaderHelper();
|
if (uploadHelper.isUploadingNow(upload)) {
|
||||||
if (uploadHelper != null && uploadHelper.isUploadingNow(upload)) {
|
|
||||||
// really uploading, bind the progress bar to listen for progress updates
|
// really uploading, bind the progress bar to listen for progress updates
|
||||||
status = parentActivity.getString(R.string.uploader_upload_in_progress_ticker);
|
status = parentActivity.getString(R.string.uploader_upload_in_progress_ticker);
|
||||||
}
|
}
|
||||||
|
@ -873,8 +862,6 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
||||||
}
|
}
|
||||||
|
|
||||||
void fixAndSortItems(OCUpload... array) {
|
void fixAndSortItems(OCUpload... array) {
|
||||||
FilesUploadHelper uploadHelper = parentActivity.getFileUploaderHelper();
|
|
||||||
|
|
||||||
for (OCUpload upload : array) {
|
for (OCUpload upload : array) {
|
||||||
upload.setDataFixed(uploadHelper);
|
upload.setDataFixed(uploadHelper);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue