Add “share profile” row to conversation settings.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-08-01 16:16:33 -04:00
parent 1c1e173c58
commit 282ac4bb29
9 changed files with 156 additions and 24 deletions

View File

@ -58,7 +58,7 @@
34B3F8861E8DF1700035BE1A /* NotificationSettingsOptionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F8571E8DF1700035BE1A /* NotificationSettingsOptionsViewController.m */; };
34B3F8871E8DF1700035BE1A /* NotificationSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F8591E8DF1700035BE1A /* NotificationSettingsViewController.m */; };
34B3F8881E8DF1700035BE1A /* OversizeTextMessageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F85A1E8DF1700035BE1A /* OversizeTextMessageViewController.swift */; };
34B3F8891E8DF1700035BE1A /* OWSConversationSettingsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F85C1E8DF1700035BE1A /* OWSConversationSettingsTableViewController.m */; };
34B3F8891E8DF1700035BE1A /* OWSConversationSettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F85C1E8DF1700035BE1A /* OWSConversationSettingsViewController.m */; };
34B3F88A1E8DF1700035BE1A /* OWSLinkDeviceViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F85E1E8DF1700035BE1A /* OWSLinkDeviceViewController.m */; };
34B3F88B1E8DF1700035BE1A /* OWSLinkedDevicesTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F8601E8DF1700035BE1A /* OWSLinkedDevicesTableViewController.m */; };
34B3F88C1E8DF1700035BE1A /* OWSMessagesToolbarContentView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34B3F8611E8DF1700035BE1A /* OWSMessagesToolbarContentView.xib */; };
@ -471,8 +471,8 @@
34B3F8581E8DF1700035BE1A /* NotificationSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotificationSettingsViewController.h; sourceTree = "<group>"; };
34B3F8591E8DF1700035BE1A /* NotificationSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NotificationSettingsViewController.m; sourceTree = "<group>"; };
34B3F85A1E8DF1700035BE1A /* OversizeTextMessageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OversizeTextMessageViewController.swift; sourceTree = "<group>"; };
34B3F85B1E8DF1700035BE1A /* OWSConversationSettingsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSConversationSettingsTableViewController.h; sourceTree = "<group>"; };
34B3F85C1E8DF1700035BE1A /* OWSConversationSettingsTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSConversationSettingsTableViewController.m; sourceTree = "<group>"; };
34B3F85B1E8DF1700035BE1A /* OWSConversationSettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSConversationSettingsViewController.h; sourceTree = "<group>"; };
34B3F85C1E8DF1700035BE1A /* OWSConversationSettingsViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSConversationSettingsViewController.m; sourceTree = "<group>"; };
34B3F85D1E8DF1700035BE1A /* OWSLinkDeviceViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSLinkDeviceViewController.h; sourceTree = "<group>"; };
34B3F85E1E8DF1700035BE1A /* OWSLinkDeviceViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSLinkDeviceViewController.m; sourceTree = "<group>"; };
34B3F85F1E8DF1700035BE1A /* OWSLinkedDevicesTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSLinkedDevicesTableViewController.h; sourceTree = "<group>"; };
@ -1004,8 +1004,8 @@
34CCAF3A1F0C2748004084F4 /* OWSAddToContactViewController.m */,
34533F161EA8D2070006114F /* OWSAudioAttachmentPlayer.h */,
34533F171EA8D2070006114F /* OWSAudioAttachmentPlayer.m */,
34B3F85B1E8DF1700035BE1A /* OWSConversationSettingsTableViewController.h */,
34B3F85C1E8DF1700035BE1A /* OWSConversationSettingsTableViewController.m */,
34B3F85B1E8DF1700035BE1A /* OWSConversationSettingsViewController.h */,
34B3F85C1E8DF1700035BE1A /* OWSConversationSettingsViewController.m */,
34D5CCAB1EAE7136005515DB /* OWSConversationSettingsViewDelegate.h */,
3497DBEA1ECE257500DB2605 /* OWSCountryMetadata.h */,
3497DBEB1ECE257500DB2605 /* OWSCountryMetadata.m */,
@ -2283,7 +2283,7 @@
4574A5D61DD6704700C6B692 /* CallService.swift in Sources */,
34B3F8721E8DF1700035BE1A /* AdvancedSettingsTableViewController.m in Sources */,
45F170D61E315310003FC1F2 /* Weak.swift in Sources */,
34B3F8891E8DF1700035BE1A /* OWSConversationSettingsTableViewController.m in Sources */,
34B3F8891E8DF1700035BE1A /* OWSConversationSettingsViewController.m in Sources */,
34B3F87E1E8DF1700035BE1A /* InboxTableViewCell.m in Sources */,
34B3F8731E8DF1700035BE1A /* AttachmentApprovalViewController.swift in Sources */,
B6B1013C196D213F007E3930 /* SignalKeyingStorage.m in Sources */,

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "table_ic_share_profile@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "table_ic_share_profile@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "table_ic_share_profile@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -17,7 +17,7 @@
#import "OWSAudioAttachmentPlayer.h"
#import "OWSCall.h"
#import "OWSContactsManager.h"
#import "OWSConversationSettingsTableViewController.h"
#import "OWSConversationSettingsViewController.h"
#import "OWSConversationSettingsViewDelegate.h"
#import "OWSDisappearingMessagesJob.h"
#import "OWSExpirableMessageView.h"
@ -1973,7 +1973,7 @@ typedef enum : NSUInteger {
return;
}
OWSConversationSettingsTableViewController *settingsVC = [OWSConversationSettingsTableViewController new];
OWSConversationSettingsViewController *settingsVC = [OWSConversationSettingsViewController new];
settingsVC.conversationSettingsViewDelegate = self;
[settingsVC configureWithThread:self.thread];
settingsVC.showVerificationOnAppear = showVerification;

View File

@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN
@class TSThread;
@interface OWSConversationSettingsTableViewController : OWSTableViewController
@interface OWSConversationSettingsViewController : OWSTableViewController
@property (nonatomic, weak) id<OWSConversationSettingsViewDelegate> conversationSettingsViewDelegate;

View File

@ -2,7 +2,7 @@
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSConversationSettingsTableViewController.h"
#import "OWSConversationSettingsViewController.h"
#import "BlockListUIUtils.h"
#import "ContactsViewHelper.h"
#import "Environment.h"
@ -24,6 +24,7 @@
#import <SignalServiceKit/OWSDisappearingMessagesConfiguration.h>
#import <SignalServiceKit/OWSMessageSender.h>
#import <SignalServiceKit/OWSNotifyRemoteOfUpdatedDisappearingConfigurationJob.h>
#import <SignalServiceKit/OWSProfilesManager.h>
#import <SignalServiceKit/TSGroupThread.h>
#import <SignalServiceKit/TSOutgoingMessage.h>
#import <SignalServiceKit/TSStorageManager.h>
@ -33,7 +34,7 @@
NS_ASSUME_NONNULL_BEGIN
@interface OWSConversationSettingsTableViewController () <ContactEditingDelegate, ContactsViewHelperDelegate>
@interface OWSConversationSettingsViewController () <ContactEditingDelegate, ContactsViewHelperDelegate>
@property (nonatomic) TSThread *thread;
@ -52,7 +53,7 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark -
@implementation OWSConversationSettingsTableViewController
@implementation OWSConversationSettingsViewController
- (instancetype)init
{
@ -78,14 +79,15 @@ NS_ASSUME_NONNULL_BEGIN
return self;
}
- (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil {
- (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (!self) {
return self;
}
[self commonInit];
return self;
}
@ -244,7 +246,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSTableContents *contents = [OWSTableContents new];
contents.title = NSLocalizedString(@"CONVERSATION_SETTINGS", @"title for conversation settings screen");
__weak OWSConversationSettingsTableViewController *weakSelf = self;
__weak OWSConversationSettingsViewController *weakSelf = self;
// Main section.
@ -271,7 +273,7 @@ NS_ASSUME_NONNULL_BEGIN
iconName:@"table_ic_add_to_existing_contact"];
}
actionBlock:^{
OWSConversationSettingsTableViewController *strongSelf = weakSelf;
OWSConversationSettingsViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
TSContactThread *contactThread = (TSContactThread *)strongSelf.thread;
NSString *recipientId = contactThread.contactIdentifier;
@ -292,10 +294,50 @@ NS_ASSUME_NONNULL_BEGIN
}]];
}
BOOL isOnProfileWhitelist = NO;
if (self.isGroupThread) {
TSGroupThread *groupThread = (TSGroupThread *)self.thread;
NSData *groupId = groupThread.groupModel.groupId;
isOnProfileWhitelist = [OWSProfilesManager.sharedManager isGroupIdInProfileWhitelist:groupId];
} else {
NSString *recipientId = self.thread.contactIdentifier;
isOnProfileWhitelist = [OWSProfilesManager.sharedManager isUserInProfileWhitelist:recipientId];
}
if (isOnProfileWhitelist) {
[mainSection addItem:[OWSTableItem itemWithCustomCellBlock:^{
return [weakSelf
labelCellWithName:(self.isGroupThread
? NSLocalizedString(
@"CONVERSATION_SETTINGS_VIEW_PROFILE_IS_SHARED_WITH_GROUP",
@"Indicates that user's profile has been shared with a group.")
: NSLocalizedString(@"CONVERSATION_SETTINGS_VIEW_PROFILE_IS_SHARED_WITH_USER",
@"Indicates that user's profile has been shared with a user."))iconName
:@"table_ic_share_profile"];
}
actionBlock:^{
[weakSelf showShareProfileAlert];
}]];
} else {
[mainSection addItem:[OWSTableItem itemWithCustomCellBlock:^{
return
[weakSelf disclosureCellWithName:(self.isGroupThread
? NSLocalizedString(
@"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE_WITH_GROUP",
@"Action that shares user profile with a group.")
: NSLocalizedString(
@"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE_WITH_USER",
@"Action that shares user profile with a user."))iconName
:@"table_ic_share_profile"];
}
actionBlock:^{
[weakSelf showShareProfileAlert];
}]];
}
[mainSection
addItem:[OWSTableItem itemWithCustomCellBlock:^{
UITableViewCell *cell = [UITableViewCell new];
OWSConversationSettingsTableViewController *strongSelf = weakSelf;
OWSConversationSettingsViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES;
@ -354,7 +396,7 @@ NS_ASSUME_NONNULL_BEGIN
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
UITableViewCell *cell = [UITableViewCell new];
OWSConversationSettingsTableViewController *strongSelf = weakSelf;
OWSConversationSettingsViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES;
@ -442,7 +484,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSTableSection *muteSection = [OWSTableSection new];
[muteSection addItem:[OWSTableItem itemWithCustomCellBlock:^{
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
OWSConversationSettingsTableViewController *strongSelf = weakSelf;
OWSConversationSettingsViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES;
@ -514,7 +556,7 @@ NS_ASSUME_NONNULL_BEGIN
[weakSelf disclosureCellWithName:NSLocalizedString(@"CONVERSATION_SETTINGS_BLOCK_THIS_USER",
@"table cell label in conversation settings")
iconName:@"table_ic_block"];
OWSConversationSettingsTableViewController *strongSelf = weakSelf;
OWSConversationSettingsViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
cell.selectionStyle = UITableViewCellSelectionStyleNone;
@ -538,7 +580,7 @@ NS_ASSUME_NONNULL_BEGIN
return 12.f;
}
- (UITableViewCell *)disclosureCellWithName:(NSString *)name iconName:(NSString *)iconName
- (UITableViewCell *)cellWithName:(NSString *)name iconName:(NSString *)iconName
{
OWSAssert(name.length > 0);
OWSAssert(iconName.length > 0);
@ -546,7 +588,6 @@ NS_ASSUME_NONNULL_BEGIN
UITableViewCell *cell = [UITableViewCell new];
cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
UIImageView *iconView = [self viewForIconWithName:iconName];
[cell.contentView addSubview:iconView];
@ -566,6 +607,20 @@ NS_ASSUME_NONNULL_BEGIN
return cell;
}
- (UITableViewCell *)disclosureCellWithName:(NSString *)name iconName:(NSString *)iconName
{
UITableViewCell *cell = [self cellWithName:name iconName:iconName];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (UITableViewCell *)labelCellWithName:(NSString *)name iconName:(NSString *)iconName
{
UITableViewCell *cell = [self cellWithName:name iconName:iconName];
cell.accessoryType = UITableViewCellAccessoryNone;
return cell;
}
- (UIView *)mainSectionHeader
{
UIView *mainSectionHeader = [UIView new];
@ -728,6 +783,45 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Actions
- (void)showShareProfileAlert
{
UIAlertController *alertController =
[UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *leaveAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE",
@"Button to confirm that user wants to share their profile with a user or group.")
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *_Nonnull action) {
[self shareProfile];
}];
[alertController addAction:leaveAction];
UIAlertAction *cancelAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"TXT_CANCEL_TITLE", nil)
style:UIAlertActionStyleCancel
handler:^(UIAlertAction *_Nonnull action) {
[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];
}];
[alertController addAction:cancelAction];
[self presentViewController:alertController animated:YES completion:nil];
}
- (void)shareProfile
{
if (self.isGroupThread) {
TSGroupThread *groupThread = (TSGroupThread *)self.thread;
NSData *groupId = groupThread.groupModel.groupId;
[OWSProfilesManager.sharedManager addGroupIdToProfileWhitelist:groupId];
} else {
NSString *recipientId = self.thread.contactIdentifier;
[OWSProfilesManager.sharedManager addUserToProfileWhitelist:recipientId];
}
[self updateTableContents];
}
- (void)showVerificationView
{
NSString *recipientId = self.thread.contactIdentifier;
@ -949,7 +1043,7 @@ NS_ASSUME_NONNULL_BEGIN
message:message
preferredStyle:UIAlertControllerStyleActionSheet];
__weak OWSConversationSettingsTableViewController *weakSelf = self;
__weak OWSConversationSettingsViewController *weakSelf = self;
if (self.thread.isMuted) {
UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"CONVERSATION_SETTINGS_UNMUTE_ACTION",
@"Label for button to unmute a thread.")

View File

@ -340,6 +340,21 @@
/* Label for button to unmute a thread. */
"CONVERSATION_SETTINGS_UNMUTE_ACTION" = "Unmute";
/* Indicates that user's profile has been shared with a group. */
"CONVERSATION_SETTINGS_VIEW_PROFILE_IS_SHARED_WITH_GROUP" = "Your profile is shared this group.";
/* Indicates that user's profile has been shared with a user. */
"CONVERSATION_SETTINGS_VIEW_PROFILE_IS_SHARED_WITH_USER" = "Your profile is shared this user.";
/* Button to confirm that user wants to share their profile with a user or group. */
"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE" = "Share Profile";
/* Action that shares user profile with a group. */
"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE_WITH_GROUP" = "Share Your Profile";
/* Action that shares user profile with a user. */
"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE_WITH_USER" = "Share Your Profile";
/* ActionSheet title */
"CORRUPTED_SESSION_DESCRIPTION" = "Resetting your session will allow you to receive future messages from %@, but it will not recover any already corrupted messages.";