Verified Commit eee9e1a4 authored by Torsten Grote's avatar Torsten Grote
Browse files

Address review feedback for Transfer Data UI

parent f832f663
......@@ -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);
......
......@@ -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());
}
/**
......
......@@ -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 {
......
......@@ -333,6 +333,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.
......
......@@ -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"
......
......@@ -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"
......
......@@ -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"
......
......@@ -696,23 +696,23 @@
<!-- Transfer Data via Removable Drives -->
<string name="removable_drive_menu_title">Transfer data</string>
<string name="removable_drive_intro">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.</string>
<string name="removable_drive_intro">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.</string>
<string name="removable_drive_title_send">Send data</string>
<string name="removable_drive_title_receive">Receive data</string>
<string name="removable_drive_send_intro">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.</string>
<string name="removable_drive_send_no_data">There are currently no messages waiting to be send to this contact.\n\nWrite at least one message and try again.</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_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">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.</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>
<string name="removable_drive_receive_button">Choose file for import</string>
<string name="removable_drive_success_send_title">Export successful</string>
<string name="removable_drive_success_send_text">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.</string>
<string name="removable_drive_success_send_text">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.</string>
<string name="removable_drive_success_receive_title">Import successful</string>
<string name="removable_drive_success_receive_text">All messages contained in this file have arrived.</string>
<string name="removable_drive_success_receive_text">All encrypted messages contained in this file have been received.</string>
<string name="removable_drive_error_send_title">Error exporting data</string>
<string name="removable_drive_error_send_text">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.</string>
<string name="removable_drive_error_send_text">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.</string>
<string name="removable_drive_error_receive_title">Error importing data</string>
<string name="removable_drive_error_receive_text">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.</string>
<string name="removable_drive_error_receive_text">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.</string>
<!-- Screenshots -->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment