Merge branch 'social-backup-poc' into remote-wipe-poc

* social-backup-poc:
  Improve setup password explanation string
  Improve choose password info dialog
  Improve threshold selector screen
  Basic strength meter when choosing threshold
This commit is contained in:
ameba23
2022-02-21 08:34:34 +01:00
3 changed files with 38 additions and 8 deletions

View File

@@ -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

View File

@@ -45,7 +45,7 @@
app:layout_constraintTop_toBottomOf="@+id/seekBar" />
<TextView
android:id="@+id/textViewmOfn"
android:id="@+id/text_view_m_of_n"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
@@ -55,6 +55,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewThresholdRepresentation" />
<org.briarproject.briar.android.login.StrengthMeter
android:id="@+id/strength_meter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:visibility="visible"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text_view_m_of_n"
tools:visibility="visible" />
<TextView
android:id="@+id/textViewMessage"
android:layout_width="wrap_content"
@@ -64,6 +75,6 @@
android:textSize="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textViewmOfn" />
app:layout_constraintTop_toBottomOf="@+id/strength_meter" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -9,7 +9,7 @@
<string name="setup_name_explanation">Your nickname will be shown next to any content you post. You can\'t change it after creating your account.</string>
<string name="setup_next">Next</string>
<string name="setup_password_intro">Choose a Password</string>
<string name="setup_password_explanation">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.</string>
<string name="setup_password_explanation">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.</string>
<string name="setup_doze_title">Background Connections</string>
<string name="setup_doze_intro">To receive messages, Briar needs to stay connected in the background.</string>
<string name="setup_doze_explanation">To receive messages, Briar needs to stay connected in the background. Please disable battery optimizations so Briar can stay connected.</string>