show unverified devices warning in contact and account details

This commit is contained in:
Daniel Gultsch 2023-10-30 13:06:04 +01:00
parent 0bbc1193e3
commit 71b6492d61
No known key found for this signature in database
GPG key ID: F43D18AD2A0982C2
8 changed files with 178 additions and 96 deletions

View file

@ -736,8 +736,12 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
return axolotlStore.getFingerprintCertificate(fingerprint);
}
public void setFingerprintTrust(String fingerprint, FingerprintStatus status) {
public void setFingerprintTrust(final String fingerprint, final FingerprintStatus status) {
axolotlStore.setFingerprintStatus(fingerprint, status);
// TODO we decided to call this after a fingerprint gets toggled to update the 'your contact
// is using unverified devices text'; however this means the entire screen gets redrawn
// after a toggle which might be annoying or cause other weird UI glitches
mXmppConnectionService.updateAccountUi();
}
private ListenableFuture<XmppAxolotlSession> verifySessionWithPEP(final XmppAxolotlSession session) {

View file

@ -97,6 +97,10 @@ public class FingerprintStatus implements Comparable<FingerprintStatus> {
return trust == Trust.TRUSTED || isVerified();
}
public boolean isUnverified() {
return trust == Trust.TRUSTED;
}
public boolean isVerified() {
return trust == Trust.VERIFIED || trust == Trust.VERIFIED_X509;
}

View file

@ -455,6 +455,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
}
boolean skippedInactive = false;
boolean showsInactive = false;
boolean showUnverifiedWarning = false;
for (final XmppAxolotlSession session : sessions) {
final FingerprintStatus trust = session.getTrust();
hasKeys |= !trust.isCompromised();
@ -470,7 +471,11 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
boolean highlight = session.getFingerprint().equals(messageFingerprint);
addFingerprintRow(binding.detailsContactKeys, session, highlight);
}
if (trust.isUnverified()) {
showUnverifiedWarning = true;
}
}
binding.unverifiedWarning.setVisibility(showUnverifiedWarning ? View.VISIBLE : View.GONE);
if (showsInactive || skippedInactive) {
binding.showInactiveDevices.setText(showsInactive ? R.string.hide_inactive_devices : R.string.show_inactive_devices);
binding.showInactiveDevices.setVisibility(View.VISIBLE);
@ -480,7 +485,8 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
} else {
binding.showInactiveDevices.setVisibility(View.GONE);
}
binding.scanButton.setVisibility(hasKeys && isCameraFeatureAvailable() ? View.VISIBLE : View.GONE);
final boolean isCameraFeatureAvailable = isCameraFeatureAvailable();
binding.scanButton.setVisibility(hasKeys && isCameraFeatureAvailable ? View.VISIBLE : View.GONE);
if (hasKeys) {
binding.scanButton.setOnClickListener((v) -> ScanActivity.scan(this));
}

View file

@ -49,6 +49,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.crypto.axolotl.FingerprintStatus;
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
import eu.siacs.conversations.databinding.ActivityEditAccountBinding;
import eu.siacs.conversations.databinding.DialogPresenceBinding;
@ -630,6 +631,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
this.binding.accountRegisterNew.setVisibility(View.GONE);
}
this.binding.actionEditYourName.setOnClickListener(this::onEditYourNameClicked);
this.binding.scanButton.setOnClickListener((v) -> ScanActivity.scan(this));
}
private void onEditYourNameClicked(View view) {
@ -1166,13 +1168,18 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
this.binding.axolotlFingerprintBox.setVisibility(View.GONE);
}
boolean hasKeys = false;
boolean showUnverifiedWarning = false;
binding.otherDeviceKeys.removeAllViews();
for (XmppAxolotlSession session : mAccount.getAxolotlService().findOwnSessions()) {
if (!session.getTrust().isCompromised()) {
for (final XmppAxolotlSession session : mAccount.getAxolotlService().findOwnSessions()) {
final FingerprintStatus trust = session.getTrust();
if (!trust.isCompromised()) {
boolean highlight = session.getFingerprint().equals(messageFingerprint);
addFingerprintRow(binding.otherDeviceKeys, session, highlight);
hasKeys = true;
}
if (trust.isUnverified()) {
showUnverifiedWarning = true;
}
}
if (hasKeys && Config.supportOmemo()) { //TODO: either the button should be visible if we print an active device or the device list should be fed with reactived devices
this.binding.otherDeviceKeysCard.setVisibility(View.VISIBLE);
@ -1182,6 +1189,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
} else {
binding.clearDevices.setVisibility(View.VISIBLE);
}
binding.unverifiedWarning.setVisibility(showUnverifiedWarning ? View.VISIBLE : View.GONE);
binding.scanButton.setVisibility(showUnverifiedWarning ? View.VISIBLE : View.GONE);
} else {
this.binding.otherDeviceKeysCard.setVisibility(View.GONE);
}

View file

@ -205,6 +205,7 @@ public abstract class OmemoActivity extends XmppActivity {
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
ScanActivity.onRequestPermissionResult(this, requestCode, grantResults);
}
}

View file

@ -186,6 +186,19 @@
android:orientation="vertical"
android:padding="@dimen/card_padding_list"/>
<LinearLayout
android:id="@+id/unverified_warning"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="@dimen/card_padding_list">
<TextView
android:layout_marginHorizontal="@dimen/list_padding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.Conversations.Body1.Secondary"
android:text="@string/contact_uses_unverified_keys"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"

View file

@ -8,7 +8,8 @@
android:layout_height="match_parent"
android:background="?attr/color_background_secondary">
<include android:id="@+id/toolbar"
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<ScrollView
@ -28,10 +29,10 @@
android:id="@+id/editor"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin">
android:layout_marginBottom="@dimen/activity_vertical_margin">
<RelativeLayout
android:layout_width="match_parent"
@ -58,17 +59,17 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/account_settings_jabber_id"
app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint"
app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error">
app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error"
app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint">
<AutoCompleteTextView
android:id="@+id/account_jid"
style="@style/Widget.Conversations.EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:textColor="?attr/edit_text_color"
style="@style/Widget.Conversations.EditText"/>
android:textColor="?attr/edit_text_color" />
</com.google.android.material.textfield.TextInputLayout>
@ -76,21 +77,21 @@
android:id="@+id/account_password_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error"
app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint"
app:passwordToggleDrawable="@drawable/visibility_toggle_drawable"
app:passwordToggleEnabled="true"
app:passwordToggleTint="?android:textColorSecondary"
app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint"
app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error">
app:passwordToggleTint="?android:textColorSecondary">
<eu.siacs.conversations.ui.widget.TextInputEditText
android:id="@+id/account_password"
style="@style/Widget.Conversations.EditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:hint="@string/password"
android:inputType="textPassword"
android:textColor="?attr/edit_text_color"
style="@style/Widget.Conversations.EditText"/>
android:textColor="?attr/edit_text_color" />
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
@ -112,15 +113,15 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/account_settings_hostname"
app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint"
app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error">
app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error"
app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint">
<EditText
android:id="@+id/hostname"
style="@style/Widget.Conversations.EditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textWebEmailAddress"
style="@style/Widget.Conversations.EditText"/>
android:inputType="textWebEmailAddress" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
@ -135,16 +136,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/account_settings_port"
app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint"
app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error">
app:errorTextAppearance="@style/TextAppearance.Conversations.Design.Error"
app:hintTextAppearance="@style/TextAppearance.Conversations.Design.Hint">
<EditText
android:id="@+id/port"
style="@style/Widget.Conversations.EditText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="number"
android:maxLength="5"
style="@style/Widget.Conversations.EditText"/>
android:maxLength="5" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</LinearLayout>
@ -164,10 +165,10 @@
android:id="@+id/os_optimization"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:visibility="gone">
<LinearLayout
@ -222,10 +223,10 @@
android:id="@+id/stats"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:visibility="gone">
<LinearLayout
@ -642,12 +643,17 @@
android:id="@+id/other_device_keys_card"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -667,16 +673,53 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>
<LinearLayout
android:id="@+id/unverified_warning"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="@dimen/card_padding_list">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/list_padding"
android:text="@string/unverified_devices"
android:textAppearance="@style/TextAppearance.Conversations.Body1.Secondary" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<Button
android:id="@+id/scan_button"
style="@style/Widget.Conversations.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="0dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/scan_qr_code"
android:textColor="?attr/colorAccent" />
<Button
android:id="@+id/clear_devices"
style="@style/Widget.Conversations.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:minWidth="0dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/clear_other_devices"
android:textColor="?colorAccent"/>
android:textColor="?attr/colorAccent" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</ScrollView>
@ -685,11 +728,11 @@
android:id="@+id/button_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true">
android:layout_alignParentBottom="true">
<Button
android:id="@+id/cancel_button"
@ -702,8 +745,8 @@
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_marginBottom="7dp"
android:layout_marginTop="7dp"
android:layout_marginBottom="7dp"
android:background="?attr/divider" />
<Button

View file

@ -1018,4 +1018,6 @@
<string name="hide_notification">Hide notification</string>
<string name="log_out">Log out</string>
<string name="log_in">Log in</string>
<string name="contact_uses_unverified_keys">Your contact uses unverified devices. Scan their 2D barcode to perform verification and impede active MITM attacks.</string>
<string name="unverified_devices">You are using unverified devices. Scan the 2D barcodes of your other devices to perform verification and impede active MITM attack.</string>
</resources>