2015-04-14 21:49:00 +02:00
|
|
|
//
|
2017-02-17 23:30:49 +01:00
|
|
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
2015-04-14 21:49:00 +02:00
|
|
|
//
|
|
|
|
|
2015-12-22 12:45:09 +01:00
|
|
|
#import "NotificationSettingsOptionsViewController.h"
|
2016-10-10 22:02:09 +02:00
|
|
|
#import "Environment.h"
|
|
|
|
#import "PropertyListPreferences.h"
|
2015-04-14 21:49:00 +02:00
|
|
|
|
|
|
|
@implementation NotificationSettingsOptionsViewController
|
|
|
|
|
2015-12-22 12:45:09 +01:00
|
|
|
- (void)viewDidLoad {
|
2017-07-14 16:18:22 +02:00
|
|
|
[self updateTableContents];
|
2015-04-14 21:49:00 +02:00
|
|
|
}
|
|
|
|
|
2017-07-14 16:18:22 +02:00
|
|
|
#pragma mark - Table Contents
|
2015-04-14 21:49:00 +02:00
|
|
|
|
2017-07-14 16:18:22 +02:00
|
|
|
- (void)updateTableContents
|
|
|
|
{
|
|
|
|
OWSTableContents *contents = [OWSTableContents new];
|
2015-04-14 21:49:00 +02:00
|
|
|
|
2017-07-14 16:18:22 +02:00
|
|
|
__weak NotificationSettingsOptionsViewController *weakSelf = self;
|
2015-04-14 21:49:00 +02:00
|
|
|
|
2017-07-14 16:18:22 +02:00
|
|
|
OWSTableSection *section = [OWSTableSection new];
|
|
|
|
section.footerTitle = NSLocalizedString(@"NOTIFICATIONS_FOOTER_WARNING", nil);
|
2015-12-22 12:45:09 +01:00
|
|
|
|
2017-07-14 16:18:22 +02:00
|
|
|
PropertyListPreferences *prefs = [Environment preferences];
|
2015-05-23 15:54:50 +02:00
|
|
|
NotificationType selectedNotifType = [prefs notificationPreviewType];
|
2017-07-14 16:18:22 +02:00
|
|
|
for (NSNumber *option in
|
|
|
|
@[ @(NotificationNamePreview), @(NotificationNameNoPreview), @(NotificationNoNameNoPreview) ]) {
|
|
|
|
NotificationType notificationType = (NotificationType)option.intValue;
|
|
|
|
|
|
|
|
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{
|
|
|
|
UITableViewCell *cell = [UITableViewCell new];
|
|
|
|
[[cell textLabel] setText:[prefs nameForNotificationPreviewType:notificationType]];
|
|
|
|
if (selectedNotifType == notificationType) {
|
|
|
|
cell.accessoryType = UITableViewCellAccessoryCheckmark;
|
|
|
|
}
|
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
actionBlock:^{
|
|
|
|
[weakSelf setNotificationType:notificationType];
|
|
|
|
}]];
|
2015-05-23 15:54:50 +02:00
|
|
|
}
|
2017-07-14 16:18:22 +02:00
|
|
|
[contents addSection:section];
|
2015-12-22 12:45:09 +01:00
|
|
|
|
2017-07-14 16:18:22 +02:00
|
|
|
self.contents = contents;
|
2015-05-23 15:54:50 +02:00
|
|
|
}
|
|
|
|
|
2017-07-14 16:18:22 +02:00
|
|
|
- (void)setNotificationType:(NotificationType)notificationType
|
|
|
|
{
|
|
|
|
[Environment.preferences setNotificationPreviewType:notificationType];
|
2015-04-14 21:49:00 +02:00
|
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|