mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-17 15:09:31 +02:00
MESSENGER-5706 show federation announcement promt
This commit is contained in:
@@ -700,3 +700,8 @@
|
||||
"room_participants_invite_prompt_server_acl_for_room_not_configured_text" = "Du kannst noch keine Personen aus einer föderierten Organisation einladen, da die Freigabe hierfür noch nicht erteilt wurde. Gib dem Admin Bescheid, dass die Einstellung getroffen werden muss.";
|
||||
|
||||
"room_participants_invite_prompt_server_acl_loading_error_text" = "Die Person kann aktuell nicht eingeladen werden, bitte versuche es später erneut.";
|
||||
|
||||
"federation_announcement_title" = "Ankündigung";
|
||||
"federation_announcement_text" = "Ab Mai 2024 ist die **Föderation** zwischen verschiedenen Organisationen möglich. Dies bietet eine übergreifende sichere Kommunikation.\n\nDetails findest du in der Datenschutzerklärung.";
|
||||
"federation_announcement_sub_text" = "Wenn du dein Profilbild vorweg ändern möchtest, gehe zu den Einstellungen.";
|
||||
"federation_announcement_button" = "Verstanden";
|
||||
|
||||
@@ -613,3 +613,8 @@
|
||||
"room_participants_invite_prompt_server_acl_for_room_not_configured_text" = "You cannot yet invite people from a federated organization, as this has not yet been approved. Let the admin know that the setting needs to be made.";
|
||||
|
||||
"room_participants_invite_prompt_server_acl_loading_error_text" = "You cannot invite this user at the moment, please try again later.";
|
||||
|
||||
"federation_announcement_title" = "Announcement";
|
||||
"federation_announcement_text" = "The **Federation** will start in May 2024. This enables secure communication across different organizations.\n\nDetails can be found in the privacy policies.";
|
||||
"federation_announcement_sub_text" = "If you want to change your profile picture, go to the settings.";
|
||||
"federation_announcement_button" = "Understood";
|
||||
|
||||
@@ -831,6 +831,22 @@ public class BWIL10n: NSObject {
|
||||
public static var e2eKeyBackupWrongVersion: String {
|
||||
return BWIL10n.tr("Bwi", "e2e_key_backup_wrong_version")
|
||||
}
|
||||
/// Verstanden
|
||||
public static var federationAnnouncementButton: String {
|
||||
return BWIL10n.tr("Bwi", "federation_announcement_button")
|
||||
}
|
||||
/// Wenn du dein Profilbild vorweg ändern möchtest, gehe zu den Einstellungen.
|
||||
public static var federationAnnouncementSubText: String {
|
||||
return BWIL10n.tr("Bwi", "federation_announcement_sub_text")
|
||||
}
|
||||
/// Ab Mai 2024 ist die **Föderation** zwischen verschiedenen Organisationen möglich. Dies bietet eine übergreifende sichere Kommunikation.\n\nDetails findest du in der Datenschutzerklärung.
|
||||
public static var federationAnnouncementText: String {
|
||||
return BWIL10n.tr("Bwi", "federation_announcement_text")
|
||||
}
|
||||
/// Ankündigung
|
||||
public static var federationAnnouncementTitle: String {
|
||||
return BWIL10n.tr("Bwi", "federation_announcement_title")
|
||||
}
|
||||
/// Notizen ausblenden
|
||||
public static var homeContextMenuPersonalNotes: String {
|
||||
return BWIL10n.tr("Bwi", "home_context_menu_personal_notes")
|
||||
@@ -1143,10 +1159,6 @@ public class BWIL10n: NSObject {
|
||||
public static var roomAdminFederationDecisionSheetDeactivateFederationButton: String {
|
||||
return BWIL10n.tr("Bwi", "room_admin_federation_decision_sheet_deactivate_federation_button")
|
||||
}
|
||||
/// Später erinnern
|
||||
public static var roomAdminFederationDecisionSheetRemindLaterButton: String {
|
||||
return BWIL10n.tr("Bwi", "room_admin_federation_decision_sheet_remind_later_button")
|
||||
}
|
||||
/// Hierdurch kann der Raum von externen Organisationen mitgenutzt werden. Dies kann nachträglich in den Einstellungen geändert werden.
|
||||
public static var roomAdminFederationDecisionSheetText: String {
|
||||
return BWIL10n.tr("Bwi", "room_admin_federation_decision_sheet_text")
|
||||
@@ -1639,6 +1651,10 @@ public class BWIL10n: NSObject {
|
||||
public static var settingsCallInvitations: String {
|
||||
return BWIL10n.tr("Bwi", "settings_call_invitations")
|
||||
}
|
||||
/// Auch Nutzer aus föderierten Organisationen können dein Profilbild sehen.
|
||||
public static var settingsChangeProfileAvatarHint: String {
|
||||
return BWIL10n.tr("Bwi", "settings_change_profile_avatar_hint")
|
||||
}
|
||||
/// Neues Passwort bestätigen
|
||||
public static var settingsConfirmPassword: String {
|
||||
return BWIL10n.tr("Bwi", "settings_confirm_password")
|
||||
|
||||
@@ -302,6 +302,23 @@ class RiotSharedSettings: NSObject {
|
||||
|
||||
return session.setAccountData(notificationsDict, forType: "de.bwi.notifications", success: success, failure: failure)
|
||||
}
|
||||
|
||||
// MARK: FederationAnnouncement
|
||||
// bwi: 5706 show federation announcement promt
|
||||
func shouldShowFederationAnnouncement() -> Bool {
|
||||
guard let notificationsDict = getAccountData(forEventType: "de.bwi.notifications") else {
|
||||
return true
|
||||
}
|
||||
return (notificationsDict["should_show_federation_announcement"] as? Bool) ?? true
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
func setFederationAnnouncement() -> MXHTTPOperation? {
|
||||
var notificationsDict = getAccountData(forEventType: "de.bwi.notifications") ?? [:]
|
||||
notificationsDict["should_show_federation_announcement"] = false
|
||||
|
||||
return session.setAccountData(notificationsDict, forType: "de.bwi.notifications", success: nil, failure: nil)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
private func getAccountData(forEventType eventType: String) -> [String: Any]? {
|
||||
|
||||
@@ -712,6 +712,9 @@ class AllChatsCoordinator: NSObject, SplitViewMasterCoordinatorProtocol {
|
||||
private func bwiCheckForMatomoPromt() {
|
||||
if BWIBuildSettings.shared.bwiMatomoEnabled && BWIAnalytics.sharedTracker.needsToShowPromt() {
|
||||
self.allChatsViewController.bwiPresentMatomoConsentAlert()
|
||||
} else {
|
||||
// bwi: 5706 show federation announcement promt
|
||||
self.allChatsViewController.bwiCheckForFederationAnnouncementPromt()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -477,6 +477,8 @@ class AllChatsViewController: HomeViewController {
|
||||
style: .default,
|
||||
handler: { action in
|
||||
BWIAnalytics.sharedTracker.running = false
|
||||
// bwi: 5706 show federation announcement promt
|
||||
self.bwiCheckForFederationAnnouncementPromt()
|
||||
}))
|
||||
|
||||
alert.addAction(UIAlertAction(title: BWIL10n.bwiAnalyticsAlertOkButton,
|
||||
@@ -484,11 +486,26 @@ class AllChatsViewController: HomeViewController {
|
||||
handler: { action in
|
||||
BWIAnalytics.sharedTracker.running = true
|
||||
BWIAnalytics.sharedTracker.trackBwiValue(0, "General", "ConsentGiven", "popup")
|
||||
// bwi: 5706 show federation announcement promt
|
||||
self.bwiCheckForFederationAnnouncementPromt()
|
||||
}))
|
||||
|
||||
self.present(alert, animated: true)
|
||||
}
|
||||
|
||||
// bwi: 5706 show federation announcement promt
|
||||
func bwiCheckForFederationAnnouncementPromt() {
|
||||
if AppConfigService.shared.shouldShowFederationAnnouncement() {
|
||||
let sharedSettings = RiotSharedSettings(session: self.mainSession)
|
||||
if sharedSettings.shouldShowFederationAnnouncement() {
|
||||
let viewController = FederationAnnouncementSheet().makeViewController()
|
||||
viewController.modalPresentationStyle = .formSheet
|
||||
self.present(viewController, animated: true, completion: nil)
|
||||
sharedSettings.setFederationAnnouncement()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
@objc private func showSpaceSelectorAction(sender: AnyObject) {
|
||||
|
||||
@@ -24,4 +24,5 @@ struct AppConfig: Codable, Equatable {
|
||||
var pusherUrl: String? = nil
|
||||
var permalinkUrl: String? = nil
|
||||
var externalUrlScheme: String? = nil
|
||||
var shouldShowFederationAnnouncement: Bool? = false
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ extension UserDefaults
|
||||
private let pusherUrlKey = "pusherUrl"
|
||||
private let permalinkUrlKey = "permalinkUrl"
|
||||
private let externalUrlSchemeKey = "external_url_scheme"
|
||||
private let federationAnnouncementKey = "should_show_federation_announcement"
|
||||
|
||||
private let savedConfig = "savedAppConfig"
|
||||
|
||||
@@ -147,6 +148,9 @@ extension UserDefaults
|
||||
if let externalUrlScheme = dict[externalUrlSchemeKey] as? String {
|
||||
config.externalUrlScheme = externalUrlScheme
|
||||
}
|
||||
if let shouldShowFederationAnnouncement = dict[federationAnnouncementKey] as? Bool {
|
||||
config.shouldShowFederationAnnouncement = shouldShowFederationAnnouncement
|
||||
}
|
||||
|
||||
// app config needs at least a valid server url
|
||||
if let serverUrl = config.serverUrl {
|
||||
@@ -201,4 +205,8 @@ extension UserDefaults
|
||||
func externalUrlScheme() -> String? {
|
||||
return appConfig.externalUrlScheme
|
||||
}
|
||||
|
||||
func shouldShowFederationAnnouncement() -> Bool {
|
||||
return appConfig.shouldShowFederationAnnouncement ?? false
|
||||
}
|
||||
}
|
||||
|
||||
125
bwi/Federation/UI/FederationAnnouncementView.swift
Normal file
125
bwi/Federation/UI/FederationAnnouncementView.swift
Normal file
@@ -0,0 +1,125 @@
|
||||
//
|
||||
/*
|
||||
* Copyright (c) 2024 BWI GmbH
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import SwiftUI
|
||||
|
||||
@objcMembers class FederationAnnouncementSheet: NSObject {
|
||||
@Published var theme: Theme
|
||||
|
||||
override init() {
|
||||
theme = ThemeService.shared().theme
|
||||
}
|
||||
|
||||
func makeViewController() -> UIViewController {
|
||||
registerThemeServiceDidChangeThemeNotification()
|
||||
return UIHostingController(rootView: FederationAnnouncementView(theme: Binding(get: {
|
||||
return self.theme
|
||||
}, set: { newTheme in
|
||||
self.theme = newTheme
|
||||
})))
|
||||
}
|
||||
|
||||
private func registerThemeServiceDidChangeThemeNotification() {
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(themeDidChange), name: .themeServiceDidChangeTheme, object: nil)
|
||||
}
|
||||
|
||||
@objc private func themeDidChange() {
|
||||
self.theme = ThemeService.shared().theme
|
||||
}
|
||||
}
|
||||
|
||||
struct FederationAnnouncementView: View {
|
||||
@Environment(\.dismiss) var dismissView
|
||||
@Binding var theme: Theme
|
||||
|
||||
let imageStackScale = 0.30
|
||||
let imageStackShift = 5.0
|
||||
let lineWith = 7.0
|
||||
let spacing = 16.0
|
||||
|
||||
var announcementText: AttributedString {
|
||||
do {
|
||||
return try AttributedString(markdown: (BWIL10n.federationAnnouncementText), options: AttributedString.MarkdownParsingOptions(interpretedSyntax: .inlineOnlyPreservingWhitespace))
|
||||
} catch {
|
||||
return AttributedString(BWIL10n.federationAnnouncementText)
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { geo in
|
||||
ScrollView(.vertical) {
|
||||
VStack(spacing: spacing) {
|
||||
|
||||
Spacer()
|
||||
|
||||
ZStack(alignment: .center) {
|
||||
Circle()
|
||||
.fill(Color(theme.colors.quinaryContent))
|
||||
.overlay(Circle()
|
||||
.stroke(Color(theme.colors.background), lineWidth: lineWith))
|
||||
.offset(x:((getImageSize(width: geo.size.width, height: geo.size.height) * imageStackScale) / imageStackShift))
|
||||
Image("welcome_experience_1")
|
||||
.resizable()
|
||||
.clipShape(Circle())
|
||||
.overlay(Circle()
|
||||
.stroke(Color(theme.colors.background), lineWidth: lineWith))
|
||||
.offset(x:-((getImageSize(width: geo.size.width, height: geo.size.height) * imageStackScale) / imageStackShift))
|
||||
}
|
||||
.frame(width: getImageSize(width: geo.size.width, height: geo.size.height) * imageStackScale, height: getImageSize(width: geo.size.width, height: geo.size.height) * imageStackScale)
|
||||
|
||||
LazyVStack(spacing: spacing) {
|
||||
Text(BWIL10n.federationAnnouncementTitle)
|
||||
.font(.system(size: 24).bold())
|
||||
.multilineTextAlignment(.center)
|
||||
.lineLimit(nil)
|
||||
.foregroundColor(Color(theme.colors.primaryContent))
|
||||
Text(announcementText)
|
||||
.font(Font(theme.fonts.subheadline))
|
||||
.multilineTextAlignment(.center)
|
||||
.lineLimit(nil)
|
||||
.foregroundColor(Color(theme.colors.primaryContent))
|
||||
Text(BWIL10n.federationAnnouncementSubText)
|
||||
.font(Font(theme.fonts.subheadline))
|
||||
.multilineTextAlignment(.center)
|
||||
.lineLimit(nil)
|
||||
.foregroundColor(Color(theme.colors.secondaryContent))
|
||||
}
|
||||
.padding(spacing)
|
||||
|
||||
Spacer()
|
||||
|
||||
Button {
|
||||
dismissView()
|
||||
} label: {
|
||||
Text(BWIL10n.federationAnnouncementButton)
|
||||
}
|
||||
.buttonStyle(PrimaryActionButtonStyle())
|
||||
.accessibilityIdentifier("federationAnnouncementCloseButton")
|
||||
.padding(spacing)
|
||||
}
|
||||
.frame(minHeight: geo.size.height)
|
||||
}
|
||||
.interactiveDismissDisabled()
|
||||
.frame(width: geo.size.width, height: geo.size.height)
|
||||
.background(Color(theme.colors.background))
|
||||
}
|
||||
}
|
||||
|
||||
func getImageSize(width: CGFloat, height: CGFloat) -> CGFloat {
|
||||
return (width > height ? height : width)
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ struct RoomFederationDecisionView: View {
|
||||
|
||||
|
||||
var textStack: some View {
|
||||
VStack(spacing: spacing) {
|
||||
LazyVStack(spacing: spacing) {
|
||||
Text(BWIL10n.roomAdminFederationDecisionSheetTitle(room.displayName ?? ""))
|
||||
.font(.system(size: 24).bold())
|
||||
.multilineTextAlignment(.center)
|
||||
|
||||
Reference in New Issue
Block a user