mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 22:29:53 +01:00
pass treshold to DistributedBackupActivity
This commit is contained in:
@@ -44,7 +44,7 @@ public class DistributedBackupActivity extends BriarActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void thresholdDefined() {
|
public void thresholdDefined(int threshold) {
|
||||||
ShardsSentFragment fragment = new ShardsSentFragment();
|
ShardsSentFragment fragment = new ShardsSentFragment();
|
||||||
showNextFragment(fragment);
|
showNextFragment(fragment);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ import androidx.annotation.UiThread;
|
|||||||
public interface ThresholdDefinedListener {
|
public interface ThresholdDefinedListener {
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
void thresholdDefined();
|
void thresholdDefined(int threshold);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -33,6 +33,7 @@ public class ThresholdSelectorFragment extends BaseFragment {
|
|||||||
|
|
||||||
// TODO this should be the actual number of custodians
|
// TODO this should be the actual number of custodians
|
||||||
private int numberOfCustodians;
|
private int numberOfCustodians;
|
||||||
|
private int threshold;
|
||||||
private SeekBar seekBar;
|
private SeekBar seekBar;
|
||||||
private TextView thresholdRepresentation;
|
private TextView thresholdRepresentation;
|
||||||
private TextView message;
|
private TextView message;
|
||||||
@@ -73,10 +74,10 @@ public class ThresholdSelectorFragment extends BaseFragment {
|
|||||||
int max = numberOfCustodians - 3;
|
int max = numberOfCustodians - 3;
|
||||||
seekBar.setMax(max);
|
seekBar.setMax(max);
|
||||||
seekBar.setOnSeekBarChangeListener(new SeekBarListener());
|
seekBar.setOnSeekBarChangeListener(new SeekBarListener());
|
||||||
int defaultThreshold = SecretSharingWrapper.defaultThreshold(numberOfCustodians);
|
threshold = SecretSharingWrapper.defaultThreshold(numberOfCustodians);
|
||||||
seekBar.setProgress(defaultThreshold - 2);
|
seekBar.setProgress(threshold - 2);
|
||||||
|
|
||||||
thresholdRepresentation.setText(buildThresholdRepresentationString(defaultThreshold));
|
thresholdRepresentation.setText(buildThresholdRepresentationString());
|
||||||
return view;
|
return view;
|
||||||
// return super.onCreateView(inflater, container, savedInstanceState);
|
// return super.onCreateView(inflater, container, savedInstanceState);
|
||||||
}
|
}
|
||||||
@@ -108,14 +109,14 @@ public class ThresholdSelectorFragment extends BaseFragment {
|
|||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case R.id.action_threshold_defined:
|
case R.id.action_threshold_defined:
|
||||||
listener.thresholdDefined();
|
listener.thresholdDefined(threshold);
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String buildThresholdRepresentationString (int threshold) {
|
private String buildThresholdRepresentationString () {
|
||||||
String thresholdRepresentationText = "";
|
String thresholdRepresentationText = "";
|
||||||
for (int i = 0; i < threshold; i++) {
|
for (int i = 0; i < threshold; i++) {
|
||||||
thresholdRepresentationText += getString(R.string.filled_bullet);
|
thresholdRepresentationText += getString(R.string.filled_bullet);
|
||||||
@@ -133,10 +134,10 @@ public class ThresholdSelectorFragment extends BaseFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress,
|
public void onProgressChanged(SeekBar seekBar, int progress,
|
||||||
boolean fromUser) {
|
boolean fromUser) {
|
||||||
int threshold = progress + 2;
|
threshold = progress + 2;
|
||||||
|
|
||||||
thresholdRepresentation.setText(
|
thresholdRepresentation.setText(
|
||||||
buildThresholdRepresentationString(threshold)
|
buildThresholdRepresentationString()
|
||||||
);
|
);
|
||||||
|
|
||||||
int sanityLevel = SecretSharingWrapper.thresholdSanity(threshold, numberOfCustodians);
|
int sanityLevel = SecretSharingWrapper.thresholdSanity(threshold, numberOfCustodians);
|
||||||
|
|||||||
Reference in New Issue
Block a user