session-ios/Signal/src/util/MainAppContext.m

92 lines
2.8 KiB
Mathematica
Raw Normal View History

2017-11-29 20:51:39 +01:00
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "MainAppContext.h"
#import "OWS100RemoveTSRecipientsMigration.h"
#import "OWS102MoveLoggingPreferenceToUserDefaults.h"
#import "OWS103EnableVideoCalling.h"
#import "OWS105AttachmentFilePaths.h"
#import "Signal-Swift.h"
#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;
}
- (BOOL)isRTL
{
return
[[UIApplication sharedApplication] userInterfaceLayoutDirection] == UIUserInterfaceLayoutDirectionRightToLeft;
}
- (UIApplicationState)mainApplicationState
{
return [UIApplication sharedApplication].applicationState;
}
2017-11-29 20:51:39 +01:00
- (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler:
(BackgroundTaskExpirationHandler)expirationHandler
{
return [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:expirationHandler];
}
- (void)endBackgroundTask:(UIBackgroundTaskIdentifier)backgroundTaskIdentifier
{
[UIApplication.sharedApplication endBackgroundTask:backgroundTaskIdentifier];
}
- (void)setMainAppBadgeNumber:(NSInteger)value
{
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:value];
}
- (NSArray<OWSDatabaseMigration *> *)allMigrations
{
TSStorageManager *storageManager = TSStorageManager.sharedManager;
return @[
[[OWS100RemoveTSRecipientsMigration alloc] initWithStorageManager:storageManager],
[[OWS102MoveLoggingPreferenceToUserDefaults alloc] initWithStorageManager:storageManager],
[[OWS103EnableVideoCalling alloc] initWithStorageManager:storageManager],
// OWS104CreateRecipientIdentities is run separately. See runSafeBlockingMigrations.
[[OWS105AttachmentFilePaths alloc] initWithStorageManager:storageManager],
[[OWS106EnsureProfileComplete alloc] initWithStorageManager:storageManager]
];
}
- (nullable UIViewController *)frontmostViewController
{
return UIApplication.sharedApplication.frontmostViewControllerIgnoringAlerts;
}
- (void)openSystemSettings
{
[UIApplication.sharedApplication openSystemSettings];
}
- (void)doMultiDeviceUpdateWithProfileKey:(OWSAES256Key *)profileKey
{
OWSAssert(profileKey);
[MultiDeviceProfileKeyUpdateJob runWithProfileKey:profileKey
identityManager:OWSIdentityManager.sharedManager
messageSender:Environment.current.messageSender
profileManager:OWSProfileManager.sharedManager];
}
2017-11-29 20:51:39 +01:00
@end
2017-11-30 16:10:30 +01:00
NS_ASSUME_NONNULL_END