From 6331fbb22a27d66e6d87937ddf892e22e81a5f34 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 15 Jun 2018 13:39:35 -0400 Subject: [PATCH] Show de-registration nag view. --- .../HomeView/HomeViewController.m | 25 ++++++++++++++++--- Signal/src/views/ReminderView.swift | 2 +- .../translations/en.lproj/Localizable.strings | 5 +++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index 4d99f6e43..9f62b3cdf 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -74,6 +74,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations // Views +@property (nonatomic) NSLayoutConstraint *hideDeregisteredViewConstraint; @property (nonatomic) NSLayoutConstraint *hideArchiveReminderViewConstraint; @property (nonatomic) NSLayoutConstraint *hideMissingContactsPermissionViewConstraint; @@ -193,7 +194,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations { OWSAssertIsOnMainThread(); - [self reloadTableViewData]; + [self updateReminderViews]; } #pragma mark - View Life Cycle @@ -209,12 +210,24 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations [SignalApp.sharedApp setHomeViewController:self]; } + ReminderView *deregisteredView = + [ReminderView nagWithText:NSLocalizedString(@"INBOX_VIEW_DEREGISTRATION_WARNING", + @"Label warning the user that they have been de-registered.") + tapAction:^{ + // TODO: + }]; + [self.view addSubview:deregisteredView]; + [deregisteredView autoPinWidthToSuperview]; + [deregisteredView autoPinToTopLayoutGuideOfViewController:self withInset:0]; + self.hideDeregisteredViewConstraint = [deregisteredView autoSetDimension:ALDimensionHeight toSize:0]; + self.hideDeregisteredViewConstraint.priority = UILayoutPriorityRequired; + ReminderView *archiveReminderView = [ReminderView explanationWithText:NSLocalizedString(@"INBOX_VIEW_ARCHIVE_MODE_REMINDER", @"Label reminding the user that they are in archive mode.")]; [self.view addSubview:archiveReminderView]; [archiveReminderView autoPinWidthToSuperview]; - [archiveReminderView autoPinToTopLayoutGuideOfViewController:self withInset:0]; + [archiveReminderView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:deregisteredView]; self.hideArchiveReminderViewConstraint = [archiveReminderView autoSetDimension:ALDimensionHeight toSize:0]; self.hideArchiveReminderViewConstraint.priority = UILayoutPriorityRequired; @@ -270,12 +283,18 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations { BOOL shouldHideArchiveReminderView = self.homeViewMode != HomeViewMode_Archive; BOOL shouldHideMissingContactsPermissionView = !self.shouldShowMissingContactsPermissionView; + BOOL shouldHideDeregisteredView = !TSAccountManager.sharedInstance.isDeregistered; + if (self.hideArchiveReminderViewConstraint.active == shouldHideArchiveReminderView - && self.hideMissingContactsPermissionViewConstraint.active == shouldHideMissingContactsPermissionView) { + && self.hideMissingContactsPermissionViewConstraint.active == shouldHideMissingContactsPermissionView + && self.hideDeregisteredViewConstraint.active == shouldHideDeregisteredView) { return; } + self.hideArchiveReminderViewConstraint.active = shouldHideArchiveReminderView; self.hideMissingContactsPermissionViewConstraint.active = shouldHideMissingContactsPermissionView; + self.hideDeregisteredViewConstraint.active = shouldHideDeregisteredView; + [self.view setNeedsLayout]; [self.view layoutSubviews]; } diff --git a/Signal/src/views/ReminderView.swift b/Signal/src/views/ReminderView.swift index a0c138a76..6b122d8a7 100644 --- a/Signal/src/views/ReminderView.swift +++ b/Signal/src/views/ReminderView.swift @@ -91,7 +91,7 @@ class ReminderView: UIView { // Label switch (mode) { case .nag: - label.font = UIFont.ows_regularFont(withSize: 14) + label.font = UIFont.ows_dynamicTypeFootnote case .explanation: label.font = UIFont.ows_dynamicTypeSubheadline } diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index f7346ece4..0c39bc411 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -659,7 +659,7 @@ /* table cell label in conversation settings */ "DISAPPEARING_MESSAGES" = "Disappearing Messages"; -/* Info Message when added to {{group name}} which has enabled message expiration after {{time amount}}, see the *_TIME_AMOUNT strings for context. */ +/* Info Message when added to a group which has enabled disappearing messages. Embeds {{time amount}} before messages disappear, see the *_TIME_AMOUNT strings for context. */ "DISAPPEARING_MESSAGES_CONFIGURATION_GROUP_EXISTING_FORMAT" = "Messages in this conversation will disappear after %@."; /* subheading in conversation settings */ @@ -1022,6 +1022,9 @@ /* Label reminding the user that they are in archive mode. */ "INBOX_VIEW_ARCHIVE_MODE_REMINDER" = "These conversations are archived. They will appear in the inbox if new messages are received."; +/* Label warning the user that they have been de-registered. */ +"INBOX_VIEW_DEREGISTRATION_WARNING" = "You are not logged in. Another device may have been registered with your phone number."; + /* Multi-line label explaining how to show names instead of phone numbers in your inbox */ "INBOX_VIEW_MISSING_CONTACTS_PERMISSION" = "To see the names of your contacts, update your system settings to allow contact access.";