mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			70 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Swift
		
	
		
		
			
		
	
	
			70 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Swift
		
	
| 
											9 years ago
										 | // | ||
| 
											7 years ago
										 | //  Copyright (c) 2019 Open Whisper Systems. All rights reserved. | ||
| 
											9 years ago
										 | // | ||
|  | 
 | ||
|  | import Foundation | ||
|  | 
 | ||
| 
											8 years ago
										 | @objc | ||
| 
											8 years ago
										 | public extension UIDevice { | ||
| 
											5 years ago
										 |      | ||
| 
											9 years ago
										 |     var supportsCallKit: Bool { | ||
|  |         return ProcessInfo().isOperatingSystemAtLeast(OperatingSystemVersion(majorVersion: 10, minorVersion: 0, patchVersion: 0)) | ||
|  |     } | ||
| 
											8 years ago
										 | 
 | ||
| 
											8 years ago
										 |     @objc | ||
| 
											5 years ago
										 |     var hasIPhoneXNotch: Bool { | ||
| 
											8 years ago
										 |         switch UIScreen.main.nativeBounds.height { | ||
| 
											8 years ago
										 |         case 960: | ||
|  |             //  iPad in iPhone compatibility mode (using old iPhone 4 screen size) | ||
|  |             return false | ||
| 
											8 years ago
										 |         case 1136: | ||
|  |             // iPhone 5 or 5S or 5C | ||
|  |             return false | ||
|  |         case 1334: | ||
|  |             // iPhone 6/6S/7/8 | ||
|  |             return false | ||
| 
											7 years ago
										 |         case 1792: | ||
|  |             // iPhone XR | ||
|  |             return true | ||
| 
											8 years ago
										 |         case 1920, 2208: | ||
|  |             // iPhone 6+/6S+/7+/8+// | ||
|  |             return false | ||
|  |         case 2436: | ||
| 
											7 years ago
										 |             // iPhone X, iPhone XS | ||
|  |             return true | ||
|  |         case 2688: | ||
|  |             // iPhone X Max | ||
| 
											8 years ago
										 |             return true | ||
|  |         default: | ||
| 
											8 years ago
										 |             // Verify all our IOS_DEVICE_CONSTANT tags make sense when adding a new device size. | ||
| 
											8 years ago
										 |             return false | ||
|  |         } | ||
|  |     } | ||
| 
											7 years ago
										 | 
 | ||
| 
											7 years ago
										 |     @objc | ||
| 
											5 years ago
										 |     var isShorterThanIPhone5: Bool { | ||
| 
											7 years ago
										 |         return UIScreen.main.bounds.height < 568 | ||
| 
											7 years ago
										 |     } | ||
|  | 
 | ||
| 
											7 years ago
										 |     @objc | ||
| 
											5 years ago
										 |     var isIPad: Bool { | ||
| 
											7 years ago
										 |         let isNativeIPad = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad | ||
|  |         let isCompatabilityModeIPad = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.phone && self.model.hasPrefix("iPad") | ||
|  | 
 | ||
|  |         return isNativeIPad || isCompatabilityModeIPad | ||
|  |     } | ||
| 
											7 years ago
										 | 
 | ||
| 
											7 years ago
										 |     @objc | ||
| 
											5 years ago
										 |     func ows_setOrientation(_ orientation: UIInterfaceOrientation) { | ||
| 
											7 years ago
										 |         // XXX - This is not officially supported, but there's no other way to programmatically rotate | ||
|  |         // the interface. | ||
|  |         let orientationKey = "orientation" | ||
|  |         self.setValue(orientation.rawValue, forKey: orientationKey) | ||
|  | 
 | ||
|  |         // Not strictly necessary for the orientation to appear as changed | ||
|  |         // but allegedly helps ensure related rotation delegate methods are called. | ||
|  |         // https://stackoverflow.com/questions/20987249/how-do-i-programmatically-set-device-orientation-in-ios7 | ||
|  |         UINavigationController.attemptRotationToDeviceOrientation() | ||
|  |     } | ||
| 
											9 years ago
										 | } |