From d065c952703ab4553796c56336dfd0d2e05d37c9 Mon Sep 17 00:00:00 2001 From: Matthew Chen <charlesmchen@gmail.com> Date: Fri, 26 May 2017 20:41:27 -0400 Subject: [PATCH] Hide the socket status view when censorship circumvention is active. // FREEBIE --- Signal/src/AppDelegate.m | 8 ++-- Signal/src/Signal-Bridging-Header.h | 9 ++-- .../SettingsTableViewController.m | 4 +- .../SignalsNavigationController.h | 10 +---- .../SignalsNavigationController.m | 43 ++++++++++++++----- Signal/src/network/PushManager.m | 10 ++--- 6 files changed, 49 insertions(+), 35 deletions(-) diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 58ea73f60..240fe7e6b 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -18,10 +18,6 @@ #import "Release.h" #import "SendExternalFileViewController.h" #import "Signal-Swift.h" -#import "TSMessagesManager.h" -#import "TSSocketManager.h" -#import "TSStorageManager+Calling.h" -#import "TextSecureKitEnv.h" #import "VersionMigrations.h" #import "ViewControllerUtils.h" #import <AxolotlKit/SessionCipher.h> @@ -31,7 +27,11 @@ #import <SignalServiceKit/OWSIncomingMessageReadObserver.h> #import <SignalServiceKit/OWSMessageSender.h> #import <SignalServiceKit/TSAccountManager.h> +#import <SignalServiceKit/TSMessagesManager.h> #import <SignalServiceKit/TSPreKeyManager.h> +#import <SignalServiceKit/TSSocketManager.h> +#import <SignalServiceKit/TSStorageManager+Calling.h> +#import <SignalServiceKit/TextSecureKitEnv.h> @import WebRTC; @import Intents; diff --git a/Signal/src/Signal-Bridging-Header.h b/Signal/src/Signal-Bridging-Header.h index aaae1d437..5c1f3dd43 100644 --- a/Signal/src/Signal-Bridging-Header.h +++ b/Signal/src/Signal-Bridging-Header.h @@ -4,7 +4,6 @@ #import <Foundation/Foundation.h> -#import "Asserts.h" #import "AttachmentSharing.h" #import "Environment.h" #import "FLAnimatedImage.h" @@ -14,8 +13,6 @@ #import "OWSCallNotificationsAdaptee.h" #import "OWSContactAvatarBuilder.h" #import "OWSContactsManager.h" -#import "OWSDispatch.h" -#import "OWSError.h" #import "OWSLogger.h" #import "OWSMessageEditing.h" #import "OWSProgressView.h" @@ -24,8 +21,6 @@ #import "PropertyListPreferences.h" #import "PushManager.h" #import "SettingsTableViewController.h" -#import "TSSocketManager.h" -#import "TSStorageManager+Calling.h" #import "UIColor+OWS.h" #import "UIFont+OWS.h" #import "UIUtil.h" @@ -38,6 +33,7 @@ #import <JSQSystemSoundPlayer.h> #import <PureLayout/PureLayout.h> #import <SignalServiceKit/AppVersion.h> +#import <SignalServiceKit/Asserts.h> #import <SignalServiceKit/Contact.h> #import <SignalServiceKit/ContactsUpdater.h> #import <SignalServiceKit/Cryptography.h> @@ -52,6 +48,7 @@ #import <SignalServiceKit/OWSCallIceUpdateMessage.h> #import <SignalServiceKit/OWSCallMessageHandler.h> #import <SignalServiceKit/OWSCallOfferMessage.h> +#import <SignalServiceKit/OWSDispatch.h> #import <SignalServiceKit/OWSEndSessionMessage.h> #import <SignalServiceKit/OWSError.h> #import <SignalServiceKit/OWSGetMessagesRequest.h> @@ -75,6 +72,8 @@ #import <SignalServiceKit/TSInfoMessage.h> #import <SignalServiceKit/TSMessagesManager.h> #import <SignalServiceKit/TSNetworkManager.h> +#import <SignalServiceKit/TSSocketManager.h> +#import <SignalServiceKit/TSStorageManager+Calling.h> #import <SignalServiceKit/TSStorageManager+IdentityKeyStore.h> #import <SignalServiceKit/TSStorageManager+SessionStore.h> #import <SignalServiceKit/TSStorageManager+keyingMaterial.h> diff --git a/Signal/src/ViewControllers/SettingsTableViewController.m b/Signal/src/ViewControllers/SettingsTableViewController.m index 26286121b..f5d234403 100644 --- a/Signal/src/ViewControllers/SettingsTableViewController.m +++ b/Signal/src/ViewControllers/SettingsTableViewController.m @@ -13,9 +13,9 @@ #import "PropertyListPreferences.h" #import "PushManager.h" #import "Signal-Swift.h" -#import "TSAccountManager.h" -#import "TSSocketManager.h" #import "UIUtil.h" +#import <SignalServiceKit/TSAccountManager.h> +#import <SignalServiceKit/TSSocketManager.h> @interface SettingsTableViewController () diff --git a/Signal/src/ViewControllers/SignalsNavigationController.h b/Signal/src/ViewControllers/SignalsNavigationController.h index 97b699fe0..88d3f97ff 100644 --- a/Signal/src/ViewControllers/SignalsNavigationController.h +++ b/Signal/src/ViewControllers/SignalsNavigationController.h @@ -1,15 +1,9 @@ // -// SignalsNavigationController.h -// Signal -// -// Created by Dylan Bourgeois on 18/11/14. -// Copyright (c) 2014 Open Whisper Systems. All rights reserved. +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // #import <UIKit/UIKit.h> -#import "TSSocketManager.h" @interface SignalsNavigationController : UINavigationController -@property (nonatomic, strong) UIProgressView *socketStatusView; -@property (nonatomic, strong) NSTimer *updateStatusTimer; + @end diff --git a/Signal/src/ViewControllers/SignalsNavigationController.m b/Signal/src/ViewControllers/SignalsNavigationController.m index d82f5eabc..e8310f160 100644 --- a/Signal/src/ViewControllers/SignalsNavigationController.m +++ b/Signal/src/ViewControllers/SignalsNavigationController.m @@ -3,16 +3,22 @@ // #import "SignalsNavigationController.h" - #import "UIUtil.h" +#import <SignalServiceKit/OWSSignalService.h> +#import <SignalServiceKit/TSSocketManager.h> + +static double const STALLED_PROGRESS = 0.9; @interface SignalsNavigationController () +@property (nonatomic) UIProgressView *socketStatusView; +@property (nonatomic) NSTimer *updateStatusTimer; + @end -static double const STALLED_PROGRESS = 0.9; -@implementation SignalsNavigationController +#pragma mark - +@implementation SignalsNavigationController - (void)viewDidLoad { [super viewDidLoad]; @@ -36,7 +42,8 @@ static double const STALLED_PROGRESS = 0.9; } } -- (void)dealloc { +- (void)dealloc +{ [[NSNotificationCenter defaultCenter] removeObserver:self]; } @@ -47,6 +54,17 @@ static double const STALLED_PROGRESS = 0.9; selector:@selector(socketManagerStateDidChange) name:kNSNotification_SocketManagerStateDidChange object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(isCensorshipCircumventionActiveDidChange:) + name:kNSNotificationName_IsCensorshipCircumventionActiveDidChange + object:nil]; +} + +- (void)isCensorshipCircumventionActiveDidChange:(NSNotification *)notification +{ + OWSAssert([NSThread isMainThread]); + + [self updateSocketStatusView]; } - (void)socketManagerStateDidChange { @@ -57,7 +75,14 @@ static double const STALLED_PROGRESS = 0.9; - (void)updateSocketStatusView { OWSAssert([NSThread isMainThread]); - + + if ([OWSSignalService sharedInstance].isCensorshipCircumventionActive) { + [_updateStatusTimer invalidate]; + [_socketStatusView removeFromSuperview]; + _socketStatusView = nil; + return; + } + switch ([TSSocketManager sharedManager].state) { case SocketManagerStateClosed: if (_socketStatusView == nil) { @@ -77,12 +102,8 @@ static double const STALLED_PROGRESS = 0.9; break; case SocketManagerStateOpen: [_updateStatusTimer invalidate]; - for (UIView *view in self.navigationBar.subviews) { - if ([view isKindOfClass:[UIProgressView class]]) { - [view removeFromSuperview]; - _socketStatusView = nil; - } - } + [_socketStatusView removeFromSuperview]; + _socketStatusView = nil; break; } } diff --git a/Signal/src/network/PushManager.m b/Signal/src/network/PushManager.m index 08afdddb2..9dfe06f95 100644 --- a/Signal/src/network/PushManager.m +++ b/Signal/src/network/PushManager.m @@ -5,16 +5,16 @@ #import "PushManager.h" #import "AppDelegate.h" #import "NSData+ows_StripToken.h" -#import "NSDate+millisecondTimeStamp.h" #import "OWSContactsManager.h" #import "PropertyListPreferences.h" #import "Signal-Swift.h" -#import "TSMessagesManager.h" -#import "TSAccountManager.h" -#import "TSOutgoingMessage.h" -#import "TSSocketManager.h" +#import <SignalServiceKit/NSDate+millisecondTimeStamp.h> #import <SignalServiceKit/OWSMessageSender.h> #import <SignalServiceKit/OWSSignalService.h> +#import <SignalServiceKit/TSAccountManager.h> +#import <SignalServiceKit/TSMessagesManager.h> +#import <SignalServiceKit/TSOutgoingMessage.h> +#import <SignalServiceKit/TSSocketManager.h> #define pushManagerDomain @"org.whispersystems.pushmanager"