mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
set initial state of threshold representation
This commit is contained in:
@@ -30,6 +30,8 @@ public class ThresholdSelectorFragment extends BaseFragment {
|
|||||||
|
|
||||||
protected ThresholdDefinedListener listener;
|
protected ThresholdDefinedListener listener;
|
||||||
|
|
||||||
|
// TODO this should be the actual number of custodians
|
||||||
|
private int numberOfCustodians = 5;
|
||||||
private SeekBar seekBar;
|
private SeekBar seekBar;
|
||||||
private TextView thresholdRepresentation;
|
private TextView thresholdRepresentation;
|
||||||
private TextView message;
|
private TextView message;
|
||||||
@@ -54,6 +56,7 @@ public class ThresholdSelectorFragment extends BaseFragment {
|
|||||||
seekBar.setOnSeekBarChangeListener(new SeekBarListener());
|
seekBar.setOnSeekBarChangeListener(new SeekBarListener());
|
||||||
seekBar.setProgress(1);
|
seekBar.setProgress(1);
|
||||||
|
|
||||||
|
thresholdRepresentation.setText(buildThresholdRepresentationString(3));
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,26 +94,31 @@ public class ThresholdSelectorFragment extends BaseFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildThresholdRepresentationString (int threshold) {
|
||||||
|
String thresholdRepresentationText = "";
|
||||||
|
for (int i = 0; i < threshold; i++) {
|
||||||
|
thresholdRepresentationText += R.string.filled_bullet;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < (numberOfCustodians - threshold); i++) {
|
||||||
|
thresholdRepresentationText += R.string.linear_bullet;
|
||||||
|
}
|
||||||
|
return thresholdRepresentationText;
|
||||||
|
}
|
||||||
|
|
||||||
private class SeekBarListener implements SeekBar.OnSeekBarChangeListener {
|
private class SeekBarListener implements SeekBar.OnSeekBarChangeListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress,
|
public void onProgressChanged(SeekBar seekBar, int progress,
|
||||||
boolean fromUser) {
|
boolean fromUser) {
|
||||||
int numCustodians = 5; // TODO this should be the actual number of custodians
|
|
||||||
// progress can be 0, 1, 2 - translate allowed slider value to actual
|
// progress can be 0, 1, 2 - translate allowed slider value to actual
|
||||||
// threshold
|
// threshold
|
||||||
int threshold = progress + 2;
|
int threshold = progress + 2;
|
||||||
|
|
||||||
String thresholdRepresentationText = "";
|
thresholdRepresentation.setText(
|
||||||
for (int i = 0; i < threshold; i++) {
|
buildThresholdRepresentationString(threshold)
|
||||||
thresholdRepresentationText += R.string.filled_bullet;
|
);
|
||||||
}
|
|
||||||
for (int i = 0; i < (numCustodians - threshold); i++) {
|
|
||||||
thresholdRepresentationText += R.string.linear_bullet;
|
|
||||||
}
|
|
||||||
thresholdRepresentation.setText(thresholdRepresentationText);
|
|
||||||
|
|
||||||
int sanityLevel = SecretSharingWrapper.thresholdSanity(threshold, numCustodians);
|
int sanityLevel = SecretSharingWrapper.thresholdSanity(threshold, numberOfCustodians);
|
||||||
int text = R.string.threshold_secure;
|
int text = R.string.threshold_secure;
|
||||||
if (sanityLevel < -1) text = R.string.threshold_low_insecure;
|
if (sanityLevel < -1) text = R.string.threshold_low_insecure;
|
||||||
if (sanityLevel > 1) text = R.string.threshold_high_insecure;
|
if (sanityLevel > 1) text = R.string.threshold_high_insecure;
|
||||||
|
|||||||
Reference in New Issue
Block a user