Improve strings for ui for displaying existing social backup

This commit is contained in:
ameba23
2021-05-18 12:06:09 +02:00
parent 71e63fb6f1
commit 4db1c4cc6b
2 changed files with 13 additions and 9 deletions

View File

@@ -30,15 +30,16 @@ public class ExistingBackupFragment extends BaseFragment {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
List<Author> custodians = backupMetadata.getCustodians(); List<Author> custodians = backupMetadata.getCustodians();
ArrayList custodianNames = new ArrayList(); ArrayList custodianNames = new ArrayList();
for (Author custodian : custodians) { for (Author custodian : custodians) {
custodianNames.add(custodian.getName()); custodianNames.add(custodian.getName());
} }
bundle.putStringArrayList(CUSTODIANS, custodianNames); bundle.putStringArrayList(CUSTODIANS, custodianNames);
bundle.putInt(THRESHOLD, backupMetadata.getThreshold()); bundle.putInt(THRESHOLD, backupMetadata.getThreshold());
ExistingBackupFragment fragment = new ExistingBackupFragment(); ExistingBackupFragment fragment = new ExistingBackupFragment();
fragment.setArguments(bundle); fragment.setArguments(bundle);
return fragment; return fragment;
} }
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -53,7 +54,7 @@ public class ExistingBackupFragment extends BaseFragment {
View view = inflater.inflate(R.layout.fragment_existing_backup, View view = inflater.inflate(R.layout.fragment_existing_backup,
container, false); container, false);
Bundle args = requireArguments(); Bundle args = requireArguments();
ArrayList<String> custodianNames = args.getStringArrayList(CUSTODIANS); ArrayList<String> custodianNames = args.getStringArrayList(CUSTODIANS);
StringBuilder custodianNamesString = new StringBuilder(); StringBuilder custodianNamesString = new StringBuilder();
for (String custodianName : custodianNames) { for (String custodianName : custodianNames) {
@@ -63,10 +64,12 @@ public class ExistingBackupFragment extends BaseFragment {
.append("\n"); .append("\n");
} }
TextView textViewThreshold = view.findViewById(R.id.textViewThreshold); TextView textViewThreshold = view.findViewById(R.id.textViewThreshold);
textViewThreshold.setText(String.format("%d of %d contacts needed to restore account", args.getInt(THRESHOLD), custodianNames.size())); textViewThreshold.setText(getString(R.string.existing_backup_explain,
TextView textViewCustodians = view.findViewById(R.id.textViewCustodians); args.getInt(THRESHOLD)));
textViewCustodians.setText(custodianNamesString); TextView textViewCustodians =
view.findViewById(R.id.textViewCustodians);
textViewCustodians.setText(custodianNamesString);
return view; return view;
} }

View File

@@ -729,4 +729,5 @@
<string name="activity_name_new_or_recover_account">Create new account or recover existing account</string> <string name="activity_name_new_or_recover_account">Create new account or recover existing account</string>
<string name="activity_name_recovery">Recover Account</string> <string name="activity_name_recovery">Recover Account</string>
<string name="activity_name_custodian_help_recovery">Help recover account</string> <string name="activity_name_custodian_help_recovery">Help recover account</string>
<string name="existing_backup_explain">%d of the following contacts are needed to restore your account:</string>
</resources> </resources>