From 0807325190d1743ace9dc162a660ccb1f1af0aec Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 6 Feb 2019 14:21:32 -0500 Subject: [PATCH] First draft of image editor's text tool. --- .../xcshareddata/xcschemes/Signal.xcscheme | 17 ++++++------ .../ConversationViewController.m | 26 +++++++++++++++++++ .../HomeView/HomeViewController.m | 18 +++++++++++++ .../src/Network/WebSockets/OWSWebSocket.m | 2 ++ 4 files changed, 54 insertions(+), 9 deletions(-) diff --git a/Signal.xcodeproj/xcshareddata/xcschemes/Signal.xcscheme b/Signal.xcodeproj/xcshareddata/xcschemes/Signal.xcscheme index f5fde70a8..16d93f758 100644 --- a/Signal.xcodeproj/xcshareddata/xcschemes/Signal.xcscheme +++ b/Signal.xcodeproj/xcshareddata/xcschemes/Signal.xcscheme @@ -28,7 +28,7 @@ buildForAnalyzing = "YES"> @@ -56,7 +56,7 @@ skipped = "NO"> @@ -66,7 +66,7 @@ skipped = "NO"> @@ -76,7 +76,7 @@ skipped = "NO"> @@ -86,7 +86,7 @@ skipped = "NO"> @@ -96,7 +96,7 @@ skipped = "NO"> @@ -106,7 +106,7 @@ skipped = "NO"> @@ -136,8 +136,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - enableThreadSanitizer = "YES" - enableUBSanitizer = "YES" + disableMainThreadChecker = "YES" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index a40183cd2..51c1bf479 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -1234,6 +1234,32 @@ typedef enum : NSUInteger { self.actionOnOpen = ConversationViewActionNone; [self updateInputToolbarLayout]; + + [self showDebugImageEditorAsync]; +} + +- (void)showDebugImageEditorAsync +{ + dispatch_async(dispatch_get_main_queue(), ^{ + NSString *_Nullable filePath = [[NSBundle mainBundle] pathForResource:@"qr@2x" ofType:@"png" inDirectory:nil]; + if (!filePath) { + OWSFailDebug(@"Missing asset."); + } + + DataSource *_Nullable dataSource = + [DataSourcePath dataSourceWithFilePath:filePath shouldDeleteOnDeallocation:NO]; + if (!dataSource) { + OWSFailDebug(@"Invalid asset."); + return; + } + + // "Document picker" attachments _SHOULD NOT_ be resized, if possible. + SignalAttachment *attachment = [SignalAttachment attachmentWithDataSource:dataSource + dataUTI:(NSString *)kUTTypePNG + imageQuality:TSImageQualityOriginal]; + + [self showApprovalDialogForAttachment:attachment]; + }); } // `viewWillDisappear` is called whenever the view *starts* to disappear, diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index 2e8ab8ba1..02850c1d2 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -482,8 +482,26 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations [self.searchResultsController viewDidAppear:animated]; self.hasEverAppeared = YES; + + [self presentFirstThreadAsync]; } +#ifdef DEBUG + +- (void)presentFirstThreadAsync +{ + dispatch_async(dispatch_get_main_queue(), ^{ + if ([self.tableView numberOfRowsInSection:HomeViewControllerSectionConversations] < 1) { + return; + } + TSThread *thread = + [self threadForIndexPath:[NSIndexPath indexPathForRow:0 inSection:HomeViewControllerSectionConversations]]; + [self presentThread:thread action:ConversationViewActionNone animated:YES]; + }); +} + +#endif + - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; diff --git a/SignalServiceKit/src/Network/WebSockets/OWSWebSocket.m b/SignalServiceKit/src/Network/WebSockets/OWSWebSocket.m index 17d6b7c5a..c93a07d23 100644 --- a/SignalServiceKit/src/Network/WebSockets/OWSWebSocket.m +++ b/SignalServiceKit/src/Network/WebSockets/OWSWebSocket.m @@ -910,6 +910,8 @@ NSString *const kNSNotification_OWSWebSocketStateDidChange = @"kNSNotification_O { OWSAssertIsOnMainThread(); + return NO; + // Don't open socket in app extensions. if (!CurrentAppContext().isMainApp) { return NO;