mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Basic strength meter when choosing threshold
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user