Address review feedback for Transfer Data UI

This commit is contained in:
Torsten Grote
2021-06-24 17:35:02 -03:00
parent f832f663c9
commit eee9e1a488
8 changed files with 32 additions and 21 deletions

View File

@@ -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);

View File

@@ -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());
}
/**

View File

@@ -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 {

View File

@@ -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.