зеркало из https://github.com/nextcloud/talk-ios.git
Add call notification setting in room info view.
Signed-off-by: Ivan Sein <ivan@nextcloud.com>
This commit is contained in:
Родитель
09b26dd2fd
Коммит
5c5a238a4a
|
@ -129,6 +129,7 @@ extern NSInteger const kReceivedChatMessagesLimit;
|
|||
- (NSURLSessionDataTask *)addRoomToFavorites:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(FavoriteRoomCompletionBlock)block;
|
||||
- (NSURLSessionDataTask *)removeRoomFromFavorites:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(FavoriteRoomCompletionBlock)block;
|
||||
- (NSURLSessionDataTask *)setNotificationLevel:(NCRoomNotificationLevel)level forRoom:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(NotificationLevelCompletionBlock)block;
|
||||
- (NSURLSessionDataTask *)setCallNotificationEnabled:(BOOL)enabled forRoom:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(NotificationLevelCompletionBlock)block;
|
||||
- (NSURLSessionDataTask *)setReadOnlyState:(NCRoomReadOnlyState)state forRoom:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(ReadOnlyCompletionBlock)block;
|
||||
- (NSURLSessionDataTask *)setLobbyState:(NCRoomLobbyState)state withTimer:(NSInteger)timer forRoom:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(SetLobbyStateCompletionBlock)block;
|
||||
- (NSURLSessionDataTask *)setSIPEnabled:(BOOL)enabled forRoom:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(SetSIPStateCompletionBlock)block;
|
||||
|
|
|
@ -561,6 +561,30 @@ NSInteger const kReceivedChatMessagesLimit = 100;
|
|||
return task;
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)setCallNotificationEnabled:(BOOL)enabled forRoom:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(NotificationLevelCompletionBlock)block
|
||||
{
|
||||
NSString *encodedToken = [token stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
|
||||
NSString *endpoint = [NSString stringWithFormat:@"room/%@/notify-calls", encodedToken];
|
||||
NSInteger conversationAPIVersion = [self conversationAPIVersionForAccount:account];
|
||||
NSString *URLString = [self getRequestURLForEndpoint:endpoint withAPIVersion:conversationAPIVersion forAccount:account];
|
||||
NSDictionary *parameters = @{@"level" : @(enabled)};
|
||||
|
||||
NCAPISessionManager *apiSessionManager = [_apiSessionManagers objectForKey:account.accountId];
|
||||
NSURLSessionDataTask *task = [apiSessionManager POST:URLString parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
if (block) {
|
||||
block(nil);
|
||||
}
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
NSInteger statusCode = [self getResponseStatusCode:task.response];
|
||||
[self checkResponseStatusCode:statusCode forAccount:account];
|
||||
if (block) {
|
||||
block(error);
|
||||
}
|
||||
}];
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)setReadOnlyState:(NCRoomReadOnlyState)state forRoom:(NSString *)token forAccount:(TalkAccount *)account withCompletionBlock:(ReadOnlyCompletionBlock)block
|
||||
{
|
||||
NSString *encodedToken = [token stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]];
|
||||
|
|
|
@ -53,6 +53,7 @@ extern NSString * const kCapabilityVoiceMessage;
|
|||
extern NSString * const kCapabilitySignalingV3;
|
||||
extern NSString * const kCapabilityClearHistory;
|
||||
extern NSString * const kCapabilityDirectMentionFlag;
|
||||
extern NSString * const kCapabilityNotificationCalls;
|
||||
|
||||
extern NSString * const kMinimumRequiredTalkCapability;
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
NSString *const kTalkDatabaseFolder = @"Library/Application Support/Talk";
|
||||
NSString *const kTalkDatabaseFileName = @"talk.realm";
|
||||
uint64_t const kTalkDatabaseSchemaVersion = 25;
|
||||
uint64_t const kTalkDatabaseSchemaVersion = 26;
|
||||
|
||||
NSString * const kCapabilitySystemMessages = @"system-messages";
|
||||
NSString * const kCapabilityNotificationLevels = @"notification-levels";
|
||||
|
@ -55,6 +55,7 @@ NSString * const kCapabilityVoiceMessage = @"voice-message-sharing";
|
|||
NSString * const kCapabilitySignalingV3 = @"signaling-v3";
|
||||
NSString * const kCapabilityClearHistory = @"clear-history";
|
||||
NSString * const kCapabilityDirectMentionFlag = @"direct-mention-flag";
|
||||
NSString * const kCapabilityNotificationCalls = @"notification-calls";
|
||||
|
||||
NSString * const kMinimumRequiredTalkCapability = kCapabilitySystemMessages; // Talk 4.0 is the minimum required version
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ extern NSString * const NCRoomObjectTypeSharePassword;
|
|||
@property (nonatomic, copy) NSString *lastMessageId;
|
||||
@property (nonatomic, assign) BOOL isFavorite;
|
||||
@property (nonatomic, assign) NCRoomNotificationLevel notificationLevel;
|
||||
@property (nonatomic, assign) BOOL notificationCalls;
|
||||
@property (nonatomic, copy) NSString *objectType;
|
||||
@property (nonatomic, copy) NSString *objectId;
|
||||
@property (nonatomic, assign) NCRoomReadOnlyState readOnlyState;
|
||||
|
|
|
@ -54,6 +54,7 @@ NSString * const NCRoomObjectTypeSharePassword = @"share:password";
|
|||
room.lastActivity = [[roomDict objectForKey:@"lastActivity"] integerValue];
|
||||
room.isFavorite = [[roomDict objectForKey:@"isFavorite"] boolValue];
|
||||
room.notificationLevel = (NCRoomNotificationLevel)[[roomDict objectForKey:@"notificationLevel"] integerValue];
|
||||
room.notificationCalls = [[roomDict objectForKey:@"notificationCalls"] boolValue];
|
||||
room.objectType = [roomDict objectForKey:@"objectType"];
|
||||
room.objectId = [roomDict objectForKey:@"objectId"];
|
||||
room.readOnlyState = (NCRoomReadOnlyState)[[roomDict objectForKey:@"readOnly"] integerValue];
|
||||
|
@ -128,6 +129,7 @@ NSString * const NCRoomObjectTypeSharePassword = @"share:password";
|
|||
managedRoom.lastMessageId = room.lastMessageId;
|
||||
managedRoom.isFavorite = room.isFavorite;
|
||||
managedRoom.notificationLevel = room.notificationLevel;
|
||||
managedRoom.notificationCalls = room.notificationCalls;
|
||||
managedRoom.objectType = room.objectType;
|
||||
managedRoom.objectId = room.objectId;
|
||||
managedRoom.readOnlyState = room.readOnlyState;
|
||||
|
|
|
@ -58,7 +58,8 @@ typedef enum RoomInfoSection {
|
|||
|
||||
typedef enum RoomAction {
|
||||
kRoomActionFavorite = 0,
|
||||
kRoomActionNotifications,
|
||||
kRoomActionChatNotifications,
|
||||
kRoomActionCallNotifications,
|
||||
kRoomActionSendLink
|
||||
} RoomAction;
|
||||
|
||||
|
@ -91,6 +92,7 @@ typedef enum ModificationError {
|
|||
kModificationErrorRename = 0,
|
||||
kModificationErrorFavorite,
|
||||
kModificationErrorNotifications,
|
||||
kModificationErrorCallNotifications,
|
||||
kModificationErrorShare,
|
||||
kModificationErrorPassword,
|
||||
kModificationErrorResendInvitations,
|
||||
|
@ -121,6 +123,7 @@ typedef enum FileAction {
|
|||
@property (nonatomic, strong) UISwitch *publicSwtich;
|
||||
@property (nonatomic, strong) UISwitch *lobbySwtich;
|
||||
@property (nonatomic, strong) UISwitch *sipSwtich;
|
||||
@property (nonatomic, strong) UISwitch *callNotificationSwtich;
|
||||
@property (nonatomic, strong) UIDatePicker *lobbyDatePicker;
|
||||
@property (nonatomic, strong) UITextField *lobbyDateTextField;
|
||||
@property (nonatomic, strong) UIActivityIndicatorView *modifyingRoomView;
|
||||
|
@ -181,6 +184,9 @@ typedef enum FileAction {
|
|||
_sipSwtich = [[UISwitch alloc] initWithFrame:CGRectZero];
|
||||
[_sipSwtich addTarget: self action: @selector(sipValueChanged:) forControlEvents:UIControlEventValueChanged];
|
||||
|
||||
_callNotificationSwtich = [[UISwitch alloc] initWithFrame:CGRectZero];
|
||||
[_callNotificationSwtich addTarget: self action: @selector(callNotificationValueChanged:) forControlEvents:UIControlEventValueChanged];
|
||||
|
||||
_lobbyDatePicker = [[UIDatePicker alloc] init];
|
||||
_lobbyDatePicker.datePickerMode = UIDatePickerModeDateAndTime;
|
||||
_lobbyDateTextField = [[UITextField alloc] initWithFrame:CGRectMake(0, 00, 150, 30)];
|
||||
|
@ -305,9 +311,13 @@ typedef enum FileAction {
|
|||
NSMutableArray *actions = [[NSMutableArray alloc] init];
|
||||
// Favorite action
|
||||
[actions addObject:[NSNumber numberWithInt:kRoomActionFavorite]];
|
||||
// Notification levels action
|
||||
// Chat notifications levels action
|
||||
if ([[NCDatabaseManager sharedInstance] serverHasTalkCapability:kCapabilityNotificationLevels]) {
|
||||
[actions addObject:[NSNumber numberWithInt:kRoomActionNotifications]];
|
||||
[actions addObject:[NSNumber numberWithInt:kRoomActionChatNotifications]];
|
||||
}
|
||||
// Call notifications action
|
||||
if ([[NCDatabaseManager sharedInstance] serverHasTalkCapability:kCapabilityNotificationCalls]) {
|
||||
[actions addObject:[NSNumber numberWithInt:kRoomActionCallNotifications]];
|
||||
}
|
||||
// Public room actions
|
||||
if (_room.isPublic) {
|
||||
|
@ -440,6 +450,10 @@ typedef enum FileAction {
|
|||
errorDescription = NSLocalizedString(@"Could not change notifications setting", nil);
|
||||
break;
|
||||
|
||||
case kModificationErrorCallNotifications:
|
||||
errorDescription = NSLocalizedString(@"Could not change call notifications setting", nil);
|
||||
break;
|
||||
|
||||
case kModificationErrorShare:
|
||||
errorDescription = NSLocalizedString(@"Could not change sharing permissions of the conversation", nil);
|
||||
break;
|
||||
|
@ -556,7 +570,7 @@ typedef enum FileAction {
|
|||
|
||||
// Presentation on iPads
|
||||
optionsActionSheet.popoverPresentationController.sourceView = self.tableView;
|
||||
optionsActionSheet.popoverPresentationController.sourceRect = [self.tableView rectForRowAtIndexPath:[self getIndexPathForRoomAction:kRoomActionNotifications]];
|
||||
optionsActionSheet.popoverPresentationController.sourceRect = [self.tableView rectForRowAtIndexPath:[self getIndexPathForRoomAction:kRoomActionChatNotifications]];
|
||||
|
||||
[self presentViewController:optionsActionSheet animated:YES completion:nil];
|
||||
}
|
||||
|
@ -659,6 +673,21 @@ typedef enum FileAction {
|
|||
}];
|
||||
}
|
||||
|
||||
- (void)setCallNotificationEnabled:(BOOL)enabled
|
||||
{
|
||||
[self setModifyingRoomUI];
|
||||
[[NCAPIController sharedInstance] setCallNotificationEnabled:enabled forRoom:_room.token forAccount:[[NCDatabaseManager sharedInstance] activeAccount] withCompletionBlock:^(NSError *error) {
|
||||
if (!error) {
|
||||
[[NCRoomsManager sharedInstance] updateRoom:self->_room.token];
|
||||
} else {
|
||||
NSLog(@"Error setting room call notification: %@", error.description);
|
||||
[self.tableView reloadData];
|
||||
[self showRoomModificationError:kModificationErrorCallNotifications];
|
||||
}
|
||||
self->_callNotificationSwtich.enabled = YES;
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)showPasswordOptions
|
||||
{
|
||||
NSString *alertTitle = _room.hasPassword ? NSLocalizedString(@"Set new password:", nil) : NSLocalizedString(@"Set password:", nil);
|
||||
|
@ -1187,6 +1216,18 @@ typedef enum FileAction {
|
|||
}
|
||||
}
|
||||
|
||||
#pragma mark - Call notifications switch
|
||||
|
||||
- (void)callNotificationValueChanged:(id)sender
|
||||
{
|
||||
_callNotificationSwtich.enabled = NO;
|
||||
if (_callNotificationSwtich.on) {
|
||||
[self setCallNotificationEnabled:YES];
|
||||
} else {
|
||||
[self setCallNotificationEnabled:NO];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UIGestureRecognizer delegate
|
||||
|
||||
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
|
||||
|
@ -1512,17 +1553,34 @@ typedef enum FileAction {
|
|||
return cell;
|
||||
}
|
||||
break;
|
||||
case kRoomActionNotifications:
|
||||
case kRoomActionChatNotifications:
|
||||
{
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:notificationLevelCellIdentifier];
|
||||
if (!cell) {
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:notificationLevelCellIdentifier];
|
||||
}
|
||||
|
||||
cell.textLabel.text = NSLocalizedString(@"Notifications", nil);
|
||||
cell.textLabel.text = NSLocalizedString(@"Chat notifications", nil);
|
||||
cell.detailTextLabel.text = _room.notificationLevelString;
|
||||
[cell.imageView setImage:[UIImage imageNamed:@"notifications-settings"]];
|
||||
|
||||
return cell;
|
||||
}
|
||||
break;
|
||||
case kRoomActionCallNotifications:
|
||||
{
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:notificationLevelCellIdentifier];
|
||||
if (!cell) {
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:notificationLevelCellIdentifier];
|
||||
}
|
||||
|
||||
cell.textLabel.text = NSLocalizedString(@"Call notifications", nil);
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
cell.accessoryView = _callNotificationSwtich;
|
||||
_callNotificationSwtich.on = _room.notificationCalls;
|
||||
[cell.imageView setImage:[[UIImage imageNamed:@"phone"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]];
|
||||
cell.imageView.tintColor = [UIColor colorWithRed:0.43 green:0.43 blue:0.45 alpha:1];
|
||||
|
||||
return cell;
|
||||
}
|
||||
break;
|
||||
|
@ -1874,12 +1932,14 @@ typedef enum FileAction {
|
|||
[self addRoomToFavorites];
|
||||
}
|
||||
break;
|
||||
case kRoomActionNotifications:
|
||||
case kRoomActionChatNotifications:
|
||||
[self presentNotificationLevelSelector];
|
||||
break;
|
||||
case kRoomActionSendLink:
|
||||
[self shareRoomLinkFromIndexPath:indexPath];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче