From 780f6e97b9ecfefbeb5a188f3241d8fe677df99c Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Wed, 30 Jun 2021 16:42:28 -0300 Subject: [PATCH] Check if the chosen contact supports removable drive transport and show message if not --- .../android/removabledrive/RemovableDriveViewModel.java | 4 +++- .../briar/android/removabledrive/SendFragment.java | 3 +++ .../briar/android/removabledrive/TransferDataState.java | 7 +++++++ briar-android/src/main/res/values/strings.xml | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/RemovableDriveViewModel.java b/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/RemovableDriveViewModel.java index 21cada805..cd64932fb 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/RemovableDriveViewModel.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/RemovableDriveViewModel.java @@ -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()); diff --git a/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/SendFragment.java b/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/SendFragment.java index 22ab9c895..1d8b872cb 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/SendFragment.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/SendFragment.java @@ -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) { diff --git a/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/TransferDataState.java b/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/TransferDataState.java index dc1ae7233..e8ac85058 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/TransferDataState.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/TransferDataState.java @@ -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. */ diff --git a/briar-android/src/main/res/values/strings.xml b/briar-android/src/main/res/values/strings.xml index c86a9ea92..67eb859e0 100644 --- a/briar-android/src/main/res/values/strings.xml +++ b/briar-android/src/main/res/values/strings.xml @@ -696,6 +696,7 @@ Receive data 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. There are currently no messages waiting to be sent to this contact. + This contact is using an old version of Briar which does not yet support this feature. Choose file for export Please wait for ongoing task to complete 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.