From e6d499a354b50281db72aa0a571aa6e7ba8b4bb4 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 17 Dec 2018 15:19:33 -0500 Subject: [PATCH 1/3] Revert "Revert "Debug scaffolding."" This reverts commit a5e71e6eaa71b4ccc7f45bc574b7a1e1c3ebb772. --- .../ConversationView/ConversationViewController.m | 13 +++++++++++++ .../ViewControllers/HomeView/HomeViewController.m | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index f4f9a7a12..27b75feaf 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -1190,6 +1190,19 @@ typedef enum : NSUInteger { // Clear the "on open" state after the view has been presented. self.actionOnOpen = ConversationViewActionNone; + + dispatch_async(dispatch_get_main_queue(), ^{ + NSURL *_Nullable url = [[NSBundle mainBundle] URLForResource:@"qr@2x" withExtension:@"png"]; + OWSAssertDebug(url); + + DataSource *_Nullable dataSource = [DataSourcePath dataSourceWithURL:url shouldDeleteOnDeallocation:NO]; + OWSAssertDebug(dataSource); + SignalAttachment *attachment = [SignalAttachment attachmentWithDataSource:dataSource + dataUTI:(NSString *)kUTTypePNG + imageQuality:TSImageQualityOriginal]; + + [self showApprovalDialogForAttachments:@[ 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 586ef500e..8438abf18 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -481,6 +481,12 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations [self.searchResultsController viewDidAppear:animated]; self.hasEverAppeared = YES; + + dispatch_async(dispatch_get_main_queue(), ^{ + NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:HomeViewControllerSectionConversations]; + TSThread *thread = [self threadForIndexPath:indexPath]; + [self presentThread:thread action:ConversationViewActionNone animated:YES]; + }); } - (void)viewDidDisappear:(BOOL)animated From 8aa68327e6bc9535d47a8e5840a4e9ba9bcbf4c1 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 20 Dec 2018 09:59:31 -0500 Subject: [PATCH 2/3] Add primitive color picker. --- .../AttachmentApprovalViewController.swift | 1 - .../Views/ImageEditor/ImageEditorView.swift | 30 +++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift b/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift index 4ce2073ec..bd0a52d0e 100644 --- a/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift +++ b/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift @@ -960,7 +960,6 @@ public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarD imageMediaView.isUserInteractionEnabled = true mediaMessageView.superview?.addSubview(imageEditorView) imageEditorView.autoPin(toEdgesOf: mediaMessageView) - imageEditorView.addRedBorder() imageEditorView.addControls(to: imageEditorView) } diff --git a/SignalMessaging/Views/ImageEditor/ImageEditorView.swift b/SignalMessaging/Views/ImageEditor/ImageEditorView.swift index 67b7ea554..2afda5784 100644 --- a/SignalMessaging/Views/ImageEditor/ImageEditorView.swift +++ b/SignalMessaging/Views/ImageEditor/ImageEditorView.swift @@ -35,6 +35,10 @@ public class ImageEditorView: UIView, ImageEditorModelDelegate { } } + // TODO: + private static let defaultColor = UIColor.ows_signalBlue + private var currentColor = ImageEditorView.defaultColor + @objc public required init(model: ImageEditorModel) { self.model = model @@ -143,7 +147,11 @@ public class ImageEditorView: UIView, ImageEditorModelDelegate { label: NSLocalizedString("IMAGE_EDITOR_CROP_BUTTON", comment: "Label for crop button in image editor."), selector: #selector(didTapCrop(sender:))) - let stackView = UIStackView(arrangedSubviews: [brushButton, cropButton, undoButton, redoButton]) + let redButton = colorButton(color: UIColor.red) + let whiteButton = colorButton(color: UIColor.white) + let blackButton = colorButton(color: UIColor.black) + + let stackView = UIStackView(arrangedSubviews: [brushButton, cropButton, undoButton, redoButton, redButton, whiteButton, blackButton]) stackView.axis = .vertical stackView.alignment = .center stackView.spacing = 10 @@ -166,6 +174,17 @@ public class ImageEditorView: UIView, ImageEditorModelDelegate { button.addTarget(self, action: selector, for: .touchUpInside) } + private func colorButton(color: UIColor) -> UIButton { + let button = OWSButton { [weak self] in + self?.didSelectColor(color) + } + let size: CGFloat = 20 + let swatch = UIImage(color: color, size: CGSize(width: size, height: size)) + button.setImage(swatch, for: .normal) + button.addBorder(with: UIColor.white) + return button + } + private func updateButtons() { undoButton.isEnabled = model.canUndo() redoButton.isEnabled = model.canRedo() @@ -209,6 +228,12 @@ public class ImageEditorView: UIView, ImageEditorModelDelegate { updateButtons() } + @objc func didSelectColor(_ color: UIColor) { + Logger.verbose("") + + currentColor = color + } + @objc public func handleTouchGesture(_ gestureRecognizer: UIGestureRecognizer) { AssertIsOnMainThread() @@ -250,8 +275,7 @@ public class ImageEditorView: UIView, ImageEditorModelDelegate { self.currentStrokeSamples.append(newSample) } - // TODO: Color picker. - let strokeColor = UIColor.blue + let strokeColor = currentColor // TODO: Tune stroke width. let unitStrokeWidth = ImageEditorStrokeItem.defaultUnitStrokeWidth() From fcedd1d10fac118e3da157eb16cf59933cf1103c Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 20 Dec 2018 10:00:07 -0500 Subject: [PATCH 3/3] Revert "Revert "Revert "Debug scaffolding.""" This reverts commit 1cd6941f68cac054355277bea6972fe571651402. --- .../ConversationView/ConversationViewController.m | 13 ------------- .../ViewControllers/HomeView/HomeViewController.m | 6 ------ 2 files changed, 19 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 27b75feaf..f4f9a7a12 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -1190,19 +1190,6 @@ typedef enum : NSUInteger { // Clear the "on open" state after the view has been presented. self.actionOnOpen = ConversationViewActionNone; - - dispatch_async(dispatch_get_main_queue(), ^{ - NSURL *_Nullable url = [[NSBundle mainBundle] URLForResource:@"qr@2x" withExtension:@"png"]; - OWSAssertDebug(url); - - DataSource *_Nullable dataSource = [DataSourcePath dataSourceWithURL:url shouldDeleteOnDeallocation:NO]; - OWSAssertDebug(dataSource); - SignalAttachment *attachment = [SignalAttachment attachmentWithDataSource:dataSource - dataUTI:(NSString *)kUTTypePNG - imageQuality:TSImageQualityOriginal]; - - [self showApprovalDialogForAttachments:@[ 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 8438abf18..586ef500e 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -481,12 +481,6 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations [self.searchResultsController viewDidAppear:animated]; self.hasEverAppeared = YES; - - dispatch_async(dispatch_get_main_queue(), ^{ - NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:HomeViewControllerSectionConversations]; - TSThread *thread = [self threadForIndexPath:indexPath]; - [self presentThread:thread action:ConversationViewActionNone animated:YES]; - }); } - (void)viewDidDisappear:(BOOL)animated