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); return axolotlStore.getFingerprintCertificate(fingerprint);
} }
public void setFingerprintTrust(String fingerprint, FingerprintStatus status) { public void setFingerprintTrust(final String fingerprint, final FingerprintStatus status) {
axolotlStore.setFingerprintStatus(fingerprint, 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) { private ListenableFuture<XmppAxolotlSession> verifySessionWithPEP(final XmppAxolotlSession session) {

View file

@ -97,6 +97,10 @@ public class FingerprintStatus implements Comparable<FingerprintStatus> {
return trust == Trust.TRUSTED || isVerified(); return trust == Trust.TRUSTED || isVerified();
} }
public boolean isUnverified() {
return trust == Trust.TRUSTED;
}
public boolean isVerified() { public boolean isVerified() {
return trust == Trust.VERIFIED || trust == Trust.VERIFIED_X509; 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 skippedInactive = false;
boolean showsInactive = false; boolean showsInactive = false;
boolean showUnverifiedWarning = false;
for (final XmppAxolotlSession session : sessions) { for (final XmppAxolotlSession session : sessions) {
final FingerprintStatus trust = session.getTrust(); final FingerprintStatus trust = session.getTrust();
hasKeys |= !trust.isCompromised(); hasKeys |= !trust.isCompromised();
@ -470,7 +471,11 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
boolean highlight = session.getFingerprint().equals(messageFingerprint); boolean highlight = session.getFingerprint().equals(messageFingerprint);
addFingerprintRow(binding.detailsContactKeys, session, highlight); addFingerprintRow(binding.detailsContactKeys, session, highlight);
} }
if (trust.isUnverified()) {
showUnverifiedWarning = true;
} }
}
binding.unverifiedWarning.setVisibility(showUnverifiedWarning ? View.VISIBLE : View.GONE);
if (showsInactive || skippedInactive) { if (showsInactive || skippedInactive) {
binding.showInactiveDevices.setText(showsInactive ? R.string.hide_inactive_devices : R.string.show_inactive_devices); binding.showInactiveDevices.setText(showsInactive ? R.string.hide_inactive_devices : R.string.show_inactive_devices);
binding.showInactiveDevices.setVisibility(View.VISIBLE); binding.showInactiveDevices.setVisibility(View.VISIBLE);
@ -480,7 +485,8 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
} else { } else {
binding.showInactiveDevices.setVisibility(View.GONE); 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) { if (hasKeys) {
binding.scanButton.setOnClickListener((v) -> ScanActivity.scan(this)); 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.Config;
import eu.siacs.conversations.R; import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.axolotl.AxolotlService; 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.crypto.axolotl.XmppAxolotlSession;
import eu.siacs.conversations.databinding.ActivityEditAccountBinding; import eu.siacs.conversations.databinding.ActivityEditAccountBinding;
import eu.siacs.conversations.databinding.DialogPresenceBinding; 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.accountRegisterNew.setVisibility(View.GONE);
} }
this.binding.actionEditYourName.setOnClickListener(this::onEditYourNameClicked); this.binding.actionEditYourName.setOnClickListener(this::onEditYourNameClicked);
this.binding.scanButton.setOnClickListener((v) -> ScanActivity.scan(this));
} }
private void onEditYourNameClicked(View view) { private void onEditYourNameClicked(View view) {
@ -1166,13 +1168,18 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
this.binding.axolotlFingerprintBox.setVisibility(View.GONE); this.binding.axolotlFingerprintBox.setVisibility(View.GONE);
} }
boolean hasKeys = false; boolean hasKeys = false;
boolean showUnverifiedWarning = false;
binding.otherDeviceKeys.removeAllViews(); binding.otherDeviceKeys.removeAllViews();
for (XmppAxolotlSession session : mAccount.getAxolotlService().findOwnSessions()) { for (final XmppAxolotlSession session : mAccount.getAxolotlService().findOwnSessions()) {
if (!session.getTrust().isCompromised()) { final FingerprintStatus trust = session.getTrust();
if (!trust.isCompromised()) {
boolean highlight = session.getFingerprint().equals(messageFingerprint); boolean highlight = session.getFingerprint().equals(messageFingerprint);
addFingerprintRow(binding.otherDeviceKeys, session, highlight); addFingerprintRow(binding.otherDeviceKeys, session, highlight);
hasKeys = true; 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 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); this.binding.otherDeviceKeysCard.setVisibility(View.VISIBLE);
@ -1182,6 +1189,8 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
} else { } else {
binding.clearDevices.setVisibility(View.VISIBLE); binding.clearDevices.setVisibility(View.VISIBLE);
} }
binding.unverifiedWarning.setVisibility(showUnverifiedWarning ? View.VISIBLE : View.GONE);
binding.scanButton.setVisibility(showUnverifiedWarning ? View.VISIBLE : View.GONE);
} else { } else {
this.binding.otherDeviceKeysCard.setVisibility(View.GONE); this.binding.otherDeviceKeysCard.setVisibility(View.GONE);
} }

View file

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

View file

@ -186,6 +186,19 @@
android:orientation="vertical" android:orientation="vertical"
android:padding="@dimen/card_padding_list"/> 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 <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"

View file

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

View file

@ -1018,4 +1018,6 @@
<string name="hide_notification">Hide notification</string> <string name="hide_notification">Hide notification</string>
<string name="log_out">Log out</string> <string name="log_out">Log out</string>
<string name="log_in">Log in</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> </resources>