From 7654d0541703e00aef58daade4b1cb472904cd79 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 9 Jan 2019 10:03:28 -0500 Subject: [PATCH 1/3] Landscape orientation. --- Signal/src/AppDelegate.m | 10 +++++----- .../ThreadSettings/FingerprintViewController.m | 7 +++++++ .../ThreadSettings/FingerprintViewScanController.m | 7 +++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 5a333e2f9..549c00a1f 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -946,6 +946,11 @@ static NSTimeInterval launchStartedAt; - (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(nullable UIWindow *)window { + if (self.windowManager.hasCall) { + // The call-banner window is only suitable for portrait display + return UIInterfaceOrientationMaskPortrait; + } + if (!window) { // If `window` is nil, be permissive. Otherwise orientation // gets messed up during presentation of windows. @@ -960,11 +965,6 @@ static NSTimeInterval launchStartedAt; return UIInterfaceOrientationMaskPortrait; } - if (self.windowManager.hasCall) { - // The call-banner window is only suitable for portrait display - return UIInterfaceOrientationMaskPortrait; - } - return UIInterfaceOrientationMaskAllButUpsideDown; } diff --git a/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m b/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m index d6d920b5d..c2a9f5f1a 100644 --- a/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m @@ -540,6 +540,13 @@ typedef void (^CustomLayoutBlock)(void); [self updateVerificationStateLabel]; } +#pragma mark - Orientation + +- (UIInterfaceOrientationMask)supportedInterfaceOrientations +{ + return UIInterfaceOrientationMaskPortrait; +} + @end NS_ASSUME_NONNULL_END diff --git a/Signal/src/ViewControllers/ThreadSettings/FingerprintViewScanController.m b/Signal/src/ViewControllers/ThreadSettings/FingerprintViewScanController.m index 3a927d125..b8be8a4b6 100644 --- a/Signal/src/ViewControllers/ThreadSettings/FingerprintViewScanController.m +++ b/Signal/src/ViewControllers/ThreadSettings/FingerprintViewScanController.m @@ -246,6 +246,13 @@ NS_ASSUME_NONNULL_BEGIN [super dismissViewControllerAnimated:animated completion:completion]; } +#pragma mark - Orientation + +- (UIInterfaceOrientationMask)supportedInterfaceOrientations +{ + return UIInterfaceOrientationMaskPortrait; +} + @end NS_ASSUME_NONNULL_END From ff24e826c9af97d6bf81a48bd24a4b18b0a18b6d Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 9 Jan 2019 10:22:27 -0500 Subject: [PATCH 2/3] Landscape orientation. --- .../AppSettings/OWSLinkDeviceViewController.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Signal/src/ViewControllers/AppSettings/OWSLinkDeviceViewController.m b/Signal/src/ViewControllers/AppSettings/OWSLinkDeviceViewController.m index 273bbff63..27501cc83 100644 --- a/Signal/src/ViewControllers/AppSettings/OWSLinkDeviceViewController.m +++ b/Signal/src/ViewControllers/AppSettings/OWSLinkDeviceViewController.m @@ -237,6 +237,13 @@ NS_ASSUME_NONNULL_BEGIN return alertController; } +#pragma mark - Orientation + +- (UIInterfaceOrientationMask)supportedInterfaceOrientations +{ + return UIInterfaceOrientationMaskPortrait; +} + @end NS_ASSUME_NONNULL_END From 82d1517460d23c85312c70cdcf9b6ad9a851ccee Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 9 Jan 2019 11:31:17 -0500 Subject: [PATCH 3/3] Landscape orientation. --- Signal/src/Storyboard/Main.storyboard | 219 +----------------- .../AppSettings/AppSettingsViewController.m | 5 +- .../AppSettings/OWSLinkDeviceViewController.h | 6 +- .../AppSettings/OWSLinkDeviceViewController.m | 67 ++++-- .../OWSLinkedDevicesTableViewController.m | 26 ++- .../OWSQRCodeScanningViewController.m | 9 +- Signal/src/views/OWSDeviceTableViewCell.h | 10 +- Signal/src/views/OWSDeviceTableViewCell.m | 37 ++- 8 files changed, 118 insertions(+), 261 deletions(-) diff --git a/Signal/src/Storyboard/Main.storyboard b/Signal/src/Storyboard/Main.storyboard index ca04385c5..3b1417e92 100644 --- a/Signal/src/Storyboard/Main.storyboard +++ b/Signal/src/Storyboard/Main.storyboard @@ -1,224 +1,11 @@ - + - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m b/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m index 3c6f0709f..41fd33cba 100644 --- a/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "AppSettingsViewController.h" @@ -360,8 +360,7 @@ - (void)showLinkedDevices { - OWSLinkedDevicesTableViewController *vc = - [[UIStoryboard main] instantiateViewControllerWithIdentifier:@"OWSLinkedDevicesTableViewController"]; + OWSLinkedDevicesTableViewController *vc = [OWSLinkedDevicesTableViewController new]; [self.navigationController pushViewController:vc animated:YES]; } diff --git a/Signal/src/ViewControllers/AppSettings/OWSLinkDeviceViewController.h b/Signal/src/ViewControllers/AppSettings/OWSLinkDeviceViewController.h index 7cd3cfbf4..e03c97d50 100644 --- a/Signal/src/ViewControllers/AppSettings/OWSLinkDeviceViewController.h +++ b/Signal/src/ViewControllers/AppSettings/OWSLinkDeviceViewController.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "OWSQRCodeScanningViewController.h" @@ -9,9 +9,9 @@ NS_ASSUME_NONNULL_BEGIN @class OWSLinkedDevicesTableViewController; -@interface OWSLinkDeviceViewController : OWSViewController +@interface OWSLinkDeviceViewController : OWSViewController -@property OWSLinkedDevicesTableViewController *linkedDevicesTableViewController; +@property (nonatomic, weak) OWSLinkedDevicesTableViewController *linkedDevicesTableViewController; - (void)controller:(OWSQRCodeScanningViewController *)controller didDetectQRCodeWithString:(NSString *)string; diff --git a/Signal/src/ViewControllers/AppSettings/OWSLinkDeviceViewController.m b/Signal/src/ViewControllers/AppSettings/OWSLinkDeviceViewController.m index 27501cc83..7e707980a 100644 --- a/Signal/src/ViewControllers/AppSettings/OWSLinkDeviceViewController.m +++ b/Signal/src/ViewControllers/AppSettings/OWSLinkDeviceViewController.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "OWSLinkDeviceViewController.h" @@ -16,11 +16,11 @@ NS_ASSUME_NONNULL_BEGIN -@interface OWSLinkDeviceViewController () +@interface OWSLinkDeviceViewController () @property (nonatomic) YapDatabaseConnection *dbConnection; -@property (nonatomic) IBOutlet UIView *qrScanningView; -@property (nonatomic) IBOutlet UILabel *scanningInstructionsLabel; +@property (nonatomic) UIView *qrScanningView; +@property (nonatomic) UILabel *scanningInstructionsLabel; @property (nonatomic) OWSQRCodeScanningViewController *qrScanningController; @property (nonatomic, readonly) OWSReadReceiptManager *readReceiptManager; @@ -32,16 +32,52 @@ NS_ASSUME_NONNULL_BEGIN { [super viewDidLoad]; + self.view.backgroundColor = Theme.backgroundColor; + self.dbConnection = [[OWSPrimaryStorage sharedManager] newDatabaseConnection]; - // HACK to get full width preview layer - CGRect oldFrame = self.qrScanningView.frame; - self.qrScanningView.frame = CGRectMake( - oldFrame.origin.x, oldFrame.origin.y, self.view.frame.size.width, self.view.frame.size.height / 2.0f - 32.0f); - // END HACK to get full width preview layer + UIImage *heroImage = [UIImage imageNamed:@"ic_devices_ios"]; + OWSAssertDebug(heroImage); + UIImageView *heroImageView = [[UIImageView alloc] initWithImage:heroImage]; + [heroImageView autoSetDimensionsToSize:heroImage.size]; + self.scanningInstructionsLabel = [UILabel new]; self.scanningInstructionsLabel.text = NSLocalizedString(@"LINK_DEVICE_SCANNING_INSTRUCTIONS", @"QR Scanning screen instructions, placed alongside a camera view for scanning QR Codes"); + self.scanningInstructionsLabel.textColor = Theme.primaryColor; + self.scanningInstructionsLabel.font = UIFont.ows_dynamicTypeCaption1Font; + self.scanningInstructionsLabel.numberOfLines = 0; + self.scanningInstructionsLabel.lineBreakMode = NSLineBreakByWordWrapping; + self.scanningInstructionsLabel.textAlignment = NSTextAlignmentCenter; + + self.qrScanningController = [OWSQRCodeScanningViewController new]; + self.qrScanningController.scanDelegate = self; + [self.view addSubview:self.qrScanningController.view]; + [self.qrScanningController.view autoPinEdgeToSuperviewEdge:ALEdgeLeading]; + [self.qrScanningController.view autoPinEdgeToSuperviewEdge:ALEdgeTrailing]; + [self.qrScanningController.view autoPinToTopLayoutGuideOfViewController:self withInset:0.f]; + [self.qrScanningController.view autoPinToAspectRatio:1.f]; + + UIView *bottomView = [UIView new]; + [self.view addSubview:bottomView]; + [bottomView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.qrScanningController.view]; + [bottomView autoPinEdgeToSuperviewEdge:ALEdgeLeading]; + [bottomView autoPinEdgeToSuperviewEdge:ALEdgeTrailing]; + [bottomView autoPinEdgeToSuperviewEdge:ALEdgeBottom]; + + UIStackView *bottomStack = [[UIStackView alloc] initWithArrangedSubviews:@[ + heroImageView, + self.scanningInstructionsLabel, + ]]; + bottomStack.axis = UILayoutConstraintAxisVertical; + bottomStack.alignment = UIStackViewAlignmentCenter; + bottomStack.spacing = 2; + bottomStack.layoutMarginsRelativeArrangement = YES; + bottomStack.layoutMargins = UIEdgeInsetsMake(20, 20, 20, 20); + [bottomView addSubview:bottomStack]; + [bottomStack autoPinWidthToSuperview]; + [bottomStack autoVCenterInSuperview]; + self.title = NSLocalizedString(@"LINK_NEW_DEVICE_TITLE", "Navigation title when scanning QR code to add new device."); } @@ -83,21 +119,12 @@ NS_ASSUME_NONNULL_BEGIN - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; - [self.qrScanningController startCapture]; -} -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(nullable id)sender -{ - if ([segue.identifier isEqualToString:@"embedDeviceQRScanner"]) { - OWSQRCodeScanningViewController *qrScanningController - = (OWSQRCodeScanningViewController *)segue.destinationViewController; - qrScanningController.scanDelegate = self; - self.qrScanningController = qrScanningController; - } + [self.qrScanningController startCapture]; } - // pragma mark - OWSQRScannerDelegate + - (void)controller:(OWSQRCodeScanningViewController *)controller didDetectQRCodeWithString:(NSString *)string { OWSDeviceProvisioningURLParser *parser = [[OWSDeviceProvisioningURLParser alloc] initWithProvisioningURL:string]; diff --git a/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m b/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m index 304e2df80..f2786ba2b 100644 --- a/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "OWSLinkedDevicesTableViewController.h" @@ -49,7 +49,8 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1; self.tableView.rowHeight = UITableViewAutomaticDimension; self.tableView.estimatedRowHeight = 60; self.tableView.separatorColor = Theme.cellSeparatorColor; - + [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"AddNewDevice"]; + [self.tableView registerClass:[OWSDeviceTableViewCell class] forCellReuseIdentifier:@"ExistingDevice"]; [self.tableView applyScrollViewInsetsFix]; self.dbConnection = [[OWSPrimaryStorage sharedManager] newDatabaseConnection]; @@ -303,20 +304,29 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1; if (!granted) { return; } - [self performSegueWithIdentifier:@"LinkDeviceSegue" sender:self]; + [self showLinkNewDeviceView]; }]; } } +- (void)showLinkNewDeviceView +{ + OWSLinkDeviceViewController *vc = [OWSLinkDeviceViewController new]; + vc.linkedDevicesTableViewController = self; + [self.navigationController pushViewController:vc animated:YES]; +} + - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section == OWSLinkedDevicesTableViewControllerSectionAddDevice) { - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AddNewDevice" forIndexPath:indexPath]; + UITableViewCell *cell = + [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"AddNewDevice"]; [OWSTableItem configureCell:cell]; cell.textLabel.text = NSLocalizedString(@"LINK_NEW_DEVICE_TITLE", @"Navigation title when scanning QR code to add new device."); cell.detailTextLabel.text = NSLocalizedString(@"LINK_NEW_DEVICE_SUBTITLE", @"Subheading for 'Link New Device' navigation"); + cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell; } else if (indexPath.section == OWSLinkedDevicesTableViewControllerSectionExistingDevices) { OWSDeviceTableViewCell *cell = @@ -427,14 +437,6 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1; }]; } -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(nullable id)sender -{ - if ([segue.destinationViewController isKindOfClass:[OWSLinkDeviceViewController class]]) { - OWSLinkDeviceViewController *controller = (OWSLinkDeviceViewController *)segue.destinationViewController; - controller.linkedDevicesTableViewController = self; - } -} - @end NS_ASSUME_NONNULL_END diff --git a/Signal/src/ViewControllers/AppSettings/OWSQRCodeScanningViewController.m b/Signal/src/ViewControllers/AppSettings/OWSQRCodeScanningViewController.m index 046221ece..498191187 100644 --- a/Signal/src/ViewControllers/AppSettings/OWSQRCodeScanningViewController.m +++ b/Signal/src/ViewControllers/AppSettings/OWSQRCodeScanningViewController.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "OWSQRCodeScanningViewController.h" @@ -93,6 +93,11 @@ NS_ASSUME_NONNULL_BEGIN [self stopCapture]; } +- (void)viewWillLayoutSubviews +{ + self.capture.layer.frame = self.view.bounds; +} + - (void)startCapture { self.captureEnabled = YES; @@ -101,10 +106,10 @@ NS_ASSUME_NONNULL_BEGIN self.capture = [[ZXCapture alloc] init]; self.capture.camera = self.capture.back; self.capture.focusMode = AVCaptureFocusModeContinuousAutoFocus; - self.capture.layer.frame = self.view.bounds; self.capture.delegate = self; dispatch_async(dispatch_get_main_queue(), ^{ + self.capture.layer.frame = self.view.bounds; [self.view.layer addSublayer:self.capture.layer]; [self.view bringSubviewToFront:self.maskingView]; [self.capture start]; diff --git a/Signal/src/views/OWSDeviceTableViewCell.h b/Signal/src/views/OWSDeviceTableViewCell.h index 7dc65759b..12caed02c 100644 --- a/Signal/src/views/OWSDeviceTableViewCell.h +++ b/Signal/src/views/OWSDeviceTableViewCell.h @@ -1,4 +1,6 @@ -// Copyright © 2016 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. +// #import #import @@ -7,9 +9,9 @@ NS_ASSUME_NONNULL_BEGIN @interface OWSDeviceTableViewCell : UITableViewCell -@property (strong, nonatomic) IBOutlet UILabel *nameLabel; -@property (strong, nonatomic) IBOutlet UILabel *linkedLabel; -@property (strong, nonatomic) IBOutlet UILabel *lastSeenLabel; +@property (nonatomic) UILabel *nameLabel; +@property (nonatomic) UILabel *linkedLabel; +@property (nonatomic) UILabel *lastSeenLabel; - (void)configureWithDevice:(OWSDevice *)device; diff --git a/Signal/src/views/OWSDeviceTableViewCell.m b/Signal/src/views/OWSDeviceTableViewCell.m index c4d418127..d77355ae5 100644 --- a/Signal/src/views/OWSDeviceTableViewCell.m +++ b/Signal/src/views/OWSDeviceTableViewCell.m @@ -1,22 +1,57 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "OWSDeviceTableViewCell.h" #import "DateUtil.h" #import #import +#import +#import NS_ASSUME_NONNULL_BEGIN @implementation OWSDeviceTableViewCell +- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier +{ + if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { + [self configure]; + } + return self; +} + +- (void)configure +{ + self.preservesSuperviewLayoutMargins = YES; + self.contentView.preservesSuperviewLayoutMargins = YES; + + self.nameLabel = [UILabel new]; + self.linkedLabel = [UILabel new]; + self.lastSeenLabel = [UILabel new]; + + UIStackView *stackView = [[UIStackView alloc] initWithArrangedSubviews:@[ + self.nameLabel, + self.linkedLabel, + self.lastSeenLabel, + ]]; + stackView.axis = UILayoutConstraintAxisVertical; + stackView.alignment = UIStackViewAlignmentLeading; + stackView.spacing = 2; + [self.contentView addSubview:stackView]; + [stackView ows_autoPinToSuperviewMargins]; +} + - (void)configureWithDevice:(OWSDevice *)device { OWSAssertDebug(device); [OWSTableItem configureCell:self]; + self.nameLabel.font = UIFont.ows_dynamicTypeBodyFont; + self.linkedLabel.font = UIFont.ows_dynamicTypeCaption1Font; + self.lastSeenLabel.font = UIFont.ows_dynamicTypeCaption1Font; + self.nameLabel.textColor = Theme.primaryColor; self.linkedLabel.textColor = Theme.secondaryColor; self.lastSeenLabel.textColor = Theme.secondaryColor;