mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
wire up window mgmt
This commit is contained in:
parent
3cc13a66af
commit
6037a440c9
7 changed files with 109 additions and 2 deletions
|
@ -420,6 +420,7 @@
|
|||
4C20B2B920CA10DE001BAC90 /* ConversationSearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C20B2B820CA10DE001BAC90 /* ConversationSearchViewController.swift */; };
|
||||
4C4AEC4520EC343B0020E72B /* DismissableTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C4AEC4420EC343B0020E72B /* DismissableTextField.swift */; };
|
||||
4CC0B59C20EC5F2E00CF6EE0 /* ConversationConfigurationSyncOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CC0B59B20EC5F2E00CF6EE0 /* ConversationConfigurationSyncOperation.swift */; };
|
||||
4CFF4C0A20F55BBA005DA313 /* MessageActionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CFF4C0920F55BBA005DA313 /* MessageActionsViewController.swift */; };
|
||||
70377AAB1918450100CAF501 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 70377AAA1918450100CAF501 /* MobileCoreServices.framework */; };
|
||||
768A1A2B17FC9CD300E00ED8 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 768A1A2A17FC9CD300E00ED8 /* libz.dylib */; };
|
||||
76C87F19181EFCE600C4ACAB /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 76C87F18181EFCE600C4ACAB /* MediaPlayer.framework */; };
|
||||
|
@ -1083,6 +1084,7 @@
|
|||
4C20B2B820CA10DE001BAC90 /* ConversationSearchViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationSearchViewController.swift; sourceTree = "<group>"; };
|
||||
4C4AEC4420EC343B0020E72B /* DismissableTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DismissableTextField.swift; sourceTree = "<group>"; };
|
||||
4CC0B59B20EC5F2E00CF6EE0 /* ConversationConfigurationSyncOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConversationConfigurationSyncOperation.swift; sourceTree = "<group>"; };
|
||||
4CFF4C0920F55BBA005DA313 /* MessageActionsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageActionsViewController.swift; sourceTree = "<group>"; };
|
||||
69349DE607F5BA6036C9AC60 /* Pods-SignalShareExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SignalShareExtension.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SignalShareExtension/Pods-SignalShareExtension.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
70377AAA1918450100CAF501 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
|
||||
748A5CAEDD7C919FC64C6807 /* Pods_SignalTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SignalTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
@ -1689,6 +1691,7 @@
|
|||
452EC6DE205E9E30000E787C /* MediaGalleryViewController.swift */,
|
||||
45F32C1D205718B000A300D5 /* MediaPageViewController.swift */,
|
||||
454A84032059C787008B8C75 /* MediaTileViewController.swift */,
|
||||
4CFF4C0920F55BBA005DA313 /* MessageActionsViewController.swift */,
|
||||
34CA1C261F7156F300E51C51 /* MessageDetailViewController.swift */,
|
||||
34B3F84F1E8DF1700035BE1A /* NewContactThreadViewController.h */,
|
||||
34B3F8501E8DF1700035BE1A /* NewContactThreadViewController.m */,
|
||||
|
@ -3246,6 +3249,7 @@
|
|||
4585C4681ED8F8D200896AEA /* SafetyNumberConfirmationAlert.swift in Sources */,
|
||||
4C20B2B920CA10DE001BAC90 /* ConversationSearchViewController.swift in Sources */,
|
||||
450D19131F85236600970622 /* RemoteVideoView.m in Sources */,
|
||||
4CFF4C0A20F55BBA005DA313 /* MessageActionsViewController.swift in Sources */,
|
||||
B6B9ECFC198B31BA00C620D3 /* PushManager.m in Sources */,
|
||||
34386A54207D271D009F5D9C /* NeverClearView.swift in Sources */,
|
||||
45DF5DF21DDB843F00C936C7 /* CompareSafetyNumbersActivity.swift in Sources */,
|
||||
|
|
|
@ -22,6 +22,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@protocol ConversationViewCellDelegate <NSObject>
|
||||
|
||||
- (void)conversationCellDidLongpressText:(ConversationViewCell *)cell viewItem:(ConversationViewItem *)viewItem;
|
||||
|
||||
- (void)didPanWithGestureRecognizer:(UIPanGestureRecognizer *)gestureRecognizer
|
||||
viewItem:(ConversationViewItem *)conversationItem;
|
||||
|
||||
|
|
|
@ -448,8 +448,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
switch ([self.messageBubbleView gestureLocationForLocation:locationInMessageBubble]) {
|
||||
case OWSMessageGestureLocation_Default:
|
||||
case OWSMessageGestureLocation_OversizeText: {
|
||||
CGPoint location = [sender locationInView:self];
|
||||
[self showTextMenuController:location];
|
||||
[self.delegate conversationCellDidLongpressText:self viewItem:self.viewItem];
|
||||
break;
|
||||
}
|
||||
case OWSMessageGestureLocation_Media: {
|
||||
|
|
|
@ -1980,6 +1980,12 @@ typedef enum : NSUInteger {
|
|||
|
||||
#pragma mark - ConversationViewCellDelegate
|
||||
|
||||
- (void)conversationCellDidLongpressText:(ConversationViewCell *)cell viewItem:(ConversationViewItem *)viewItem
|
||||
{
|
||||
UIViewController *messageActionsViewController = [MessageActionsViewController new];
|
||||
[[OWSWindowManager sharedManager] presentMessageActions:messageActionsViewController];
|
||||
}
|
||||
|
||||
- (NSAttributedString *)attributedContactOrProfileNameForPhoneIdentifier:(NSString *)recipientId
|
||||
{
|
||||
OWSAssertIsOnMainThread();
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc
|
||||
class MessageActionsViewController: UIViewController {
|
||||
|
||||
override func loadView() {
|
||||
self.view = UIView()
|
||||
view.backgroundColor = .purple
|
||||
}
|
||||
}
|
|
@ -27,6 +27,10 @@ extern const UIWindowLevel UIWindowLevel_Background;
|
|||
|
||||
- (void)setIsScreenBlockActive:(BOOL)isScreenBlockActive;
|
||||
|
||||
#pragma mark - Message Actions
|
||||
|
||||
- (void)presentMessageActions:(UIViewController *)messageActionsViewController;
|
||||
|
||||
#pragma mark - Calls
|
||||
|
||||
@property (nonatomic, readonly) BOOL shouldShowCallView;
|
||||
|
|
|
@ -50,6 +50,14 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
|
|||
return UIWindowLevelStatusBar + 2.f;
|
||||
}
|
||||
|
||||
// In front of everything, including the status bar.
|
||||
const UIWindowLevel UIWindowLevel_MessageActions(void);
|
||||
const UIWindowLevel UIWindowLevel_MessageActions(void)
|
||||
{
|
||||
// TODO This won't cover the keyboard...
|
||||
return UIWindowLevel_ScreenBlocking() - 1;
|
||||
}
|
||||
|
||||
@implementation OWSWindowRootViewController
|
||||
|
||||
- (BOOL)canBecomeFirstResponder
|
||||
|
@ -74,6 +82,10 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
|
|||
@property (nonatomic) UIWindow *callViewWindow;
|
||||
@property (nonatomic) UINavigationController *callNavigationController;
|
||||
|
||||
// UIWindowLevel_MessageActions
|
||||
@property (nonatomic) UIWindow *messageActionsWindow;
|
||||
@property (nonatomic, nullable) UIViewController *messageActionsViewController;
|
||||
|
||||
// UIWindowLevel_Background if inactive,
|
||||
// UIWindowLevel_ScreenBlocking() if active.
|
||||
@property (nonatomic) UIWindow *screenBlockingWindow;
|
||||
|
@ -127,6 +139,7 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
|
|||
|
||||
self.returnToCallWindow = [self createReturnToCallWindow:rootWindow];
|
||||
self.callViewWindow = [self createCallViewWindow:rootWindow];
|
||||
self.messageActionsWindow = [self createMessageActionsWindowWithRoowWindow:rootWindow];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(didChangeStatusBarFrame:)
|
||||
|
@ -169,6 +182,20 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
|
|||
return window;
|
||||
}
|
||||
|
||||
- (UIWindow *)createMessageActionsWindowWithRoowWindow:(UIWindow *)rootWindow
|
||||
{
|
||||
UIWindow *window = [[UIWindow alloc] initWithFrame:rootWindow.bounds];
|
||||
window.hidden = YES;
|
||||
window.windowLevel = UIWindowLevel_MessageActions();
|
||||
// window.opaque = YES;
|
||||
window.backgroundColor = UIColor.clearColor;
|
||||
|
||||
|
||||
// window.rootViewController = navigationController;
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
- (UIWindow *)createCallViewWindow:(UIWindow *)rootWindow
|
||||
{
|
||||
OWSAssertIsOnMainThread();
|
||||
|
@ -210,6 +237,23 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
|
|||
|
||||
#pragma mark - Calls
|
||||
|
||||
- (void)presentMessageActions:(UIViewController *)messageActionsViewController
|
||||
{
|
||||
self.messageActionsViewController = messageActionsViewController;
|
||||
self.messageActionsWindow.rootViewController = messageActionsViewController;
|
||||
[self ensureWindowState];
|
||||
}
|
||||
|
||||
- (void)dismissMessageActions
|
||||
{
|
||||
self.messageActionsWindow.rootViewController = nil;
|
||||
self.messageActionsViewController = nil;
|
||||
|
||||
[self ensureWindowState];
|
||||
}
|
||||
|
||||
#pragma mark - Calls
|
||||
|
||||
- (void)setCallViewController:(nullable UIViewController *)callViewController
|
||||
{
|
||||
OWSAssertIsOnMainThread();
|
||||
|
@ -309,6 +353,7 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
|
|||
[self ensureRootWindowHidden];
|
||||
[self ensureReturnToCallWindowHidden];
|
||||
[self ensureCallViewWindowHidden];
|
||||
[self ensureMessageActionsWindowHidden];
|
||||
[self ensureScreenBlockWindowShown];
|
||||
} else if (self.callViewController && self.shouldShowCallView) {
|
||||
// Show Call View.
|
||||
|
@ -316,6 +361,7 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
|
|||
[self ensureRootWindowHidden];
|
||||
[self ensureReturnToCallWindowHidden];
|
||||
[self ensureCallViewWindowShown];
|
||||
[self ensureMessageActionsWindowHidden];
|
||||
[self ensureScreenBlockWindowHidden];
|
||||
} else if (self.callViewController) {
|
||||
// Show Root Window + "Return to Call".
|
||||
|
@ -323,6 +369,14 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
|
|||
[self ensureRootWindowShown];
|
||||
[self ensureReturnToCallWindowShown];
|
||||
[self ensureCallViewWindowHidden];
|
||||
[self ensureMessageActionsWindowHidden];
|
||||
[self ensureScreenBlockWindowHidden];
|
||||
} else if (self.messageActionsViewController) {
|
||||
|
||||
[self ensureRootWindowHidden];
|
||||
[self ensureReturnToCallWindowHidden];
|
||||
[self ensureCallViewWindowHidden];
|
||||
[self ensureMessageActionsWindowShown];
|
||||
[self ensureScreenBlockWindowHidden];
|
||||
} else {
|
||||
// Show Root Window
|
||||
|
@ -330,6 +384,7 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
|
|||
[self ensureRootWindowShown];
|
||||
[self ensureReturnToCallWindowHidden];
|
||||
[self ensureCallViewWindowHidden];
|
||||
[self ensureMessageActionsWindowHidden];
|
||||
[self ensureScreenBlockWindowHidden];
|
||||
}
|
||||
}
|
||||
|
@ -407,6 +462,29 @@ const UIWindowLevel UIWindowLevel_ScreenBlocking(void)
|
|||
self.callViewWindow.hidden = YES;
|
||||
}
|
||||
|
||||
- (void)ensureMessageActionsWindowShown
|
||||
{
|
||||
OWSAssertIsOnMainThread();
|
||||
|
||||
if (self.messageActionsWindow.hidden) {
|
||||
DDLogInfo(@"%@ showing message actions window.", self.logTag);
|
||||
}
|
||||
|
||||
// Do not make key, we want the keyboard to stay popped.
|
||||
self.messageActionsWindow.hidden = NO;
|
||||
}
|
||||
|
||||
- (void)ensureMessageActionsWindowHidden
|
||||
{
|
||||
OWSAssertIsOnMainThread();
|
||||
|
||||
if (!self.messageActionsWindow.hidden) {
|
||||
DDLogInfo(@"%@ hiding message actions window.", self.logTag);
|
||||
}
|
||||
|
||||
self.messageActionsWindow.hidden = YES;
|
||||
}
|
||||
|
||||
- (void)ensureScreenBlockWindowShown
|
||||
{
|
||||
OWSAssertIsOnMainThread();
|
||||
|
|
Loading…
Reference in a new issue