get argument with number of custodians to thresholdselectorfragment

This commit is contained in:
ameba23
2021-03-08 11:58:05 +01:00
parent 5f7bc4a143
commit 033c9f4d59
3 changed files with 24 additions and 6 deletions

View File

@@ -37,6 +37,7 @@ public class CustodianSelectorFragment extends ContactSelectorFragment {
public static CustodianSelectorFragment newInstance() {
Bundle args = new Bundle();
CustodianSelectorFragment fragment = new CustodianSelectorFragment();
fragment.setArguments(args);
@@ -51,6 +52,7 @@ public class CustodianSelectorFragment extends ContactSelectorFragment {
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requireActivity().setTitle(R.string.title_select_custodians);
}

View File

@@ -39,8 +39,7 @@ public class DistributedBackupActivity extends BriarActivity implements
Toast.makeText(this,
String.format("selected %d contacts", contacts.size()),
Toast.LENGTH_SHORT).show();
ThresholdSelectorFragment fragment = new ThresholdSelectorFragment();
ThresholdSelectorFragment fragment = ThresholdSelectorFragment.newInstance(contacts.size());
showNextFragment(fragment);
}

View File

@@ -31,11 +31,24 @@ public class ThresholdSelectorFragment extends BaseFragment {
protected ThresholdDefinedListener listener;
// TODO this should be the actual number of custodians
private int numberOfCustodians = 5;
private int numberOfCustodians;
private SeekBar seekBar;
private TextView thresholdRepresentation;
private TextView message;
public static ThresholdSelectorFragment newInstance(int numberCustodians) {
Bundle bundle = new Bundle();
bundle.putInt("numberCustodians", numberCustodians);
ThresholdSelectorFragment fragment = new ThresholdSelectorFragment();
fragment.setArguments(bundle);
fragment.setNumberCustodians(numberCustodians);
return fragment;
}
private void setNumberCustodians(int numberCustodians) {
numberOfCustodians = numberCustodians;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -47,7 +60,9 @@ public class ThresholdSelectorFragment extends BaseFragment {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_select_threshold,
container, false);
if (savedInstanceState != null) {
numberOfCustodians = savedInstanceState.getInt("numberCustodians");
}
seekBar = view.findViewById(R.id.seekBar);
thresholdRepresentation = view.findViewById(R.id.textViewThresholdRepresentation);
message = view.findViewById(R.id.textViewMessage);
@@ -97,10 +112,12 @@ public class ThresholdSelectorFragment extends BaseFragment {
private String buildThresholdRepresentationString (int threshold) {
String thresholdRepresentationText = "";
for (int i = 0; i < threshold; i++) {
thresholdRepresentationText += R.string.filled_bullet;
// thresholdRepresentationText += R.string.filled_bullet;
thresholdRepresentationText += "1";
}
for (int i = 0; i < (numberOfCustodians - threshold); i++) {
thresholdRepresentationText += R.string.linear_bullet;
// thresholdRepresentationText += R.string.linear_bullet;
thresholdRepresentationText += "0";
}
return thresholdRepresentationText;
}