Merge branch 'feature/4295_maintenance_with_additional_information' into 'develop'

MESSENGER-4295 add additional information for maintenance

See merge request bwmessenger/bundesmessenger/bundesmessenger-ios!166
This commit is contained in:
Arnfried Griesert
2023-07-26 13:07:22 +00:00
9 changed files with 125 additions and 81 deletions
+1
View File
@@ -615,6 +615,7 @@ class BWIBuildSettings: NSObject {
// MARK: - Maintenance
var enableMaintenanceInfoOnWelcomeScreen = false
var showMaintenanceInfoMessageType = false
// MARK: User Search
var sortUserSearchResultsAlphabetically = true
@@ -37,6 +37,7 @@ extension BWIBuildSettings {
enableLabFeatureVoiceBroadcasts = true
enableNewSessionManagerByDefault = true
enableLabFeatureWYSIWYG = true
showMaintenanceInfoMessageType = true
}
}
+2 -1
View File
@@ -30,7 +30,8 @@
"downtime_title" = "⚠ Server nicht erreichbar";
"downtime_default_message" = "Wir führen gerade Wartungsarbeiten durch. Bitte versuche es später erneut.";
"downtime_alert_dismiss_button" = "Zurück";
"downtime_alert_dismiss_button" = "Ok";
"blocking_downtime_alert_dismiss_button" = "Zurück";
"settings_downtime_message_same_day" = "Der %@ steht am %@, %@ von %@ bis %@ Uhr (UTC%@) nicht zur Verfügung. Nachrichten können in dieser Zeit nicht verschickt oder empfangen werden.";
"settings_downtime_message_different_days" = "Der %@ steht von %@, %@ Uhr (UTC%@) bis %@, %@ Uhr (UTC%@) nicht zur Verfügung. Nachrichten können in dieser Zeit nicht verschickt oder empfangen werden.";
"settings_copyright" = "Copyright";
+2 -1
View File
@@ -30,7 +30,8 @@
"downtime_title" = "⚠ Server not available";
"downtime_default_message" = "We are working on our maintenance. Please try again later.";
"downtime_alert_dismiss_button" = "Back";
"downtime_alert_dismiss_button" = "Ok";
"blocking_downtime_alert_dismiss_button" = "Back";
"settings_downtime_message_same_day" = "The %@ is not available on %@, %@ between %@ and %@ (UTC%@). Messages may not be sent or received during that time.";
"settings_downtime_message_different_days" = "The %@ is not available from %@, %@ (UTC%@) to %@, %@ (UTC%@). Messages may not be sent or received during that time.";
"settings_copyright" = "Copyright";
@@ -3026,12 +3026,7 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
downtimeCell.textLabel.text = [self bwiDowntimeCellText];
downtimeCell.textLabel.textColor = [self bwiDowntimeTextColor];
downtimeCell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
// bwi: with descriptions coming soon we need to do this dynamically
if ([[[ServerDowntimeDefaultService alloc] init] isSameDay]) {
downtimeCell.textLabel.numberOfLines = 6;
} else {
downtimeCell.textLabel.numberOfLines = 7;
}
downtimeCell.textLabel.numberOfLines = 0;
cell = downtimeCell;
@@ -3048,7 +3043,7 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
downtimeCell.textLabel.text = [BWIL10n bwiOutdatedSettingsMessage:AppInfo.current.displayName];
downtimeCell.textLabel.textColor = [UIColor blackColor];
downtimeCell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
downtimeCell.textLabel.numberOfLines = 5;
downtimeCell.textLabel.numberOfLines = 0;
cell = downtimeCell;
}
@@ -5255,7 +5250,7 @@ ChangePasswordCoordinatorBridgePresenterDelegate>
#pragma mark - bwi Messenger Additions
- (NSString*) bwiDowntimeCellText {
NSString *downtimeText = [NSString stringWithFormat:@"\n%@\n\n", [[[ServerDowntimeDefaultService alloc] init] downtimeText]];
NSString *downtimeText = [NSString stringWithFormat:@"\n%@\n", [[[ServerDowntimeDefaultService alloc] init] downtimeText]];
return downtimeText;
}
@@ -17,12 +17,17 @@
import Foundation
enum ServerDowntimeType {
enum ServerDowntimeStatus {
case none
case warning
case ongoing
}
enum ServerDowntimeType: String {
case adhocMessage = "ADHOC_MESSAGE"
case maintenance = "MAINTENANCE"
}
protocol ServerDowntimeService {
func fetchDowntimes(session: MXSession, completion: @escaping () -> Void)
func isDowntimePresentable() -> Bool
@@ -27,7 +27,7 @@ fileprivate let exampleFile = "exampleDowntime"
fileprivate let maintenanceURL = "/_matrix/cmaintenance"
@objcMembers class ServerDowntimeDefaultService : NSObject {
var isCurrentDowntime: ServerDowntimeType = .none
var isCurrentDowntime: ServerDowntimeStatus = .none
/// Find the next relevant downtime
/// - Returns: ServerDowntime or nil, if there is no downtime in the future or the warning date is still in the future
@@ -69,7 +69,7 @@ fileprivate let maintenanceURL = "/_matrix/cmaintenance"
/// Check the state of the next downtime
/// - Returns: ongoing, warning or none
func nextDowntimeType() -> ServerDowntimeType {
func nextDowntimeStatus() -> ServerDowntimeStatus {
guard let downTime = self.nextDowntime() else {
return .none
}
@@ -193,54 +193,62 @@ extension ServerDowntimeDefaultService : ServerDowntimeService {
// MARK: -
@objc func isDowntimePresentable() -> Bool {
return nextDowntimeType() != .none
return nextDowntimeStatus() != .none
}
@objc func downtimeText() -> String {
guard let downTime = self.nextDowntime(), let startDate = downTime.startTime.iso8601LocalDate, let endDate = downTime.endTime.iso8601LocalDate else {
guard let downTime = self.nextDowntime() else {
return ""
}
let dayOfWeekFormatter = DateFormatter()
dayOfWeekFormatter.dateFormat = "EEEE"
dayOfWeekFormatter.timeZone = TimeZone.current
dayOfWeekFormatter.calendar = Calendar.current
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd.MM.yyyy"
dateFormatter.timeZone = TimeZone.current
dateFormatter.calendar = Calendar.current
let dateTimeFormatter = DateFormatter()
dateTimeFormatter.dateFormat = "dd.MM.yyyy HH:mm"
dateTimeFormatter.timeZone = TimeZone.current
dateTimeFormatter.calendar = Calendar.current
let timeFormatter = DateFormatter()
timeFormatter.dateFormat = "HH:mm"
timeFormatter.timeZone = TimeZone.current
timeFormatter.calendar = Calendar.current
let utcFormatter = DateFormatter()
utcFormatter.dateFormat = "ZZZZZ"
utcFormatter.timeZone = TimeZone.current
utcFormatter.calendar = Calendar.current
if self.isSameDay() {
return BWIL10n.settingsDowntimeMessageSameDay(AppInfo.current.displayName,
dayOfWeekFormatter.string(from: startDate),
dateFormatter.string(from: startDate),
timeFormatter.string(from: startDate),
timeFormatter.string(from: endDate),
utcFormatter.string(from: startDate))
} else {
return BWIL10n.settingsDowntimeMessageDifferentDays(AppInfo.current.displayName,
switch downtimeType() {
case .adhocMessage:
return downTime.description
case .maintenance:
guard let startDate = downTime.startTime.iso8601LocalDate, let endDate = downTime.endTime.iso8601LocalDate else {
return ""
}
let dayOfWeekFormatter = DateFormatter()
dayOfWeekFormatter.dateFormat = "EEEE"
dayOfWeekFormatter.timeZone = TimeZone.current
dayOfWeekFormatter.calendar = Calendar.current
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd.MM.yyyy"
dateFormatter.timeZone = TimeZone.current
dateFormatter.calendar = Calendar.current
let dateTimeFormatter = DateFormatter()
dateTimeFormatter.dateFormat = "dd.MM.yyyy HH:mm"
dateTimeFormatter.timeZone = TimeZone.current
dateTimeFormatter.calendar = Calendar.current
let timeFormatter = DateFormatter()
timeFormatter.dateFormat = "HH:mm"
timeFormatter.timeZone = TimeZone.current
timeFormatter.calendar = Calendar.current
let utcFormatter = DateFormatter()
utcFormatter.dateFormat = "ZZZZZ"
utcFormatter.timeZone = TimeZone.current
utcFormatter.calendar = Calendar.current
if self.isSameDay() {
return BWIL10n.settingsDowntimeMessageSameDay(AppInfo.current.displayName,
dayOfWeekFormatter.string(from: startDate),
dateTimeFormatter.string(from: startDate),
utcFormatter.string(from: startDate),
dayOfWeekFormatter.string(from: endDate),
dateTimeFormatter.string(from: endDate),
utcFormatter.string(from: endDate))
dateFormatter.string(from: startDate),
timeFormatter.string(from: startDate),
timeFormatter.string(from: endDate),
utcFormatter.string(from: startDate)).appending(BWIBuildSettings.shared.showMaintenanceInfoMessageType ? "\n\n\(downTime.description)" : "")
} else {
return BWIL10n.settingsDowntimeMessageDifferentDays(AppInfo.current.displayName,
dayOfWeekFormatter.string(from: startDate),
dateTimeFormatter.string(from: startDate),
utcFormatter.string(from: startDate),
dayOfWeekFormatter.string(from: endDate),
dateTimeFormatter.string(from: endDate),
utcFormatter.string(from: endDate)).appending(BWIBuildSettings.shared.showMaintenanceInfoMessageType ? "\n\n\(downTime.description)" : "")
}
}
}
@@ -252,27 +260,46 @@ extension ServerDowntimeDefaultService : ServerDowntimeService {
}
@objc func downtimeColor() -> UIColor {
switch nextDowntimeType() {
switch nextDowntimeStatus() {
case .warning:
return .yellow
case .ongoing:
return .red
if isBlocking() {
return .red
} else {
return .yellow
}
default:
return .clear
}
}
@objc func downtimeTextColor() -> UIColor {
switch nextDowntimeType() {
switch nextDowntimeStatus() {
case .warning:
return .black
case .ongoing:
return .white
if isBlocking() {
return .white
} else {
return .black
}
default:
return .clear
}
}
func downtimeType() -> ServerDowntimeType {
guard let downTime = self.nextDowntime() else {
return ServerDowntimeType.maintenance
}
if BWIBuildSettings.shared.showMaintenanceInfoMessageType && downTime.type.elementsEqual(ServerDowntimeType.adhocMessage.rawValue) {
return ServerDowntimeType.adhocMessage
} else {
return ServerDowntimeType.maintenance
}
}
@objc func isSameDay() -> Bool {
guard let downTime = self.nextDowntime(), let startDate = downTime.startTime.iso8601LocalDate, let endDate = downTime.endTime.iso8601LocalDate else {
return false
@@ -290,10 +317,10 @@ extension ServerDowntimeDefaultService : ServerDowntimeService {
}
@objc func saveCurrentStatus() {
self.isCurrentDowntime = nextDowntimeType()
self.isCurrentDowntime = nextDowntimeStatus()
}
@objc func isChanged() -> Bool {
return nextDowntimeType() != self.isCurrentDowntime
return nextDowntimeStatus() != self.isCurrentDowntime
}
}
+11 -10
View File
@@ -2,18 +2,19 @@
"downtime": [
{
"warning_start_time": "2023-04-01T00:00:00Z",
"start_time": "2023-04-01T22:30:00Z",
"end_time": "2023-05-01T22:30:00Z",
"type": "MAINTANANCE_STANDARD",
"description": "Dauerwartung 2022",
"blocking": true
"start_time": "2023-07-17T22:30:00Z",
"end_time": "2023-08-01T22:30:00Z",
"type": "ADHOC_MESSAGE",
"description": "Spezifischer Fehlertext.",
"blocking": false
},
{
"warning_start_time": "2021-12-23T10:00:00Z",
"start_time": "2021-12-23T11:00:00Z",
"end_time": "2021-12-24T20:00:00Z",
"type": "MAINTANANCE_STANDARD",
"description": "Weihnachtwartung 2021"
"warning_start_time": "2023-04-01T00:00:00Z",
"start_time": "2023-04-01T22:30:00Z",
"end_time": "2023-05-01T22:30:00Z",
"type": "MAINTANANCE",
"description": "Dauerwartung 2022",
"blocking": false
},
{
"warning_start_time": "2022-03-01T15:00:00Z",
@@ -17,7 +17,7 @@
import SwiftUI
enum OnBoardingSplashScreenAlertType {
case showServerMaintenanceAlert, showServerMaintenanceDefaultAlert, showInvalidAppVersionAlert, showDowntimeTimeAlert
case showServerMaintenanceInfoMessageAlert, showServerMaintenanceDefaultAlert, showInvalidAppVersionAlert, showDowntimeTimeAlert
}
@available(iOS 14.0, *)
@@ -90,14 +90,22 @@ struct OnboardingBwiSplashScreen: View {
case .showDowntimeTimeAlert:
return Alert(title: Text(BWIL10n.downtimeTitle),
message: Text(ServerDowntimeDefaultService().downtimeText() != "" ? BWIL10n.downtimeDefaultMessage + "\n\n" + ServerDowntimeDefaultService().downtimeText() : BWIL10n.downtimeDefaultMessage),
dismissButton: .destructive(Text(BWIL10n.downtimeAlertDismissButton)) {
return
})
case .showServerMaintenanceAlert:
return Alert(title: Text(BWIL10n.downtimeTitle),
dismissButton: .destructive(Text(service.isBlocking() ? BWIL10n.blockingDowntimeAlertDismissButton : BWIL10n.downtimeAlertDismissButton)) {
if service.isBlocking() {
return
} else {
viewModel.send(viewAction: .login)
}
})
case .showServerMaintenanceInfoMessageAlert:
return Alert(title: Text(""),
message: Text(ServerDowntimeDefaultService().downtimeText()),
dismissButton: .destructive(Text(BWIL10n.downtimeAlertDismissButton)) {
viewModel.send(viewAction: .login)
dismissButton: .destructive(Text(service.isBlocking() ? BWIL10n.blockingDowntimeAlertDismissButton : BWIL10n.downtimeAlertDismissButton)) {
if service.isBlocking() {
return
} else {
viewModel.send(viewAction: .login)
}
})
case .showServerMaintenanceDefaultAlert:
return Alert(title: Text(BWIL10n.downtimeTitle),
@@ -138,13 +146,17 @@ struct OnboardingBwiSplashScreen: View {
private func showAlertIfNeeded() {
switch service.nextDowntimeType() {
switch service.nextDowntimeStatus() {
case .none:
viewModel.send(viewAction: .login)
break
case .ongoing:
if service.downtimeType() == .adhocMessage {
activeAlert = .showServerMaintenanceInfoMessageAlert
} else {
activeAlert = .showDowntimeTimeAlert
}
showAlert = true
activeAlert = .showDowntimeTimeAlert
break
case .warning:
// only show active downtimes