diff --git a/Signal/src/views/RemoteVideoView.m b/Signal/src/views/RemoteVideoView.m index 0133ab96b..7f5cb8f07 100644 --- a/Signal/src/views/RemoteVideoView.m +++ b/Signal/src/views/RemoteVideoView.m @@ -3,16 +3,67 @@ // #import "RemoteVideoView.h" +#import "UIFont+OWS.h" +#import "UIView+OWS.h" #import #import #import #import #import -@interface RTCMTLVideoView (MakePrivatePublic) -+ (BOOL)isMetalAvailable; +NS_ASSUME_NONNULL_BEGIN + +// As of RTC M61, iOS8 crashes when ending call while de-alloc'ing the EAGLVideoView +// WebRTC doesn't seem to support iOS8 - e.g. their Podfile requires iOS9+ +// Until WebRTC supports iOS8, we show a "upgrade iOS to see remote video" view +// to our few remaining iOS8 users +@interface NullVideoRenderer : UIView + @end +@implementation NullVideoRenderer + +- (instancetype)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (!self) { + return self; + } + + self.backgroundColor = UIColor.blackColor; + + UILabel *label = [UILabel new]; + label.numberOfLines = 0; + label.text + = NSLocalizedString(@"CALL_REMOTE_VIDEO_DISABLED", @"Text shown on call screen in place of remote video"); + label.textAlignment = NSTextAlignmentCenter; + label.font = [UIFont ows_boldFontWithSize:ScaleFromIPhone5(20)]; + label.textColor = UIColor.whiteColor; + + [self addSubview:label]; + [label autoVCenterInSuperview]; + [label autoPinWidthToSuperviewWithMargin:ScaleFromIPhone5(16)]; + + return self; +} + +#pragma mark - RTCVideoRenderer + +/** The size of the frame. */ +- (void)setSize:(CGSize)size +{ + // Do nothing. +} + +/** The frame to be displayed. */ +- (void)renderFrame:(nullable RTCVideoFrame *)frame +{ + // Do nothing. +} + +@end + + @interface RemoteVideoView () @property (nonatomic, readonly) __kindof UIView *videoRenderer; @@ -28,6 +79,11 @@ return self; } + if (!SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(9, 0)) { + _videoRenderer = [NullVideoRenderer new]; + } + + if (_videoRenderer == nil) { // This class is defined in objc in order to access this compile time macro // Currently RTC only supports metal on 64bit machines #if defined(RTC_SUPPORTS_METAL) @@ -36,6 +92,8 @@ _videoRenderer = [[RTCMTLVideoView alloc] initWithFrame:CGRectZero]; } #endif + } + if (_videoRenderer == nil) { RTCEAGLVideoView *eaglVideoView = [[RTCEAGLVideoView alloc] initWithFrame:CGRectZero]; eaglVideoView.delegate = self; @@ -86,3 +144,5 @@ } @end + +NS_ASSUME_NONNULL_END diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 59137c75e..0a2dc6f9d 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -208,6 +208,9 @@ /* Accessibilty label for placing call button */ "CALL_LABEL" = "Call"; +/* Text shown on call screen in place of remote video */ +"CALL_REMOTE_VIDEO_DISABLED" = "Please upgrade to iOS 9 or newer to see remote video."; + /* Call setup status label after outgoing call times out */ "CALL_SCREEN_STATUS_NO_ANSWER" = "No Answer."; @@ -601,7 +604,7 @@ /* A label for generic attachments. */ "GENERIC_ATTACHMENT_LABEL" = "Attachment"; -/* Please enter your search. */ +/* Alert message shown when user tries to search for GIFs without entering any search terms. */ "GIF_PICKER_VIEW_MISSING_QUERY" = "Please enter your search."; /* Title for the 'gif picker' dialog. */