Merge branch 'charlesmchen/tweakVerificationUI'
This commit is contained in:
commit
d01412ae9c
23
Signal/Images.xcassets/banner_close.imageset/Contents.json
vendored
Normal file
23
Signal/Images.xcassets/banner_close.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "banner_close@1x.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "banner_close@2x.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "banner_close@3x.png",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
BIN
Signal/Images.xcassets/banner_close.imageset/banner_close@1x.png
vendored
Normal file
BIN
Signal/Images.xcassets/banner_close.imageset/banner_close@1x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
BIN
Signal/Images.xcassets/banner_close.imageset/banner_close@2x.png
vendored
Normal file
BIN
Signal/Images.xcassets/banner_close.imageset/banner_close@2x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
BIN
Signal/Images.xcassets/banner_close.imageset/banner_close@3x.png
vendored
Normal file
BIN
Signal/Images.xcassets/banner_close.imageset/banner_close@3x.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
@ -675,6 +675,19 @@ typedef enum : NSUInteger {
|
||||
[self ensureBannerState];
|
||||
}
|
||||
|
||||
// Returns a collection of the group members who are "no longer verified".
|
||||
- (NSArray<NSString *> *)noLongerVerifiedRecipientIds
|
||||
{
|
||||
NSMutableArray<NSString *> *result = [NSMutableArray new];
|
||||
for (NSString *recipientId in self.thread.recipientIdentifiers) {
|
||||
if ([[OWSIdentityManager sharedManager] verificationStateForRecipientId:recipientId]
|
||||
== OWSVerificationStateNoLongerVerified) {
|
||||
[result addObject:recipientId];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void)ensureBannerState
|
||||
{
|
||||
// This method should be called rarely, so it's simplest to discard and
|
||||
@ -686,14 +699,8 @@ typedef enum : NSUInteger {
|
||||
return;
|
||||
}
|
||||
|
||||
// A collection of the group members who are "no longer verified".
|
||||
NSMutableArray<NSString *> *noLongerVerifiedRecipientIds = [NSMutableArray new];
|
||||
for (NSString *recipientId in self.thread.recipientIdentifiers) {
|
||||
if ([[OWSIdentityManager sharedManager] verificationStateForRecipientId:recipientId]
|
||||
== OWSVerificationStateNoLongerVerified) {
|
||||
[noLongerVerifiedRecipientIds addObject:recipientId];
|
||||
}
|
||||
}
|
||||
NSArray<NSString *> *noLongerVerifiedRecipientIds = [self noLongerVerifiedRecipientIds];
|
||||
|
||||
if (noLongerVerifiedRecipientIds.count > 0) {
|
||||
NSString *message;
|
||||
if (noLongerVerifiedRecipientIds.count > 1) {
|
||||
@ -748,14 +755,6 @@ typedef enum : NSUInteger {
|
||||
OWSAssert(title.length > 0);
|
||||
OWSAssert(bannerColor);
|
||||
|
||||
UILabel *label = [UILabel new];
|
||||
label.font = [UIFont ows_mediumFontWithSize:14.f];
|
||||
label.text = title;
|
||||
label.textColor = [UIColor whiteColor];
|
||||
label.numberOfLines = 0;
|
||||
label.lineBreakMode = NSLineBreakByWordWrapping;
|
||||
label.textAlignment = NSTextAlignmentCenter;
|
||||
|
||||
UIView *bannerView = [UIView new];
|
||||
bannerView.backgroundColor = bannerColor;
|
||||
bannerView.layer.cornerRadius = 2.5f;
|
||||
@ -766,12 +765,30 @@ typedef enum : NSUInteger {
|
||||
bannerView.layer.shadowRadius = 2.f;
|
||||
bannerView.layer.shadowOpacity = 0.35f;
|
||||
|
||||
UILabel *label = [UILabel new];
|
||||
label.font = [UIFont ows_mediumFontWithSize:14.f];
|
||||
label.text = title;
|
||||
label.textColor = [UIColor whiteColor];
|
||||
label.numberOfLines = 0;
|
||||
label.lineBreakMode = NSLineBreakByWordWrapping;
|
||||
label.textAlignment = NSTextAlignmentCenter;
|
||||
|
||||
UIImage *closeIcon = [UIImage imageNamed:@"banner_close"];
|
||||
UIImageView *closeButton = [[UIImageView alloc] initWithImage:closeIcon];
|
||||
[bannerView addSubview:closeButton];
|
||||
const CGFloat kBannerCloseButtonPadding = 8.f;
|
||||
[closeButton autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:kBannerCloseButtonPadding];
|
||||
[closeButton autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:kBannerCloseButtonPadding];
|
||||
[closeButton autoSetDimension:ALDimensionWidth toSize:closeIcon.size.width];
|
||||
[closeButton autoSetDimension:ALDimensionHeight toSize:closeIcon.size.height];
|
||||
|
||||
[bannerView addSubview:label];
|
||||
[label autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:5];
|
||||
[label autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:5];
|
||||
const CGFloat kBannerHPadding = 15.f;
|
||||
[label autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:kBannerHPadding];
|
||||
[label autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:kBannerHPadding];
|
||||
const CGFloat kBannerHSpacing = 10.f;
|
||||
[label autoPinEdge:ALEdgeRight toEdge:ALEdgeLeft ofView:closeButton withOffset:-kBannerHSpacing];
|
||||
|
||||
[bannerView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:tapSelector]];
|
||||
|
||||
@ -780,7 +797,8 @@ typedef enum : NSUInteger {
|
||||
[bannerView autoHCenterInSuperview];
|
||||
|
||||
CGFloat labelDesiredWidth = [label sizeThatFits:CGSizeZero].width;
|
||||
CGFloat bannerDesiredWidth = labelDesiredWidth + kBannerHPadding * 2.f;
|
||||
CGFloat bannerDesiredWidth
|
||||
= (labelDesiredWidth + kBannerHPadding + kBannerHSpacing + closeIcon.size.width + kBannerCloseButtonPadding);
|
||||
const CGFloat kMinBannerHMargin = 20.f;
|
||||
if (bannerDesiredWidth + kMinBannerHMargin * 2.f >= self.view.width) {
|
||||
[bannerView autoPinWidthToSuperviewWithMargin:kMinBannerHMargin];
|
||||
@ -814,7 +832,57 @@ typedef enum : NSUInteger {
|
||||
- (void)noLongerVerifiedBannerViewWasTapped:(UIGestureRecognizer *)sender
|
||||
{
|
||||
if (sender.state == UIGestureRecognizerStateRecognized) {
|
||||
[self showConversationSettingsAndShowVerification:YES];
|
||||
UIAlertController *actionSheetController =
|
||||
[UIAlertController alertControllerWithTitle:nil
|
||||
message:nil
|
||||
preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
|
||||
__weak MessagesViewController *weakSelf = self;
|
||||
UIAlertAction *unblockAction = [UIAlertAction
|
||||
actionWithTitle:
|
||||
NSLocalizedString(@"VERIFY_PRIVACY",
|
||||
@"Label for button or row which allows users to verify the safety number of another user.")
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction *_Nonnull action) {
|
||||
[weakSelf showConversationSettingsAndShowVerification:YES];
|
||||
}];
|
||||
[actionSheetController addAction:unblockAction];
|
||||
|
||||
UIAlertAction *dismissAction =
|
||||
[UIAlertAction actionWithTitle:NSLocalizedString(@"DISMISS_BUTTON_TEXT",
|
||||
@"Generic short text for button to dismiss a dialog")
|
||||
style:UIAlertActionStyleCancel
|
||||
handler:^(UIAlertAction *_Nonnull action) {
|
||||
[weakSelf resetVerificationStateToDefault];
|
||||
}];
|
||||
[actionSheetController addAction:dismissAction];
|
||||
|
||||
[self presentViewController:actionSheetController animated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)resetVerificationStateToDefault
|
||||
{
|
||||
OWSAssert([NSThread isMainThread]);
|
||||
|
||||
NSArray<NSString *> *noLongerVerifiedRecipientIds = [self noLongerVerifiedRecipientIds];
|
||||
for (NSString *recipientId in noLongerVerifiedRecipientIds) {
|
||||
OWSAssert(recipientId.length > 0);
|
||||
|
||||
OWSRecipientIdentity *_Nullable recipientIdentity =
|
||||
[[OWSIdentityManager sharedManager] recipientIdentityForRecipientId:recipientId];
|
||||
OWSAssert(recipientIdentity);
|
||||
|
||||
NSData *identityKey = recipientIdentity.identityKey;
|
||||
OWSAssert(identityKey.length > 0);
|
||||
if (identityKey.length < 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
[OWSIdentityManager.sharedManager setVerificationState:OWSVerificationStateDefault
|
||||
identityKey:identityKey
|
||||
recipientId:recipientId
|
||||
sendSyncMessage:YES];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -240,16 +240,12 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
firstSection.customHeaderHeight = @(100.f);
|
||||
|
||||
if (!self.isGroupThread && self.thread.hasSafetyNumbers) {
|
||||
NSString *recipientId = self.thread.contactIdentifier;
|
||||
BOOL isVerified = [[OWSIdentityManager sharedManager] verificationStateForRecipientId:recipientId]
|
||||
== OWSVerificationStateVerified;
|
||||
|
||||
[firstSection addItem:[OWSTableItem itemWithCustomCellBlock:^{
|
||||
return [weakSelf
|
||||
disclosureCellWithName:
|
||||
NSLocalizedString(@"VERIFY_PRIVACY",
|
||||
@"Label for button or row which allows users to verify the safety number of another user.")
|
||||
iconName:(isVerified ? @"table_ic_verify" : @"table_ic_not_verified")];
|
||||
iconName:@"table_ic_not_verified"];
|
||||
}
|
||||
actionBlock:^{
|
||||
[weakSelf showVerificationView];
|
||||
|
||||
@ -722,13 +722,13 @@
|
||||
"MESSAGE_STATUS_UPLOADING" = "Uploading…";
|
||||
|
||||
/* Indicates that one member of this group conversation is no longer verified. Embeds {{user's name or phone number}}. */
|
||||
"MESSAGES_VIEW_1_MEMBER_NO_LONGER_VERIFIED_FORMAT" = "%@ is no longer verified.";
|
||||
"MESSAGES_VIEW_1_MEMBER_NO_LONGER_VERIFIED_FORMAT" = "%@ is no longer verified. Tap for options.";
|
||||
|
||||
/* Indicates that this 1:1 conversation has been blocked. */
|
||||
"MESSAGES_VIEW_CONTACT_BLOCKED" = "You Blocked this User";
|
||||
|
||||
/* Indicates that this 1:1 conversation is no longer verified. Embeds {{user's name or phone number}}. */
|
||||
"MESSAGES_VIEW_CONTACT_NO_LONGER_VERIFIED_FORMAT" = "%@ is no longer verified.";
|
||||
"MESSAGES_VIEW_CONTACT_NO_LONGER_VERIFIED_FORMAT" = "%@ is no longer verified. Tap for options.";
|
||||
|
||||
/* Action sheet title after tapping on failed download. */
|
||||
"MESSAGES_VIEW_FAILED_DOWNLOAD_ACTIONSHEET_TITLE" = "Download Failed.";
|
||||
@ -743,7 +743,7 @@
|
||||
"MESSAGES_VIEW_GROUP_N_MEMBERS_BLOCKED_FORMAT" = "You Blocked %d Members of this Group";
|
||||
|
||||
/* Indicates that more than one member of this group conversation is no longer verified. */
|
||||
"MESSAGES_VIEW_N_MEMBERS_NO_LONGER_VERIFIED" = "More than one member of this group is no longer verified.";
|
||||
"MESSAGES_VIEW_N_MEMBERS_NO_LONGER_VERIFIED" = "More than one member of this group is no longer verified. Tap for options.";
|
||||
|
||||
/* The subtitle for the messages view title indicates that the title can be tapped to access settings for this conversation. */
|
||||
"MESSAGES_VIEW_TITLE_SUBTITLE" = "Tap here for settings";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user