Merge branch 'mkirk/archive-banner'

pull/1/head
Michael Kirk 7 years ago
commit 532e0b8946

@ -76,10 +76,10 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
// Views
@property (nonatomic) NSLayoutConstraint *hideDeregisteredViewConstraint;
@property (nonatomic) NSLayoutConstraint *hideArchiveReminderViewConstraint;
@property (nonatomic) NSLayoutConstraint *hideMissingContactsPermissionViewConstraint;
@property (nonatomic) NSLayoutConstraint *outageViewConstraint;
@property (nonatomic, readonly) UIView *deregisteredView;
@property (nonatomic, readonly) UIView *outageView;
@property (nonatomic, readonly) UIView *archiveReminderView;
@property (nonatomic, readonly) UIView *missingContactsPermissionView;
@property (nonatomic) TSThread *lastThread;
@ -242,23 +242,20 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
}
[RegistrationUtils showReregistrationUIFromViewController:strongSelf];
}];
_deregisteredView = deregisteredView;
[reminderStackView addArrangedSubview:deregisteredView];
self.hideDeregisteredViewConstraint = [deregisteredView autoSetDimension:ALDimensionHeight toSize:0];
self.hideDeregisteredViewConstraint.priority = UILayoutPriorityRequired;
ReminderView *outageView = [ReminderView
nagWithText:NSLocalizedString(@"OUTAGE_WARNING", @"Label warning the user that the Signal service may be down.")
tapAction:nil];
_outageView = outageView;
[reminderStackView addArrangedSubview:outageView];
self.outageViewConstraint = [outageView autoSetDimension:ALDimensionHeight toSize:0];
self.outageViewConstraint.priority = UILayoutPriorityRequired;
ReminderView *archiveReminderView =
[ReminderView explanationWithText:NSLocalizedString(@"INBOX_VIEW_ARCHIVE_MODE_REMINDER",
@"Label reminding the user that they are in archive mode.")];
_archiveReminderView = archiveReminderView;
[reminderStackView addArrangedSubview:archiveReminderView];
self.hideArchiveReminderViewConstraint = [archiveReminderView autoSetDimension:ALDimensionHeight toSize:0];
self.hideArchiveReminderViewConstraint.priority = UILayoutPriorityRequired;
ReminderView *missingContactsPermissionView = [ReminderView
nagWithText:NSLocalizedString(@"INBOX_VIEW_MISSING_CONTACTS_PERMISSION",
@ -266,10 +263,8 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
tapAction:^{
[[UIApplication sharedApplication] openSystemSettings];
}];
_missingContactsPermissionView = missingContactsPermissionView;
[reminderStackView addArrangedSubview:missingContactsPermissionView];
self.hideMissingContactsPermissionViewConstraint =
[missingContactsPermissionView autoSetDimension:ALDimensionHeight toSize:0];
self.hideMissingContactsPermissionViewConstraint.priority = UILayoutPriorityRequired;
self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
self.tableView.delegate = self;
@ -308,25 +303,10 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
- (void)updateReminderViews
{
BOOL shouldHideArchiveReminderView = self.homeViewMode != HomeViewMode_Archive;
BOOL shouldHideMissingContactsPermissionView = !self.shouldShowMissingContactsPermissionView;
BOOL shouldHideDeregisteredView = !TSAccountManager.sharedInstance.isDeregistered;
BOOL shouldHideOutageView = !OutageDetection.sharedManager.hasOutage;
if (self.hideArchiveReminderViewConstraint.active == shouldHideArchiveReminderView
&& self.hideMissingContactsPermissionViewConstraint.active == shouldHideMissingContactsPermissionView
&& self.hideDeregisteredViewConstraint.active == shouldHideDeregisteredView
&& self.outageViewConstraint.active == shouldHideOutageView) {
return;
}
self.hideArchiveReminderViewConstraint.active = shouldHideArchiveReminderView;
self.hideMissingContactsPermissionViewConstraint.active = shouldHideMissingContactsPermissionView;
self.hideDeregisteredViewConstraint.active = shouldHideDeregisteredView;
self.outageViewConstraint.active = shouldHideOutageView;
[self.view setNeedsLayout];
[self.view layoutSubviews];
self.archiveReminderView.hidden = self.homeViewMode != HomeViewMode_Archive;
self.missingContactsPermissionView.hidden = !self.contactsManager.isSystemContactsDenied;
self.deregisteredView.hidden = !TSAccountManager.sharedInstance.isDeregistered;
self.outageView.hidden = !OutageDetection.sharedManager.hasOutage;
}
- (void)viewDidLoad
@ -719,15 +699,6 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
}
- (BOOL)shouldShowMissingContactsPermissionView
{
if (!self.contactsManager.systemContactsHaveBeenRequestedAtLeastOnce) {
return NO;
}
return !self.contactsManager.isSystemContactsAuthorized;
}
#pragma mark - Table View Data Source
// Returns YES IFF this value changes.

@ -73,49 +73,36 @@ class ReminderView: UIView {
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(gestureRecognizer:)))
self.addGestureRecognizer(tapGesture)
let container = UIView()
let container = UIStackView()
container.axis = .horizontal
container.alignment = .center
container.isLayoutMarginsRelativeArrangement = true
self.addSubview(container)
container.autoPinWidthToSuperview(withMargin: 16)
switch (mode) {
case .nag:
container.autoPinHeightToSuperview(withMargin: 16)
case .explanation:
container.autoPinHeightToSuperview(withMargin: 12)
}
// Margin: top and bottom 12 left and right 16.
container.layoutMargins = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
container.autoPinToSuperviewEdges()
// Label
label.font = UIFont.ows_dynamicTypeSubheadline
container.addSubview(label)
container.addArrangedSubview(label)
label.textColor = UIColor.black.withAlphaComponent(0.9)
label.numberOfLines = 0
label.lineBreakMode = .byWordWrapping
label.autoPinLeadingToSuperviewMargin()
label.autoPinEdge(toSuperviewEdge: .top)
label.autoPinEdge(toSuperviewEdge: .bottom)
// Show the disclosure indicator if this reminder has a tap action.
if tapAction == nil {
return
}
// Icon
let iconName = (self.isRTL() ? "system_disclosure_indicator_rtl" : "system_disclosure_indicator")
guard let iconImage = UIImage(named: iconName) else {
owsFail("\(logTag) missing icon.")
return
if tapAction != nil {
// Icon
let iconName = (self.isRTL() ? "system_disclosure_indicator_rtl" : "system_disclosure_indicator")
guard let iconImage = UIImage(named: iconName) else {
owsFail("\(logTag) missing icon.")
return
}
let iconView = UIImageView(image: iconImage.withRenderingMode(.alwaysTemplate))
iconView.contentMode = .scaleAspectFit
iconView.tintColor = UIColor.black.withAlphaComponent(0.6)
iconView.autoSetDimension(.width, toSize: 13)
container.addArrangedSubview(iconView)
}
let iconView = UIImageView(image: iconImage.withRenderingMode(.alwaysTemplate))
iconView.contentMode = .scaleAspectFit
iconView.tintColor = UIColor.black.withAlphaComponent(0.6)
container.addSubview(iconView)
iconView.autoPinLeading(toTrailingEdgeOf: label, offset: 28)
iconView.autoPinTrailingToSuperviewMargin()
iconView.autoVCenterInSuperview()
iconView.autoSetDimension(.width, toSize: 13)
}
@objc func handleTap(gestureRecognizer: UIGestureRecognizer) {

@ -41,6 +41,7 @@ extern NSString *const OWSContactsManagerSignalAccountsDidChangeNotification;
// Must call `requestSystemContactsOnce` before accessing this method
@property (nonatomic, readonly) BOOL isSystemContactsAuthorized;
@property (nonatomic, readonly) BOOL isSystemContactsDenied;
@property (nonatomic, readonly) BOOL systemContactsHaveBeenRequestedAtLeastOnce;
@property (nonatomic, readonly) BOOL supportsContactEditing;

@ -129,6 +129,11 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification
return self.systemContactsFetcher.isAuthorized;
}
- (BOOL)isSystemContactsDenied
{
return self.systemContactsFetcher.isDenied;
}
- (BOOL)systemContactsHaveBeenRequestedAtLeastOnce
{
return self.systemContactsFetcher.systemContactsHaveBeenRequestedAtLeastOnce;

@ -170,6 +170,11 @@ public class SystemContactsFetcher: NSObject {
return self.authorizationStatus == .authorized
}
@objc
public var isDenied: Bool {
return self.authorizationStatus == .denied
}
@objc
public private(set) var systemContactsHaveBeenRequestedAtLeastOnce = false
private var hasSetupObservation = false

Loading…
Cancel
Save