Skip to content

Commit

Permalink
feat: Show MLS info on device (WPB-2308) (#2037)
Browse files Browse the repository at this point in the history
  • Loading branch information
borichellow committed Aug 3, 2023
1 parent 6b26f04 commit 21e1629
Show file tree
Hide file tree
Showing 37 changed files with 163 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import com.wire.android.ui.common.shimmerPlaceholder
import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.ui.theme.wireDimensions
import com.wire.android.ui.theme.wireTypography
import com.wire.android.util.extension.formatAsFingerPrint
import com.wire.android.util.extension.formatAsString
import com.wire.android.util.formatMediumDateTime
import com.wire.android.util.ui.UIText
Expand Down Expand Up @@ -199,7 +200,24 @@ private fun DeviceItemTexts(
}

Spacer(modifier = Modifier.height(MaterialTheme.wireDimensions.removeDeviceItemTitleVerticalPadding))
val details: String = if (!device.registrationTime.isNullOrBlank()) {

device.mlsPublicKeys?.values?.firstOrNull()?.let { mlsThumbprint ->
Text(
style = MaterialTheme.wireTypography.subline01,
color = MaterialTheme.wireColorScheme.labelText,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
text = stringResource(
R.string.remove_device_mls_thumbprint_label,
mlsThumbprint.formatAsFingerPrint()
),
modifier = Modifier
.fillMaxWidth()
.shimmerPlaceholder(visible = placeholder)
)
}

val proteusDetails: String = if (!device.registrationTime.isNullOrBlank()) {
if (device.lastActiveInWholeWeeks != null) {
stringResource(
R.string.remove_device_id_and_time_label_active_label,
Expand All @@ -223,7 +241,7 @@ private fun DeviceItemTexts(
Text(
style = MaterialTheme.wireTypography.subline01,
color = MaterialTheme.wireColorScheme.labelText,
text = details,
text = proteusDetails,
modifier = Modifier
.fillMaxWidth()
.shimmerPlaceholder(visible = placeholder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ data class Device(
val registrationTime: String? = null,
val lastActiveInWholeWeeks: Int? = null,
val isValid: Boolean = true,
val isVerified: Boolean = false
val isVerified: Boolean = false,
val mlsPublicKeys: Map<String, String>? = null
) {
constructor(client: Client) : this(
name = client.displayName(),
clientId = client.id,
registrationTime = client.registrationTime?.toIsoDateTimeString(),
lastActiveInWholeWeeks = client.lastActiveInWholeWeeks(),
isValid = client.isValid,
isVerified = client.isVerified
isVerified = client.isVerified,
mlsPublicKeys = client.mlsPublicKeys
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import com.wire.android.ui.common.colorsScheme
import com.wire.android.ui.common.dimensions
import com.wire.android.ui.common.snackbar.SwipeDismissSnackbarHost
import com.wire.android.ui.common.topappbar.WireCenterAlignedTopAppBar
import com.wire.android.ui.home.conversationslist.common.FolderHeader
import com.wire.android.ui.settings.devices.model.DeviceDetailsState
import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.ui.theme.wireDimensions
Expand Down Expand Up @@ -155,6 +156,24 @@ fun DeviceDetailsContent(
.background(MaterialTheme.wireColorScheme.surface)
) {

state.device.mlsPublicKeys?.forEach { (mlsProtocolType, mlsThumbprint) ->
item {
DeviceMLSSignatureItem(mlsThumbprint, mlsProtocolType, screenState::copyMessage)
Divider(color = MaterialTheme.wireColorScheme.background)
}
}

item {
FolderHeader(
name = stringResource(id = R.string.label_proteus_details).uppercase(),
modifier = Modifier
.background(MaterialTheme.wireColorScheme.background)
.fillMaxWidth()
)
DeviceIdItem(state, screenState::copyMessage)
Divider(color = MaterialTheme.wireColorScheme.background)
}

state.device.registrationTime?.formatMediumDateTime()?.let {
item {
DeviceDetailSectionContent(
Expand All @@ -175,11 +194,6 @@ fun DeviceDetailsContent(
}
}

item {
DeviceIdItem(state, screenState::copyMessage)
Divider(color = MaterialTheme.wireColorScheme.background)
}

item {
DeviceKeyFingerprintItem(state.fingerPrint, screenState::copyMessage)
Divider(color = MaterialTheme.wireColorScheme.background)
Expand Down Expand Up @@ -227,7 +241,7 @@ fun DeviceDetailsContent(
@Composable
private fun DeviceIdItem(state: DeviceDetailsState, onCopy: (String) -> Unit) {
DeviceDetailSectionContent(
sectionTitle = stringResource(id = R.string.label_client_device_id),
sectionTitle = stringResource(id = R.string.label_client_device_id).uppercase(),
sectionText = AnnotatedString(state.device.clientId.formatAsString()),
titleTrailingItem = {
CopyButton(
Expand Down Expand Up @@ -260,6 +274,32 @@ fun DeviceKeyFingerprintItem(
)
}

@Composable
fun DeviceMLSSignatureItem(
mlsThumbprint: String,
mlsProtocolType: String,
onCopy: (String) -> Unit
) {

FolderHeader(
name = stringResource(id = R.string.label_mls_signature, mlsProtocolType).uppercase(),
modifier = Modifier
.background(MaterialTheme.wireColorScheme.background)
.fillMaxWidth()
)

DeviceDetailSectionContent(
stringResource(id = R.string.label_mls_thumbprint),
sectionText = mlsThumbprint.formatAsFingerPrint(),
titleTrailingItem = {
CopyButton(
onCopyClicked = { onCopy(mlsThumbprint) },
state = WireButtonState.Default
)
}
)
}

@Composable
fun DeviceVerificationItem(
state: Boolean,
Expand Down Expand Up @@ -433,7 +473,8 @@ fun PreviewDeviceDetailsScreen() {
device = Device(
clientId = ClientId(""),
name = UIText.DynamicString("My Device"),
registrationTime = "2022-03-24T18:02:30.360Z"
registrationTime = "2022-03-24T18:02:30.360Z",
mlsPublicKeys = mapOf("Ed25519" to "lekvmrlkgvnrelkmvrlgkvlknrgb0348gi34t09gj34v034ithjoievw")
),
isCurrentDevice = false
),
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values-af/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@
this one.
</string>
<string name="remove_device_label">YOUR DEVICES</string>
<string name="remove_device_id_and_time_label">ID: %1$s\nAdded: %2$s</string>
<string name="remove_device_id_label">ID: %1$s</string>
<string name="remove_device_id_and_time_label">Proteus ID: %1$s\nAdded: %2$s</string>
<string name="remove_device_id_label">Proteus ID: %1$s</string>
<string name="remove_device_dialog_title">Remove the following device?</string>
<string name="remove_device_invalid_password">Invalid password</string>
<string name="remove_device_details_description">Remove this device if you have stopped using it. You will be logged out of this device immediately.</string>
Expand Down Expand Up @@ -832,7 +832,7 @@
<string name="label_code_commit_id">Commit Hash: %1$s</string>
<string name="label_client_id">Client ID: %1$s</string>
<string name="label_client_added_time">ADDED</string>
<string name="label_client_device_id">DEVICE ID</string>
<string name="label_client_device_id">Proteus ID</string>
<string name="label_key_packages_count">Key-packages count: %1$s</string>
<string name="label_mls_client_id">MLS-client ID: %1$s</string>
<string name="conversation_empty_list_description">Connect with others or create a new group to start collaborating!</string>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@
this one.
</string>
<string name="remove_device_label">YOUR DEVICES</string>
<string name="remove_device_id_and_time_label">ID: %1$s\nAdded: %2$s</string>
<string name="remove_device_id_label">ID: %1$s</string>
<string name="remove_device_id_and_time_label">Proteus ID: %1$s\nAdded: %2$s</string>
<string name="remove_device_id_label">Proteus ID: %1$s</string>
<string name="remove_device_dialog_title">Remove the following device?</string>
<string name="remove_device_invalid_password">Invalid password</string>
<string name="remove_device_details_description">Remove this device if you have stopped using it. You will be logged out of this device immediately.</string>
Expand Down Expand Up @@ -880,7 +880,7 @@
<string name="label_code_commit_id">Commit Hash: %1$s</string>
<string name="label_client_id">Client ID: %1$s</string>
<string name="label_client_added_time">ADDED</string>
<string name="label_client_device_id">DEVICE ID</string>
<string name="label_client_device_id">Proteus ID</string>
<string name="label_key_packages_count">Key-packages count: %1$s</string>
<string name="label_mls_client_id">MLS-client ID: %1$s</string>
<string name="conversation_empty_list_description">Connect with others or create a new group to start collaborating!</string>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values-ca/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@
this one.
</string>
<string name="remove_device_label">YOUR DEVICES</string>
<string name="remove_device_id_and_time_label">ID: %1$s\nAdded: %2$s</string>
<string name="remove_device_id_label">ID: %1$s</string>
<string name="remove_device_id_and_time_label">Proteus ID: %1$s\nAdded: %2$s</string>
<string name="remove_device_id_label">Proteus ID: %1$s</string>
<string name="remove_device_dialog_title">Remove the following device?</string>
<string name="remove_device_invalid_password">Invalid password</string>
<string name="remove_device_details_description">Remove this device if you have stopped using it. You will be logged out of this device immediately.</string>
Expand Down Expand Up @@ -832,7 +832,7 @@
<string name="label_code_commit_id">Commit Hash: %1$s</string>
<string name="label_client_id">Client ID: %1$s</string>
<string name="label_client_added_time">ADDED</string>
<string name="label_client_device_id">DEVICE ID</string>
<string name="label_client_device_id">Proteus ID</string>
<string name="label_key_packages_count">Key-packages count: %1$s</string>
<string name="label_mls_client_id">MLS-client ID: %1$s</string>
<string name="conversation_empty_list_description">Connect with others or create a new group to start collaborating!</string>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@
this one.
</string>
<string name="remove_device_label">YOUR DEVICES</string>
<string name="remove_device_id_and_time_label">ID: %1$s\nAdded: %2$s</string>
<string name="remove_device_id_label">ID: %1$s</string>
<string name="remove_device_id_and_time_label">Proteus ID: %1$s\nAdded: %2$s</string>
<string name="remove_device_id_label">Proteus ID: %1$s</string>
<string name="remove_device_dialog_title">Remove the following device?</string>
<string name="remove_device_invalid_password">Invalid password</string>
<string name="remove_device_details_description">Remove this device if you have stopped using it. You will be logged out of this device immediately.</string>
Expand Down Expand Up @@ -856,7 +856,7 @@
<string name="label_code_commit_id">Commit Hash: %1$s</string>
<string name="label_client_id">Client ID: %1$s</string>
<string name="label_client_added_time">ADDED</string>
<string name="label_client_device_id">DEVICE ID</string>
<string name="label_client_device_id">Proteus ID</string>
<string name="label_key_packages_count">Key-packages count: %1$s</string>
<string name="label_mls_client_id">MLS-client ID: %1$s</string>
<string name="conversation_empty_list_description">Connect with others or create a new group to start collaborating!</string>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values-da/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@
this one.
</string>
<string name="remove_device_label">YOUR DEVICES</string>
<string name="remove_device_id_and_time_label">ID: %1$s\nAdded: %2$s</string>
<string name="remove_device_id_label">ID: %1$s</string>
<string name="remove_device_id_and_time_label">Proteus ID: %1$s\nAdded: %2$s</string>
<string name="remove_device_id_label">Proteus ID: %1$s</string>
<string name="remove_device_dialog_title">Remove the following device?</string>
<string name="remove_device_invalid_password">Invalid password</string>
<string name="remove_device_details_description">Remove this device if you have stopped using it. You will be logged out of this device immediately.</string>
Expand Down Expand Up @@ -832,7 +832,7 @@
<string name="label_code_commit_id">Commit Hash: %1$s</string>
<string name="label_client_id">Client ID: %1$s</string>
<string name="label_client_added_time">ADDED</string>
<string name="label_client_device_id">DEVICE ID</string>
<string name="label_client_device_id">Proteus ID</string>
<string name="label_key_packages_count">Key-packages count: %1$s</string>
<string name="label_mls_client_id">MLS-client ID: %1$s</string>
<string name="conversation_empty_list_description">Connect with others or create a new group to start collaborating!</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@
hier zu nutzen.
</string>
<string name="remove_device_label">IHRE GERÄTE</string>
<string name="remove_device_id_and_time_label">ID: %1$s\nHinzugefügt: %2$s</string>
<string name="remove_device_id_label">ID: %1$s</string>
<string name="remove_device_id_and_time_label">Proteus ID: %1$s\nHinzugefügt: %2$s</string>
<string name="remove_device_id_label">Proteus ID: %1$s</string>
<string name="remove_device_dialog_title">Folgendes Gerät entfernen?</string>
<string name="remove_device_invalid_password">Ungültiges Passwort</string>
<string name="remove_device_details_description">Entfernen Sie dieses Gerät, wenn Sie es nicht mehr nutzen. Sie werden sofort auf diesem Gerät abgemeldet.</string>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@
this one.
</string>
<string name="remove_device_label">YOUR DEVICES</string>
<string name="remove_device_id_and_time_label">ID: %1$s\nAdded: %2$s</string>
<string name="remove_device_id_label">ID: %1$s</string>
<string name="remove_device_id_and_time_label">Proteus ID: %1$s\nAdded: %2$s</string>
<string name="remove_device_id_label">Proteus ID: %1$s</string>
<string name="remove_device_dialog_title">Remove the following device?</string>
<string name="remove_device_invalid_password">Invalid password</string>
<string name="remove_device_details_description">Remove this device if you have stopped using it. You will be logged out of this device immediately.</string>
Expand Down Expand Up @@ -832,7 +832,7 @@
<string name="label_code_commit_id">Commit Hash: %1$s</string>
<string name="label_client_id">Client ID: %1$s</string>
<string name="label_client_added_time">ADDED</string>
<string name="label_client_device_id">DEVICE ID</string>
<string name="label_client_device_id">Proteus ID</string>
<string name="label_key_packages_count">Key-packages count: %1$s</string>
<string name="label_mls_client_id">MLS-client ID: %1$s</string>
<string name="conversation_empty_list_description">Connect with others or create a new group to start collaborating!</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ URL del backend:
<string name="remove_device_title">Eliminar un dispositivo</string>
<string name="remove_device_message">Elimina uno de tus otros dispositivos para empezar a usar Wire en &#233;ste.</string>
<string name="remove_device_label">TUS DISPOSITIVOS</string>
<string name="remove_device_id_and_time_label">ID: %1$s
<string name="remove_device_id_and_time_label">Proteus ID: %1$s
Agregado: %2$s</string>
<string name="remove_device_id_label">ID: %1$s</string>
<string name="remove_device_id_label">Proteus ID: %1$s</string>
<string name="remove_device_dialog_title">&#191;Eliminar el siguiente dispositivo?</string>
<string name="remove_device_invalid_password">Contrase&#241;a inv&#225;lida</string>
<string name="remove_device_details_description">Elimina este dispositivo si has dejado de usarlo. Se cerrar&#225; la sesi&#243;n en este dispositivo inmediatamente.</string>
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values-et/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@
this one.
</string>
<string name="remove_device_label">SINU SEADMED</string>
<string name="remove_device_id_and_time_label">ID: %1$s\nLisatud: %2$s</string>
<string name="remove_device_id_label">ID: %1$s</string>
<string name="remove_device_id_and_time_label">Proteus ID: %1$s\nLisatud: %2$s</string>
<string name="remove_device_id_label">Proteus ID: %1$s</string>
<string name="remove_device_dialog_title">Remove the following device?</string>
<string name="remove_device_invalid_password">Vale parool</string>
<string name="remove_device_details_description">Remove this device if you have stopped using it. You will be logged out of this device immediately.</string>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@
this one.
</string>
<string name="remove_device_label">YOUR DEVICES</string>
<string name="remove_device_id_and_time_label">ID: %1$s\nAdded: %2$s</string>
<string name="remove_device_id_label">ID: %1$s</string>
<string name="remove_device_id_and_time_label">Proteus ID: %1$s\nAdded: %2$s</string>
<string name="remove_device_id_label">Proteus ID: %1$s</string>
<string name="remove_device_dialog_title">Remove the following device?</string>
<string name="remove_device_invalid_password">Invalid password</string>
<string name="remove_device_details_description">Remove this device if you have stopped using it. You will be logged out of this device immediately.</string>
Expand Down Expand Up @@ -832,7 +832,7 @@
<string name="label_code_commit_id">Commit Hash: %1$s</string>
<string name="label_client_id">Client ID: %1$s</string>
<string name="label_client_added_time">ADDED</string>
<string name="label_client_device_id">DEVICE ID</string>
<string name="label_client_device_id">Proteus ID</string>
<string name="label_key_packages_count">Key-packages count: %1$s</string>
<string name="label_mls_client_id">MLS-client ID: %1$s</string>
<string name="conversation_empty_list_description">Connect with others or create a new group to start collaborating!</string>
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@
this one.
</string>
<string name="remove_device_label">YOUR DEVICES</string>
<string name="remove_device_id_and_time_label">ID: %1$s\nAdded: %2$s</string>
<string name="remove_device_id_label">ID: %1$s</string>
<string name="remove_device_id_and_time_label">Proteus ID: %1$s\nAdded: %2$s</string>
<string name="remove_device_id_label">Proteus ID: %1$s</string>
<string name="remove_device_dialog_title">Remove the following device?</string>
<string name="remove_device_invalid_password">Invalid password</string>
<string name="remove_device_details_description">Remove this device if you have stopped using it. You will be logged out of this device immediately.</string>
Expand Down Expand Up @@ -832,7 +832,7 @@
<string name="label_code_commit_id">Commit Hash: %1$s</string>
<string name="label_client_id">Client ID: %1$s</string>
<string name="label_client_added_time">ADDED</string>
<string name="label_client_device_id">DEVICE ID</string>
<string name="label_client_device_id">Proteus ID</string>
<string name="label_key_packages_count">Key-packages count: %1$s</string>
<string name="label_mls_client_id">MLS-client ID: %1$s</string>
<string name="conversation_empty_list_description">Connect with others or create a new group to start collaborating!</string>
Expand Down

0 comments on commit 21e1629

Please sign in to comment.