2015-01-16 15:28:41 +01:00
|
|
|
//
|
2019-01-10 18:17:39 +01:00
|
|
|
// Copyright (c) 2019 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>
|
2018-03-05 15:30:58 +01:00
|
|
|
#import <SignalServiceKit/OWSPrimaryStorage.h>
|
2017-06-22 18:58:59 +02:00
|
|
|
#import <SignalServiceKit/TSDatabaseView.h>
|
2016-11-18 23:11:56 +01:00
|
|
|
|
2015-01-16 15:28:41 +01:00
|
|
|
@implementation AboutTableViewController
|
|
|
|
|
2018-03-05 17:57:12 +01:00
|
|
|
- (void)dealloc
|
|
|
|
{
|
2017-11-18 00:04:20 +01:00
|
|
|
[[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
|
|
|
|
2018-09-27 18:32:09 +02:00
|
|
|
// Crash app if user performs obscure gesture in order to test
|
|
|
|
// crash reporting.
|
|
|
|
UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(crashApp)];
|
|
|
|
gesture.numberOfTouchesRequired = 2;
|
|
|
|
gesture.numberOfTapsRequired = 5;
|
|
|
|
[self.tableView addGestureRecognizer:gesture];
|
|
|
|
|
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"]]];
|
2018-05-23 23:48:17 +02:00
|
|
|
|
|
|
|
[informationSection addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_LEGAL_TERMS_CELL",
|
|
|
|
@"table cell label")
|
2019-03-22 18:05:35 +01:00
|
|
|
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"terms")
|
2018-05-23 23:48:17 +02:00
|
|
|
actionBlock:^{
|
|
|
|
[[UIApplication sharedApplication]
|
|
|
|
openURL:[NSURL URLWithString:kLegalTermsUrlString]];
|
|
|
|
}]];
|
2018-06-08 16:34:56 +02:00
|
|
|
|
2017-06-22 18:58:59 +02:00
|
|
|
[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", @"")
|
2019-03-22 18:05:35 +01:00
|
|
|
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"support")
|
2017-09-08 18:56:53 +02:00
|
|
|
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", @"");
|
2018-07-13 15:50:49 +02:00
|
|
|
copyrightLabel.textColor = [Theme secondaryColor];
|
2017-06-22 18:58:59 +02:00
|
|
|
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;
|
2018-03-16 12:48:21 +01:00
|
|
|
__block NSUInteger attachmentCount;
|
2018-03-05 15:30:58 +01:00
|
|
|
[OWSPrimaryStorage.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
2018-03-16 12:48:21 +01:00
|
|
|
threadCount = [transaction numberOfKeysInCollection:[TSThread collection]];
|
|
|
|
messageCount = [transaction numberOfKeysInCollection:[TSInteraction collection]];
|
|
|
|
attachmentCount = [transaction numberOfKeysInCollection:[TSAttachment collection]];
|
2017-06-22 18:58:59 +02:00
|
|
|
}];
|
|
|
|
|
2018-04-23 16:55:31 +02:00
|
|
|
NSByteCountFormatter *byteCountFormatter = [NSByteCountFormatter new];
|
|
|
|
|
|
|
|
// format counts with thousands separator
|
|
|
|
NSNumberFormatter *numberFormatter = [NSNumberFormatter new];
|
|
|
|
numberFormatter.formatterBehavior = NSNumberFormatterBehavior10_4;
|
|
|
|
numberFormatter.numberStyle = NSNumberFormatterDecimalStyle;
|
|
|
|
|
2017-06-22 18:58:59 +02:00
|
|
|
OWSTableSection *debugSection = [OWSTableSection new];
|
2018-04-23 16:55:31 +02:00
|
|
|
|
2017-06-22 18:58:59 +02:00
|
|
|
debugSection.headerTitle = @"Debug";
|
2018-04-23 16:55:31 +02:00
|
|
|
|
|
|
|
NSString *formattedThreadCount = [numberFormatter stringFromNumber:@(threadCount)];
|
2018-01-10 16:54:17 +01:00
|
|
|
[debugSection
|
2018-04-23 16:55:31 +02:00
|
|
|
addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Threads: %@", formattedThreadCount]]];
|
|
|
|
|
|
|
|
NSString *formattedMessageCount = [numberFormatter stringFromNumber:@(messageCount)];
|
2018-03-16 12:48:21 +01:00
|
|
|
[debugSection
|
2018-04-23 16:55:31 +02:00
|
|
|
addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Messages: %@", formattedMessageCount]]];
|
|
|
|
|
|
|
|
NSString *formattedAttachmentCount = [numberFormatter stringFromNumber:@(attachmentCount)];
|
|
|
|
[debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Attachments: %@",
|
|
|
|
formattedAttachmentCount]]];
|
|
|
|
|
|
|
|
NSString *dbSize =
|
|
|
|
[byteCountFormatter stringFromByteCount:(long long)[OWSPrimaryStorage.sharedManager databaseFileSize]];
|
|
|
|
[debugSection addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Database size: %@", dbSize]]];
|
|
|
|
|
|
|
|
NSString *dbWALSize =
|
|
|
|
[byteCountFormatter stringFromByteCount:(long long)[OWSPrimaryStorage.sharedManager databaseWALFileSize]];
|
2018-03-16 12:48:21 +01:00
|
|
|
[debugSection
|
2018-04-23 16:55:31 +02:00
|
|
|
addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Database WAL size: %@", dbWALSize]]];
|
|
|
|
|
|
|
|
NSString *dbSHMSize =
|
|
|
|
[byteCountFormatter stringFromByteCount:(long long)[OWSPrimaryStorage.sharedManager databaseSHMFileSize]];
|
2018-03-16 12:48:21 +01:00
|
|
|
[debugSection
|
2018-04-23 16:55:31 +02:00
|
|
|
addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Database SHM size: %@", dbSHMSize]]];
|
|
|
|
|
2017-06-22 18:58:59 +02:00
|
|
|
[contents addSection:debugSection];
|
2017-11-18 00:04:20 +01:00
|
|
|
|
2018-08-31 19:44:13 +02:00
|
|
|
OWSPreferences *preferences = Environment.shared.preferences;
|
2017-11-18 00:04:20 +01:00
|
|
|
NSString *_Nullable pushToken = [preferences getPushToken];
|
|
|
|
NSString *_Nullable voipToken = [preferences getVoipToken];
|
2018-03-05 17:57:12 +01:00
|
|
|
[debugSection
|
|
|
|
addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Push Token: %@", pushToken ?: @"None"]]];
|
|
|
|
[debugSection
|
|
|
|
addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"VOIP Token: %@", voipToken ?: @"None"]]];
|
2018-02-17 02:41:41 +01:00
|
|
|
|
|
|
|
// Strip prefix from category, otherwise it's too long to fit into cell on a small device.
|
|
|
|
NSString *audioCategory =
|
|
|
|
[AVAudioSession.sharedInstance.category stringByReplacingOccurrencesOfString:@"AVAudioSessionCategory"
|
|
|
|
withString:@""];
|
|
|
|
[debugSection
|
|
|
|
addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Audio Category: %@", audioCategory]]];
|
2017-06-22 18:58:59 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
self.contents = contents;
|
2015-01-16 15:28:41 +01:00
|
|
|
}
|
|
|
|
|
2018-09-27 18:32:09 +02:00
|
|
|
- (void)crashApp
|
|
|
|
{
|
|
|
|
OWSFail(@"crashApp");
|
|
|
|
}
|
|
|
|
|
2015-01-16 15:28:41 +01:00
|
|
|
@end
|