mirror of https://github.com/oxen-io/session-ios
Notifications enhancements.
- Tap to reply to a message. - Badges application with the number of unread messages. - Pick up a phone call from lock screen, or decline it. - Settings for notification sounds while app in foreground and text displayed on local notifications.pull/1/head
parent
80b1f2cbcb
commit
13448bdb2d
@ -0,0 +1,15 @@
|
||||
//
|
||||
// NSData+ows_StripToken.h
|
||||
// Signal
|
||||
//
|
||||
// Created by Frederic Jacobs on 14/04/15.
|
||||
// Copyright (c) 2015 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSData (ows_StripToken)
|
||||
|
||||
- (NSString*)ows_tripToken;
|
||||
|
||||
@end
|
@ -0,0 +1,19 @@
|
||||
//
|
||||
// NSData+ows_StripToken.m
|
||||
// Signal
|
||||
//
|
||||
// Created by Frederic Jacobs on 14/04/15.
|
||||
// Copyright (c) 2015 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NSData+ows_StripToken.h"
|
||||
|
||||
@implementation NSData (ows_StripToken)
|
||||
|
||||
- (NSString*)ows_tripToken {
|
||||
return [[[NSString stringWithFormat:@"%@", self]
|
||||
stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]]
|
||||
stringByReplacingOccurrencesOfString:@" " withString:@""];
|
||||
}
|
||||
|
||||
@end
|
@ -0,0 +1,13 @@
|
||||
//
|
||||
// NotificationSettingsOptionsViewController.h
|
||||
// Signal
|
||||
//
|
||||
// Created by Frederic Jacobs on 24/04/15.
|
||||
// Copyright (c) 2015 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface NotificationSettingsOptionsViewController : UITableViewController
|
||||
|
||||
@end
|
@ -0,0 +1,55 @@
|
||||
//
|
||||
// NotificationSettingsOptionsViewController.m
|
||||
// Signal
|
||||
//
|
||||
// Created by Frederic Jacobs on 24/04/15.
|
||||
// Copyright (c) 2015 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NotificationSettingsOptionsViewController.h"
|
||||
#import "Environment.h"
|
||||
#import "PropertyListPreferences.h"
|
||||
#import "PreferencesUtil.h"
|
||||
|
||||
@interface NotificationSettingsOptionsViewController ()
|
||||
@property NSArray *options;
|
||||
@end
|
||||
|
||||
@implementation NotificationSettingsOptionsViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
self.options = @[@(NotificationNamePreview),
|
||||
@(NotificationNameNoPreview),
|
||||
@(NotificationNoNameNoPreview)];
|
||||
[super viewDidLoad];
|
||||
}
|
||||
|
||||
#pragma mark - Table view data source
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return (NSInteger)[self.options count];
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"NotificationSettingsOption"];
|
||||
PropertyListPreferences *prefs = [Environment preferences];
|
||||
[[cell textLabel] setText:[prefs nameForNotificationPreviewType:[[self.options objectAtIndex:(NSUInteger)indexPath.row] unsignedIntegerValue]]];
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
[Environment.preferences setNotificationPreviewType:[[self.options objectAtIndex:(NSUInteger)indexPath.row] unsignedIntegerValue]];
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
@end
|
@ -0,0 +1,13 @@
|
||||
//
|
||||
// NotificationPreviewViewController.h
|
||||
// Signal
|
||||
//
|
||||
// Created by Dylan Bourgeois on 09/12/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface NotificationSettingsViewController : UITableViewController
|
||||
|
||||
@end
|
@ -0,0 +1,110 @@
|
||||
//
|
||||
// NotificationPreviewViewController.m
|
||||
// Signal
|
||||
//
|
||||
// Created by Frederic Jacobs on 09/12/14.
|
||||
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NotificationSettingsViewController.h"
|
||||
|
||||
#import "Environment.h"
|
||||
#import "PreferencesUtil.h"
|
||||
#import "NotificationSettingsOptionsViewController.h"
|
||||
#import "UIUtil.h"
|
||||
|
||||
@interface NotificationSettingsViewController ()
|
||||
|
||||
@property NSArray *notificationsSections;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NotificationSettingsViewController
|
||||
|
||||
- (instancetype)init {
|
||||
return [super initWithStyle:UITableViewStyleGrouped];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
[self setTitle:NSLocalizedString(@"SETTINGS_NOTIFICATIONS", nil)];
|
||||
|
||||
|
||||
self.notificationsSections = @[NSLocalizedString(@"NOTIFICATIONS_SECTION_BACKGROUND", nil),
|
||||
NSLocalizedString(@"NOTIFICATIONS_SECTION_INAPP",nil)];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
#pragma mark - Table view data source
|
||||
|
||||
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
|
||||
return [self.notificationsSections objectAtIndex:(NSUInteger)section];
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return (NSInteger)self.notificationsSections.count;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
NSString *cellIdentifier = @"SignalTableViewCellIdentifier";
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
|
||||
|
||||
if (cell == nil) {
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier];
|
||||
}
|
||||
|
||||
PropertyListPreferences *prefs = Environment.preferences;
|
||||
if (indexPath.section == 0) {
|
||||
NotificationType notifType = [prefs notificationPreviewType];
|
||||
NSString *detailString = [prefs nameForNotificationPreviewType:notifType];
|
||||
|
||||
[[cell textLabel]setText:NSLocalizedString(@"NOTIFICATIONS_SHOW", nil)];
|
||||
[[cell detailTextLabel] setText:detailString];
|
||||
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
|
||||
} else {
|
||||
BOOL soundEnabled = [prefs soundInForeground];
|
||||
|
||||
[[cell textLabel]setText:NSLocalizedString(@"NOTIFICATIONS_SOUND", nil)];
|
||||
[[cell detailTextLabel] setText:nil];
|
||||
UISwitch *switchv = [[UISwitch alloc] initWithFrame:CGRectZero];
|
||||
switchv.on = soundEnabled;
|
||||
[switchv addTarget:self
|
||||
action:@selector(didToggleSoundNotificationsSwitch:)
|
||||
forControlEvents:UIControlEventValueChanged];
|
||||
|
||||
cell.accessoryView = switchv;
|
||||
}
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)didToggleSoundNotificationsSwitch:(UISwitch*)sender
|
||||
{
|
||||
[Environment.preferences setSoundInForeground:sender.on];
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
NotificationSettingsOptionsViewController *vc = [[NotificationSettingsOptionsViewController alloc] initWithStyle:UITableViewStyleGrouped];
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
|
||||
cell.accessoryType = UITableViewCellAccessoryNone;
|
||||
}
|
||||
|
||||
@end
|
Binary file not shown.
Loading…
Reference in New Issue