mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Fix the pinned identity banner to always show the user ID regardless of ambiguity. (#3415)
This commit is contained in:
@@ -241,6 +241,8 @@
|
|||||||
"confirm_recovery_key_banner_title" = "Enter your recovery key";
|
"confirm_recovery_key_banner_title" = "Enter your recovery key";
|
||||||
"crash_detection_dialog_content" = "%1$@ crashed the last time it was used. Would you like to share a crash report with us?";
|
"crash_detection_dialog_content" = "%1$@ crashed the last time it was used. Would you like to share a crash report with us?";
|
||||||
"crypto_identity_change_pin_violation" = "%1$@'s identity appears to have changed. %2$@";
|
"crypto_identity_change_pin_violation" = "%1$@'s identity appears to have changed. %2$@";
|
||||||
|
"crypto_identity_change_pin_violation_new" = "%1$@’s %2$@ identity appears to have changed. %3$@";
|
||||||
|
"crypto_identity_change_pin_violation_new_user_id" = "(%1$@)";
|
||||||
"dialog_permission_camera" = "In order to let the application use the camera, please grant the permission in the system settings.";
|
"dialog_permission_camera" = "In order to let the application use the camera, please grant the permission in the system settings.";
|
||||||
"dialog_permission_generic" = "Please grant the permission in the system settings.";
|
"dialog_permission_generic" = "Please grant the permission in the system settings.";
|
||||||
"dialog_permission_location_description_ios" = "Grant access in Settings -> Location.";
|
"dialog_permission_location_description_ios" = "Grant access in Settings -> Location.";
|
||||||
|
|||||||
@@ -524,6 +524,14 @@ internal enum L10n {
|
|||||||
internal static func cryptoIdentityChangePinViolation(_ p1: Any, _ p2: Any) -> String {
|
internal static func cryptoIdentityChangePinViolation(_ p1: Any, _ p2: Any) -> String {
|
||||||
return L10n.tr("Localizable", "crypto_identity_change_pin_violation", String(describing: p1), String(describing: p2))
|
return L10n.tr("Localizable", "crypto_identity_change_pin_violation", String(describing: p1), String(describing: p2))
|
||||||
}
|
}
|
||||||
|
/// %1$@’s %2$@ identity appears to have changed. %3$@
|
||||||
|
internal static func cryptoIdentityChangePinViolationNew(_ p1: Any, _ p2: Any, _ p3: Any) -> String {
|
||||||
|
return L10n.tr("Localizable", "crypto_identity_change_pin_violation_new", String(describing: p1), String(describing: p2), String(describing: p3))
|
||||||
|
}
|
||||||
|
/// (%1$@)
|
||||||
|
internal static func cryptoIdentityChangePinViolationNewUserId(_ p1: Any) -> String {
|
||||||
|
return L10n.tr("Localizable", "crypto_identity_change_pin_violation_new_user_id", String(describing: p1))
|
||||||
|
}
|
||||||
/// In order to let the application use the camera, please grant the permission in the system settings.
|
/// In order to let the application use the camera, please grant the permission in the system settings.
|
||||||
internal static var dialogPermissionCamera: String { return L10n.tr("Localizable", "dialog_permission_camera") }
|
internal static var dialogPermissionCamera: String { return L10n.tr("Localizable", "dialog_permission_camera") }
|
||||||
/// Please grant the permission in the system settings.
|
/// Please grant the permission in the system settings.
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ struct RoomScreenFooterView: View {
|
|||||||
avatarSize: .user(on: .timeline),
|
avatarSize: .user(on: .timeline),
|
||||||
mediaProvider: mediaProvider)
|
mediaProvider: mediaProvider)
|
||||||
|
|
||||||
Text(pinViolationDescriptionWithLearnMoreLink(displayName: member.disambiguatedDisplayName ?? member.userID,
|
Text(pinViolationDescriptionWithLearnMoreLink(displayName: member.displayName,
|
||||||
|
userID: member.userID,
|
||||||
url: learnMoreURL))
|
url: learnMoreURL))
|
||||||
.font(.compound.bodyMD)
|
.font(.compound.bodyMD)
|
||||||
.foregroundColor(.compound.textPrimary)
|
.foregroundColor(.compound.textPrimary)
|
||||||
@@ -59,20 +60,39 @@ struct RoomScreenFooterView: View {
|
|||||||
.padding(.bottom, 8)
|
.padding(.bottom, 8)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func pinViolationDescriptionWithLearnMoreLink(displayName: String, url: URL) -> AttributedString {
|
private func pinViolationDescriptionWithLearnMoreLink(displayName: String?, userID: String, url: URL) -> AttributedString {
|
||||||
|
let userIDPlaceholder = "{mxid}"
|
||||||
let linkPlaceholder = "{link}"
|
let linkPlaceholder = "{link}"
|
||||||
var description = AttributedString(L10n.cryptoIdentityChangePinViolation(displayName, linkPlaceholder))
|
let displayName = displayName ?? fallbackDisplayName(userID)
|
||||||
|
var description = AttributedString(L10n.cryptoIdentityChangePinViolationNew(displayName, userIDPlaceholder, linkPlaceholder))
|
||||||
|
|
||||||
|
var userIDString = AttributedString(L10n.cryptoIdentityChangePinViolationNewUserId(userID))
|
||||||
|
userIDString.bold()
|
||||||
|
description.replace(userIDPlaceholder, with: userIDString)
|
||||||
|
|
||||||
var linkString = AttributedString(L10n.actionLearnMore)
|
var linkString = AttributedString(L10n.actionLearnMore)
|
||||||
linkString.link = url
|
linkString.link = url
|
||||||
linkString.bold()
|
linkString.bold()
|
||||||
description.replace(linkPlaceholder, with: linkString)
|
description.replace(linkPlaceholder, with: linkString)
|
||||||
return description
|
return description
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func fallbackDisplayName(_ userID: String) -> String {
|
||||||
|
guard let localpart = userID.components(separatedBy: ":").first else { return userID }
|
||||||
|
return String(localpart.trimmingPrefix("@"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RoomScreenFooterView_Previews: PreviewProvider, TestablePreview {
|
struct RoomScreenFooterView_Previews: PreviewProvider, TestablePreview {
|
||||||
|
static let bobDetails: RoomScreenFooterViewDetails = .pinViolation(member: RoomMemberProxyMock.mockBob,
|
||||||
|
learnMoreURL: "https://element.io/")
|
||||||
|
static let noNameDetails: RoomScreenFooterViewDetails = .pinViolation(member: RoomMemberProxyMock.mockNoName,
|
||||||
|
learnMoreURL: "https://element.io/")
|
||||||
|
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
RoomScreenFooterView(details: .pinViolation(member: RoomMemberProxyMock.mockBob, learnMoreURL: "https://element.io/"),
|
RoomScreenFooterView(details: bobDetails, mediaProvider: MediaProviderMock(configuration: .init())) { _ in }
|
||||||
mediaProvider: MediaProviderMock(configuration: .init())) { _ in }
|
.previewDisplayName("With displayname")
|
||||||
|
RoomScreenFooterView(details: noNameDetails, mediaProvider: MediaProviderMock(configuration: .init())) { _ in }
|
||||||
|
.previewDisplayName("Without displayname")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:6ff5ac1cb8df1556b0d4ba1f119e65a182cb3ece6003f58db8a6129ef701dd94
|
|
||||||
size 156835
|
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:e01dbaab1c59563feea0b36e1859fcf9171f658eb1c03ec4a5bcc7442e399694
|
||||||
|
size 156987
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:7515e499500d53851cee3922b03ae96fdfb02a9371ebc19669d3f1788bca1975
|
||||||
|
size 160605
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:b9693534082a1948f05d6f50c7e0cb8db768fdf6fe01189af4df64638edaae37
|
|
||||||
size 166386
|
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:71dbd25ef19181d442d33c708f8bf04cbf710791bd5fca8371ee382855204b55
|
||||||
|
size 169974
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:8d3b822afa220fedd562c956da594a019c0bd6391efd522e79e88adcebbebe36
|
||||||
|
size 177460
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:b02b43b978488a8e7b81d2767862a9a5289df638c502570557ef5f5e7a8dd4cc
|
|
||||||
size 77863
|
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:266b6f2530685c8be01e6c9f64139596330c52d6b3d268d46c94ab98ae136a46
|
||||||
|
size 78221
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:692b1f60a6df116b1130d839928600765ecf68ca5f825c6bb231533aeb01c746
|
||||||
|
size 86160
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:c7ab7912c6041b90042ed19c52ae21ee6ea4e88f5592b692607e7f8eb01adc40
|
|
||||||
size 99897
|
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:92c7085936fb313fb8bbf399acd1f83582ca940433119bd2ba41ea9351517ee1
|
||||||
|
size 102769
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:24524c9052a7bcc9b04b764c714680bcbcb87ef3e583cd12e8450e2b0db69829
|
||||||
|
size 107246
|
||||||
Reference in New Issue
Block a user