2015-04-14 21:49:00 +02:00
|
|
|
//
|
2018-02-21 03:49:10 +01:00
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
2015-04-14 21:49:00 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "NotificationSettingsViewController.h"
|
|
|
|
#import "NotificationSettingsOptionsViewController.h"
|
2018-02-22 04:31:55 +01:00
|
|
|
#import "OWSSoundSettingsViewController.h"
|
2017-12-19 03:50:51 +01:00
|
|
|
#import <SignalMessaging/Environment.h>
|
|
|
|
#import <SignalMessaging/OWSPreferences.h>
|
2018-02-22 20:38:40 +01:00
|
|
|
#import <SignalMessaging/OWSSounds.h>
|
2015-04-14 21:49:00 +02:00
|
|
|
|
|
|
|
@implementation NotificationSettingsViewController
|
|
|
|
|
2018-03-05 17:57:12 +01:00
|
|
|
- (void)viewDidLoad
|
|
|
|
{
|
2015-04-14 21:49:00 +02:00
|
|
|
[super viewDidLoad];
|
2017-07-14 16:18:22 +02:00
|
|
|
|
2015-04-14 21:49:00 +02:00
|
|
|
[self setTitle:NSLocalizedString(@"SETTINGS_NOTIFICATIONS", nil)];
|
2015-12-22 12:45:09 +01:00
|
|
|
|
2017-07-14 16:18:22 +02:00
|
|
|
[self updateTableContents];
|
2015-04-14 21:49:00 +02:00
|
|
|
}
|
|
|
|
|
2018-03-05 17:57:12 +01:00
|
|
|
- (void)viewDidAppear:(BOOL)animated
|
|
|
|
{
|
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 NotificationSettingsViewController *weakSelf = self;
|
2015-04-14 21:49:00 +02:00
|
|
|
|
2017-09-14 21:45:04 +02:00
|
|
|
OWSPreferences *prefs = [Environment preferences];
|
2018-03-05 17:57:12 +01:00
|
|
|
|
2018-02-22 04:31:55 +01:00
|
|
|
// Sounds section.
|
2018-03-05 17:57:12 +01:00
|
|
|
|
2018-02-21 03:49:10 +01:00
|
|
|
OWSTableSection *soundsSection = [OWSTableSection new];
|
2018-02-26 21:03:07 +01:00
|
|
|
soundsSection.headerTitle
|
|
|
|
= NSLocalizedString(@"SETTINGS_SECTION_SOUNDS", @"Header Label for the sounds section of settings views.");
|
2018-02-28 15:58:54 +01:00
|
|
|
[soundsSection
|
|
|
|
addItem:[OWSTableItem disclosureItemWithText:
|
|
|
|
NSLocalizedString(@"SETTINGS_ITEM_NOTIFICATION_SOUND",
|
|
|
|
@"Label for settings view that allows user to change the notification sound.")
|
|
|
|
detailText:[OWSSounds displayNameForSound:[OWSSounds globalNotificationSound]]
|
|
|
|
actionBlock:^{
|
|
|
|
OWSSoundSettingsViewController *vc = [OWSSoundSettingsViewController new];
|
|
|
|
[weakSelf.navigationController pushViewController:vc animated:YES];
|
|
|
|
}]];
|
2018-02-27 21:18:40 +01:00
|
|
|
|
|
|
|
NSString *inAppSoundsLabelText = NSLocalizedString(@"NOTIFICATIONS_SECTION_INAPP",
|
|
|
|
@"Table cell switch label. When disabled, Signal will not play notification sounds while the app is in the "
|
|
|
|
@"foreground.");
|
|
|
|
[soundsSection addItem:[OWSTableItem switchItemWithText:inAppSoundsLabelText
|
2018-02-26 21:03:07 +01:00
|
|
|
isOn:[prefs soundInForeground]
|
|
|
|
target:weakSelf
|
|
|
|
selector:@selector(didToggleSoundNotificationsSwitch:)]];
|
2018-02-21 03:49:10 +01:00
|
|
|
[contents addSection:soundsSection];
|
2018-03-05 17:57:12 +01:00
|
|
|
|
2017-07-14 16:18:22 +02:00
|
|
|
OWSTableSection *backgroundSection = [OWSTableSection new];
|
2018-02-23 23:08:21 +01:00
|
|
|
backgroundSection.headerTitle = NSLocalizedString(@"SETTINGS_NOTIFICATION_CONTENT_TITLE", @"table section header");
|
2018-02-28 15:58:54 +01:00
|
|
|
[backgroundSection
|
|
|
|
addItem:[OWSTableItem
|
|
|
|
disclosureItemWithText:NSLocalizedString(@"NOTIFICATIONS_SHOW", nil)
|
|
|
|
detailText:[prefs nameForNotificationPreviewType:[prefs notificationPreviewType]]
|
|
|
|
actionBlock:^{
|
|
|
|
NotificationSettingsOptionsViewController *vc =
|
|
|
|
[NotificationSettingsOptionsViewController new];
|
|
|
|
[weakSelf.navigationController pushViewController:vc animated:YES];
|
|
|
|
}]];
|
2018-02-23 23:08:21 +01:00
|
|
|
backgroundSection.footerTitle
|
|
|
|
= NSLocalizedString(@"SETTINGS_NOTIFICATION_CONTENT_DESCRIPTION", @"table section footer");
|
2017-07-14 16:18:22 +02:00
|
|
|
[contents addSection:backgroundSection];
|
|
|
|
|
|
|
|
self.contents = contents;
|
2015-04-14 21:49:00 +02:00
|
|
|
}
|
|
|
|
|
2017-07-14 16:18:22 +02:00
|
|
|
#pragma mark - Events
|
|
|
|
|
2018-03-05 17:57:12 +01:00
|
|
|
- (void)didToggleSoundNotificationsSwitch:(UISwitch *)sender
|
|
|
|
{
|
2015-04-14 21:49:00 +02:00
|
|
|
[Environment.preferences setSoundInForeground:sender.on];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|