session-ios/Signal/src/ViewControllers/AppSettings/NotificationSettingsViewController.m

90 lines
3.6 KiB
Mathematica
Raw Normal View History

//
2018-02-21 03:49:10 +01:00
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#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>
#import <SignalMessaging/OWSSounds.h>
@implementation NotificationSettingsViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self setTitle:NSLocalizedString(@"SETTINGS_NOTIFICATIONS", nil)];
[self updateTableContents];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self updateTableContents];
}
#pragma mark - Table Contents
- (void)updateTableContents
{
OWSTableContents *contents = [OWSTableContents new];
__weak NotificationSettingsViewController *weakSelf = self;
OWSPreferences *prefs = [Environment preferences];
2018-02-22 04:31:55 +01:00
// Sounds section.
2018-02-21 03:49:10 +01:00
OWSTableSection *soundsSection = [OWSTableSection new];
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
isOn:[prefs soundInForeground]
target:weakSelf
selector:@selector(didToggleSoundNotificationsSwitch:)]];
2018-02-21 03:49:10 +01:00
[contents addSection:soundsSection];
OWSTableSection *backgroundSection = [OWSTableSection new];
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];
}]];
backgroundSection.footerTitle
= NSLocalizedString(@"SETTINGS_NOTIFICATION_CONTENT_DESCRIPTION", @"table section footer");
[contents addSection:backgroundSection];
self.contents = contents;
}
#pragma mark - Events
- (void)didToggleSoundNotificationsSwitch:(UISwitch *)sender
{
[Environment.preferences setSoundInForeground:sender.on];
}
@end