2017-11-29 20:51:39 +01:00
|
|
|
//
|
|
|
|
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "MainAppContext.h"
|
2017-12-01 23:22:40 +01:00
|
|
|
#import "Signal-Swift.h"
|
2017-12-04 16:35:47 +01:00
|
|
|
#import <SignalMessaging/Environment.h>
|
|
|
|
#import <SignalMessaging/OWSProfileManager.h>
|
|
|
|
#import <SignalServiceKit/OWSIdentityManager.h>
|
2017-11-29 20:51:39 +01:00
|
|
|
|
2017-11-30 16:10:30 +01:00
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
2017-11-29 20:51:39 +01:00
|
|
|
@implementation MainAppContext
|
|
|
|
|
|
|
|
- (BOOL)isMainApp
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isMainAppAndActive
|
|
|
|
{
|
|
|
|
return [UIApplication sharedApplication].applicationState == UIApplicationStateActive;
|
|
|
|
}
|
|
|
|
|
2017-12-02 00:43:40 +01:00
|
|
|
- (BOOL)isRTL
|
|
|
|
{
|
|
|
|
return
|
|
|
|
[[UIApplication sharedApplication] userInterfaceLayoutDirection] == UIUserInterfaceLayoutDirectionRightToLeft;
|
|
|
|
}
|
|
|
|
|
2017-12-04 23:17:44 +01:00
|
|
|
- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle
|
|
|
|
{
|
|
|
|
[[UIApplication sharedApplication] setStatusBarStyle:statusBarStyle];
|
|
|
|
}
|
|
|
|
|
2017-11-29 22:32:49 +01:00
|
|
|
- (UIApplicationState)mainApplicationState
|
|
|
|
{
|
|
|
|
return [UIApplication sharedApplication].applicationState;
|
|
|
|
}
|
|
|
|
|
2017-11-29 20:51:39 +01:00
|
|
|
- (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler:
|
|
|
|
(BackgroundTaskExpirationHandler)expirationHandler
|
|
|
|
{
|
|
|
|
return [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:expirationHandler];
|
|
|
|
}
|
|
|
|
|
2017-11-29 21:27:19 +01:00
|
|
|
- (void)endBackgroundTask:(UIBackgroundTaskIdentifier)backgroundTaskIdentifier
|
|
|
|
{
|
|
|
|
[UIApplication.sharedApplication endBackgroundTask:backgroundTaskIdentifier];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setMainAppBadgeNumber:(NSInteger)value
|
|
|
|
{
|
|
|
|
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:value];
|
|
|
|
}
|
|
|
|
|
2017-12-01 23:22:40 +01:00
|
|
|
- (nullable UIViewController *)frontmostViewController
|
2017-12-01 23:10:14 +01:00
|
|
|
{
|
2017-12-01 23:22:40 +01:00
|
|
|
return UIApplication.sharedApplication.frontmostViewControllerIgnoringAlerts;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)openSystemSettings
|
|
|
|
{
|
|
|
|
[UIApplication.sharedApplication openSystemSettings];
|
2017-12-01 23:10:14 +01:00
|
|
|
}
|
|
|
|
|
2017-12-04 16:35:47 +01:00
|
|
|
- (void)doMultiDeviceUpdateWithProfileKey:(OWSAES256Key *)profileKey
|
|
|
|
{
|
|
|
|
OWSAssert(profileKey);
|
|
|
|
|
|
|
|
[MultiDeviceProfileKeyUpdateJob runWithProfileKey:profileKey
|
|
|
|
identityManager:OWSIdentityManager.sharedManager
|
|
|
|
messageSender:Environment.current.messageSender
|
|
|
|
profileManager:OWSProfileManager.sharedManager];
|
|
|
|
}
|
|
|
|
|
2017-12-04 18:38:44 +01:00
|
|
|
- (BOOL)isRunningTests
|
|
|
|
{
|
|
|
|
return getenv("runningTests_dontStartApp");
|
|
|
|
}
|
|
|
|
|
2017-12-04 22:09:26 +01:00
|
|
|
- (void)setNetworkActivityIndicatorVisible:(BOOL)value
|
|
|
|
{
|
|
|
|
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:value];
|
|
|
|
}
|
|
|
|
|
2017-11-29 20:51:39 +01:00
|
|
|
@end
|
2017-11-30 16:10:30 +01:00
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|