pass treshold to DistributedBackupActivity

This commit is contained in:
ameba23
2021-03-08 12:43:04 +01:00
parent 085e25cc14
commit bf6dd0d924
3 changed files with 10 additions and 9 deletions

View File

@@ -44,7 +44,7 @@ public class DistributedBackupActivity extends BriarActivity implements
}
@Override
public void thresholdDefined() {
public void thresholdDefined(int threshold) {
ShardsSentFragment fragment = new ShardsSentFragment();
showNextFragment(fragment);
}

View File

@@ -5,6 +5,6 @@ import androidx.annotation.UiThread;
public interface ThresholdDefinedListener {
@UiThread
void thresholdDefined();
void thresholdDefined(int threshold);
}

View File

@@ -33,6 +33,7 @@ public class ThresholdSelectorFragment extends BaseFragment {
// TODO this should be the actual number of custodians
private int numberOfCustodians;
private int threshold;
private SeekBar seekBar;
private TextView thresholdRepresentation;
private TextView message;
@@ -73,10 +74,10 @@ public class ThresholdSelectorFragment extends BaseFragment {
int max = numberOfCustodians - 3;
seekBar.setMax(max);
seekBar.setOnSeekBarChangeListener(new SeekBarListener());
int defaultThreshold = SecretSharingWrapper.defaultThreshold(numberOfCustodians);
seekBar.setProgress(defaultThreshold - 2);
threshold = SecretSharingWrapper.defaultThreshold(numberOfCustodians);
seekBar.setProgress(threshold - 2);
thresholdRepresentation.setText(buildThresholdRepresentationString(defaultThreshold));
thresholdRepresentation.setText(buildThresholdRepresentationString());
return view;
// return super.onCreateView(inflater, container, savedInstanceState);
}
@@ -108,14 +109,14 @@ public class ThresholdSelectorFragment extends BaseFragment {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_threshold_defined:
listener.thresholdDefined();
listener.thresholdDefined(threshold);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private String buildThresholdRepresentationString (int threshold) {
private String buildThresholdRepresentationString () {
String thresholdRepresentationText = "";
for (int i = 0; i < threshold; i++) {
thresholdRepresentationText += getString(R.string.filled_bullet);
@@ -133,10 +134,10 @@ public class ThresholdSelectorFragment extends BaseFragment {
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
int threshold = progress + 2;
threshold = progress + 2;
thresholdRepresentation.setText(
buildThresholdRepresentationString(threshold)
buildThresholdRepresentationString()
);
int sanityLevel = SecretSharingWrapper.thresholdSanity(threshold, numberOfCustodians);