Check if the chosen contact supports removable drive transport

and show message if not
This commit is contained in:
Torsten Grote
2021-06-30 16:42:28 -03:00
parent ccb4f88b89
commit 765dbcc111
4 changed files with 14 additions and 1 deletions

View File

@@ -93,7 +93,9 @@ class RemovableDriveViewModel extends DbViewModel {
ContactId c = requireNonNull(contactId);
runOnDbThread(() -> {
try {
if (manager.isWriterTaskNeeded(c)) {
if (!manager.isTransportSupportedByContact(c)) {
state.postValue(new TransferDataState.NotSupported());
} else if (manager.isWriterTaskNeeded(c)) {
state.postValue(new TransferDataState.Ready());
} else {
state.postValue(new TransferDataState.NoDataToSend());

View File

@@ -102,6 +102,9 @@ public class SendFragment extends Fragment {
if (state instanceof TransferDataState.NoDataToSend) {
introTextView.setText(R.string.removable_drive_send_no_data);
button.setEnabled(false);
} else if (state instanceof TransferDataState.NotSupported) {
introTextView.setText(R.string.removable_drive_send_not_supported);
button.setEnabled(false);
} else if (state instanceof TransferDataState.Ready) {
button.setEnabled(true);
} else if (state instanceof TransferDataState.TaskAvailable) {

View File

@@ -13,6 +13,13 @@ abstract class TransferDataState {
static class NoDataToSend extends TransferDataState {
}
/**
* The chosen contact does not support the transport, yet.
* So we can't send them data this way.
*/
static class NotSupported extends TransferDataState {
}
/**
* We are ready to let the user select a file for sending or receiving data.
*/