mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-26 03:20:50 +02:00
MESSENGER-2762 Initial Merge
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
Copyright 2015 OpenMarket Ltd
|
||||
Copyright 2017 Vector Creations Ltd
|
||||
Copyright 2018 New Vector Ltd
|
||||
Copyright (c) 2021 BWI GmbH
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -170,10 +171,9 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
|
||||
// Observe user interface theme change.
|
||||
kThemeServiceDidChangeThemeNotificationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:kThemeServiceDidChangeThemeNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notif) {
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
|
||||
[self userInterfaceThemeDidChange];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self userInterfaceThemeDidChange];
|
||||
});
|
||||
}];
|
||||
[self userInterfaceThemeDidChange];
|
||||
}
|
||||
@@ -1076,6 +1076,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
|
||||
editedRoomId = room.roomId;
|
||||
|
||||
UIColor *selectedColor = ThemeService.shared.theme.tintColor;
|
||||
UIColor *selectedWarningColor = ThemeService.shared.theme.warningColor;
|
||||
UIColor *unselectedColor = ThemeService.shared.theme.tabBarUnselectedItemTintColor;
|
||||
UIColor *actionBackgroundColor = ThemeService.shared.theme.baseColor;
|
||||
|
||||
@@ -1099,38 +1100,44 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
|
||||
|
||||
// Notification toggle
|
||||
|
||||
BOOL isMuted = room.isMute || room.isMentionsOnly;
|
||||
UIContextualAction *muteAction = nil;
|
||||
|
||||
UIContextualAction *muteAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
|
||||
title:title
|
||||
handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
|
||||
if (BuildSettings.featureWorkTime) {
|
||||
muteAction = [self muteActionWithWorkTime:room];
|
||||
} else {
|
||||
BOOL isMuted = room.isMute || room.isMentionsOnly;
|
||||
|
||||
muteAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
|
||||
title:title
|
||||
handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
|
||||
|
||||
if ([BuildSettings roomSettingsScreenShowNotificationsV2])
|
||||
{
|
||||
[self changeEditedRoomNotificationSettings];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self muteEditedRoomNotifications:!isMuted];
|
||||
}
|
||||
|
||||
|
||||
completionHandler(YES);
|
||||
}];
|
||||
muteAction.backgroundColor = actionBackgroundColor;
|
||||
|
||||
UIImage *notificationImage;
|
||||
if ([BuildSettings showNotificationsV2])
|
||||
{
|
||||
[self changeEditedRoomNotificationSettings];
|
||||
notificationImage = isMuted ? [UIImage imageNamed:@"room_action_notification_muted"] : [UIImage imageNamed:@"room_action_notification"];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self muteEditedRoomNotifications:!isMuted];
|
||||
notificationImage = [UIImage imageNamed:@"room_action_notification"];
|
||||
}
|
||||
|
||||
|
||||
completionHandler(YES);
|
||||
}];
|
||||
muteAction.backgroundColor = actionBackgroundColor;
|
||||
|
||||
UIImage *notificationImage;
|
||||
if([BuildSettings showNotificationsV2])
|
||||
{
|
||||
notificationImage = isMuted ? [UIImage imageNamed:@"room_action_notification_muted"] : [UIImage imageNamed:@"room_action_notification"];
|
||||
}
|
||||
else
|
||||
{
|
||||
notificationImage = [UIImage imageNamed:@"room_action_notification"];
|
||||
}
|
||||
|
||||
notificationImage = [notificationImage vc_tintedImageUsingColor:isMuted ? unselectedColor : selectedColor];
|
||||
muteAction.image = [notificationImage vc_notRenderedImage];
|
||||
notificationImage = [notificationImage vc_tintedImageUsingColor:isMuted ? unselectedColor : selectedColor];
|
||||
muteAction.image = [notificationImage vc_notRenderedImage];
|
||||
}
|
||||
|
||||
// Favorites management
|
||||
|
||||
@@ -1179,7 +1186,7 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
|
||||
priorityAction.image = [priorityImage vc_notRenderedImage];
|
||||
|
||||
// Leave action
|
||||
|
||||
|
||||
UIContextualAction *leaveAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
|
||||
title:title
|
||||
handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
|
||||
@@ -1189,18 +1196,28 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
|
||||
leaveAction.backgroundColor = actionBackgroundColor;
|
||||
|
||||
UIImage *leaveImage = [UIImage imageNamed:@"room_action_leave"];
|
||||
leaveImage = [leaveImage vc_tintedImageUsingColor:unselectedColor];
|
||||
leaveImage = [leaveImage vc_tintedImageUsingColor:selectedWarningColor];
|
||||
leaveAction.image = [leaveImage vc_notRenderedImage];
|
||||
|
||||
// Create swipe action configuration
|
||||
|
||||
NSArray<UIContextualAction*> *actions = @[
|
||||
leaveAction,
|
||||
priorityAction,
|
||||
favouriteAction,
|
||||
muteAction,
|
||||
directChatAction
|
||||
];
|
||||
NSArray<UIContextualAction*> *actions = nil;
|
||||
|
||||
if ( [room isPersonalNotesRoom]) {
|
||||
actions = @[
|
||||
favouriteAction
|
||||
];
|
||||
} else {
|
||||
actions = @[
|
||||
leaveAction,
|
||||
// priorityAction,
|
||||
favouriteAction,
|
||||
muteAction
|
||||
// directChatAction
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
UISwipeActionsConfiguration *swipeActionConfiguration = [UISwipeActionsConfiguration configurationWithActions:actions];
|
||||
swipeActionConfiguration.performsFirstActionWithFullSwipe = NO;
|
||||
@@ -2374,4 +2391,95 @@ NSString *const RecentsViewControllerDataReadyNotification = @"RecentsViewContro
|
||||
self.roomNotificationSettingsCoordinatorBridgePresenter = nil;
|
||||
}
|
||||
|
||||
#pragma mark - Bwi Rest Time
|
||||
|
||||
- (UIContextualAction*) muteActionWithWorkTime:(MXRoom*)room {
|
||||
BOOL isMuted = room.isMute || room.isMentionsOnly;
|
||||
BOOL isWorkTime = [self isWorkTimeActive:room];
|
||||
|
||||
UIContextualAction *muteAction = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
|
||||
title:@""
|
||||
handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
|
||||
[self muteEditedRoomNotificationsWithWorkTime:!isMuted];
|
||||
completionHandler(YES);
|
||||
}];
|
||||
muteAction.backgroundColor = ThemeService.shared.theme.baseColor;
|
||||
muteAction.image =[self editedRoomNotififcationImageForMuted:isMuted andWorkTime:isWorkTime];
|
||||
|
||||
return muteAction;
|
||||
}
|
||||
|
||||
- (void)muteEditedRoomNotificationsWithWorkTime:(BOOL)mute
|
||||
{
|
||||
if (editedRoomId)
|
||||
{
|
||||
// Check whether the user didn't leave the room
|
||||
MXRoom *room = [self.mainSession roomWithRoomId:editedRoomId];
|
||||
if (room)
|
||||
{
|
||||
[self startActivityIndicator];
|
||||
|
||||
if (mute)
|
||||
{
|
||||
[room mentionsOnly:^{
|
||||
|
||||
[self stopActivityIndicator];
|
||||
|
||||
// Leave editing mode
|
||||
[self cancelEditionMode:self->isRefreshPending];
|
||||
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
[room allMessages:^{
|
||||
|
||||
[self stopActivityIndicator];
|
||||
|
||||
// Leave editing mode
|
||||
[self cancelEditionMode:self->isRefreshPending];
|
||||
|
||||
}];
|
||||
WorkTimeService *service = [WorkTimeService workTimeService:self.mainSession.myUserId];
|
||||
|
||||
if ([service isWorkTimeGlobalyEnabled]) {
|
||||
[service activateWorkTimeInRoom:editedRoomId];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Leave editing mode
|
||||
[self cancelEditionMode:isRefreshPending];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) isWorkTimeActive:(MXRoom*)room {
|
||||
WorkTimeService *service = [WorkTimeService workTimeService:self.mainSession.myUser.userId];
|
||||
|
||||
if ([service isWorkTimeGlobalyEnabled]) {
|
||||
if ([service.store isWorkTimeRoom:room.roomId]) {
|
||||
return [service.store isWorkTimeInRoomActive:room.roomId];
|
||||
} else {
|
||||
return !room.isDirect;
|
||||
}
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (UIImage*)editedRoomNotififcationImageForMuted:(BOOL)isMuted andWorkTime:(BOOL)WorkTimeActive {
|
||||
UIImage *image = nil;
|
||||
|
||||
if (WorkTimeActive && !isMuted ) {
|
||||
image = [[UIImage imageNamed:@"room_action_resttime"] vc_tintedImageUsingColor:isMuted ? ThemeService.shared.theme.tabBarUnselectedItemTintColor
|
||||
: ThemeService.shared.theme.tintColor];
|
||||
} else {
|
||||
image = [[UIImage imageNamed:@"room_action_notification"] vc_tintedImageUsingColor:isMuted ? ThemeService.shared.theme.tabBarUnselectedItemTintColor
|
||||
: ThemeService.shared.theme.tintColor];
|
||||
}
|
||||
|
||||
return [image vc_notRenderedImage];
|
||||
}
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user