|
@@ -33,6 +33,7 @@ import android.graphics.drawable.Drawable;
|
|
import android.net.Uri;
|
|
import android.net.Uri;
|
|
import android.text.format.DateUtils;
|
|
import android.text.format.DateUtils;
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
|
|
+import android.view.MenuItem;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
import android.widget.PopupMenu;
|
|
import android.widget.PopupMenu;
|
|
@@ -122,7 +123,8 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|
|
|
|
|
switch (group.type) {
|
|
switch (group.type) {
|
|
case CURRENT, FINISHED -> headerViewHolder.binding.uploadListAction.setImageResource(R.drawable.ic_close);
|
|
case CURRENT, FINISHED -> headerViewHolder.binding.uploadListAction.setImageResource(R.drawable.ic_close);
|
|
- case FAILED -> headerViewHolder.binding.uploadListAction.setImageResource(R.drawable.ic_dots_vertical);
|
|
|
|
|
|
+ case CANCELLED, FAILED -> headerViewHolder.binding.uploadListAction.setImageResource(R.drawable.ic_dots_vertical);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
headerViewHolder.binding.uploadListAction.setOnClickListener(v -> {
|
|
headerViewHolder.binding.uploadListAction.setOnClickListener(v -> {
|
|
@@ -143,6 +145,10 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|
// show popup with option clear or retry filed uploads
|
|
// show popup with option clear or retry filed uploads
|
|
createFailedPopupMenu(headerViewHolder);
|
|
createFailedPopupMenu(headerViewHolder);
|
|
}
|
|
}
|
|
|
|
+ case CANCELLED -> {
|
|
|
|
+ // show popup with option clear or retry manually cancelled uploads
|
|
|
|
+ createCancelledActionsPopupMenu(headerViewHolder);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -173,6 +179,30 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|
failedPopup.show();
|
|
failedPopup.show();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void createCancelledActionsPopupMenu(HeaderViewHolder headerViewHolder){
|
|
|
|
+ PopupMenu popup = new PopupMenu(MainApp.getAppContext(), headerViewHolder.binding.uploadListAction);
|
|
|
|
+ popup.inflate(R.menu.upload_list_cancelled_options);
|
|
|
|
+
|
|
|
|
+ popup.setOnMenuItemClickListener(i -> {
|
|
|
|
+ int itemId = i.getItemId();
|
|
|
|
+
|
|
|
|
+ if (itemId == R.id.action_upload_list_cancelled_clear) {
|
|
|
|
+ uploadsStorageManager.clearManuallyCancelledUploadsForCurrentAccount();
|
|
|
|
+ loadUploadItemsFromDb();
|
|
|
|
+ } else if (itemId == R.id.action_upload_list_cancelled_resume) {
|
|
|
|
+
|
|
|
|
+ new Thread(() -> {
|
|
|
|
+ parentActivity.runOnUiThread(this::loadUploadItemsFromDb);
|
|
|
|
+ // TODO Do something
|
|
|
|
+ }).start();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ });
|
|
|
|
+ popup.show();
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void onBindFooterViewHolder(SectionedViewHolder holder, int section) {
|
|
public void onBindFooterViewHolder(SectionedViewHolder holder, int section) {
|
|
// not needed
|
|
// not needed
|
|
@@ -197,7 +227,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|
this.clock = clock;
|
|
this.clock = clock;
|
|
this.viewThemeUtils = viewThemeUtils;
|
|
this.viewThemeUtils = viewThemeUtils;
|
|
|
|
|
|
- uploadGroups = new UploadGroup[3];
|
|
|
|
|
|
+ uploadGroups = new UploadGroup[4];
|
|
|
|
|
|
shouldShowHeadersForEmptySections(false);
|
|
shouldShowHeadersForEmptySections(false);
|
|
|
|
|
|
@@ -225,6 +255,14 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ uploadGroups[3] = new UploadGroup(Type.CANCELLED,
|
|
|
|
+ parentActivity.getString(R.string.upload_manually_cancelled)) {
|
|
|
|
+ @Override
|
|
|
|
+ public void refresh() {
|
|
|
|
+ fixAndSortItems(uploadsStorageManager.getManuallyCancelledUploadsForCurrentAccount());
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
showUser = accountManager.getAccounts().length > 1;
|
|
showUser = accountManager.getAccounts().length > 1;
|
|
|
|
|
|
loadUploadItemsFromDb();
|
|
loadUploadItemsFromDb();
|
|
@@ -655,7 +693,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|
status = parentActivity.getString(R.string.uploads_view_upload_status_succeeded);
|
|
status = parentActivity.getString(R.string.uploads_view_upload_status_succeeded);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- case UPLOAD_FAILED -> status = getUploadFailedStatusText(upload.getLastResult());
|
|
|
|
|
|
+ case UPLOAD_FAILED, UPLOAD_MANUALLY_CANCELLED -> status = getUploadFailedStatusText(upload.getLastResult());
|
|
default -> status = "Uncontrolled status: " + upload.getUploadStatus();
|
|
default -> status = "Uncontrolled status: " + upload.getUploadStatus();
|
|
}
|
|
}
|
|
return status;
|
|
return status;
|
|
@@ -709,8 +747,8 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|
case SSL_RECOVERABLE_PEER_UNVERIFIED:
|
|
case SSL_RECOVERABLE_PEER_UNVERIFIED:
|
|
status =
|
|
status =
|
|
parentActivity.getString(
|
|
parentActivity.getString(
|
|
- R.string.uploads_view_upload_status_failed_ssl_certificate_not_trusted
|
|
|
|
- );
|
|
|
|
|
|
+ R.string.uploads_view_upload_status_failed_ssl_certificate_not_trusted
|
|
|
|
+ );
|
|
break;
|
|
break;
|
|
case UNKNOWN:
|
|
case UNKNOWN:
|
|
status = parentActivity.getString(R.string.uploads_view_upload_status_unknown_fail);
|
|
status = parentActivity.getString(R.string.uploads_view_upload_status_unknown_fail);
|
|
@@ -720,7 +758,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|
break;
|
|
break;
|
|
case DELAYED_IN_POWER_SAVE_MODE:
|
|
case DELAYED_IN_POWER_SAVE_MODE:
|
|
status = parentActivity.getString(
|
|
status = parentActivity.getString(
|
|
- R.string.uploads_view_upload_status_waiting_exit_power_save_mode);
|
|
|
|
|
|
+ R.string.uploads_view_upload_status_waiting_exit_power_save_mode);
|
|
break;
|
|
break;
|
|
case VIRUS_DETECTED:
|
|
case VIRUS_DETECTED:
|
|
status = parentActivity.getString(R.string.uploads_view_upload_status_virus_detected);
|
|
status = parentActivity.getString(R.string.uploads_view_upload_status_virus_detected);
|
|
@@ -743,6 +781,9 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|
case QUOTA_EXCEEDED:
|
|
case QUOTA_EXCEEDED:
|
|
status = parentActivity.getString(R.string.upload_quota_exceeded);
|
|
status = parentActivity.getString(R.string.upload_quota_exceeded);
|
|
break;
|
|
break;
|
|
|
|
+ case MANUALLY_CANCELLED:
|
|
|
|
+ status = parentActivity.getString(R.string.upload_manually_cancelled);
|
|
|
|
+ break;
|
|
default:
|
|
default:
|
|
status = parentActivity.getString(R.string.upload_unknown_error);
|
|
status = parentActivity.getString(R.string.upload_unknown_error);
|
|
break;
|
|
break;
|
|
@@ -795,17 +836,17 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|
*/
|
|
*/
|
|
private void onUploadedItemClick(OCUpload upload) {
|
|
private void onUploadedItemClick(OCUpload upload) {
|
|
final OCFile file = parentActivity.getStorageManager().getFileByEncryptedRemotePath(upload.getRemotePath());
|
|
final OCFile file = parentActivity.getStorageManager().getFileByEncryptedRemotePath(upload.getRemotePath());
|
|
- if (file == null) {
|
|
|
|
|
|
+ if (file == null){
|
|
DisplayUtils.showSnackMessage(parentActivity, R.string.error_retrieving_file);
|
|
DisplayUtils.showSnackMessage(parentActivity, R.string.error_retrieving_file);
|
|
Log_OC.i(TAG, "Could not find uploaded file on remote.");
|
|
Log_OC.i(TAG, "Could not find uploaded file on remote.");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- if (PreviewImageFragment.canBePreviewed(file)) {
|
|
|
|
|
|
+ if (PreviewImageFragment.canBePreviewed(file)){
|
|
//show image preview and stay in uploads tab
|
|
//show image preview and stay in uploads tab
|
|
Intent intent = FileDisplayActivity.openFileIntent(parentActivity, parentActivity.getUser().get(), file);
|
|
Intent intent = FileDisplayActivity.openFileIntent(parentActivity, parentActivity.getUser().get(), file);
|
|
parentActivity.startActivity(intent);
|
|
parentActivity.startActivity(intent);
|
|
- } else {
|
|
|
|
|
|
+ }else{
|
|
Intent intent = new Intent(parentActivity, FileDisplayActivity.class);
|
|
Intent intent = new Intent(parentActivity, FileDisplayActivity.class);
|
|
intent.setAction(Intent.ACTION_VIEW);
|
|
intent.setAction(Intent.ACTION_VIEW);
|
|
intent.putExtra(FileDisplayActivity.KEY_FILE_PATH, upload.getRemotePath());
|
|
intent.putExtra(FileDisplayActivity.KEY_FILE_PATH, upload.getRemotePath());
|
|
@@ -857,7 +898,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|
}
|
|
}
|
|
|
|
|
|
enum Type {
|
|
enum Type {
|
|
- CURRENT, FINISHED, FAILED
|
|
|
|
|
|
+ CURRENT, FINISHED, FAILED, CANCELLED
|
|
}
|
|
}
|
|
|
|
|
|
abstract class UploadGroup implements Refresh {
|
|
abstract class UploadGroup implements Refresh {
|
|
@@ -901,16 +942,14 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public void cancelOldErrorNotification(OCUpload upload) {
|
|
|
|
|
|
+ public void cancelOldErrorNotification(OCUpload upload){
|
|
|
|
|
|
if (mNotificationManager == null) {
|
|
if (mNotificationManager == null) {
|
|
mNotificationManager = (NotificationManager) parentActivity.getSystemService(parentActivity.NOTIFICATION_SERVICE);
|
|
mNotificationManager = (NotificationManager) parentActivity.getSystemService(parentActivity.NOTIFICATION_SERVICE);
|
|
}
|
|
}
|
|
|
|
|
|
- if (upload == null) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- mNotificationManager.cancel(NotificationUtils.createUploadNotificationTag(upload.getRemotePath(), upload.getLocalPath()),
|
|
|
|
|
|
+ if (upload == null) return;
|
|
|
|
+ mNotificationManager.cancel(NotificationUtils.createUploadNotificationTag(upload.getRemotePath(),upload.getLocalPath()),
|
|
FileUploadWorker.NOTIFICATION_ERROR_ID);
|
|
FileUploadWorker.NOTIFICATION_ERROR_ID);
|
|
|
|
|
|
}
|
|
}
|