2015-01-16 15:28:41 +01:00
|
|
|
//
|
2018-01-10 16:54:17 +01:00
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
2015-01-16 15:28:41 +01:00
|
|
|
//
|
|
|
|
|
2015-12-22 12:45:09 +01:00
|
|
|
#import "AboutTableViewController.h"
|
2017-11-18 00:04:20 +01:00
|
|
|
#import "Signal-Swift.h"
|
2017-06-22 18:58:59 +02:00
|
|
|
#import "UIView+OWS.h"
|
2017-12-19 03:50:51 +01:00
|
|
|
#import <SignalMessaging/Environment.h>
|
|
|
|
#import <SignalMessaging/OWSPreferences.h>
|
2017-12-08 17:50:35 +01:00
|
|
|
#import <SignalMessaging/UIUtil.h>
|
2017-06-22 18:58:59 +02:00
|
|
|
#import <SignalServiceKit/TSDatabaseView.h>
|
|
|
|
#import <SignalServiceKit/TSStorageManager.h>
|
2016-11-18 23:11:56 +01:00
|
|
|
|
2015-01-16 15:28:41 +01:00
|
|
|
@implementation AboutTableViewController
|
|
|
|
|
2017-11-18 00:04:20 +01:00
|
|
|
- (void)dealloc {
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
|
}
|
|
|
|
|
2017-06-22 18:58:59 +02:00
|
|
|
- (void)viewDidLoad
|
|
|
|
{
|
2015-01-16 15:28:41 +01:00
|
|
|
[super viewDidLoad];
|
2015-12-22 12:45:09 +01:00
|
|
|
|
2016-11-29 22:54:01 +01:00
|
|
|
self.title = NSLocalizedString(@"SETTINGS_ABOUT", @"Navbar title");
|
2015-12-22 12:45:09 +01:00
|
|
|
|
2017-06-22 18:58:59 +02:00
|
|
|
[self updateTableContents];
|
2017-11-18 00:04:20 +01:00
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
selector:@selector(pushTokensDidChange:)
|
|
|
|
name:[OWSSyncPushTokensJob PushTokensDidChange]
|
|
|
|
object:nil];
|
|
|
|
}
|
|
|
|
|
2017-11-20 20:11:49 +01:00
|
|
|
- (void)pushTokensDidChange:(NSNotification *)notification
|
|
|
|
{
|
2017-11-18 00:04:20 +01:00
|
|
|
[self updateTableContents];
|
2015-01-16 15:28:41 +01:00
|
|
|
}
|
|
|
|
|
2017-06-22 18:58:59 +02:00
|
|
|
#pragma mark - Table Contents
|
|
|
|
|
|
|
|
- (void)updateTableContents
|
|
|
|
{
|
|
|
|
OWSTableContents *contents = [OWSTableContents new];
|
|
|
|
|
|
|
|
OWSTableSection *informationSection = [OWSTableSection new];
|
|
|
|
informationSection.headerTitle = NSLocalizedString(@"SETTINGS_INFORMATION_HEADER", @"");
|
|
|
|
[informationSection addItem:[OWSTableItem labelItemWithText:NSLocalizedString(@"SETTINGS_VERSION", @"")
|
|
|
|
accessoryText:[[[NSBundle mainBundle] infoDictionary]
|
|
|
|
objectForKey:@"CFBundleVersion"]]];
|
|
|
|
[contents addSection:informationSection];
|
|
|
|
|
|
|
|
OWSTableSection *helpSection = [OWSTableSection new];
|
|
|
|
helpSection.headerTitle = NSLocalizedString(@"SETTINGS_HELP_HEADER", @"");
|
2017-09-08 18:56:53 +02:00
|
|
|
[helpSection addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_SUPPORT", @"")
|
|
|
|
actionBlock:^{
|
|
|
|
[[UIApplication sharedApplication]
|
|
|
|
openURL:[NSURL URLWithString:@"https://support.signal.org"]];
|
|
|
|
}]];
|
2017-06-22 18:58:59 +02:00
|
|
|
[contents addSection:helpSection];
|
|
|
|
|
|
|
|
UILabel *copyrightLabel = [UILabel new];
|
|
|
|
copyrightLabel.text = NSLocalizedString(@"SETTINGS_COPYRIGHT", @"");
|
|
|
|
copyrightLabel.textColor = [UIColor ows_darkGrayColor];
|
|
|
|
copyrightLabel.font = [UIFont ows_regularFontWithSize:15.0f];
|
|
|
|
copyrightLabel.numberOfLines = 2;
|
|
|
|
copyrightLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
|
|
|
copyrightLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
|
helpSection.customFooterView = copyrightLabel;
|
|
|
|
helpSection.customFooterHeight = @(60.f);
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
__block NSUInteger threadCount;
|
|
|
|
__block NSUInteger messageCount;
|
2017-12-19 03:34:22 +01:00
|
|
|
[TSStorageManager.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
2017-06-22 18:58:59 +02:00
|
|
|
threadCount = [[transaction ext:TSThreadDatabaseViewExtensionName] numberOfItemsInAllGroups];
|
|
|
|
messageCount = [[transaction ext:TSMessageDatabaseViewExtensionName] numberOfItemsInAllGroups];
|
|
|
|
}];
|
2018-01-10 16:54:17 +01:00
|
|
|
unsigned long long databaseFileSize = [TSStorageManager.sharedManager databaseFileSize];
|
2017-06-22 18:58:59 +02:00
|
|
|
|
|
|
|
OWSTableSection *debugSection = [OWSTableSection new];
|
|
|
|
debugSection.headerTitle = @"Debug";
|
|
|
|
[debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Threads: %zd", threadCount]]];
|
|
|
|
[debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Messages: %zd", messageCount]]];
|
2018-01-10 16:54:17 +01:00
|
|
|
[debugSection
|
|
|
|
addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Database size: %llu", databaseFileSize]]];
|
2017-06-22 18:58:59 +02:00
|
|
|
[contents addSection:debugSection];
|
2017-11-18 00:04:20 +01:00
|
|
|
|
|
|
|
OWSPreferences *preferences = [Environment preferences];
|
|
|
|
NSString *_Nullable pushToken = [preferences getPushToken];
|
|
|
|
NSString *_Nullable voipToken = [preferences getVoipToken];
|
|
|
|
[debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Push Token: %@", pushToken ?: @"None" ]]];
|
|
|
|
[debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"VOIP Token: %@", voipToken ?: @"None" ]]];
|
2017-06-22 18:58:59 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
self.contents = contents;
|
2015-01-16 15:28:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|