Add actions

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2023-12-06 14:26:43 +01:00
parent 5f99e4379d
commit f4ffe4fdae
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF
3 changed files with 32 additions and 19 deletions

View file

@ -70,7 +70,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
* Activity listing pending, active, and completed uploads. User can delete completed uploads from view. Content of this * Activity listing pending, active, and completed uploads. User can delete completed uploads from view. Content of this
* list of coming from {@link UploadsStorageManager}. * list of coming from {@link UploadsStorageManager}.
*/ */
public class UploadListActivity extends FileActivity implements TwoActionDialogFragment.TwoActionDialogActionListener { public class UploadListActivity extends FileActivity {
private static final String TAG = UploadListActivity.class.getSimpleName(); private static final String TAG = UploadListActivity.class.getSimpleName();
public static final String HANDLE_FILE_EXISTENCE_RECEIVER = "HANDLE_FILE_EXISTENCE_RECEIVER"; public static final String HANDLE_FILE_EXISTENCE_RECEIVER = "HANDLE_FILE_EXISTENCE_RECEIVER";
@ -161,24 +161,27 @@ public class UploadListActivity extends FileActivity implements TwoActionDialogF
}; };
private void showHandleFileExistenceDialog() { private void showHandleFileExistenceDialog() {
TwoActionDialogFragment dialog = TwoActionDialogFragment.Companion.newInstance(R.string.uploader_handle_not_existed_file_dialog_title, TwoActionDialogFragment dialog = TwoActionDialogFragment
R.string.uploader_handle_not_existed_file_dialog_message, .Companion
R.string.common_cancel, .newInstance(R.string.uploader_handle_not_existed_file_dialog_title,
R.string.common_ok, R.string.uploader_handle_not_existed_file_dialog_message,
this); R.string.uploader_handle_not_existed_file_dialog_negative_button_text,
R.string.common_ok,
new TwoActionDialogFragment.TwoActionDialogActionListener() {
@Override
public void positiveAction() {
}
@Override
public void negativeAction() {
OCFile fileOnlyExistOnLocalStorage = uploadListAdapter.getSelectedOCFile();
uploadListAdapter.removeUpload(uploadListAdapter.selectedOCUpload);
}
});
dialog.show(this.getSupportFragmentManager(), null); dialog.show(this.getSupportFragmentManager(), null);
} }
@Override
public void positiveAction() {
}
@Override
public void negativeAction() {
}
@Override @Override
protected void onDestroy() { protected void onDestroy() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(handleFileExistenceReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(handleFileExistenceReceiver);
@ -240,8 +243,7 @@ public class UploadListActivity extends FileActivity implements TwoActionDialogF
uploadsStorageManager, uploadsStorageManager,
connectivityService, connectivityService,
userAccountManager, userAccountManager,
powerManagementService powerManagementService)).start();
)).start();
// update UI // update UI
uploadListAdapter.loadUploadItemsFromDb(); uploadListAdapter.loadUploadItemsFromDb();

View file

@ -502,6 +502,7 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
ItemViewHolder itemViewHolder, ItemViewHolder itemViewHolder,
OCUpload item, OCUpload item,
String status) { String status) {
selectedFileRemotePath = item.getRemotePath();
String remotePath = item.getRemotePath(); String remotePath = item.getRemotePath();
OCFile localFile = storageManager.getFileByEncryptedRemotePath(remotePath); OCFile localFile = storageManager.getFileByEncryptedRemotePath(remotePath);
@ -526,7 +527,10 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
return false; return false;
} }
public OCUpload selectedOCUpload;
private void refreshFolderAndUpdateUI(ItemViewHolder holder, User user, OCFile folder, String remotePath, OCUpload item, String status) { private void refreshFolderAndUpdateUI(ItemViewHolder holder, User user, OCFile folder, String remotePath, OCUpload item, String status) {
selectedOCUpload = item;
Context context = MainApp.getAppContext(); Context context = MainApp.getAppContext();
this.refreshFolder(context, holder, user, folder, (caller, result) -> { this.refreshFolder(context, holder, user, folder, (caller, result) -> {
@ -570,7 +574,13 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
popup.show(); popup.show();
} }
private void removeUpload(OCUpload item) { private String selectedFileRemotePath;
public OCFile getSelectedOCFile() {
return storageManager.getFileByEncryptedRemotePath(selectedFileRemotePath);
}
public void removeUpload(OCUpload item) {
uploadsStorageManager.removeUpload(item); uploadsStorageManager.removeUpload(item);
loadUploadItemsFromDb(); loadUploadItemsFromDb();
} }

View file

@ -913,6 +913,7 @@
<string name="create_rich_workspace">Add folder info</string> <string name="create_rich_workspace">Add folder info</string>
<string name="creates_rich_workspace">creates folder info</string> <string name="creates_rich_workspace">creates folder info</string>
<string name="uploader_handle_not_existed_file_dialog_title">File Not Found</string> <string name="uploader_handle_not_existed_file_dialog_title">File Not Found</string>
<string name="uploader_handle_not_existed_file_dialog_negative_button_text">Delete Local File</string>
<string name="uploader_handle_not_existed_file_dialog_message">This file does not longer exist in server still want to upload?</string> <string name="uploader_handle_not_existed_file_dialog_message">This file does not longer exist in server still want to upload?</string>
<string name="uploader_file_not_found_on_server_message">We couldnt locate the file on server. Another user may have deleted the file</string> <string name="uploader_file_not_found_on_server_message">We couldnt locate the file on server. Another user may have deleted the file</string>
<string name="uploader_file_not_found_message">File not found. Are you sure this file exist or conflict not solved before?</string> <string name="uploader_file_not_found_message">File not found. Are you sure this file exist or conflict not solved before?</string>