mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
163 lines
7.3 KiB
Matlab
163 lines
7.3 KiB
Matlab
10 years ago
|
//
|
||
6 years ago
|
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||
10 years ago
|
//
|
||
|
|
||
9 years ago
|
#import "AboutTableViewController.h"
|
||
6 years ago
|
#import "Session-Swift.h"
|
||
8 years ago
|
#import "UIView+OWS.h"
|
||
4 years ago
|
#import <SessionMessagingKit/Environment.h>
|
||
|
#import <SessionMessagingKit/OWSPreferences.h>
|
||
5 years ago
|
#import <SignalUtilitiesKit/UIUtil.h>
|
||
4 years ago
|
#import <SessionMessagingKit/OWSPrimaryStorage.h>
|
||
|
#import <SessionMessagingKit/TSDatabaseView.h>
|
||
9 years ago
|
|
||
10 years ago
|
@implementation AboutTableViewController
|
||
|
|
||
7 years ago
|
- (void)dealloc
|
||
|
{
|
||
8 years ago
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||
|
}
|
||
|
|
||
8 years ago
|
- (void)viewDidLoad
|
||
|
{
|
||
10 years ago
|
[super viewDidLoad];
|
||
9 years ago
|
|
||
9 years ago
|
self.title = NSLocalizedString(@"SETTINGS_ABOUT", @"Navbar title");
|
||
9 years ago
|
|
||
8 years ago
|
[self updateTableContents];
|
||
8 years ago
|
|
||
7 years ago
|
// 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];
|
||
|
|
||
8 years ago
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||
|
selector:@selector(pushTokensDidChange:)
|
||
|
name:[OWSSyncPushTokensJob PushTokensDidChange]
|
||
|
object:nil];
|
||
|
}
|
||
|
|
||
8 years ago
|
- (void)pushTokensDidChange:(NSNotification *)notification
|
||
|
{
|
||
8 years ago
|
[self updateTableContents];
|
||
10 years ago
|
}
|
||
|
|
||
8 years ago
|
#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"]]];
|
||
7 years ago
|
|
||
|
[informationSection addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_LEGAL_TERMS_CELL",
|
||
|
@"table cell label")
|
||
6 years ago
|
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"terms")
|
||
7 years ago
|
actionBlock:^{
|
||
|
[[UIApplication sharedApplication]
|
||
|
openURL:[NSURL URLWithString:kLegalTermsUrlString]];
|
||
|
}]];
|
||
7 years ago
|
|
||
8 years ago
|
[contents addSection:informationSection];
|
||
|
|
||
|
OWSTableSection *helpSection = [OWSTableSection new];
|
||
|
helpSection.headerTitle = NSLocalizedString(@"SETTINGS_HELP_HEADER", @"");
|
||
8 years ago
|
[helpSection addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_SUPPORT", @"")
|
||
6 years ago
|
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"support")
|
||
8 years ago
|
actionBlock:^{
|
||
|
[[UIApplication sharedApplication]
|
||
|
openURL:[NSURL URLWithString:@"https://support.signal.org"]];
|
||
|
}]];
|
||
8 years ago
|
[contents addSection:helpSection];
|
||
|
|
||
|
UILabel *copyrightLabel = [UILabel new];
|
||
|
copyrightLabel.text = NSLocalizedString(@"SETTINGS_COPYRIGHT", @"");
|
||
7 years ago
|
copyrightLabel.textColor = [Theme secondaryColor];
|
||
8 years ago
|
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;
|
||
7 years ago
|
__block NSUInteger attachmentCount;
|
||
7 years ago
|
[OWSPrimaryStorage.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
|
||
7 years ago
|
threadCount = [transaction numberOfKeysInCollection:[TSThread collection]];
|
||
|
messageCount = [transaction numberOfKeysInCollection:[TSInteraction collection]];
|
||
|
attachmentCount = [transaction numberOfKeysInCollection:[TSAttachment collection]];
|
||
8 years ago
|
}];
|
||
|
|
||
7 years ago
|
NSByteCountFormatter *byteCountFormatter = [NSByteCountFormatter new];
|
||
|
|
||
|
// format counts with thousands separator
|
||
|
NSNumberFormatter *numberFormatter = [NSNumberFormatter new];
|
||
|
numberFormatter.formatterBehavior = NSNumberFormatterBehavior10_4;
|
||
|
numberFormatter.numberStyle = NSNumberFormatterDecimalStyle;
|
||
|
|
||
8 years ago
|
OWSTableSection *debugSection = [OWSTableSection new];
|
||
7 years ago
|
|
||
8 years ago
|
debugSection.headerTitle = @"Debug";
|
||
7 years ago
|
|
||
|
NSString *formattedThreadCount = [numberFormatter stringFromNumber:@(threadCount)];
|
||
7 years ago
|
[debugSection
|
||
7 years ago
|
addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Threads: %@", formattedThreadCount]]];
|
||
|
|
||
|
NSString *formattedMessageCount = [numberFormatter stringFromNumber:@(messageCount)];
|
||
7 years ago
|
[debugSection
|
||
7 years ago
|
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]];
|
||
7 years ago
|
[debugSection
|
||
7 years ago
|
addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Database WAL size: %@", dbWALSize]]];
|
||
|
|
||
|
NSString *dbSHMSize =
|
||
|
[byteCountFormatter stringFromByteCount:(long long)[OWSPrimaryStorage.sharedManager databaseSHMFileSize]];
|
||
7 years ago
|
[debugSection
|
||
7 years ago
|
addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Database SHM size: %@", dbSHMSize]]];
|
||
|
|
||
8 years ago
|
[contents addSection:debugSection];
|
||
8 years ago
|
|
||
7 years ago
|
OWSPreferences *preferences = Environment.shared.preferences;
|
||
8 years ago
|
NSString *_Nullable pushToken = [preferences getPushToken];
|
||
|
NSString *_Nullable voipToken = [preferences getVoipToken];
|
||
7 years ago
|
[debugSection
|
||
|
addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"Push Token: %@", pushToken ?: @"None"]]];
|
||
|
[debugSection
|
||
|
addItem:[OWSTableItem labelItemWithText:[NSString stringWithFormat:@"VOIP Token: %@", voipToken ?: @"None"]]];
|
||
7 years ago
|
|
||
|
// 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]]];
|
||
8 years ago
|
#endif
|
||
|
|
||
|
self.contents = contents;
|
||
10 years ago
|
}
|
||
|
|
||
7 years ago
|
- (void)crashApp
|
||
|
{
|
||
|
OWSFail(@"crashApp");
|
||
|
}
|
||
|
|
||
10 years ago
|
@end
|