diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index 247a6ea32..83e0bd5f5 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -83,7 +83,6 @@ 34480B671FD0AA9400BC14EF /* UIFont+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = 34480B651FD0AA9400BC14EF /* UIFont+OWS.m */; }; 34480B681FD0AA9400BC14EF /* UIFont+OWS.h in Headers */ = {isa = PBXBuildFile; fileRef = 34480B661FD0AA9400BC14EF /* UIFont+OWS.h */; settings = {ATTRIBUTES = (Public, ); }; }; 344825C6211390C800DB4BD8 /* OWSOrphanDataCleaner.m in Sources */ = {isa = PBXBuildFile; fileRef = 344825C5211390C800DB4BD8 /* OWSOrphanDataCleaner.m */; }; - 3448E15C22133274004B052E /* OnboardingPermissionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3448E15B22133274004B052E /* OnboardingPermissionsViewController.swift */; }; 3448E1662215B313004B052E /* OnboardingCaptchaViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3448E1652215B313004B052E /* OnboardingCaptchaViewController.swift */; }; 344F248D2007CCD600CFB4F4 /* DisplayableText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 344F248C2007CCD600CFB4F4 /* DisplayableText.swift */; }; 3461284B1FD0B94000532771 /* SAELoadViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3461284A1FD0B93F00532771 /* SAELoadViewController.swift */; }; @@ -249,7 +248,6 @@ 34C6B0AC1FA0E46F00D35993 /* test-mp4.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 34C6B0A81FA0E46F00D35993 /* test-mp4.mp4 */; }; 34C6B0AE1FA0E4AA00D35993 /* test-jpg.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 34C6B0AD1FA0E4AA00D35993 /* test-jpg.jpg */; }; 34CA631B2097806F00E526A0 /* OWSContactShareView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CA631A2097806E00E526A0 /* OWSContactShareView.m */; }; - 34CE88E71F2FB9A10098030F /* ProfileViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34CE88E61F2FB9A10098030F /* ProfileViewController.m */; }; 34CF0787203E6B78005C4D61 /* busy_tone_ansi.caf in Resources */ = {isa = PBXBuildFile; fileRef = 34CF0783203E6B77005C4D61 /* busy_tone_ansi.caf */; }; 34CF0788203E6B78005C4D61 /* ringback_tone_ansi.caf in Resources */ = {isa = PBXBuildFile; fileRef = 34CF0784203E6B77005C4D61 /* ringback_tone_ansi.caf */; }; 34CF078A203E6B78005C4D61 /* end_call_tone_cept.caf in Resources */ = {isa = PBXBuildFile; fileRef = 34CF0786203E6B78005C4D61 /* end_call_tone_cept.caf */; }; @@ -572,8 +570,8 @@ BFF3FB9730634F37D25903F4 /* Pods_Signal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D17BB5C25D615AB49813100C /* Pods_Signal.framework */; }; C31A6C5A247F214E001123EF /* UIView+Glow.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31A6C59247F214E001123EF /* UIView+Glow.swift */; }; C31A6C5C247F2CF3001123EF /* CGRect+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = C31A6C5B247F2CF3001123EF /* CGRect+Utilities.swift */; }; - C329FEEF24F7743F00B1C64C /* UIViewController+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = C329FEED24F7742E00B1C64C /* UIViewController+Utilities.swift */; }; C329FEEC24F7277900B1C64C /* LightModeSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = C329FEEB24F7277900B1C64C /* LightModeSheet.swift */; }; + C329FEEF24F7743F00B1C64C /* UIViewController+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = C329FEED24F7742E00B1C64C /* UIViewController+Utilities.swift */; }; C34C8F7423A7830B00D82669 /* SpaceMono-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = C34C8F7323A7830A00D82669 /* SpaceMono-Bold.ttf */; }; C353F8F9244809150011121A /* PNOptionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C353F8F8244809150011121A /* PNOptionView.swift */; }; C3548F0624456447009433A8 /* PNModeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3548F0524456447009433A8 /* PNModeVC.swift */; }; @@ -811,7 +809,6 @@ 34480B661FD0AA9400BC14EF /* UIFont+OWS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIFont+OWS.h"; sourceTree = ""; }; 344825C4211390C700DB4BD8 /* OWSOrphanDataCleaner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSOrphanDataCleaner.h; sourceTree = ""; }; 344825C5211390C800DB4BD8 /* OWSOrphanDataCleaner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSOrphanDataCleaner.m; sourceTree = ""; }; - 3448E15B22133274004B052E /* OnboardingPermissionsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingPermissionsViewController.swift; sourceTree = ""; }; 3448E1652215B313004B052E /* OnboardingCaptchaViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OnboardingCaptchaViewController.swift; sourceTree = ""; }; 344F248C2007CCD600CFB4F4 /* DisplayableText.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DisplayableText.swift; sourceTree = ""; }; 3461284A1FD0B93F00532771 /* SAELoadViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SAELoadViewController.swift; sourceTree = ""; }; @@ -1001,8 +998,6 @@ 34CA1C261F7156F300E51C51 /* MessageDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageDetailViewController.swift; sourceTree = ""; }; 34CA63192097806E00E526A0 /* OWSContactShareView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSContactShareView.h; sourceTree = ""; }; 34CA631A2097806E00E526A0 /* OWSContactShareView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSContactShareView.m; sourceTree = ""; }; - 34CE88E51F2FB9A10098030F /* ProfileViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProfileViewController.h; sourceTree = ""; }; - 34CE88E61F2FB9A10098030F /* ProfileViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProfileViewController.m; sourceTree = ""; }; 34CF0783203E6B77005C4D61 /* busy_tone_ansi.caf */ = {isa = PBXFileReference; lastKnownFileType = file; name = busy_tone_ansi.caf; path = Signal/AudioFiles/busy_tone_ansi.caf; sourceTree = SOURCE_ROOT; }; 34CF0784203E6B77005C4D61 /* ringback_tone_ansi.caf */ = {isa = PBXFileReference; lastKnownFileType = file; name = ringback_tone_ansi.caf; path = Signal/AudioFiles/ringback_tone_ansi.caf; sourceTree = SOURCE_ROOT; }; 34CF0786203E6B78005C4D61 /* end_call_tone_cept.caf */ = {isa = PBXFileReference; lastKnownFileType = file; name = end_call_tone_cept.caf; path = Signal/AudioFiles/end_call_tone_cept.caf; sourceTree = SOURCE_ROOT; }; @@ -1364,8 +1359,8 @@ B9EB5ABC1884C002007CBB57 /* MessageUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MessageUI.framework; path = System/Library/Frameworks/MessageUI.framework; sourceTree = SDKROOT; }; C31A6C59247F214E001123EF /* UIView+Glow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Glow.swift"; sourceTree = ""; }; C31A6C5B247F2CF3001123EF /* CGRect+Utilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CGRect+Utilities.swift"; sourceTree = ""; }; - C329FEED24F7742E00B1C64C /* UIViewController+Utilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Utilities.swift"; sourceTree = ""; }; C329FEEB24F7277900B1C64C /* LightModeSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LightModeSheet.swift; sourceTree = ""; }; + C329FEED24F7742E00B1C64C /* UIViewController+Utilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+Utilities.swift"; sourceTree = ""; }; C34C8F7323A7830A00D82669 /* SpaceMono-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "SpaceMono-Bold.ttf"; sourceTree = ""; }; C353F8F8244809150011121A /* PNOptionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PNOptionView.swift; sourceTree = ""; }; C3548F0524456447009433A8 /* PNModeVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PNModeVC.swift; sourceTree = ""; }; @@ -1573,7 +1568,6 @@ children = ( 3441FD9E21A3604F00BB9542 /* BackupRestoreViewController.swift */, 3448E1652215B313004B052E /* OnboardingCaptchaViewController.swift */, - 3448E15B22133274004B052E /* OnboardingPermissionsViewController.swift */, ); path = Registration; sourceTree = ""; @@ -1920,8 +1914,6 @@ 34CA1C261F7156F300E51C51 /* MessageDetailViewController.swift */, 34A6C27F21E503E600B5B12E /* OWSImagePickerController.swift */, 34969558219B605E00DCFE74 /* Photos */, - 34CE88E51F2FB9A10098030F /* ProfileViewController.h */, - 34CE88E61F2FB9A10098030F /* ProfileViewController.m */, 340FC875204DAC8C007AEB0F /* Registration */, 4585C4671ED8F8D200896AEA /* SafetyNumberConfirmationAlert.swift */, 34B3F86D1E8DF1700035BE1A /* SignalsNavigationController.h */, @@ -3806,7 +3798,6 @@ 45B27B862037FFB400A539DF /* DebugUIFileBrowser.swift in Sources */, B886B4A92398BA1500211ABE /* QRCode.swift in Sources */, 3496955D219B605E00DCFE74 /* PhotoCollectionPickerController.swift in Sources */, - 34CE88E71F2FB9A10098030F /* ProfileViewController.m in Sources */, 3403B95D20EA9527001A1F44 /* OWSContactShareButtonsView.m in Sources */, 34B0796D1FCF46B100E248C2 /* MainAppContext.m in Sources */, 34E3EF101EFC2684007F6822 /* DebugUIPage.m in Sources */, @@ -3852,7 +3843,6 @@ 4542DF54208D40AC007B4E76 /* LoadingViewController.swift in Sources */, 34D5CCA91EAE3D30005515DB /* AvatarViewHelper.m in Sources */, 34D1F0B71F87F8850066283D /* OWSGenericAttachmentView.m in Sources */, - 3448E15C22133274004B052E /* OnboardingPermissionsViewController.swift in Sources */, B8B5BCEC2394D869003823C9 /* Button.swift in Sources */, 34D920E720E179C200D51158 /* OWSMessageFooterView.m in Sources */, 341341EF2187467A00192D59 /* ConversationViewModel.m in Sources */, diff --git a/Signal/src/Signal-Bridging-Header.h b/Signal/src/Signal-Bridging-Header.h index b271f1c5d..e5e54d724 100644 --- a/Signal/src/Signal-Bridging-Header.h +++ b/Signal/src/Signal-Bridging-Header.h @@ -39,7 +39,6 @@ #import "OWSWindowManager.h" #import "PinEntryView.h" #import "PrivacySettingsTableViewController.h" -#import "ProfileViewController.h" #import "RemoteVideoView.h" #import "OWSQRCodeScanningViewController.h" #import "SignalApp.h" diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m index 07d07a46d..c547ec56a 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m @@ -1271,10 +1271,10 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) if (interationType == OWSInteractionType_IncomingMessage) { // Only allow deletion on incoming messages if the user has moderation permission return [LKPublicChatAPI isUserModerator:self.userHexEncodedPublicKey forChannel:publicChat.channel onServer:publicChat.server]; + } else { + // Only allow deletion on outgoing messages if the user was the sender (i.e. it was not sent from another linked device) + return [self.interaction.actualSenderHexEncodedPublicKey isEqual:self.userHexEncodedPublicKey]; } - - // Only allow deletion on outgoing messages if the user was the sender (i.e. it was not sent from another linked device) - return [self.interaction.actualSenderHexEncodedPublicKey isEqual:self.userHexEncodedPublicKey]; } @end diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIContacts.m b/Signal/src/ViewControllers/DebugUI/DebugUIContacts.m index d3f55f929..e5ab7643d 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIContacts.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUIContacts.m @@ -109,7 +109,6 @@ NS_ASSUME_NONNULL_BEGIN TSAccountManager.localNumber, ] mutableCopy]; NSData *groupId = [Randomness generateRandomBytes:16]; - // TODO: Figure out if this is correct TSGroupModel *model = [[TSGroupModel alloc] initWithTitle:groupName memberIds:recipientIds image:nil groupId:groupId groupType:closedGroup adminIds:@[ TSAccountManager.localNumber ]]; TSGroupThread *thread = [TSGroupThread getOrCreateThreadWithGroupModel:model]; diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m b/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m index 678e4d28b..c7a742d86 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m @@ -3878,7 +3878,6 @@ typedef OWSContact * (^OWSContactBlock)(YapDatabaseReadWriteTransaction *transac TSAccountManager.localNumber, ] mutableCopy]; NSData *groupId = [Randomness generateRandomBytes:kGroupIdLength]; - // TODO: Figure out if this is correct TSGroupModel *groupModel = [[TSGroupModel alloc] initWithTitle:groupName memberIds:recipientIds image:nil groupId:groupId groupType:closedGroup adminIds:@[ TSAccountManager.localNumber ]]; __block TSGroupThread *thread; diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIStress.m b/Signal/src/ViewControllers/DebugUI/DebugUIStress.m index 78e958361..41de8afda 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIStress.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUIStress.m @@ -530,7 +530,6 @@ NS_ASSUME_NONNULL_BEGIN __block TSGroupThread *thread; [OWSPrimaryStorage.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { - // TODO: Figure out if this is correct TSGroupModel *groupModel = [[TSGroupModel alloc] initWithTitle:[groupThread.groupModel.groupName stringByAppendingString:@" Copy"] memberIds:groupThread.groupModel.groupMemberIds @@ -561,7 +560,6 @@ NS_ASSUME_NONNULL_BEGIN __block TSGroupThread *thread; [OWSPrimaryStorage.dbReadWriteConnection readWriteWithBlock:^( YapDatabaseReadWriteTransaction *_Nonnull transaction) { - // TODO: Figure out if this is correct TSGroupModel *groupModel = [[TSGroupModel alloc] initWithTitle:NSUUID.UUID.UUIDString memberIds:recipientIds image:nil diff --git a/Signal/src/ViewControllers/LongTextViewController.swift b/Signal/src/ViewControllers/LongTextViewController.swift index 841e7dd87..a74209843 100644 --- a/Signal/src/ViewControllers/LongTextViewController.swift +++ b/Signal/src/ViewControllers/LongTextViewController.swift @@ -56,24 +56,7 @@ public class LongTextViewController: OWSViewController { public override func viewDidLoad() { super.viewDidLoad() - // Loki: Set gradient background - view.backgroundColor = .clear - let gradient = Gradients.defaultLokiBackground - view.setGradient(gradient) - - // Loki: Set navigation bar background color - let navigationBar = navigationController!.navigationBar - navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default) - navigationBar.shadowImage = UIImage() - navigationBar.isTranslucent = false - navigationBar.barTintColor = Colors.navigationBarBackground - - // Loki: Customize title - let titleLabel = UILabel() - titleLabel.text = NSLocalizedString("LONG_TEXT_VIEW_TITLE", comment: "") - titleLabel.textColor = Colors.text - titleLabel.font = .boldSystemFont(ofSize: Values.veryLargeFontSize) - navigationItem.titleView = titleLabel + ViewControllerUtilities.setUpDefaultSessionStyle(for: self, title: NSLocalizedString("LONG_TEXT_VIEW_TITLE", comment: ""), hasCustomBackButton: false) createViews() diff --git a/Signal/src/ViewControllers/MediaGalleryViewController.swift b/Signal/src/ViewControllers/MediaGalleryViewController.swift index 1eb0591c2..ccc9c253e 100644 --- a/Signal/src/ViewControllers/MediaGalleryViewController.swift +++ b/Signal/src/ViewControllers/MediaGalleryViewController.swift @@ -802,13 +802,13 @@ class MediaGallery: NSObject, MediaGalleryDataSource, MediaTileViewControllerDel func buildGalleryItem(attachment: TSAttachment, transaction: YapDatabaseReadTransaction) -> MediaGalleryItem? { guard let attachmentStream = attachment as? TSAttachmentStream else { - // Avoid crash on dev mode + // Avoid crash in debug mode // owsFailDebug("gallery doesn't yet support showing undownloaded attachments") return nil } guard let message = attachmentStream.fetchAlbumMessage(with: transaction) else { - // Avoid crash on dev mode + // Avoid crash in debug mode // owsFailDebug("message was unexpectedly nil") return nil } diff --git a/Signal/src/ViewControllers/MediaTileViewController.swift b/Signal/src/ViewControllers/MediaTileViewController.swift index f30cff72a..23f551585 100644 --- a/Signal/src/ViewControllers/MediaTileViewController.swift +++ b/Signal/src/ViewControllers/MediaTileViewController.swift @@ -85,22 +85,7 @@ public class MediaTileViewController: UICollectionViewController, MediaGalleryDa override public func viewDidLoad() { super.viewDidLoad() - // Loki: Set gradient background - view.backgroundColor = .clear - let gradient = Gradients.defaultLokiBackground - view.setGradient(gradient) - // Loki: Set navigation bar background color - let navigationBar = navigationController!.navigationBar - navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default) - navigationBar.shadowImage = UIImage() - navigationBar.isTranslucent = false - navigationBar.barTintColor = Colors.navigationBarBackground - // Loki: Customize title - let titleLabel = UILabel() - titleLabel.text = MediaStrings.allMedia - titleLabel.textColor = Colors.text - titleLabel.font = .boldSystemFont(ofSize: Values.veryLargeFontSize) - navigationItem.titleView = titleLabel + ViewControllerUtilities.setUpDefaultSessionStyle(for: self, title: MediaStrings.allMedia, hasCustomBackButton: false) guard let collectionView = self.collectionView else { owsFailDebug("collectionView was unexpectedly nil") diff --git a/Signal/src/ViewControllers/MessageDetailViewController.swift b/Signal/src/ViewControllers/MessageDetailViewController.swift index 8f71d8a74..c333df72a 100644 --- a/Signal/src/ViewControllers/MessageDetailViewController.swift +++ b/Signal/src/ViewControllers/MessageDetailViewController.swift @@ -99,22 +99,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele self.conversationStyle.viewWidth = view.width() - // Loki: Set gradient background - view.backgroundColor = .clear - let gradient = Gradients.defaultLokiBackground - view.setGradient(gradient) - // Loki: Set navigation bar background color - let navigationBar = navigationController!.navigationBar - navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default) - navigationBar.shadowImage = UIImage() - navigationBar.isTranslucent = false - navigationBar.barTintColor = Colors.navigationBarBackground - // Loki: Customize title - let titleLabel = UILabel() - titleLabel.text = NSLocalizedString("MESSAGE_METADATA_VIEW_TITLE", comment: "Title for the 'message metadata' view.") - titleLabel.textColor = Colors.text - titleLabel.font = .boldSystemFont(ofSize: Values.veryLargeFontSize) - navigationItem.titleView = titleLabel + ViewControllerUtilities.setUpDefaultSessionStyle(for: self, title: NSLocalizedString("MESSAGE_METADATA_VIEW_TITLE", comment: "Title for the 'message metadata' view."), hasCustomBackButton: false) createViews() diff --git a/Signal/src/ViewControllers/ProfileViewController.h b/Signal/src/ViewControllers/ProfileViewController.h deleted file mode 100644 index b53c2a0d7..000000000 --- a/Signal/src/ViewControllers/ProfileViewController.h +++ /dev/null @@ -1,23 +0,0 @@ -// -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@class HomeViewController; - -@interface ProfileViewController : OWSViewController - -- (instancetype)init NS_UNAVAILABLE; - -+ (BOOL)shouldDisplayProfileViewOnLaunch; - -+ (void)presentForAppSettings:(UINavigationController *)navigationController; -+ (void)presentForRegistration:(UINavigationController *)navigationController; -+ (void)presentForUpgradeOrNag:(HomeViewController *)fromViewController NS_SWIFT_NAME(presentForUpgradeOrNag(from:)); - -@end - -NS_ASSUME_NONNULL_END diff --git a/Signal/src/ViewControllers/ProfileViewController.m b/Signal/src/ViewControllers/ProfileViewController.m deleted file mode 100644 index 218e805f8..000000000 --- a/Signal/src/ViewControllers/ProfileViewController.m +++ /dev/null @@ -1,648 +0,0 @@ -// -// Copyright (c) 2019 Open Whisper Systems. All rights reserved. -// - -#import "ProfileViewController.h" -#import "AppDelegate.h" -#import "AvatarViewHelper.h" -#import "OWSNavigationController.h" -#import "Session-Swift.h" -#import "SignalsNavigationController.h" -#import "UIColor+OWS.h" -#import "UIFont+OWS.h" -#import "UIView+OWS.h" -#import -#import -#import -#import -#import -#import -#import -#import - -NS_ASSUME_NONNULL_BEGIN - -typedef NS_ENUM(NSInteger, ProfileViewMode) { - ProfileViewMode_AppSettings = 0, - ProfileViewMode_Registration, - ProfileViewMode_UpgradeOrNag, -}; - -NSString *const kProfileView_Collection = @"kProfileView_Collection"; -NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDate"; - -@interface ProfileViewController () - -@property (nonatomic, readonly) AvatarViewHelper *avatarViewHelper; - -@property (nonatomic) UITextField *nameTextField; - -@property (nonatomic) AvatarImageView *avatarView; - -@property (nonatomic) UIImageView *cameraImageView; - -@property (nonatomic) OWSFlatButton *saveButton; - -@property (nonatomic, nullable) UIImage *avatar; - -@property (nonatomic) BOOL hasUnsavedChanges; - -@property (nonatomic) ProfileViewMode profileViewMode; - -@end - -#pragma mark - - -@implementation ProfileViewController - -- (instancetype)initWithMode:(ProfileViewMode)profileViewMode -{ - self = [super init]; - - if (!self) { - return self; - } - - self.profileViewMode = profileViewMode; - - // Use the OWSPrimaryStorage.dbReadWriteConnection for consistency with the reads below. - [[[OWSPrimaryStorage sharedManager] dbReadWriteConnection] setDate:[NSDate new] - forKey:kProfileView_LastPresentedDate - inCollection:kProfileView_Collection]; - - return self; -} - -- (void)loadView -{ - [super loadView]; - - self.title = NSLocalizedString(@"PROFILE_VIEW_TITLE", @"Title for the profile view."); - - _avatarViewHelper = [AvatarViewHelper new]; - _avatarViewHelper.delegate = self; - - _avatar = [OWSProfileManager.sharedManager localProfileAvatarImage]; - - [self createViews]; - [self updateNavigationItem]; - - if (self.nameTextField.text.length > 0) { - self.hasUnsavedChanges = YES; - } -} - -- (void)createViews -{ - self.view.backgroundColor = Theme.backgroundColor; - - UIView *contentView = [UIView containerView]; - contentView.backgroundColor = Theme.backgroundColor; - [self.view addSubview:contentView]; - [contentView autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:self.view withOffset:0.0f]; - [contentView autoPinWidthToSuperview]; - - const CGFloat fontSizePoints = ScaleFromIPhone5To7Plus(16.f, 20.f); - NSMutableArray *rows = [NSMutableArray new]; - - // Name - - UIView *nameRow = [UIView containerView]; - nameRow.userInteractionEnabled = YES; - [nameRow - addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(nameRowTapped:)]]; - nameRow.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"nameRow"); - [rows addObject:nameRow]; - - UILabel *nameLabel = [UILabel new]; - nameLabel.text = NSLocalizedString(@"Display Name", @""); - nameLabel.textColor = Theme.primaryColor; - nameLabel.font = [UIFont ows_regularFontWithSize:fontSizePoints]; - [nameRow addSubview:nameLabel]; - [nameLabel autoPinLeadingToSuperviewMargin]; - [nameLabel autoPinHeightToSuperviewWithMargin:5.f]; - - UITextField *nameTextField; - if (UIDevice.currentDevice.isShorterThanIPhone5) { - nameTextField = [DismissableTextField new]; - } else { - nameTextField = [OWSTextField new]; - } - _nameTextField = nameTextField; - nameTextField.font = [UIFont ows_regularFontWithSize:18.f]; - nameTextField.textColor = UIColor.whiteColor; - nameTextField.tintColor = UIColor.lokiGreen; - nameTextField.placeholder = NSLocalizedString( - @"PROFILE_VIEW_NAME_DEFAULT_TEXT", @"Default text for the profile name field of the profile view."); - nameTextField.delegate = self; - nameTextField.text = [OWSProfileManager.sharedManager localProfileName]; - nameTextField.textAlignment = NSTextAlignmentRight; - nameTextField.font = [UIFont ows_regularFontWithSize:fontSizePoints]; - SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, nameTextField); - [nameTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; - [nameRow addSubview:nameTextField]; - [nameTextField autoPinLeadingToTrailingEdgeOfView:nameLabel offset:10.f]; - [nameTextField autoPinTrailingToSuperviewMargin]; - [nameTextField autoVCenterInSuperview]; - - // Avatar - - UIView *avatarRow = [UIView containerView]; - avatarRow.userInteractionEnabled = YES; - [avatarRow - addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarRowTapped:)]]; - avatarRow.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"avatarRow"); - - [rows addObject:avatarRow]; - - UILabel *avatarLabel = [UILabel new]; - avatarLabel.text = NSLocalizedString(@"Profile Picture", @""); - avatarLabel.textColor = Theme.primaryColor; - avatarLabel.font = [UIFont ows_regularFontWithSize:fontSizePoints]; - [avatarRow addSubview:avatarLabel]; - [avatarLabel autoPinLeadingToSuperviewMargin]; - [avatarLabel autoVCenterInSuperview]; - - self.avatarView = [AvatarImageView new]; - self.avatarView.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"avatarView"); - - UIImage *cameraImage = [UIImage imageNamed:@"settings-avatar-camera"]; - self.cameraImageView = [[UIImageView alloc] initWithImage:cameraImage]; - - [avatarRow addSubview:self.avatarView]; - [avatarRow addSubview:self.cameraImageView]; - [self updateAvatarView]; - [self.avatarView autoPinTrailingToSuperviewMargin]; - [self.avatarView autoPinLeadingToTrailingEdgeOfView:avatarLabel offset:10.f]; - const CGFloat kAvatarVMargin = 4.f; - [self.avatarView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:kAvatarVMargin]; - [self.avatarView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:kAvatarVMargin]; - [self.avatarView autoSetDimension:ALDimensionWidth toSize:self.avatarSize]; - [self.avatarView autoSetDimension:ALDimensionHeight toSize:self.avatarSize]; - [self.cameraImageView autoPinTrailingToEdgeOfView:self.avatarView]; - [self.cameraImageView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.avatarView]; - - // Information - -// Loki: Original code -// ======== -// UIView *infoRow = [UIView containerView]; -// infoRow.userInteractionEnabled = YES; -// [infoRow -// addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(infoRowTapped:)]]; -// infoRow.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"infoRow"); -// [rows addObject:infoRow]; -// -// UILabel *infoLabel = [UILabel new]; -// infoLabel.textColor = Theme.secondaryColor; -// infoLabel.font = [UIFont ows_regularFontWithSize:11.f]; -// infoLabel.textAlignment = NSTextAlignmentCenter; -// NSMutableAttributedString *text = [NSMutableAttributedString new]; -// [text appendAttributedString:[[NSAttributedString alloc] -// initWithString:NSLocalizedString(@"PROFILE_VIEW_PROFILE_DESCRIPTION", -// @"Description of the user profile.") -// attributes:@{}]]; -// [text appendAttributedString:[[NSAttributedString alloc] initWithString:@" " attributes:@{}]]; -// [text appendAttributedString:[[NSAttributedString alloc] -// initWithString:NSLocalizedString(@"PROFILE_VIEW_PROFILE_DESCRIPTION_LINK", -// @"Link to more information about the user profile.") -// attributes:@{ -// NSUnderlineStyleAttributeName : -// @(NSUnderlineStyleSingle | NSUnderlinePatternSolid), -// NSForegroundColorAttributeName : [UIColor ows_materialBlueColor], -// }]]; -// infoLabel.attributedText = text; -// infoLabel.numberOfLines = 0; -// infoLabel.lineBreakMode = NSLineBreakByWordWrapping; -// [infoRow addSubview:infoLabel]; -// [infoLabel autoPinLeadingToSuperviewMargin]; -// [infoLabel autoPinTrailingToSuperviewMargin]; -// [infoLabel autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:10.f]; -// [infoLabel autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:10.f]; -// ======== - - // Big Button - - if (self.profileViewMode == ProfileViewMode_Registration || self.profileViewMode == ProfileViewMode_UpgradeOrNag) { - UIView *buttonRow = [UIView containerView]; - [rows addObject:buttonRow]; - - const CGFloat kButtonHeight = 47.f; - // NOTE: We use ows_signalBrandBlueColor instead of ows_materialBlueColor - // throughout the onboarding flow to be consistent with the headers. - OWSFlatButton *saveButton = - [OWSFlatButton buttonWithTitle:NSLocalizedString(@"PROFILE_VIEW_SAVE_BUTTON", - @"Button to save the profile view in the profile view.") - font:[OWSFlatButton fontForHeight:kButtonHeight] - titleColor:[UIColor whiteColor] - backgroundColor:[UIColor ows_signalBrandBlueColor] - target:self - selector:@selector(saveButtonPressed)]; - SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, saveButton); - self.saveButton = saveButton; - [buttonRow addSubview:saveButton]; - [saveButton autoPinLeadingAndTrailingToSuperviewMargin]; - [saveButton autoPinHeightToSuperview]; - [saveButton autoSetDimension:ALDimensionHeight toSize:47.f]; - } - - // Row Layout - - UIView *_Nullable lastRow = nil; - for (UIView *row in rows) { - [contentView addSubview:row]; - if (lastRow) { - [row autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:lastRow withOffset:5.f]; - } else { - [row autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:15.f]; - } - [row autoPinLeadingToSuperviewMarginWithInset:18.f]; - [row autoPinTrailingToSuperviewMarginWithInset:18.f]; - lastRow = row; - - if (lastRow == nameRow || lastRow == avatarRow) { - UIView *separator = [UIView containerView]; - separator.backgroundColor = Theme.cellSeparatorColor; - [contentView addSubview:separator]; - [separator autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:lastRow withOffset:5.f]; - [separator autoPinLeadingToSuperviewMarginWithInset:18.f]; - [separator autoPinTrailingToSuperviewMarginWithInset:18.f]; - [separator autoSetDimension:ALDimensionHeight toSize:CGHairlineWidth()]; - lastRow = separator; - } - } - [lastRow autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:10.f]; -} - -- (void)viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; - - [self.nameTextField becomeFirstResponder]; -} - -#pragma mark - Event Handling - -- (void)backOrSkipButtonPressed -{ - [self leaveViewCheckingForUnsavedChanges]; -} - -- (void)leaveViewCheckingForUnsavedChanges -{ - [self.nameTextField resignFirstResponder]; - - if (!self.hasUnsavedChanges) { - // If user made no changes, return to conversation settings view. - [self profileCompletedOrSkipped]; - return; - } - - __weak ProfileViewController *weakSelf = self; - UIAlertController *alert = [UIAlertController - alertControllerWithTitle: - NSLocalizedString(@"NEW_GROUP_VIEW_UNSAVED_CHANGES_TITLE", - @"The alert title if user tries to exit the new group view without saving changes.") - message: - NSLocalizedString(@"NEW_GROUP_VIEW_UNSAVED_CHANGES_MESSAGE", - @"The alert message if user tries to exit the new group view without saving changes.") - preferredStyle:UIAlertControllerStyleAlert]; - UIAlertAction *discardAction = - [UIAlertAction actionWithTitle:NSLocalizedString(@"ALERT_DISCARD_BUTTON", - @"The label for the 'discard' button in alerts and action sheets.") - accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"discard") - style:UIAlertActionStyleDestructive - handler:^(UIAlertAction *action) { - [weakSelf profileCompletedOrSkipped]; - }]; - [alert addAction:discardAction]; - - [alert addAction:[OWSAlerts cancelAction]]; - [self presentAlert:alert]; -} - -- (void)avatarTapped -{ - [self.avatarViewHelper showChangeAvatarUI]; -} - -- (void)setHasUnsavedChanges:(BOOL)hasUnsavedChanges -{ - _hasUnsavedChanges = hasUnsavedChanges; - - [self updateNavigationItem]; -} - -- (void)updateNavigationItem -{ - // The navigation bar is hidden in the registration workflow. - if (self.navigationController.navigationBarHidden) { - [self.navigationController setNavigationBarHidden:NO animated:YES]; - } - - // Always display a left item to leave the view without making changes. - // This might be a "back", "skip" or "cancel" button depending on the - // context. - switch (self.profileViewMode) { - case ProfileViewMode_AppSettings: - if (self.hasUnsavedChanges) { - // If we have a unsaved changes, right item should be a "save" button. - UIBarButtonItem *saveButton = - [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave - target:self - action:@selector(updatePressed)]; - SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, saveButton); - self.navigationItem.rightBarButtonItem = saveButton; - } else { - self.navigationItem.rightBarButtonItem = nil; - } - break; - case ProfileViewMode_UpgradeOrNag: - case ProfileViewMode_Registration: - self.navigationItem.hidesBackButton = YES; - self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] - initWithTitle:NSLocalizedString(@"NAVIGATION_ITEM_SKIP_BUTTON", @"A button to skip a view.") - style:UIBarButtonItemStylePlain - target:self - action:@selector(backOrSkipButtonPressed)]; - break; - } - - // The save button is only used in "registration" and "upgrade or nag" modes. - if (self.hasUnsavedChanges) { - self.saveButton.enabled = YES; - [self.saveButton setBackgroundColorsWithUpColor:[UIColor ows_signalBrandBlueColor]]; - } else { - self.saveButton.enabled = NO; - [self.saveButton - setBackgroundColorsWithUpColor:[[UIColor ows_signalBrandBlueColor] blendWithColor:Theme.backgroundColor - alpha:0.5f]]; - } -} - -- (void)updatePressed -{ - [self updateProfile]; -} - -- (void)updateProfile -{ - __weak ProfileViewController *weakSelf = self; - - NSString *normalizedProfileName = [self normalizedProfileName]; - - if (normalizedProfileName.length == 0) { - return [OWSAlerts showErrorAlertWithMessage:NSLocalizedString(@"Please pick a display name", @"")]; - } - - NSCharacterSet *allowedCharacters = [NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_ "]; - if ([normalizedProfileName rangeOfCharacterFromSet:allowedCharacters.invertedSet].location != NSNotFound) { - return [OWSAlerts showErrorAlertWithMessage:NSLocalizedString(@"Please pick a display name that consists of only a-z, A-Z, 0-9 and _ characters", @"")]; - } - - if ([OWSProfileManager.sharedManager isProfileNameTooLong:normalizedProfileName]) { - return [OWSAlerts showErrorAlertWithMessage:NSLocalizedString(@"Please pick a shorter display name", @"")]; - } - - // Show an activity indicator to block the UI during the profile upload. - [ModalActivityIndicatorViewController - presentFromViewController:self - canCancel:NO - backgroundBlock:^(ModalActivityIndicatorViewController *modalActivityIndicator) { - [OWSProfileManager.sharedManager updateLocalProfileName:normalizedProfileName - avatarImage:weakSelf.avatar - success:^{ - dispatch_async(dispatch_get_main_queue(), ^{ - [modalActivityIndicator dismissWithCompletion:^{ - [weakSelf updateProfileCompleted]; - }]; - }); - } - failure:^(NSError *error) { - dispatch_async(dispatch_get_main_queue(), ^{ - [modalActivityIndicator dismissWithCompletion:^{ - [OWSAlerts showErrorAlertWithMessage:NSLocalizedString( - @"PROFILE_VIEW_ERROR_UPDATE_FAILED", - @"Error message shown when a " - @"profile update fails.")]; - }]; - }); - } requiresSync:NO]; - }]; -} - -- (NSString *)normalizedProfileName -{ - return [self.nameTextField.text ows_stripped]; -} - -- (void)updateProfileCompleted -{ - OWSLogVerbose(@""); - - [self profileCompletedOrSkipped]; -} - -- (void)profileCompletedOrSkipped -{ - OWSLogVerbose(@""); - - // Dismiss this view. - switch (self.profileViewMode) { - case ProfileViewMode_AppSettings: - [self.navigationController popViewControllerAnimated:YES]; - break; - case ProfileViewMode_Registration: - [self showHomeView]; - break; - case ProfileViewMode_UpgradeOrNag: - [self dismissViewControllerAnimated:YES completion:nil]; - break; - } -} - -- (void)showHomeView -{ - OWSAssertIsOnMainThread(); - OWSLogVerbose(@""); - - [SignalApp.sharedApp showHomeView]; -} - -#pragma mark - UITextFieldDelegate - -- (BOOL)textField:(UITextField *)textField - shouldChangeCharactersInRange:(NSRange)editingRange - replacementString:(NSString *)insertionText -{ - // TODO: Possibly filter invalid input. - return [TextFieldHelper textField:textField - shouldChangeCharactersInRange:editingRange - replacementString:insertionText - byteLimit:kOWSProfileManager_NameDataLength]; -} - -- (BOOL)textFieldShouldReturn:(UITextField *)textField -{ - [self updateProfile]; - return NO; -} - -- (void)textFieldDidChange:(id)sender -{ - self.hasUnsavedChanges = YES; - - // TODO: Update length warning. -} - -#pragma mark - Avatar - -- (void)setAvatar:(nullable UIImage *)avatar -{ - OWSAssertIsOnMainThread(); - - _avatar = avatar; - - self.hasUnsavedChanges = YES; - - [self updateAvatarView]; -} - -- (NSUInteger)avatarSize -{ - return 48; -} - -- (void)updateAvatarView -{ - self.avatarView.image = (self.avatar - ?: [[[OWSContactAvatarBuilder alloc] initForLocalUserWithDiameter:self.avatarSize] buildDefaultImage]); - self.cameraImageView.hidden = self.avatar != nil; -} - -- (void)nameRowTapped:(UIGestureRecognizer *)sender -{ - if (sender.state == UIGestureRecognizerStateRecognized) { - [self.nameTextField becomeFirstResponder]; - } -} - -- (void)avatarRowTapped:(UIGestureRecognizer *)sender -{ - if (sender.state == UIGestureRecognizerStateRecognized) { - [self avatarTapped]; - } -} - -- (void)infoRowTapped:(UIGestureRecognizer *)sender -{ - if (sender.state == UIGestureRecognizerStateRecognized) { - [UIApplication.sharedApplication - openURL:[NSURL URLWithString:@"https://support.signal.org/hc/en-us/articles/115001110511"]]; - } -} - -- (void)saveButtonPressed -{ - [self updatePressed]; -} - -#pragma mark - AvatarViewHelperDelegate - -+ (BOOL)shouldDisplayProfileViewOnLaunch -{ - // Only nag until the user sets a profile _name_. Profile names are - // recommended; profile avatars are optional. - if ([OWSProfileManager sharedManager].localProfileName.length > 0) { - return NO; - } - - // Use the OWSPrimaryStorage.dbReadWriteConnection for consistency with the writes above. - NSTimeInterval kProfileNagFrequency = kDayInterval * 30; - NSDate *_Nullable lastPresentedDate = - [[[OWSPrimaryStorage sharedManager] dbReadWriteConnection] dateForKey:kProfileView_LastPresentedDate - inCollection:kProfileView_Collection]; - return (!lastPresentedDate || fabs([lastPresentedDate timeIntervalSinceNow]) > kProfileNagFrequency); -} - -+ (void)presentForAppSettings:(UINavigationController *)navigationController -{ - OWSAssertDebug(navigationController); - OWSAssertDebug([navigationController isKindOfClass:[OWSNavigationController class]]); - - ProfileViewController *vc = [[ProfileViewController alloc] initWithMode:ProfileViewMode_AppSettings]; - [navigationController pushViewController:vc animated:YES]; -} - -+ (void)presentForRegistration:(UINavigationController *)navigationController -{ - OWSAssertDebug(navigationController); - OWSAssertDebug([navigationController isKindOfClass:[OWSNavigationController class]]); - - ProfileViewController *vc = [[ProfileViewController alloc] initWithMode:ProfileViewMode_Registration]; - [navigationController pushViewController:vc animated:YES]; -} - -+ (void)presentForUpgradeOrNag:(HomeViewController *)fromViewController -{ - -} - -#pragma mark - AvatarViewHelperDelegate - -- (nullable NSString *)avatarActionSheetTitle -{ - return NSLocalizedString(@"Set Profile Picture", @""); -} - -- (void)avatarDidChange:(UIImage *)image -{ - OWSAssertIsOnMainThread(); - OWSAssertDebug(image); - - self.avatar = [image resizedImageToFillPixelSize:CGSizeMake(kOWSProfileManager_MaxAvatarDiameter, - kOWSProfileManager_MaxAvatarDiameter)]; -} - -- (UIViewController *)fromViewController -{ - return self; -} - -- (BOOL)hasClearAvatarAction -{ - return YES; -} - -- (NSString *)clearAvatarActionLabel -{ - return NSLocalizedString(@"Clear Profile Picture", @""); -} - -- (void)clearAvatar -{ - self.avatar = nil; -} - -#pragma mark - OWSNavigationView - -- (BOOL)shouldCancelNavigationBack -{ - BOOL result = self.hasUnsavedChanges; - if (result) { - [self backOrSkipButtonPressed]; - } - return result; -} - -#pragma mark - Orientation - -- (UIInterfaceOrientationMask)supportedInterfaceOrientations -{ - return (self.profileViewMode == ProfileViewMode_Registration ? UIInterfaceOrientationMaskPortrait - : DefaultUIInterfaceOrientationMask()); -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/Signal/src/ViewControllers/Registration/OnboardingPermissionsViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingPermissionsViewController.swift deleted file mode 100644 index fabf45256..000000000 --- a/Signal/src/ViewControllers/Registration/OnboardingPermissionsViewController.swift +++ /dev/null @@ -1,111 +0,0 @@ -// -// Copyright (c) 2019 Open Whisper Systems. All rights reserved. -// - -/* -import UIKit -import PromiseKit -import Contacts - -@objc -public class OnboardingPermissionsViewController: OnboardingBaseViewController { - - override public func loadView() { - super.loadView() - - view.backgroundColor = Theme.backgroundColor - view.layoutMargins = .zero - - navigationItem.rightBarButtonItem = UIBarButtonItem(title: NSLocalizedString("NAVIGATION_ITEM_SKIP_BUTTON", comment: "A button to skip a view."), - style: .plain, - target: self, - action: #selector(skipWasPressed)) - - let titleLabel = self.createTitleLabel(text: NSLocalizedString("Loki Messenger can let you know when you get a message (and who it is from)", comment: "")) - titleLabel.accessibilityIdentifier = "onboarding.permissions." + "titleLabel" - - let explanationLabel = self.createExplanationLabel(text: NSLocalizedString("ONBOARDING_PERMISSIONS_EXPLANATION", - comment: "Explanation in the 'onboarding permissions' view.")) - explanationLabel.accessibilityIdentifier = "onboarding.permissions." + "explanationLabel" - - let giveAccessButton = self.createButton(title: NSLocalizedString("ONBOARDING_PERMISSIONS_ENABLE_PERMISSIONS_BUTTON", - comment: "Label for the 'give access' button in the 'onboarding permissions' view."), - selector: #selector(giveAccessPressed)) - giveAccessButton.accessibilityIdentifier = "onboarding.permissions." + "giveAccessButton" - - let notNowButton = self.createLinkButton(title: NSLocalizedString("ONBOARDING_PERMISSIONS_NOT_NOW_BUTTON", - comment: "Label for the 'not now' button in the 'onboarding permissions' view."), - selector: #selector(notNowPressed)) - notNowButton.accessibilityIdentifier = "onboarding.permissions." + "notNowButton" - - let stackView = UIStackView(arrangedSubviews: [ - titleLabel, - UIView.spacer(withHeight: 20), - explanationLabel, - UIView.vStretchingSpacer(), - notNowButton, - UIView.spacer(withHeight: 12), - giveAccessButton - ]) - stackView.axis = .vertical - stackView.alignment = .fill - stackView.layoutMargins = UIEdgeInsets(top: 32, left: 32, bottom: 32, right: 32) - stackView.isLayoutMarginsRelativeArrangement = true - view.addSubview(stackView) - stackView.autoPinWidthToSuperview() - stackView.autoPinEdge(.top, to: .top, of: view) - stackView.autoPinEdge(.bottom, to: .bottom, of: view) - } - - // MARK: Request Access - - private func requestAccess() { - Logger.info("") - - requestContactsAccess().then { _ in - return PushRegistrationManager.shared.registerUserNotificationSettings() - }.done { [weak self] in - guard let self = self else { - return - } - self.onboardingController.onboardingPermissionsDidComplete(viewController: self) - }.retainUntilComplete() - } - - private func requestContactsAccess() -> Promise { - Logger.info("") - - let (promise, resolver) = Promise.pending() - CNContactStore().requestAccess(for: CNEntityType.contacts) { (granted, error) -> Void in - if granted { - Logger.info("Granted.") - } else { - Logger.error("Error: \(String(describing: error)).") - } - // Always fulfill. - resolver.fulfill(()) - } - return promise - } - - // MARK: - Events - - @objc func skipWasPressed() { - Logger.info("") - - onboardingController.onboardingPermissionsWasSkipped(viewController: self) - } - - @objc func giveAccessPressed() { - Logger.info("") - - requestAccess() - } - - @objc func notNowPressed() { - Logger.info("") - - onboardingController.onboardingPermissionsWasSkipped(viewController: self) - } -} - */ diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index 3a0da4db5..6edf9a2d5 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -303,34 +303,14 @@ const CGFloat kIconViewLength = 24; [self updateTableContents]; - // Loki: Set gradient background - self.tableView.backgroundColor = UIColor.clearColor; - LKGradient *gradient = LKGradients.defaultLokiBackground; - self.view.backgroundColor = UIColor.clearColor; - [self.view setGradient:gradient]; - - // Loki: Set navigation bar background color - UINavigationBar *navigationBar = self.navigationController.navigationBar; - [navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; - navigationBar.shadowImage = [UIImage new]; - [navigationBar setTranslucent:NO]; - navigationBar.barTintColor = LKColors.navigationBarBackground; - - // Loki: Customize title - UILabel *titleLabel = [UILabel new]; + NSString *title; if ([self.thread isKindOfClass:[TSContactThread class]]) { - titleLabel.text = NSLocalizedString(@"Settings", @""); + title = NSLocalizedString(@"Settings", @""); } else { - titleLabel.text = NSLocalizedString(@"Group Settings", @""); + title = NSLocalizedString(@"Group Settings", @""); } - titleLabel.textColor = LKColors.text; - titleLabel.font = [UIFont boldSystemFontOfSize:LKValues.veryLargeFontSize]; - self.navigationItem.titleView = titleLabel; - - // Loki: Set up back button - UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back", "") style:UIBarButtonItemStylePlain target:nil action:nil]; - backButton.tintColor = LKColors.text; - self.navigationItem.backBarButtonItem = backButton; + [LKViewControllerUtilities setUpDefaultSessionStyleForVC:self withTitle:title customBackButton:YES]; + self.tableView.backgroundColor = UIColor.clearColor; } - (void)viewDidAppear:(BOOL)animated