From 7e3db6c6dfde93868d2390d6491ee57bcb559ac4 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Thu, 24 Jun 2021 17:35:02 -0300 Subject: [PATCH] Address review feedback for Transfer Data UI --- .../removabledrive/RemovableDriveActivity.java | 15 +++++++++++++-- .../removabledrive/RemovableDriveViewModel.java | 2 +- .../android/removabledrive/SendFragment.java | 2 +- .../briarproject/briar/android/util/UiUtils.java | 5 +++++ .../layout/fragment_transfer_data_chooser.xml | 5 +++-- .../layout/fragment_transfer_data_receive.xml | 2 -- .../res/layout/fragment_transfer_data_send.xml | 6 +----- briar-android/src/main/res/values/strings.xml | 16 ++++++++-------- 8 files changed, 32 insertions(+), 21 deletions(-) diff --git a/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/RemovableDriveActivity.java b/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/RemovableDriveActivity.java index 4f67bce32..501f458fb 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/RemovableDriveActivity.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/removabledrive/RemovableDriveActivity.java @@ -22,6 +22,7 @@ import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.annotation.StringRes; import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; import androidx.lifecycle.ViewModelProvider; import static java.util.Objects.requireNonNull; @@ -95,8 +96,18 @@ public class RemovableDriveActivity extends BriarActivity { if (!(state instanceof TaskAvailable)) return; RemovableDriveTask.State s = ((TaskAvailable) state).state; if (s.isFinished()) { - Action action = - requireNonNull(viewModel.getActionEvent().getLastValue()); + FragmentManager fm = getSupportFragmentManager(); + Action action; + // We can't simply rely on viewModel.getActionEvent() + // as that might have been destroyed in the meantime. + if (fm.findFragmentByTag(SendFragment.TAG) != null) { + action = Action.SEND; + } else if (fm.findFragmentByTag(ReceiveFragment.TAG) != null) { + action = Action.RECEIVE; + } else { + action = requireNonNull( + viewModel.getActionEvent().getLastValue()); + } Fragment f; if (s.isSuccess()) f = getSuccessFragment(action); else f = getErrorFragment(action); 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 87e98c275..21cada805 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 @@ -130,7 +130,7 @@ class RemovableDriveViewModel extends DbViewModel { String getFileName() { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss", US); - return sdf.format(new Date()) + ".zip"; + return sdf.format(new Date()); } /** 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 432a9e7d2..53a478235 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 @@ -107,7 +107,7 @@ public class SendFragment extends Fragment { progressBar.setMax(100); } int progress = s.getTotal() == 0 ? 0 : // no div by null - (int) (s.getDone() / s.getTotal()) * 100; + (int) ((double) s.getDone() / s.getTotal() * 100); if (SDK_INT >= 24) { progressBar.setProgress(progress, true); } else { diff --git a/briar-android/src/main/java/org/briarproject/briar/android/util/UiUtils.java b/briar-android/src/main/java/org/briarproject/briar/android/util/UiUtils.java index fd5140407..9661f1e01 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/util/UiUtils.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/util/UiUtils.java @@ -329,6 +329,11 @@ public class UiUtils { return i; } + public static void putShowAdvancedExtra(Intent i) { + i.putExtra(SDK_INT <= 28 ? "android.content.extra.SHOW_ADVANCED" : + "android.provider.extra.SHOW_ADVANCED", true); + } + /** * @return true if location is enabled, * or it isn't required due to this being a SDK < 28 device. diff --git a/briar-android/src/main/res/layout/fragment_transfer_data_chooser.xml b/briar-android/src/main/res/layout/fragment_transfer_data_chooser.xml index 038945af7..372af3b37 100644 --- a/briar-android/src/main/res/layout/fragment_transfer_data_chooser.xml +++ b/briar-android/src/main/res/layout/fragment_transfer_data_chooser.xml @@ -9,8 +9,9 @@ android:id="@+id/imageView" android:layout_width="0dp" android:layout_height="0dp" - android:layout_margin="32dp" - app:layout_constrainedHeight="true" + android:layout_marginLeft="32dp" + android:layout_marginTop="32dp" + android:layout_marginRight="32dp" app:layout_constraintBottom_toTopOf="@+id/introView" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHeight_max="200dp" diff --git a/briar-android/src/main/res/layout/fragment_transfer_data_receive.xml b/briar-android/src/main/res/layout/fragment_transfer_data_receive.xml index 6448b9d28..29fa5ac9c 100644 --- a/briar-android/src/main/res/layout/fragment_transfer_data_receive.xml +++ b/briar-android/src/main/res/layout/fragment_transfer_data_receive.xml @@ -22,7 +22,6 @@ app:layout_constraintBottom_toBottomOf="@+id/phoneImageView" app:layout_constraintDimensionRatio="1:1" app:layout_constraintEnd_toStartOf="@+id/arrowImageView" - app:layout_constraintHorizontal_bias="0.75" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="@+id/phoneImageView" app:layout_constraintWidth_max="150dp" @@ -67,7 +66,6 @@ app:layout_constraintBottom_toTopOf="@+id/progressBar" app:layout_constraintDimensionRatio="1:1" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.25" app:layout_constraintStart_toEndOf="@+id/arrowImageView" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_chainStyle="spread" diff --git a/briar-android/src/main/res/layout/fragment_transfer_data_send.xml b/briar-android/src/main/res/layout/fragment_transfer_data_send.xml index d2fbc9bef..26fa160dc 100644 --- a/briar-android/src/main/res/layout/fragment_transfer_data_send.xml +++ b/briar-android/src/main/res/layout/fragment_transfer_data_send.xml @@ -22,8 +22,6 @@ app:layout_constraintBottom_toTopOf="@+id/progressBar" app:layout_constraintDimensionRatio="1:1" app:layout_constraintEnd_toStartOf="@+id/arrowImageView" - app:layout_constraintHeight_min="16dp" - app:layout_constraintHorizontal_chainStyle="packed" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_chainStyle="spread" @@ -68,8 +66,7 @@ style="?android:attr/progressBarStyleHorizontal" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginStart="32dp" - android:layout_marginEnd="32dp" + android:layout_margin="32dp" android:visibility="invisible" app:layout_constraintBottom_toTopOf="@+id/introTextView" app:layout_constraintEnd_toEndOf="parent" @@ -82,7 +79,6 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="32dp" - android:layout_marginTop="58dp" android:layout_marginEnd="32dp" android:layout_marginBottom="8dp" android:text="@string/removable_drive_send_intro" diff --git a/briar-android/src/main/res/values/strings.xml b/briar-android/src/main/res/values/strings.xml index c6959f6ef..c86a9ea92 100644 --- a/briar-android/src/main/res/values/strings.xml +++ b/briar-android/src/main/res/values/strings.xml @@ -691,23 +691,23 @@ Transfer data - You can send messages (and other data) using removable storage such as USB flash drives or SD cards.\n\nTransport the removable storage medium to your contact and they can receive the encrypted messages by importing them into Briar by using the receive button below. + You can send encrypted messages to your contact using removable storage such as USB flash drives or SD cards.\n\nIf your contact has sent you a removable drive containing encrypted messages, you can import the messages into Briar by using the receive button below. Send data Receive data - Press the button below to create a new file that will contain the encrypted Briar messages.\n\nAfter inserting a storage medium, you should be able to find it with your phone\'s file manager and create a new file there. - There are currently no messages waiting to be send to this contact.\n\nWrite at least one message and try again. + 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. Choose file for export Please wait for ongoing task to complete - Plug in the storage medium containing encrypted Briar data for you and select the correct file in the file manager by pressing the button below. + 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. Choose file for import Export successful - Data exported successfully to file. You now have 14 days to transport the storage medium to your contact.\n\nRemember to eject the medium from the notification before unplugging it to prevent data loss. + Data exported successfully. You now have 14 days to transport the file to your contact.\n\nIf the file is on a removable drive, use the notification in the status bar to eject the drive before unplugging it. Import successful - All messages contained in this file have arrived. + All encrypted messages contained in this file have been received. Error exporting data - There was an error writing data to the file.\n\nEnsure that the storage medium is properly plugged in and try again.\n\nIf the error persists, you can send feedback to inform about the issue. + There was an error writing data to the file.\n\nIf you are using a removable drive, ensure that it is properly inserted and try again.\n\nIf the error persists, please send feedback to let the Briar team know about the issue. Error importing data - The selected file did not contain anything that Briar could recognize.\n\nEnsure that you chose the correct file and that it was not created more than 14 days ago. + The selected file did not contain anything that Briar could recognize.\n\nPlease check that you chose the right file.\n\nIf your contact created the file more than 14 days ago, Briar will not be able to recognize it.