Respond to CR.

// FREEBIE
pull/1/head
Matthew Chen 7 years ago
parent 253776d65c
commit 71007cc3d1

@ -479,7 +479,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Disappearing Messages" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="qbY-qJ-enK" userLabel="Disappearing Messages">
<rect key="frame" x="68" y="0.0" width="234" height="44"/>
<rect key="frame" x="64" y="0.0" width="238" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="dT5-gx-pqJ"/>
</constraints>
@ -497,7 +497,7 @@
</connections>
</switch>
<imageView opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="table_ic_timer" translatesAutoresizingMaskIntoConstraints="NO" id="iRL-ZI-kXA">
<rect key="frame" x="20" y="6" width="32" height="32"/>
<rect key="frame" x="16" y="6" width="32" height="32"/>
<color key="tintColor" red="0.054901960780000002" green="0.054901960780000002" blue="0.054901960780000002" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="iRL-ZI-kXA" secondAttribute="height" multiplier="1:1" id="QMF-qg-bIc"/>
@ -505,14 +505,14 @@
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="When enabled, messages sent and received in this conversation will disappear after they have been seen." textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="zIg-K4-8lV">
<rect key="frame" x="68" y="40" width="283" height="59"/>
<rect key="frame" x="64" y="40" width="287" height="59"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="iRL-ZI-kXA" firstAttribute="leading" secondItem="Nmz-2u-fOY" secondAttribute="leading" constant="20" id="FsM-rL-dWt"/>
<constraint firstItem="iRL-ZI-kXA" firstAttribute="leading" secondItem="Nmz-2u-fOY" secondAttribute="leading" constant="16" id="FsM-rL-dWt"/>
<constraint firstItem="qbY-qJ-enK" firstAttribute="top" secondItem="Nmz-2u-fOY" secondAttribute="top" id="Hzt-Rw-yQA"/>
<constraint firstItem="zIg-K4-8lV" firstAttribute="top" secondItem="qbY-qJ-enK" secondAttribute="bottom" constant="-4" id="NGz-Yy-9uN"/>
<constraint firstItem="zIg-K4-8lV" firstAttribute="leading" secondItem="qbY-qJ-enK" secondAttribute="leading" id="PYG-46-cLa"/>
@ -535,13 +535,13 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Messages disappear after 8 hours." lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="c6Q-rV-1LO" userLabel="Keep messages for 8 hours.">
<rect key="frame" x="68" y="6" width="299" height="32"/>
<rect key="frame" x="64" y="6" width="303" height="32"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleFootnote"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" value="0.5" minValue="0.0" maxValue="1" translatesAutoresizingMaskIntoConstraints="NO" id="4Hn-9p-qsR">
<rect key="frame" x="66" y="38" width="291" height="31"/>
<rect key="frame" x="62" y="38" width="295" height="31"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="D1q-zH-wtT"/>
</constraints>
@ -550,7 +550,7 @@
</connections>
</slider>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="table_ic_hourglass_empty" translatesAutoresizingMaskIntoConstraints="NO" id="X7n-1t-1Q7">
<rect key="frame" x="20" y="6" width="32" height="32"/>
<rect key="frame" x="16" y="6" width="32" height="32"/>
<color key="tintColor" red="0.054901960784313725" green="0.054901960784313725" blue="0.054901960784313725" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="32" id="Pmb-2B-dEA"/>
@ -566,7 +566,7 @@
<constraint firstItem="c6Q-rV-1LO" firstAttribute="bottom" secondItem="X7n-1t-1Q7" secondAttribute="bottom" id="WOE-pQ-2zh"/>
<constraint firstItem="c6Q-rV-1LO" firstAttribute="leading" secondItem="X7n-1t-1Q7" secondAttribute="trailing" constant="16" id="itv-VA-m3d"/>
<constraint firstItem="c6Q-rV-1LO" firstAttribute="top" secondItem="X7n-1t-1Q7" secondAttribute="top" id="oa2-QP-Lhu"/>
<constraint firstItem="X7n-1t-1Q7" firstAttribute="leading" secondItem="2a2-Po-p8O" secondAttribute="leading" constant="20" id="qNh-GB-pE2"/>
<constraint firstItem="X7n-1t-1Q7" firstAttribute="leading" secondItem="2a2-Po-p8O" secondAttribute="leading" constant="16" id="qNh-GB-pE2"/>
<constraint firstItem="4Hn-9p-qsR" firstAttribute="top" secondItem="c6Q-rV-1LO" secondAttribute="bottom" id="ssH-ql-B0K"/>
</constraints>
</tableViewCellContentView>

@ -281,7 +281,7 @@ NSString *const kContactsTable_CellReuseIdentifier = @"kContactsTable_CellReuseI
contactsManager:_contactsManager
completionBlock:^(BOOL isBlocked) {
if (isBlocked) {
// Clear phone number text field is block succeeds.
// Clear phone number text field if block succeeds.
weakSelf.phoneNumberTextField.text = nil;
[weakSelf.navigationController popViewControllerAnimated:YES];
}

@ -4,6 +4,8 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class Contact;
@class OWSBlockingManager;
@class OWSContactsManager;
@ -18,18 +20,20 @@ typedef void (^BlockActionCompletionBlock)(BOOL isBlocked);
fromViewController:(UIViewController *)fromViewController
blockingManager:(OWSBlockingManager *)blockingManager
contactsManager:(OWSContactsManager *)contactsManager
completionBlock:(BlockActionCompletionBlock)completionBlock;
completionBlock:(nullable BlockActionCompletionBlock)completionBlock;
+ (void)showBlockPhoneNumberActionSheet:(NSString *)phoneNumber
fromViewController:(UIViewController *)fromViewController
blockingManager:(OWSBlockingManager *)blockingManager
contactsManager:(OWSContactsManager *)contactsManager
completionBlock:(BlockActionCompletionBlock)completionBlock;
completionBlock:(nullable BlockActionCompletionBlock)completionBlock;
+ (void)showUnblockPhoneNumberActionSheet:(NSString *)phoneNumber
fromViewController:(UIViewController *)fromViewController
blockingManager:(OWSBlockingManager *)blockingManager
contactsManager:(OWSContactsManager *)contactsManager
completionBlock:(BlockActionCompletionBlock)completionBlock;
completionBlock:(nullable BlockActionCompletionBlock)completionBlock;
@end
NS_ASSUME_NONNULL_END

@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
fromViewController:(UIViewController *)fromViewController
blockingManager:(OWSBlockingManager *)blockingManager
contactsManager:(OWSContactsManager *)contactsManager
completionBlock:(BlockActionCompletionBlock)completionBlock
completionBlock:(nullable BlockActionCompletionBlock)completionBlock
{
NSMutableArray<NSString *> *phoneNumbers = [NSMutableArray new];
for (PhoneNumber *phoneNumber in contact.parsedPhoneNumbers) {
@ -25,6 +25,8 @@ NS_ASSUME_NONNULL_BEGIN
}
}
if (phoneNumbers.count < 1) {
DDLogError(@"%@ Contact has no phone numbers", self.tag);
OWSAssert(0);
[self showBlockFailedAlert:fromViewController];
if (completionBlock) {
completionBlock(NO);
@ -43,7 +45,7 @@ NS_ASSUME_NONNULL_BEGIN
fromViewController:(UIViewController *)fromViewController
blockingManager:(OWSBlockingManager *)blockingManager
contactsManager:(OWSContactsManager *)contactsManager
completionBlock:(BlockActionCompletionBlock)completionBlock
completionBlock:(nullable BlockActionCompletionBlock)completionBlock
{
NSString *displayName = [contactsManager displayNameForPhoneIdentifier:phoneNumber];
[self showBlockPhoneNumbersActionSheet:@[ phoneNumber ]
@ -57,7 +59,7 @@ NS_ASSUME_NONNULL_BEGIN
displayName:(NSString *)displayName
fromViewController:(UIViewController *)fromViewController
blockingManager:(OWSBlockingManager *)blockingManager
completionBlock:(BlockActionCompletionBlock)completionBlock
completionBlock:(nullable BlockActionCompletionBlock)completionBlock
{
OWSAssert(phoneNumbers.count > 0);
OWSAssert(displayName.length > 0);
@ -67,7 +69,7 @@ NS_ASSUME_NONNULL_BEGIN
NSString *title = [NSString stringWithFormat:NSLocalizedString(@"BLOCK_LIST_BLOCK_TITLE_FORMAT",
@"A format for the 'block user' action sheet title. Embeds {{the "
@"blocked user's name or phone number}}."),
displayName];
[self formatDisplayNameForAlertTitle:displayName]];
UIAlertController *actionSheetController =
[UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleActionSheet];
@ -119,7 +121,7 @@ NS_ASSUME_NONNULL_BEGIN
stringWithFormat:NSLocalizedString(@"BLOCK_LIST_VIEW_BLOCKED_ALERT_MESSAGE_FORMAT",
@"The message format of the 'user blocked' "
@"alert. Embeds {{the blocked user's name or phone number}}."),
displayName]
[self formatDisplayNameForAlertMessage:displayName]]
fromViewController:fromViewController];
}
@ -127,18 +129,19 @@ NS_ASSUME_NONNULL_BEGIN
fromViewController:(UIViewController *)fromViewController
blockingManager:(OWSBlockingManager *)blockingManager
contactsManager:(OWSContactsManager *)contactsManager
completionBlock:(BlockActionCompletionBlock)completionBlock
completionBlock:(nullable BlockActionCompletionBlock)completionBlock
{
OWSAssert(phoneNumber.length > 0);
OWSAssert(fromViewController);
OWSAssert(blockingManager);
OWSAssert(contactsManager);
NSString *displayName = [contactsManager displayNameForPhoneIdentifier:phoneNumber];
NSString *title = [NSString stringWithFormat:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_TITLE_FORMAT",
@"A format for the 'unblock user' action sheet title. Embeds "
@"{{the blocked user's name or phone number}}."),
displayName];
[self formatDisplayNameForAlertTitle:displayName]];
UIAlertController *actionSheetController =
[UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleActionSheet];
@ -187,7 +190,7 @@ NS_ASSUME_NONNULL_BEGIN
stringWithFormat:NSLocalizedString(@"BLOCK_LIST_VIEW_UNBLOCKED_ALERT_MESSAGE_FORMAT",
@"The message format of the 'user unblocked' "
@"alert. Embeds {{the blocked user's name or phone number}}."),
displayName]
[self formatDisplayNameForAlertMessage:displayName]]
fromViewController:fromViewController];
}
@ -230,6 +233,27 @@ NS_ASSUME_NONNULL_BEGIN
[fromViewController presentViewController:controller animated:YES completion:nil];
}
+ (NSString *)formatDisplayNameForAlertTitle:(NSString *)displayName
{
return [self formatDisplayName:displayName withMaxLength:20];
}
+ (NSString *)formatDisplayNameForAlertMessage:(NSString *)displayName
{
return [self formatDisplayName:displayName withMaxLength:127];
}
+ (NSString *)formatDisplayName:(NSString *)displayName withMaxLength:(NSUInteger)maxLength
{
OWSAssert(displayName.length > 0);
if (displayName.length > maxLength) {
return [[displayName substringToIndex:maxLength] stringByAppendingString:@"…"];
}
return displayName;
}
#pragma mark - Logging
+ (NSString *)tag

@ -159,7 +159,6 @@ typedef NS_ENUM(NSInteger, BlockListViewControllerSection) {
[BlockListUIUtils showUnblockPhoneNumberActionSheet:phoneNumber
fromViewController:self
blockingManager:_blockingManager
contactsManager:_contactsManager
completionBlock:nil];
break;

@ -426,6 +426,7 @@ static NSString *const OWSConversationSettingsTableViewControllerSegueShowGroupM
if (![sender isKindOfClass:[UISwitch class]]) {
DDLogError(@"%@ Unexpected sender for block user switch: %@", self.tag, sender);
OWSAssert(0);
}
UISwitch *blockUserSwitch = (UISwitch *)sender;

@ -41,18 +41,18 @@ typedef UITableViewCell * (^OWSTableCustomCellBlock)();
@interface OWSTableItem : NSObject
+ (OWSTableItem *)itemWithTitle:(NSString *)title actionBlock:(OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)itemWithTitle:(NSString *)title actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)itemWithCustomCell:(UITableViewCell *)customCell
customRowHeight:(CGFloat)customRowHeight
actionBlock:(OWSTableActionBlock)actionBlock;
actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)itemWithCustomCellBlock:(OWSTableCustomCellBlock)customCellBlock
customRowHeight:(CGFloat)customRowHeight
actionBlock:(OWSTableActionBlock)actionBlock;
actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)itemWithCustomCellBlock:(OWSTableCustomCellBlock)customCellBlock
actionBlock:(OWSTableActionBlock)actionBlock;
actionBlock:(nullable OWSTableActionBlock)actionBlock;
- (UITableViewCell *)customCell;
- (NSNumber *)customRowHeight;

@ -88,7 +88,7 @@ NS_ASSUME_NONNULL_BEGIN
@implementation OWSTableItem
+ (OWSTableItem *)itemWithTitle:(NSString *)title actionBlock:(OWSTableActionBlock)actionBlock
+ (OWSTableItem *)itemWithTitle:(NSString *)title actionBlock:(nullable OWSTableActionBlock)actionBlock
{
OWSAssert(title.length > 0);
@ -101,7 +101,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (OWSTableItem *)itemWithCustomCell:(UITableViewCell *)customCell
customRowHeight:(CGFloat)customRowHeight
actionBlock:(OWSTableActionBlock)actionBlock
actionBlock:(nullable OWSTableActionBlock)actionBlock
{
OWSAssert(customCell);
OWSAssert(customRowHeight > 0);
@ -116,7 +116,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (OWSTableItem *)itemWithCustomCellBlock:(OWSTableCustomCellBlock)customCellBlock
customRowHeight:(CGFloat)customRowHeight
actionBlock:(OWSTableActionBlock)actionBlock
actionBlock:(nullable OWSTableActionBlock)actionBlock
{
OWSAssert(customCellBlock);
OWSAssert(customRowHeight > 0);
@ -130,7 +130,7 @@ NS_ASSUME_NONNULL_BEGIN
}
+ (OWSTableItem *)itemWithCustomCellBlock:(OWSTableCustomCellBlock)customCellBlock
actionBlock:(OWSTableActionBlock)actionBlock
actionBlock:(nullable OWSTableActionBlock)actionBlock
{
OWSAssert(customCellBlock);

Loading…
Cancel
Save