mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Show backup progress as a percentage.
This commit is contained in:
committed by
Greyson Parrelli
parent
4f73e36d72
commit
8014a70134
@@ -35,6 +35,7 @@ import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.util.BackupUtil;
|
||||
import org.thoughtcrime.securesms.util.StorageUtil;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -54,6 +55,8 @@ public class BackupsPreferenceFragment extends Fragment {
|
||||
private ProgressBar progress;
|
||||
private TextView progressSummary;
|
||||
|
||||
private final NumberFormat formatter = NumberFormat.getInstance();
|
||||
|
||||
@Override
|
||||
public @Nullable View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_backups, container, false);
|
||||
@@ -75,6 +78,9 @@ public class BackupsPreferenceFragment extends Fragment {
|
||||
create.setOnClickListener(unused -> onCreateClicked());
|
||||
verify.setOnClickListener(unused -> BackupDialog.showVerifyBackupPassphraseDialog(requireContext()));
|
||||
|
||||
formatter.setMinimumFractionDigits(1);
|
||||
formatter.setMaximumFractionDigits(1);
|
||||
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@@ -120,8 +126,19 @@ public class BackupsPreferenceFragment extends Fragment {
|
||||
create.setEnabled(false);
|
||||
summary.setText(getString(R.string.BackupsPreferenceFragment__in_progress));
|
||||
progress.setVisibility(View.VISIBLE);
|
||||
progressSummary.setVisibility(View.VISIBLE);
|
||||
progressSummary.setText(getString(R.string.BackupsPreferenceFragment__d_so_far, event.getCount()));
|
||||
progressSummary.setVisibility(event.getCount() > 0 ? View.VISIBLE : View.GONE);
|
||||
|
||||
if (event.getEstimatedTotalCount() == 0) {
|
||||
progress.setIndeterminate(true);
|
||||
progressSummary.setText(getString(R.string.BackupsPreferenceFragment__d_so_far, event.getCount()));
|
||||
} else {
|
||||
double completionPercentage = event.getCompletionPercentage();
|
||||
|
||||
progress.setIndeterminate(false);
|
||||
progress.setMax(100);
|
||||
progress.setProgress((int) completionPercentage);
|
||||
progressSummary.setText(getString(R.string.BackupsPreferenceFragment__s_so_far, formatter.format(completionPercentage)));
|
||||
}
|
||||
} else if (event.getType() == FullBackupBase.BackupEvent.Type.FINISHED) {
|
||||
create.setEnabled(true);
|
||||
progress.setVisibility(View.GONE);
|
||||
|
||||
Reference in New Issue
Block a user