mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
get argument with number of custodians to thresholdselectorfragment
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user