2017-11-29 17:01:30 +01:00
|
|
|
//
|
2018-01-10 17:14:02 +01:00
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
2017-11-29 17:01:30 +01:00
|
|
|
//
|
|
|
|
|
2017-11-30 16:10:30 +01:00
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
2018-01-10 17:14:02 +01:00
|
|
|
// These are fired whenever the corresponding "main app" or "app extension"
|
|
|
|
// notification is fired.
|
|
|
|
//
|
|
|
|
// 1. This saves you the work of observing both.
|
|
|
|
// 2. This allows us to ensure that any critical work (e.g. re-opening
|
|
|
|
// databases) has been done before app re-enters foreground, etc.
|
|
|
|
extern NSString *const OWSApplicationDidEnterBackgroundNotification;
|
|
|
|
extern NSString *const OWSApplicationWillEnterForegroundNotification;
|
|
|
|
extern NSString *const OWSApplicationWillResignActiveNotification;
|
|
|
|
extern NSString *const OWSApplicationDidBecomeActiveNotification;
|
|
|
|
|
2017-11-29 17:01:30 +01:00
|
|
|
typedef void (^BackgroundTaskExpirationHandler)(void);
|
|
|
|
|
2017-12-04 16:35:47 +01:00
|
|
|
@class OWSAES256Key;
|
2017-12-01 21:17:29 +01:00
|
|
|
|
2017-11-29 17:01:30 +01:00
|
|
|
@protocol AppContext <NSObject>
|
|
|
|
|
2017-12-07 01:29:12 +01:00
|
|
|
@property (nonatomic, readonly) BOOL isMainApp;
|
|
|
|
@property (nonatomic, readonly) BOOL isMainAppAndActive;
|
|
|
|
|
|
|
|
// Whether the user is using a right-to-left language like Arabic
|
|
|
|
@property (nonatomic, readonly) BOOL isRTL;
|
|
|
|
|
|
|
|
@property (nonatomic, readonly) BOOL isRunningTests;
|
|
|
|
|
|
|
|
// Useful for translating coordinates to the "entire screen"
|
2017-12-07 16:39:15 +01:00
|
|
|
@property (nonatomic, readonly, nullable) UIView *rootReferenceView;
|
2017-11-29 17:01:30 +01:00
|
|
|
|
2017-11-29 22:32:49 +01:00
|
|
|
// Should only be called if isMainApp is YES.
|
|
|
|
//
|
2018-01-12 20:24:35 +01:00
|
|
|
// Wherever possible, use isMainAppAndActive or isInBackground instead.
|
|
|
|
// This should only be used by debugging/logging code.
|
2017-11-29 22:32:49 +01:00
|
|
|
- (UIApplicationState)mainApplicationState;
|
|
|
|
|
2018-01-12 20:24:35 +01:00
|
|
|
// Similar to UIApplicationStateBackground, but works in SAE.
|
|
|
|
- (BOOL)isInBackground;
|
|
|
|
|
2017-11-29 22:32:49 +01:00
|
|
|
// Should start a background task if isMainApp is YES.
|
|
|
|
// Should just return UIBackgroundTaskInvalid if isMainApp is NO.
|
2017-11-29 17:01:30 +01:00
|
|
|
- (UIBackgroundTaskIdentifier)beginBackgroundTaskWithExpirationHandler:
|
|
|
|
(BackgroundTaskExpirationHandler)expirationHandler;
|
2017-12-04 22:09:26 +01:00
|
|
|
|
2017-11-29 22:32:49 +01:00
|
|
|
// Should be a NOOP if isMainApp is NO.
|
2017-11-29 21:27:19 +01:00
|
|
|
- (void)endBackgroundTask:(UIBackgroundTaskIdentifier)backgroundTaskIdentifier;
|
|
|
|
|
2017-12-06 23:44:00 +01:00
|
|
|
// Should be a NOOP if isMainApp is NO.
|
|
|
|
- (void)ensureSleepBlocking:(BOOL)shouldBeBlocking blockingObjects:(NSArray<id> *)blockingObjects;
|
|
|
|
|
2017-11-29 21:27:19 +01:00
|
|
|
// Should only be called if isMainApp is YES.
|
|
|
|
- (void)setMainAppBadgeNumber:(NSInteger)value;
|
2017-11-29 17:01:30 +01:00
|
|
|
|
2017-12-04 23:17:44 +01:00
|
|
|
- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle;
|
2018-01-16 23:55:53 +01:00
|
|
|
- (void)setStatusBarHidden:(BOOL)isHidden animated:(BOOL)isAnimated;
|
2017-12-02 00:43:40 +01:00
|
|
|
|
2017-12-01 23:10:14 +01:00
|
|
|
// Returns the VC that should be used to present alerts, modals, etc.
|
2017-12-01 23:22:40 +01:00
|
|
|
- (nullable UIViewController *)frontmostViewController;
|
|
|
|
|
|
|
|
// Should only be called if isMainApp is YES.
|
|
|
|
- (void)openSystemSettings;
|
2017-12-01 23:10:14 +01:00
|
|
|
|
2017-12-04 16:35:47 +01:00
|
|
|
// Should only be called if isMainApp is YES,
|
|
|
|
// but should only be necessary to call if isMainApp is YES.
|
|
|
|
- (void)doMultiDeviceUpdateWithProfileKey:(OWSAES256Key *)profileKey;
|
|
|
|
|
2017-12-04 22:09:26 +01:00
|
|
|
// Should be a NOOP if isMainApp is NO.
|
|
|
|
- (void)setNetworkActivityIndicatorVisible:(BOOL)value;
|
|
|
|
|
2017-11-29 17:01:30 +01:00
|
|
|
@end
|
|
|
|
|
2017-11-29 21:27:19 +01:00
|
|
|
id<AppContext> CurrentAppContext(void);
|
2017-11-29 17:01:30 +01:00
|
|
|
void SetCurrentAppContext(id<AppContext> appContext);
|
2017-11-30 16:10:30 +01:00
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|