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 c7932245f..c2252af8e 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
@@ -34,9 +34,11 @@ public class ThresholdSelectorFragment extends BaseFragment {
// TODO this should be the actual number of custodians
private int numberOfCustodians;
private int threshold;
+ private int recommendedThreshold;
private SeekBar seekBar;
private TextView thresholdRepresentation;
private TextView message;
+ private TextView mOfn;
public static ThresholdSelectorFragment newInstance(int numberCustodians) {
Bundle bundle = new Bundle();
@@ -46,10 +48,6 @@ public class ThresholdSelectorFragment extends BaseFragment {
return fragment;
}
- private void setNumberCustodians(int numberCustodians) {
- numberOfCustodians = numberCustodians;
- }
-
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -67,17 +65,24 @@ public class ThresholdSelectorFragment extends BaseFragment {
seekBar = view.findViewById(R.id.seekBar);
thresholdRepresentation = view.findViewById(R.id.textViewThresholdRepresentation);
message = view.findViewById(R.id.textViewMessage);
+ mOfn = view.findViewById(R.id.textViewmOfn);
int max = numberOfCustodians - 3;
seekBar.setMax(max);
seekBar.setOnSeekBarChangeListener(new SeekBarListener());
- threshold = SecretSharingWrapper.defaultThreshold(numberOfCustodians);
+ recommendedThreshold = SecretSharingWrapper.defaultThreshold(numberOfCustodians);
+ threshold = recommendedThreshold;
seekBar.setProgress(threshold - 2);
thresholdRepresentation.setText(buildThresholdRepresentationString());
+ setmOfnText();
return view;
// return super.onCreateView(inflater, container, savedInstanceState);
}
+ private void setmOfnText() {
+ mOfn.setText(String.format("%d of %d contacts needed to recover your account", threshold, numberOfCustodians));
+ }
+
@Override
public void onAttach(Context context) {
super.onAttach(context);
@@ -116,11 +121,9 @@ public class ThresholdSelectorFragment extends BaseFragment {
String thresholdRepresentationText = "";
for (int i = 0; i < threshold; i++) {
thresholdRepresentationText += getString(R.string.filled_bullet);
-// thresholdRepresentationText += "1 ";
}
for (int i = 0; i < (numberOfCustodians - threshold); i++) {
thresholdRepresentationText += getString(R.string.linear_bullet);
-// thresholdRepresentationText += "0 ";
}
return thresholdRepresentationText;
}
@@ -135,11 +138,12 @@ public class ThresholdSelectorFragment extends BaseFragment {
thresholdRepresentation.setText(
buildThresholdRepresentationString()
);
+ setmOfnText();
int sanityLevel = SecretSharingWrapper.thresholdSanity(threshold, numberOfCustodians);
int text = R.string.threshold_secure;
- // TODO use 1 / -1 instead of 0
- if (sanityLevel < 0) text = R.string.threshold_low_insecure;
+ if (threshold == recommendedThreshold) text = R.string.threshold_recommended;
+ if (sanityLevel < -1) text = R.string.threshold_low_insecure;
if (sanityLevel > 0) text = R.string.threshold_high_insecure;
message.setText(text);
// TODO change colour of thresholdRepresentation to green/red based on sanityLevel
diff --git a/briar-android/src/main/res/layout/fragment_select_threshold.xml b/briar-android/src/main/res/layout/fragment_select_threshold.xml
index 2b47a40b4..fe74f5cd1 100644
--- a/briar-android/src/main/res/layout/fragment_select_threshold.xml
+++ b/briar-android/src/main/res/layout/fragment_select_threshold.xml
@@ -39,11 +39,22 @@
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="placeholder"
- android:textSize="16dp"
+ android:textSize="64dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/seekBar" />
+
+
+ app:layout_constraintTop_toBottomOf="@+id/textViewmOfn" />
diff --git a/briar-android/src/main/res/values/strings.xml b/briar-android/src/main/res/values/strings.xml
index c809aa1f8..43a6a89b9 100644
--- a/briar-android/src/main/res/values/strings.xml
+++ b/briar-android/src/main/res/values/strings.xml
@@ -657,9 +657,9 @@
The minimum number of trusted contacts needed to restore your account:
Secure
+ Secure - recommended threshold
Insecure – higher threshold recommended
Danger of loss – lower threshold recommended
-
Choose Threshold
Backup pieces sent to trusted contacts