Make SignalMessaging AppExtension safe

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent fcb17585b0
commit 2af818b3ba

@ -3493,6 +3493,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 9B533A9FA46206D3D99C9ADA /* Pods-SignalMessaging.debug.xcconfig */;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
@ -3546,6 +3547,7 @@
baseConfigurationReference = 948239851C08032C842937CC /* Pods-SignalMessaging.test.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
@ -3618,6 +3620,7 @@
baseConfigurationReference = 8EEE74B0753448C085B48721 /* Pods-SignalMessaging.app store release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";

@ -18,6 +18,12 @@ NS_ASSUME_NONNULL_BEGIN
return [UIApplication sharedApplication].applicationState == UIApplicationStateActive;
}
- (BOOL)isRTL
{
return
[[UIApplication sharedApplication] userInterfaceLayoutDirection] == UIUserInterfaceLayoutDirectionRightToLeft;
}
- (UIApplicationState)mainApplicationState
{
return [UIApplication sharedApplication].applicationState;

@ -4,6 +4,7 @@
#import "OWSMath.h"
#import "UIView+OWS.h"
#import <SignalServiceKit/AppContext.h>
NS_ASSUME_NONNULL_BEGIN
@ -256,8 +257,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
return ([UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.semanticContentAttribute]
== UIUserInterfaceLayoutDirectionRightToLeft);
} else {
return
[UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft;
return [CurrentAppContext() isRTL];
}
}

@ -26,6 +26,8 @@ typedef void (^BackgroundTaskExpirationHandler)(void);
// Should only be called if isMainApp is YES.
- (void)setMainAppBadgeNumber:(NSInteger)value;
- (BOOL)isRTL;
@end
id<AppContext> CurrentAppContext(void);

@ -18,6 +18,15 @@ NS_ASSUME_NONNULL_BEGIN
return NO;
}
- (BOOL)isRTL
{
// Borrowed from PureLayout's AppExtension compatible RTL support.
// App Extensions may not access -[UIApplication sharedApplication]; fall back to checking the bundle's preferred
// localization character direction
return [NSLocale characterDirectionForLanguage:[[NSBundle mainBundle] preferredLocalizations][0]]
== NSLocaleLanguageDirectionRightToLeft;
}
- (UIApplicationState)mainApplicationState
{
OWSFail(@"%@ called %s.", self.logTag, __PRETTY_FUNCTION__);

Loading…
Cancel
Save