2017-04-19 15:48:56 +02:00
|
|
|
//
|
2018-01-10 16:40:48 +01:00
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
2017-04-19 15:48:56 +02:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "DebugUITableViewController.h"
|
|
|
|
#import "DebugUIContacts.h"
|
2017-06-22 18:58:59 +02:00
|
|
|
#import "DebugUIDiskUsage.h"
|
2017-04-19 15:48:56 +02:00
|
|
|
#import "DebugUIMessages.h"
|
2017-07-28 17:13:55 +02:00
|
|
|
#import "DebugUIMisc.h"
|
2017-06-07 16:56:06 +02:00
|
|
|
#import "DebugUISessionState.h"
|
2017-09-22 06:31:13 +02:00
|
|
|
#import "DebugUIStress.h"
|
2017-11-21 16:58:25 +01:00
|
|
|
#import "DebugUISyncMessages.h"
|
2017-04-19 15:48:56 +02:00
|
|
|
#import "Signal-Swift.h"
|
|
|
|
#import <SignalServiceKit/TSContactThread.h>
|
|
|
|
#import <SignalServiceKit/TSThread.h>
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
@implementation DebugUITableViewController
|
|
|
|
|
2017-07-06 18:52:44 +02:00
|
|
|
- (void)viewWillAppear:(BOOL)animated
|
|
|
|
{
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
|
|
|
// Block device from sleeping while in the Debug UI.
|
|
|
|
//
|
|
|
|
// This is useful if you're using long-running actions in the
|
|
|
|
// Debug UI, like "send 1k messages", etc.
|
|
|
|
[DeviceSleepManager.sharedInstance addBlockWithBlockObject:self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated
|
|
|
|
{
|
|
|
|
[super viewWillDisappear:animated];
|
|
|
|
|
|
|
|
[DeviceSleepManager.sharedInstance removeBlockWithBlockObject:self];
|
|
|
|
}
|
|
|
|
|
2017-04-19 15:48:56 +02:00
|
|
|
#pragma mark - Factory Methods
|
|
|
|
|
2017-06-02 21:49:34 +02:00
|
|
|
- (void)pushPageWithSection:(OWSTableSection *)section
|
|
|
|
{
|
|
|
|
DebugUITableViewController *viewController = [DebugUITableViewController new];
|
|
|
|
OWSTableContents *contents = [OWSTableContents new];
|
|
|
|
contents.title = section.headerTitle;
|
|
|
|
[contents addSection:section];
|
|
|
|
viewController.contents = contents;
|
|
|
|
[self.navigationController pushViewController:viewController animated:YES];
|
|
|
|
}
|
|
|
|
|
2017-06-22 18:58:59 +02:00
|
|
|
+ (OWSTableItem *)itemForSubsection:(DebugUIPage *)page
|
2017-06-09 22:21:59 +02:00
|
|
|
viewController:(DebugUITableViewController *)viewController
|
2017-06-22 18:58:59 +02:00
|
|
|
thread:(nullable TSThread *)thread
|
2017-06-09 22:21:59 +02:00
|
|
|
{
|
2017-06-22 18:58:59 +02:00
|
|
|
OWSAssert(page);
|
|
|
|
OWSAssert(viewController);
|
2017-06-09 22:21:59 +02:00
|
|
|
|
|
|
|
__weak DebugUITableViewController *weakSelf = viewController;
|
2017-06-22 18:58:59 +02:00
|
|
|
return [OWSTableItem disclosureItemWithText:page.name
|
2017-06-09 22:21:59 +02:00
|
|
|
actionBlock:^{
|
2017-06-22 18:58:59 +02:00
|
|
|
[weakSelf pushPageWithSection:[page sectionForThread:thread]];
|
2017-06-09 22:21:59 +02:00
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2017-04-19 15:48:56 +02:00
|
|
|
+ (void)presentDebugUIForThread:(TSThread *)thread fromViewController:(UIViewController *)fromViewController
|
|
|
|
{
|
|
|
|
OWSAssert(thread);
|
|
|
|
OWSAssert(fromViewController);
|
|
|
|
|
2017-06-02 21:49:34 +02:00
|
|
|
DebugUITableViewController *viewController = [DebugUITableViewController new];
|
|
|
|
|
2017-04-19 15:48:56 +02:00
|
|
|
OWSTableContents *contents = [OWSTableContents new];
|
|
|
|
contents.title = @"Debug: Conversation";
|
|
|
|
|
2017-06-09 22:21:59 +02:00
|
|
|
NSMutableArray<OWSTableItem *> *subsectionItems = [NSMutableArray new];
|
|
|
|
[subsectionItems
|
2017-06-22 18:58:59 +02:00
|
|
|
addObject:[self itemForSubsection:[DebugUIMessages new] viewController:viewController thread:thread]];
|
|
|
|
[subsectionItems
|
|
|
|
addObject:[self itemForSubsection:[DebugUIContacts new] viewController:viewController thread:thread]];
|
|
|
|
[subsectionItems
|
|
|
|
addObject:[self itemForSubsection:[DebugUIDiskUsage new] viewController:viewController thread:thread]];
|
2018-01-10 16:40:48 +01:00
|
|
|
[subsectionItems
|
|
|
|
addObject:[self itemForSubsection:[DebugUISessionState new] viewController:viewController thread:thread]];
|
2017-06-07 15:49:58 +02:00
|
|
|
if ([thread isKindOfClass:[TSContactThread class]]) {
|
2017-08-11 15:13:54 +02:00
|
|
|
[subsectionItems
|
|
|
|
addObject:[self itemForSubsection:[DebugUICalling new] viewController:viewController thread:thread]];
|
2017-06-09 22:21:59 +02:00
|
|
|
}
|
2017-08-28 22:06:30 +02:00
|
|
|
[subsectionItems addObject:[self itemForSubsection:[DebugUIProfile new] viewController:viewController thread:thread]];
|
2017-09-22 06:31:13 +02:00
|
|
|
[subsectionItems
|
|
|
|
addObject:[self itemForSubsection:[DebugUIStress new] viewController:viewController thread:thread]];
|
2017-11-21 16:58:25 +01:00
|
|
|
[subsectionItems
|
|
|
|
addObject:[self itemForSubsection:[DebugUISyncMessages new] viewController:viewController thread:thread]];
|
2017-07-28 17:13:55 +02:00
|
|
|
[subsectionItems addObject:[self itemForSubsection:[DebugUIMisc new] viewController:viewController thread:thread]];
|
2017-06-22 18:58:59 +02:00
|
|
|
|
2017-06-09 22:21:59 +02:00
|
|
|
[contents addSection:[OWSTableSection sectionWithTitle:@"Sections" items:subsectionItems]];
|
2017-06-07 15:49:58 +02:00
|
|
|
|
2017-04-19 15:48:56 +02:00
|
|
|
viewController.contents = contents;
|
|
|
|
[viewController presentFromViewController:fromViewController];
|
|
|
|
}
|
|
|
|
|
2017-06-22 18:58:59 +02:00
|
|
|
+ (void)presentDebugUIFromViewController:(UIViewController *)fromViewController
|
|
|
|
{
|
|
|
|
OWSAssert(fromViewController);
|
|
|
|
|
|
|
|
DebugUITableViewController *viewController = [DebugUITableViewController new];
|
|
|
|
|
|
|
|
OWSTableContents *contents = [OWSTableContents new];
|
|
|
|
contents.title = @"Debug UI";
|
|
|
|
|
|
|
|
NSMutableArray<OWSTableItem *> *subsectionItems = [NSMutableArray new];
|
|
|
|
[subsectionItems addObject:[self itemForSubsection:[DebugUIContacts new] viewController:viewController thread:nil]];
|
|
|
|
[subsectionItems
|
|
|
|
addObject:[self itemForSubsection:[DebugUIDiskUsage new] viewController:viewController thread:nil]];
|
2018-01-10 16:40:48 +01:00
|
|
|
[subsectionItems
|
|
|
|
addObject:[self itemForSubsection:[DebugUISessionState new] viewController:viewController thread:nil]];
|
2017-11-21 16:58:25 +01:00
|
|
|
[subsectionItems
|
|
|
|
addObject:[self itemForSubsection:[DebugUISyncMessages new] viewController:viewController thread:nil]];
|
2017-07-28 17:17:25 +02:00
|
|
|
[subsectionItems addObject:[self itemForSubsection:[DebugUIMisc new] viewController:viewController thread:nil]];
|
2017-06-22 18:58:59 +02:00
|
|
|
[contents addSection:[OWSTableSection sectionWithTitle:@"Sections" items:subsectionItems]];
|
|
|
|
|
|
|
|
viewController.contents = contents;
|
|
|
|
[viewController presentFromViewController:fromViewController];
|
|
|
|
}
|
|
|
|
|
2017-04-19 15:48:56 +02:00
|
|
|
@end
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|