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 716a448e9..b61126d8a 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 @@ -18,6 +18,7 @@ import android.widget.TextView; import org.briarproject.briar.R; import org.briarproject.briar.android.activity.ActivityComponent; import org.briarproject.briar.android.fragment.BaseFragment; +import org.briarproject.briar.android.login.StrengthMeter; import org.magmacollective.darkcrystal.secretsharingwrapper.SecretSharingWrapper; import java.util.Arrays; @@ -29,6 +30,8 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.lifecycle.ViewModelProvider; +import static android.view.View.GONE; + public class ThresholdSelectorFragment extends BaseFragment { public static final String TAG = ThresholdSelectorFragment.class.getName(); @@ -41,6 +44,7 @@ public class ThresholdSelectorFragment extends BaseFragment { private TextView thresholdRepresentation; private TextView message; private TextView mOfn; + private StrengthMeter strengthMeter; @Inject ViewModelProvider.Factory viewModelFactory; @@ -81,7 +85,8 @@ public class ThresholdSelectorFragment extends BaseFragment { thresholdRepresentation = view.findViewById(R.id.textViewThresholdRepresentation); message = view.findViewById(R.id.textViewMessage); - mOfn = view.findViewById(R.id.textViewmOfn); + mOfn = view.findViewById(R.id.text_view_m_of_n); + strengthMeter = view.findViewById(R.id.strength_meter); if (numberOfCustodians > 3) { seekBar.setMax(numberOfCustodians -3); @@ -90,8 +95,11 @@ public class ThresholdSelectorFragment extends BaseFragment { SecretSharingWrapper.defaultThreshold(numberOfCustodians); threshold = recommendedThreshold; seekBar.setProgress(threshold - 2); + strengthMeter.setStrength(1); } else { seekBar.setEnabled(false); + seekBar.setVisibility(GONE); + strengthMeter.setVisibility(GONE); threshold = 2; seekBar.setMax(numberOfCustodians); seekBar.setProgress(threshold); @@ -184,12 +192,23 @@ public class ThresholdSelectorFragment extends BaseFragment { int sanityLevel = SecretSharingWrapper .thresholdSanity(threshold, numberOfCustodians); int text = R.string.threshold_secure; - if (threshold == recommendedThreshold) + float strength = 1; + 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; + } + if (sanityLevel < -1) { + strength = 0.75f; + text = R.string.threshold_low_insecure; + } + if (sanityLevel < -2) { + strength = 0.5f; + } + if (sanityLevel > 0) { + strength = 0.75f; + text = R.string.threshold_high_insecure; + } + strengthMeter.setStrength(strength); message.setText(text); - // TODO change colour of thresholdRepresentation to green/red based on sanityLevel } @Override 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 fe74f5cd1..98ae96397 100644 --- a/briar-android/src/main/res/layout/fragment_select_threshold.xml +++ b/briar-android/src/main/res/layout/fragment_select_threshold.xml @@ -45,7 +45,7 @@ app:layout_constraintTop_toBottomOf="@+id/seekBar" /> + + + app:layout_constraintTop_toBottomOf="@+id/strength_meter" /> diff --git a/briar-android/src/main/res/values/strings.xml b/briar-android/src/main/res/values/strings.xml index 935f68e2a..abe77db2a 100644 --- a/briar-android/src/main/res/values/strings.xml +++ b/briar-android/src/main/res/values/strings.xml @@ -9,7 +9,7 @@ Your nickname will be shown next to any content you post. You can\'t change it after creating your account. Next Choose a Password - Your Briar account is stored encrypted on your device, not in the cloud. If you forget your password or uninstall Briar, you can only recover your account if you have made a social backup.\n\nChoose a long password that\'s hard to guess, such as four random words, or ten random letters, numbers and symbols. + Your Briar account is stored encrypted on your device, not in the cloud. If you forget your password or uninstall Briar, your account will be lost.\n\nTo avoid this, use the \'Social Backup\' feature in settings menu to make a backup. Background Connections To receive messages, Briar needs to stay connected in the background. To receive messages, Briar needs to stay connected in the background. Please disable battery optimizations so Briar can stay connected.