This repository has been archived by the owner on May 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 444
Fix #8484: Portrait Orientation Locking on Phone is not working #8485
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b6812f2
Fixing locking orientation logici for iOS16 and beyond
soner-yuksel 3d10663
NavigationController is added for changing orientation
soner-yuksel 58cfce4
Cleanup and proper include for portrait switch
soner-yuksel 8ac94bc
Device_Orientation comments addressed
soner-yuksel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright 2023 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
import UIKit | ||
|
||
public final class DeviceOrientation { | ||
|
||
private var windowScene: UIWindowScene? { | ||
return UIApplication.shared.connectedScenes.first as? UIWindowScene | ||
} | ||
|
||
public static let shared: DeviceOrientation = DeviceOrientation() | ||
|
||
public func changeOrientation(_ orientationMask: UIInterfaceOrientationMask) { | ||
if #available(iOS 16.0, *) { | ||
windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: orientationMask)) | ||
} else { | ||
var orientation: UIInterfaceOrientation? | ||
|
||
switch orientationMask { | ||
case .portrait: | ||
orientation = UIInterfaceOrientation.portrait | ||
case .portraitUpsideDown: | ||
orientation = UIInterfaceOrientation.portraitUpsideDown | ||
case .landscapeRight: | ||
orientation = UIInterfaceOrientation.landscapeRight | ||
case .landscapeLeft: | ||
orientation = UIInterfaceOrientation.landscapeLeft | ||
default: | ||
orientation = UIInterfaceOrientation.unknown | ||
} | ||
|
||
if let orientation = orientation { | ||
UIDevice.current.setValue(orientation.rawValue, forKey: "orientation") | ||
} | ||
} | ||
} | ||
|
||
private var isLandscape: Bool { | ||
if #available(iOS 16.0, *) { | ||
return windowScene?.interfaceOrientation.isLandscape ?? false | ||
} | ||
|
||
return UIDevice.current.orientation.isLandscape | ||
} | ||
|
||
private var isPortrait: Bool { | ||
if #available(iOS 16.0, *) { | ||
return windowScene?.interfaceOrientation.isPortrait ?? false | ||
} | ||
return UIDevice.current.orientation.isPortrait | ||
} | ||
|
||
public func changeOrientationToPortraitOnPhone() { | ||
if UIDevice.current.userInterfaceIdiom != .pad && isLandscape { | ||
changeOrientation(.portrait) | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to move this to
BraveShared
? We shouldn't be adding anything to Shared anymoreThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh sorry I just merged this before your comment, let me do this in a different PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR created #8499