diff --git a/Signal/Images.xcassets/file-thin-black-filled-large.imageset/Contents.json b/Signal/Images.xcassets/file-thin-black-filled-large.imageset/Contents.json new file mode 100644 index 000000000..00bbda011 --- /dev/null +++ b/Signal/Images.xcassets/file-thin-black-filled-large.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "file-thin-black-w-shadow-large.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Signal/Images.xcassets/file-thin-black-filled-large.imageset/file-thin-black-w-shadow-large.png b/Signal/Images.xcassets/file-thin-black-filled-large.imageset/file-thin-black-w-shadow-large.png new file mode 100644 index 000000000..cfb329224 Binary files /dev/null and b/Signal/Images.xcassets/file-thin-black-filled-large.imageset/file-thin-black-w-shadow-large.png differ diff --git a/Signal/src/ViewControllers/AttachmentApprovalViewController.swift b/Signal/src/ViewControllers/AttachmentApprovalViewController.swift index 450be391d..beec6221b 100644 --- a/Signal/src/ViewControllers/AttachmentApprovalViewController.swift +++ b/Signal/src/ViewControllers/AttachmentApprovalViewController.swift @@ -217,7 +217,7 @@ class AttachmentApprovalViewController: UIViewController, OWSAudioAttachmentPlay private func createGenericPreview(attachmentPreviewView: UIView) { var subviews = [UIView]() - let imageView = createHeroImageView(imageName: "file-thin-black-large") + let imageView = createHeroImageView(imageName: "file-thin-black-filled-large") subviews.append(imageView) if let fileNameLabel = createFileNameLabel() { @@ -245,6 +245,11 @@ class AttachmentApprovalViewController: UIViewController, OWSAudioAttachmentPlay let imageView = UIImageView(image:image) imageView.layer.minificationFilter = kCAFilterTrilinear imageView.layer.magnificationFilter = kCAFilterTrilinear + imageView.layer.shadowColor = UIColor.black.cgColor + let shadowScaling = 5.0 + imageView.layer.shadowRadius = CGFloat(2.0 * shadowScaling) + imageView.layer.shadowOpacity = 0.25 + imageView.layer.shadowOffset = CGSize(width: 0.75 * shadowScaling, height: 0.75 * shadowScaling) imageView.autoSetDimension(.width, toSize:imageSize) imageView.autoSetDimension(.height, toSize:imageSize) diff --git a/Signal/src/ViewControllers/SelectThreadViewController.h b/Signal/src/ViewControllers/SelectThreadViewController.h index b09abf4c4..f420843c0 100644 --- a/Signal/src/ViewControllers/SelectThreadViewController.h +++ b/Signal/src/ViewControllers/SelectThreadViewController.h @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN - (BOOL)canSelectBlockedContact; -- (nullable UIView *)createHeader:(UIView *)superview; +- (nullable UIView *)createHeaderWithSearchBar:(UISearchBar *)searchBar; @end diff --git a/Signal/src/ViewControllers/SelectThreadViewController.m b/Signal/src/ViewControllers/SelectThreadViewController.m index 0230aa8b3..807346731 100644 --- a/Signal/src/ViewControllers/SelectThreadViewController.m +++ b/Signal/src/ViewControllers/SelectThreadViewController.m @@ -92,7 +92,16 @@ NS_ASSUME_NONNULL_BEGIN { OWSAssert(self.delegate); - UIView *header = [self.delegate createHeader:self.view]; + // Search + UISearchBar *searchBar = [UISearchBar new]; + _searchBar = searchBar; + searchBar.searchBarStyle = UISearchBarStyleMinimal; + searchBar.delegate = self; + searchBar.placeholder = NSLocalizedString(@"SEARCH_BYNAMEORNUMBER_PLACEHOLDER_TEXT", @""); + searchBar.backgroundColor = [UIColor whiteColor]; + [searchBar sizeToFit]; + + UIView *header = [self.delegate createHeaderWithSearchBar:searchBar]; // Table _tableViewController = [OWSTableViewController new]; @@ -100,21 +109,13 @@ NS_ASSUME_NONNULL_BEGIN _tableViewController.contents = [OWSTableContents new]; [self.view addSubview:self.tableViewController.view]; [_tableViewController.view autoPinWidthToSuperview]; + [_tableViewController.view autoPinToTopLayoutGuideOfViewController:self withInset:0]; if (header) { - [_tableViewController.view autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:header]; + _tableViewController.tableView.tableHeaderView = header; } else { - [_tableViewController.view autoPinToTopLayoutGuideOfViewController:self withInset:0]; + _tableViewController.tableView.tableHeaderView = searchBar; } [_tableViewController.view autoPinEdgeToSuperviewEdge:ALEdgeBottom]; - - // Search - UISearchBar *searchBar = [UISearchBar new]; - _searchBar = searchBar; - searchBar.searchBarStyle = UISearchBarStyleProminent; - searchBar.delegate = self; - searchBar.placeholder = NSLocalizedString(@"SEARCH_BYNAMEORNUMBER_PLACEHOLDER_TEXT", @""); - [searchBar sizeToFit]; - _tableViewController.tableView.tableHeaderView = searchBar; } #pragma mark - UISearchBarDelegate diff --git a/Signal/src/ViewControllers/SendExternalFileViewController.m b/Signal/src/ViewControllers/SendExternalFileViewController.m index bbcac0a93..1c46aee18 100644 --- a/Signal/src/ViewControllers/SendExternalFileViewController.m +++ b/Signal/src/ViewControllers/SendExternalFileViewController.m @@ -57,22 +57,21 @@ NS_ASSUME_NONNULL_BEGIN return NO; } -- (nullable UIView *)createHeader:(UIView *)superview +- (nullable UIView *)createHeaderWithSearchBar:(UISearchBar *)searchBar { - OWSAssert(superview) + OWSAssert(searchBar) const CGFloat imageSize - = ScaleFromIPhone5To7Plus(40, 40); - const CGFloat imageLabelSpacing = ScaleFromIPhone5To7Plus(5, 5); - const CGFloat titleVSpacing = ScaleFromIPhone5To7Plus(10, 10); + = ScaleFromIPhone5To7Plus(40, 50); + const CGFloat imageLabelSpacing = ScaleFromIPhone5To7Plus(5, 8); + const CGFloat titleVSpacing = ScaleFromIPhone5To7Plus(10, 15); const CGFloat contentVMargin = ScaleFromIPhone5To7Plus(20, 20); UIView *header = [UIView new]; - [superview addSubview:header]; - [header autoPinWidthToSuperview]; - [header autoPinToTopLayoutGuideOfViewController:self withInset:0]; + header.backgroundColor = [UIColor whiteColor]; UIView *titleLabel = [self createTitleLabel]; + [titleLabel sizeToFit]; [header addSubview:titleLabel]; [titleLabel autoHCenterInSuperview]; [titleLabel autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:contentVMargin]; @@ -80,14 +79,17 @@ NS_ASSUME_NONNULL_BEGIN UIView *fileView = [UIView new]; [header addSubview:fileView]; [fileView autoHCenterInSuperview]; - [fileView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:contentVMargin]; [fileView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:titleLabel withOffset:titleVSpacing]; - UIImage *image = [UIImage imageNamed:@"file-thin-black-large"]; + UIImage *image = [UIImage imageNamed:@"file-thin-black-filled-large"]; OWSAssert(image); UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; imageView.layer.minificationFilter = kCAFilterTrilinear; imageView.layer.magnificationFilter = kCAFilterTrilinear; + imageView.layer.shadowColor = [UIColor blackColor].CGColor; + imageView.layer.shadowRadius = 2.f; + imageView.layer.shadowOpacity = 0.2f; + imageView.layer.shadowOffset = CGSizeMake(0.75f, 0.75f); [fileView addSubview:imageView]; [imageView autoSetDimension:ALDimensionWidth toSize:imageSize]; [imageView autoSetDimension:ALDimensionHeight toSize:imageSize]; @@ -101,6 +103,17 @@ NS_ASSUME_NONNULL_BEGIN [fileNameLabel autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:imageView withOffset:imageLabelSpacing]; [fileNameLabel autoPinEdgeToSuperviewEdge:ALEdgeRight]; + [header addSubview:searchBar]; + [searchBar autoPinWidthToSuperview]; + [searchBar autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:fileView withOffset:contentVMargin]; + [searchBar autoPinEdgeToSuperviewEdge:ALEdgeBottom]; + + // UITableViewController.tableHeaderView must have its height set. + header.frame = CGRectMake(0, + 0, + 0, + (contentVMargin * 2 + titleLabel.frame.size.height + titleVSpacing + imageSize + searchBar.frame.size.height)); + return header; } @@ -125,7 +138,7 @@ NS_ASSUME_NONNULL_BEGIN UILabel *label = [UILabel new]; label.text = [self formattedFileName]; label.textColor = [UIColor ows_materialBlueColor]; - label.font = [UIFont ows_regularFontWithSize:16.f]; + label.font = [UIFont ows_regularFontWithSize:ScaleFromIPhone5To7Plus(16.f, 20.f)]; label.lineBreakMode = NSLineBreakByTruncatingMiddle; return label; } @@ -137,7 +150,7 @@ NS_ASSUME_NONNULL_BEGIN label.text = NSLocalizedString(@"SEND_EXTERNAL_FILE_HEADER_TITLE", @"Header title for the 'send external file' view."); label.textColor = [UIColor blackColor]; - label.font = [UIFont ows_mediumFontWithSize:18.f]; + label.font = [UIFont ows_mediumFontWithSize:ScaleFromIPhone5To7Plus(18.f, 20.f)]; return label; } diff --git a/Signal/src/ViewControllers/SignalAttachment.swift b/Signal/src/ViewControllers/SignalAttachment.swift index 584948a0b..76e89810c 100644 --- a/Signal/src/ViewControllers/SignalAttachment.swift +++ b/Signal/src/ViewControllers/SignalAttachment.swift @@ -12,6 +12,7 @@ enum SignalAttachmentError: Error { case couldNotParseImage case couldNotConvertToJpeg case invalidFileFormat + case unknownType } extension SignalAttachmentError: LocalizedError { @@ -29,6 +30,8 @@ extension SignalAttachmentError: LocalizedError { return NSLocalizedString("ATTACHMENT_ERROR_COULD_NOT_CONVERT_TO_JPEG", comment: "Attachment error message for image attachments which could not be converted to JPEG") case .invalidFileFormat: return NSLocalizedString("ATTACHMENT_ERROR_INVALID_FILE_FORMAT", comment: "Attachment error message for attachments with an invalid file format") + case .unknownType: + return NSLocalizedString("ATTACHMENT_ERROR_UNKNOWN_TYPE", comment: "Attachment error message for attachments with an invalid file format") } } } @@ -111,6 +114,10 @@ class SignalAttachment: NSObject { self.dataUTI = dataUTI self.filename = filename super.init() + + if self.mimeType == nil { + error = .unknownType + } } // MARK: Methods diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 954f72407..5b985982d 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -94,6 +94,9 @@ /* Attachment error message for attachments without any data */ "ATTACHMENT_ERROR_MISSING_DATA" = "Attachment is empty."; +/* Attachment error message for attachments with an invalid file format */ +"ATTACHMENT_ERROR_UNKNOWN_TYPE" = "Attachment is of invalid type"; + /* Accessibility hint describing what you can do with the attachment button */ "ATTACHMENT_HINT" = "Choose or take a picture and then send it";