2015-04-14 21:49:00 +02:00
|
|
|
//
|
2019-03-19 21:17:10 +01:00
|
|
|
// Copyright (c) 2019 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"
|
2019-05-02 23:58:48 +02:00
|
|
|
#import "Session-Swift.h"
|
2018-02-23 23:08:21 +01:00
|
|
|
#import "SignalApp.h"
|
2020-11-26 00:37:56 +01:00
|
|
|
#import <SessionMessagingKit/Environment.h>
|
2020-11-11 07:45:50 +01:00
|
|
|
#import <SignalUtilitiesKit/SignalUtilitiesKit-Swift.h>
|
2015-04-14 21:49:00 +02:00
|
|
|
|
|
|
|
@implementation NotificationSettingsOptionsViewController
|
|
|
|
|
2018-03-05 17:57:12 +01:00
|
|
|
- (void)viewDidLoad
|
|
|
|
{
|
2018-07-18 03:50:13 +02:00
|
|
|
[super viewDidLoad];
|
|
|
|
|
2017-07-14 16:18:22 +02:00
|
|
|
[self updateTableContents];
|
2020-08-27 07:06:11 +02:00
|
|
|
|
2020-08-27 07:10:28 +02:00
|
|
|
[LKViewControllerUtilities setUpDefaultSessionStyleForVC:self withTitle:NSLocalizedString(@"Content", @"") customBackButton:NO];
|
2019-12-09 05:29:05 +01:00
|
|
|
self.tableView.backgroundColor = UIColor.clearColor;
|
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];
|
2019-06-14 07:25:39 +02:00
|
|
|
// section.footerTitle = NSLocalizedString(@"NOTIFICATIONS_FOOTER_WARNING", nil);
|
2015-12-22 12:45:09 +01:00
|
|
|
|
2018-08-31 19:44:13 +02:00
|
|
|
OWSPreferences *prefs = Environment.shared.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;
|
|
|
|
|
2018-07-13 00:14:04 +02:00
|
|
|
[section addItem:[OWSTableItem
|
|
|
|
itemWithCustomCellBlock:^{
|
|
|
|
UITableViewCell *cell = [OWSTableItem newCell];
|
2019-12-05 23:25:26 +01:00
|
|
|
cell.tintColor = LKColors.accent;
|
2018-07-13 00:14:04 +02:00
|
|
|
[[cell textLabel] setText:[prefs nameForNotificationPreviewType:notificationType]];
|
|
|
|
if (selectedNotifType == notificationType) {
|
|
|
|
cell.accessoryType = UITableViewCellAccessoryCheckmark;
|
|
|
|
}
|
2019-03-21 15:26:38 +01:00
|
|
|
cell.accessibilityIdentifier
|
2019-03-22 18:05:35 +01:00
|
|
|
= ACCESSIBILITY_IDENTIFIER_WITH_NAME(NotificationSettingsOptionsViewController,
|
2019-03-21 15:26:38 +01:00
|
|
|
NSStringForNotificationType(notificationType));
|
2018-07-13 00:14:04 +02:00
|
|
|
return cell;
|
|
|
|
}
|
2017-07-14 16:18:22 +02:00
|
|
|
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
|
|
|
|
{
|
2018-08-31 19:44:13 +02:00
|
|
|
[Environment.shared.preferences setNotificationPreviewType:notificationType];
|
2018-02-23 23:08:21 +01:00
|
|
|
|
2015-04-14 21:49:00 +02:00
|
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|