Skip to content

Commit

Permalink
Merge pull request #3084 from vector-im/riot_3067
Browse files Browse the repository at this point in the history
Consider Safe Area Insets for Some Screens
  • Loading branch information
ismailgulek authored Apr 23, 2020
2 parents 490de55 + 9e01e22 commit 911eb38
Show file tree
Hide file tree
Showing 42 changed files with 1,060 additions and 721 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Improvements:
Bug fix:
* Key backup banner is not hidden correctly (#2899).

Bug fix:
* Considered safe area insets for some screens (PR #3084).

Changes in 0.10.5 (2020-04-01)
===============================================

Expand Down
38 changes: 38 additions & 0 deletions Riot.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@
3AF393339D2D566CE14AC200 /* Pods_RiotTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 129EB7E27E7E4AC3F5F098F5 /* Pods_RiotTests.framework */; };
405FD41D306133A48D9B5AA1 /* Pods_RiotPods_Riot.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ACF09217ADF1D7E7A35BC02 /* Pods_RiotPods_Riot.framework */; };
670966FEFE120D865FD8A5B6 /* Pods_RiotPods_SiriIntents.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51187E952D5CECF6D6F5A28E /* Pods_RiotPods_SiriIntents.framework */; };
6E6F1CAA244DC1E90068B78B /* SectionHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6E6F1CA9244DC1E90068B78B /* SectionHeaderView.m */; };
6E6F1CAD244DDF3B0068B78B /* DirectorySectionHeaderContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6E6F1CAC244DDF3B0068B78B /* DirectorySectionHeaderContainerView.m */; };
6E6F1CB1244E00FD0068B78B /* LocalContactsSectionHeaderContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6E6F1CAF244E00FD0068B78B /* LocalContactsSectionHeaderContainerView.m */; };
6E6F1CB324506EC50068B78B /* UITableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E6F1CB224506EC50068B78B /* UITableViewCell.swift */; };
6E6F1CB524506FA40068B78B /* UITableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E6F1CB424506FA40068B78B /* UITableView.swift */; };
6E7A9E9C243E10E700FD039E /* UIDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6E7A9E9B243E10E700FD039E /* UIDevice.swift */; };
926FA53F1F4C132000F826C2 /* MXSession+Riot.m in Sources */ = {isa = PBXBuildFile; fileRef = 926FA53E1F4C132000F826C2 /* MXSession+Riot.m */; };
92726A471F58737A004AD26F /* IntentHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 92726A461F58737A004AD26F /* IntentHandler.m */; };
92726A4B1F58737A004AD26F /* SiriIntents.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 92726A431F58737A004AD26F /* SiriIntents.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -892,6 +898,15 @@
43C2962BE367F59220F517FA /* Pods-RiotPods-Riot.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RiotPods-Riot.debug.xcconfig"; path = "Target Support Files/Pods-RiotPods-Riot/Pods-RiotPods-Riot.debug.xcconfig"; sourceTree = "<group>"; };
4FC6A5D63FAD1B27C2F57AFA /* Pods-RiotPods-RiotShareExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RiotPods-RiotShareExtension.release.xcconfig"; path = "Target Support Files/Pods-RiotPods-RiotShareExtension/Pods-RiotPods-RiotShareExtension.release.xcconfig"; sourceTree = "<group>"; };
51187E952D5CECF6D6F5A28E /* Pods_RiotPods_SiriIntents.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RiotPods_SiriIntents.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6E6F1CA8244DC1E90068B78B /* SectionHeaderView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SectionHeaderView.h; sourceTree = "<group>"; };
6E6F1CA9244DC1E90068B78B /* SectionHeaderView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SectionHeaderView.m; sourceTree = "<group>"; };
6E6F1CAB244DDF3B0068B78B /* DirectorySectionHeaderContainerView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DirectorySectionHeaderContainerView.h; sourceTree = "<group>"; };
6E6F1CAC244DDF3B0068B78B /* DirectorySectionHeaderContainerView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DirectorySectionHeaderContainerView.m; sourceTree = "<group>"; };
6E6F1CAF244E00FD0068B78B /* LocalContactsSectionHeaderContainerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LocalContactsSectionHeaderContainerView.m; sourceTree = "<group>"; };
6E6F1CB0244E00FD0068B78B /* LocalContactsSectionHeaderContainerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalContactsSectionHeaderContainerView.h; sourceTree = "<group>"; };
6E6F1CB224506EC50068B78B /* UITableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITableViewCell.swift; sourceTree = "<group>"; };
6E6F1CB424506FA40068B78B /* UITableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UITableView.swift; sourceTree = "<group>"; };
6E7A9E9B243E10E700FD039E /* UIDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIDevice.swift; sourceTree = "<group>"; };
926FA53D1F4C132000F826C2 /* MXSession+Riot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MXSession+Riot.h"; sourceTree = "<group>"; };
926FA53E1F4C132000F826C2 /* MXSession+Riot.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MXSession+Riot.m"; sourceTree = "<group>"; };
92726A431F58737A004AD26F /* SiriIntents.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = SiriIntents.appex; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -2080,6 +2095,15 @@
name = Frameworks;
sourceTree = "<group>";
};
6E6F1CAE244DFB840068B78B /* SectionHeaders */ = {
isa = PBXGroup;
children = (
6E6F1CA8244DC1E90068B78B /* SectionHeaderView.h */,
6E6F1CA9244DC1E90068B78B /* SectionHeaderView.m */,
);
path = SectionHeaders;
sourceTree = "<group>";
};
92726A441F58737A004AD26F /* SiriIntents */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3075,6 +3099,7 @@
B1B556CD20EE6C4C00210D55 /* Common */ = {
isa = PBXGroup;
children = (
6E6F1CAE244DFB840068B78B /* SectionHeaders */,
B183226923F59F3E0035B2E8 /* Buttons */,
B1963B3622933B9500CBA17F /* CollectionView */,
B1B556CE20EE6C4C00210D55 /* WebViewController */,
Expand Down Expand Up @@ -3411,6 +3436,8 @@
B1B5579D20EF58AC00210D55 /* Views */ = {
isa = PBXGroup;
children = (
6E6F1CB0244E00FD0068B78B /* LocalContactsSectionHeaderContainerView.h */,
6E6F1CAF244E00FD0068B78B /* LocalContactsSectionHeaderContainerView.m */,
B1B557A020EF58AC00210D55 /* ContactTableViewCell.h */,
B1B5579E20EF58AC00210D55 /* ContactTableViewCell.m */,
B1B5579F20EF58AC00210D55 /* ContactTableViewCell.xib */,
Expand Down Expand Up @@ -3795,6 +3822,8 @@
B1B5594F20EF9A8600210D55 /* RecentTableViewCell.h */,
B1B5595020EF9A8600210D55 /* RecentTableViewCell.m */,
B1B5595120EF9A8600210D55 /* RecentTableViewCell.xib */,
6E6F1CAB244DDF3B0068B78B /* DirectorySectionHeaderContainerView.h */,
6E6F1CAC244DDF3B0068B78B /* DirectorySectionHeaderContainerView.m */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -4236,6 +4265,7 @@
926FA53D1F4C132000F826C2 /* MXSession+Riot.h */,
926FA53E1F4C132000F826C2 /* MXSession+Riot.m */,
32242F0821E8B05F00725742 /* UIColor.swift */,
6E7A9E9B243E10E700FD039E /* UIDevice.swift */,
B1CA3A2621EF6913000D1D89 /* UIViewController.swift */,
B1CA3A2821EF692B000D1D89 /* UIView.swift */,
B140B4A121F87F7100E3F5FE /* OperationQueue.swift */,
Expand All @@ -4250,6 +4280,8 @@
B1B12B2822942315002CB419 /* UITouch.swift */,
B1DCC63322E72C1B00625807 /* UISearchBar.swift */,
B11291EB238D704C0077B478 /* FloatingPoint.swift */,
6E6F1CB224506EC50068B78B /* UITableViewCell.swift */,
6E6F1CB424506FA40068B78B /* UITableView.swift */,
);
path = Categories;
sourceTree = "<group>";
Expand Down Expand Up @@ -4920,6 +4952,7 @@
B1B5574B20EE6C4D00210D55 /* MediaAlbumContentViewController.m in Sources */,
B1B5598820EFC3E000210D55 /* WidgetManager.m in Sources */,
B1DB4F0E22316FFF0065DBFA /* UserNameColorGenerator.swift in Sources */,
6E6F1CB524506FA40068B78B /* UITableView.swift in Sources */,
B157FAA123264AE900EBFBD4 /* SettingsDiscoveryThreePidDetailsCoordinatorType.swift in Sources */,
32607D6C243E0A55006674CC /* KeyBackupRecoverFromPrivateKeyViewController.swift in Sources */,
B1057789221304EC00334B1E /* KeyBackupSetupSuccessFromPassphraseViewController.swift in Sources */,
Expand Down Expand Up @@ -4979,6 +5012,7 @@
B157FAA823264BED00EBFBD4 /* SettingsDiscoveryThreePidDetailsCoordinatorBridgePresenter.swift in Sources */,
B169330B20F3CA3A00746532 /* Contact.m in Sources */,
B1A5B33E227ADF2A004CBA85 /* UIImage.swift in Sources */,
6E6F1CB324506EC50068B78B /* UITableViewCell.swift in Sources */,
B1D4752A21EE52B10067973F /* KeyBackupSetupIntroViewController.swift in Sources */,
B108931F23AB80EF00802670 /* KeyVerificationIncomingRequestApprovalBubbleCell.swift in Sources */,
B1CE83D42422817200D07506 /* KeyVerificationVerifiedViewController.swift in Sources */,
Expand Down Expand Up @@ -5295,6 +5329,7 @@
B1C562E1228C7C8C0037F12A /* RoomContextualMenuToolbarView.swift in Sources */,
B1CE83DF2422817200D07506 /* KeyVerificationVerifyBySASCoordinatorType.swift in Sources */,
B1B557BF20EF5B4500210D55 /* DisabledRoomInputToolbarView.m in Sources */,
6E6F1CAD244DDF3B0068B78B /* DirectorySectionHeaderContainerView.m in Sources */,
B157A7BB2445BD86008A5504 /* KeyVerificationScanConfirmationCoordinatorType.swift in Sources */,
B1B5578620EF564900210D55 /* GroupTableViewCellWithSwitch.m in Sources */,
B1098BE821ECFE52000DDA48 /* Coordinator.swift in Sources */,
Expand Down Expand Up @@ -5326,6 +5361,7 @@
B1B557AC20EF5A6D00210D55 /* DeviceView.m in Sources */,
3281BCF72201FA4200F4A383 /* UIControl.swift in Sources */,
B16932EE20F3C3C900746532 /* FilesSearchCellData.m in Sources */,
6E6F1CB1244E00FD0068B78B /* LocalContactsSectionHeaderContainerView.m in Sources */,
B1B558E520EF768F00210D55 /* RoomMembershipExpandedBubbleCell.m in Sources */,
32BF995121FA29DC00698084 /* SettingsKeyBackupViewModelType.swift in Sources */,
B190F55922CE356800AEB493 /* EditHistoryHeaderView.swift in Sources */,
Expand All @@ -5340,6 +5376,7 @@
B1D211E422C18E3800D939BD /* ReactionsMenuViewModelType.swift in Sources */,
324A2055225FC571004FE8B0 /* DeviceVerificationIncomingViewModelType.swift in Sources */,
B1B5572C20EE6C4D00210D55 /* RoomParticipantsViewController.m in Sources */,
6E6F1CAA244DC1E90068B78B /* SectionHeaderView.m in Sources */,
B1B558EE20EF768F00210D55 /* RoomOutgoingAttachmentBubbleCell.m in Sources */,
32BF994F21FA29A400698084 /* SettingsKeyBackupViewModel.swift in Sources */,
B190F55D22CE5A9700AEB493 /* EditHistorySection.swift in Sources */,
Expand Down Expand Up @@ -5389,6 +5426,7 @@
B1E5368921FB1E20001F3AFF /* UIButton.swift in Sources */,
B1DCC63422E72C1B00625807 /* UISearchBar.swift in Sources */,
32A6001622C661100042C1D9 /* EditHistoryViewState.swift in Sources */,
6E7A9E9C243E10E700FD039E /* UIDevice.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
64 changes: 53 additions & 11 deletions Riot/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -4081,6 +4081,11 @@ - (void)presentJitsiViewController:(void (^)(void))completion

if (_jitsiViewController)
{
if (@available(iOS 13.0, *))
{
_jitsiViewController.modalPresentationStyle = UIModalPresentationFullScreen;
}

[self presentViewController:_jitsiViewController animated:YES completion:completion];
}
}
Expand Down Expand Up @@ -4232,11 +4237,26 @@ - (void)askNativeWidgetPermissionWithWidget:(Widget*)widget completion:(void (^)

#pragma mark - Call status handling

/// Returns a suitable height for call status bar. Considers safe area insets if available and notch status.
- (CGFloat)calculateCallStatusBarHeight
{
CGFloat result = CALL_STATUS_BAR_HEIGHT;
if (@available(iOS 11.0, *))
{
if (UIDevice.currentDevice.hasNotch)
{
// this device has a notch (iPhone X +)
result += UIApplication.sharedApplication.keyWindow.safeAreaInsets.top;
}
}
return result;
}

- (void)addCallStatusBar:(NSString*)buttonTitle
{
// Add a call status bar
CGSize topBarSize = CGSizeMake([[UIScreen mainScreen] bounds].size.width, CALL_STATUS_BAR_HEIGHT);
CGSize topBarSize = CGSizeMake([[UIScreen mainScreen] bounds].size.width, [self calculateCallStatusBarHeight]);

_callStatusBarWindow = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, topBarSize.width, topBarSize.height)];
_callStatusBarWindow.windowLevel = UIWindowLevelStatusBar;

Expand All @@ -4246,8 +4266,9 @@ - (void)addCallStatusBar:(NSString*)buttonTitle

[_callStatusBarButton setTitle:buttonTitle forState:UIControlStateNormal];
[_callStatusBarButton setTitle:buttonTitle forState:UIControlStateHighlighted];

_callStatusBarButton.titleLabel.textColor = ThemeService.shared.theme.backgroundColor;

_callStatusBarButton.titleLabel.font = [UIFont systemFontOfSize:17 weight:UIFontWeightMedium];

[_callStatusBarButton setBackgroundColor:ThemeService.shared.theme.tintColor];
Expand Down Expand Up @@ -4322,6 +4343,11 @@ - (void)presentCallViewController:(BOOL)animated completion:(void (^)(void))comp

if (currentCallViewController)
{
if (@available(iOS 13.0, *))
{
currentCallViewController.modalPresentationStyle = UIModalPresentationFullScreen;
}

[self presentViewController:currentCallViewController animated:animated completion:completion];
}
}
Expand All @@ -4333,36 +4359,52 @@ - (void)statusBarDidChangeFrame

// Refresh the root view controller frame
CGRect rootControllerFrame = [[UIScreen mainScreen] bounds];

if (_callStatusBarWindow)
{
CGFloat callStatusBarHeight = [self calculateCallStatusBarHeight];

UIInterfaceOrientation statusBarOrientation = [UIApplication sharedApplication].statusBarOrientation;

switch (statusBarOrientation)
{
case UIInterfaceOrientationLandscapeLeft:
{
_callStatusBarWindow.frame = CGRectMake(-rootControllerFrame.size.width / 2, -CALL_STATUS_BAR_HEIGHT / 2, rootControllerFrame.size.width, CALL_STATUS_BAR_HEIGHT);
_callStatusBarWindow.transform = CGAffineTransformMake(0, -1, 1, 0, CALL_STATUS_BAR_HEIGHT / 2, rootControllerFrame.size.width / 2);
_callStatusBarWindow.frame = CGRectMake(-rootControllerFrame.size.width / 2, -callStatusBarHeight / 2, rootControllerFrame.size.width, callStatusBarHeight);
_callStatusBarWindow.transform = CGAffineTransformMake(0, -1, 1, 0, callStatusBarHeight / 2, rootControllerFrame.size.width / 2);
break;
}
case UIInterfaceOrientationLandscapeRight:
{
_callStatusBarWindow.frame = CGRectMake(-rootControllerFrame.size.width / 2, -CALL_STATUS_BAR_HEIGHT / 2, rootControllerFrame.size.width, CALL_STATUS_BAR_HEIGHT);
_callStatusBarWindow.transform = CGAffineTransformMake(0, 1, -1, 0, rootControllerFrame.size.height - CALL_STATUS_BAR_HEIGHT / 2, rootControllerFrame.size.width / 2);
_callStatusBarWindow.frame = CGRectMake(-rootControllerFrame.size.width / 2, -callStatusBarHeight / 2, rootControllerFrame.size.width, callStatusBarHeight);
_callStatusBarWindow.transform = CGAffineTransformMake(0, 1, -1, 0, rootControllerFrame.size.height - callStatusBarHeight / 2, rootControllerFrame.size.width / 2);
break;
}
default:
{
_callStatusBarWindow.transform = CGAffineTransformIdentity;
_callStatusBarWindow.frame = CGRectMake(0, 0, rootControllerFrame.size.width, CALL_STATUS_BAR_HEIGHT);
_callStatusBarWindow.frame = CGRectMake(0, 0, rootControllerFrame.size.width, callStatusBarHeight);
break;
}
}

UIEdgeInsets callBarButtonContentEdgeInsets = UIEdgeInsetsZero;

if (@available(iOS 11.0, *))
{
callBarButtonContentEdgeInsets = UIApplication.sharedApplication.keyWindow.safeAreaInsets;
// should override top inset
callBarButtonContentEdgeInsets.top = callStatusBarHeight - CALL_STATUS_BAR_HEIGHT;
// should ignore bottom inset
callBarButtonContentEdgeInsets.bottom = 0.0;
// should keep left, and right insets as original
}

_callStatusBarButton.contentEdgeInsets = callBarButtonContentEdgeInsets;

// Apply the vertical offset due to call status bar
rootControllerFrame.origin.y = CALL_STATUS_BAR_HEIGHT;
rootControllerFrame.size.height -= CALL_STATUS_BAR_HEIGHT;
rootControllerFrame.origin.y = callStatusBarHeight;
rootControllerFrame.size.height -= callStatusBarHeight;
}

rootController.view.frame = rootControllerFrame;
Expand Down
Loading

0 comments on commit 911eb38

Please sign in to comment.