From bf6dd0d924d62605f778c2009815b9fa3ea53e29 Mon Sep 17 00:00:00 2001 From: ameba23 Date: Mon, 8 Mar 2021 12:43:04 +0100 Subject: [PATCH] pass treshold to DistributedBackupActivity --- .../socialbackup/DistributedBackupActivity.java | 2 +- .../socialbackup/ThresholdDefinedListener.java | 2 +- .../socialbackup/ThresholdSelectorFragment.java | 15 ++++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/briar-android/src/main/java/org/briarproject/briar/android/socialbackup/DistributedBackupActivity.java b/briar-android/src/main/java/org/briarproject/briar/android/socialbackup/DistributedBackupActivity.java index b4d7f51ab..c333c3cf4 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/socialbackup/DistributedBackupActivity.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/socialbackup/DistributedBackupActivity.java @@ -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); } diff --git a/briar-android/src/main/java/org/briarproject/briar/android/socialbackup/ThresholdDefinedListener.java b/briar-android/src/main/java/org/briarproject/briar/android/socialbackup/ThresholdDefinedListener.java index 7a1c9961c..df7c37fb5 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/socialbackup/ThresholdDefinedListener.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/socialbackup/ThresholdDefinedListener.java @@ -5,6 +5,6 @@ import androidx.annotation.UiThread; public interface ThresholdDefinedListener { @UiThread - void thresholdDefined(); + void thresholdDefined(int threshold); } \ No newline at end of file diff --git a/briar-android/src/main/java/org/briarproject/briar/android/socialbackup/ThresholdSelectorFragment.java b/briar-android/src/main/java/org/briarproject/briar/android/socialbackup/ThresholdSelectorFragment.java index 01e75dd35..a9d59d49d 100644 --- a/briar-android/src/main/java/org/briarproject/briar/android/socialbackup/ThresholdSelectorFragment.java +++ b/briar-android/src/main/java/org/briarproject/briar/android/socialbackup/ThresholdSelectorFragment.java @@ -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);