mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Address review feedback for Transfer Data UI
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user