From ae7a553aa333d1d937feac99afa97cdf9f8be9fe Mon Sep 17 00:00:00 2001 From: ameba23 Date: Fri, 11 Feb 2022 12:02:39 +0100 Subject: [PATCH 1/4] Basic strength meter when choosing threshold --- .../ThresholdSelectorFragment.java | 20 +++++++++++++++---- .../res/layout/fragment_select_threshold.xml | 15 ++++++++++++-- 2 files changed, 29 insertions(+), 6 deletions(-) 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..60cba332a 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; @@ -41,6 +42,7 @@ public class ThresholdSelectorFragment extends BaseFragment { private TextView thresholdRepresentation; private TextView message; private TextView mOfn; + private StrengthMeter strengthMeter; @Inject ViewModelProvider.Factory viewModelFactory; @@ -81,7 +83,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); @@ -184,10 +187,19 @@ 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 > 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 } 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" /> From 32f1676e5558337e81442dc6a9f23bf0b6c556af Mon Sep 17 00:00:00 2001 From: ameba23 Date: Tue, 15 Feb 2022 08:44:36 +0100 Subject: [PATCH 2/4] Improve threshold selector screen --- .../android/socialbackup/ThresholdSelectorFragment.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 60cba332a..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 @@ -30,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(); @@ -93,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); @@ -195,13 +200,15 @@ public class ThresholdSelectorFragment extends BaseFragment { 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 From 8ad7ec3a6673c99a3a1dd9b3c9130e49e085d24e Mon Sep 17 00:00:00 2001 From: ameba23 Date: Fri, 18 Feb 2022 09:00:21 +0100 Subject: [PATCH 3/4] Improve choose password info dialog --- briar-android/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/briar-android/src/main/res/values/strings.xml b/briar-android/src/main/res/values/strings.xml index 9dee28f5d..b9b8b111f 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. 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. From 7a9794e62a744afd93f05002ea59689017cfd85d Mon Sep 17 00:00:00 2001 From: ameba23 Date: Mon, 21 Feb 2022 08:25:48 +0100 Subject: [PATCH 4/4] Improve setup password explanation string --- briar-android/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/briar-android/src/main/res/values/strings.xml b/briar-android/src/main/res/values/strings.xml index b9b8b111f..c1dcd03fb 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, your account will be lost. Use the \'social backup\' feature in settings menu to make a backup. + 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.