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 1756215183
commit 780f6e97b9
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.
*/

View File

@@ -696,6 +696,7 @@
<string name="removable_drive_title_receive">Receive data</string>
<string name="removable_drive_send_intro">Tap the button below to create a new file containing the encrypted messages. You can choose where the file will be saved.\n\nIf you want to save the file on a removable drive, insert the drive now.</string>
<string name="removable_drive_send_no_data">There are currently no messages waiting to be sent to this contact.</string>
<string name="removable_drive_send_not_supported">This contact is using an old version of Briar which does not yet support this feature.</string>
<string name="removable_drive_send_button">Choose file for export</string>
<string name="removable_drive_ongoing">Please wait for ongoing task to complete</string>
<string name="removable_drive_receive_intro">Tap the button below to choose the file that your contact sent you.\n\nIf the file is on a removable drive, insert the drive now.</string>