From f74c55632ba9272de6ced63a54dc379aa0ee5504 Mon Sep 17 00:00:00 2001 From: lithium03 Date: Wed, 22 Jul 2020 02:43:38 +0900 Subject: [PATCH] Add landscape rotation lock direction --- .../CryptCloudViewer.xcodeproj/project.pbxproj | 4 ++-- ccViewer/ccViewer/AppDelegate.swift | 16 ---------------- .../ccViewer/CustomPlayerViewController.swift | 3 +++ .../ccViewer/NavigationControllerHide.swift | 17 +++++++++++++++++ .../ccViewer/TableViewControllerSetting.swift | 15 ++++++++++++++- ccViewer/ccViewer/ja.lproj/Localizable.strings | 1 + ffplayer/ffplayer/playerView.swift | 3 +++ 7 files changed, 40 insertions(+), 19 deletions(-) diff --git a/ccViewer/CryptCloudViewer.xcodeproj/project.pbxproj b/ccViewer/CryptCloudViewer.xcodeproj/project.pbxproj index 56ca27f..312952e 100644 --- a/ccViewer/CryptCloudViewer.xcodeproj/project.pbxproj +++ b/ccViewer/CryptCloudViewer.xcodeproj/project.pbxproj @@ -748,7 +748,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = ccViewer/ccViewer.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 69; + CURRENT_PROJECT_VERSION = 70; DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES; DEVELOPMENT_TEAM = 7A9X38B4YU; "ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES; @@ -783,7 +783,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = ccViewer/ccViewer.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 69; + CURRENT_PROJECT_VERSION = 70; DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES; DEVELOPMENT_TEAM = 7A9X38B4YU; "ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES; diff --git a/ccViewer/ccViewer/AppDelegate.swift b/ccViewer/ccViewer/AppDelegate.swift index e01df95..8d421ed 100644 --- a/ccViewer/ccViewer/AppDelegate.swift +++ b/ccViewer/ccViewer/AppDelegate.swift @@ -178,19 +178,3 @@ extension UIApplication { return controller2 } } - -extension UINavigationController { - override open var shouldAutorotate: Bool { - if UserDefaults.standard.bool(forKey: "MediaViewerRotation") { - return false - } - return true - } - - override open var supportedInterfaceOrientations: UIInterfaceOrientationMask { - if UserDefaults.standard.bool(forKey: "ForceLandscape") { - return .landscapeLeft - } - return .all - } -} diff --git a/ccViewer/ccViewer/CustomPlayerViewController.swift b/ccViewer/ccViewer/CustomPlayerViewController.swift index 95a6f2d..88e2745 100644 --- a/ccViewer/ccViewer/CustomPlayerViewController.swift +++ b/ccViewer/ccViewer/CustomPlayerViewController.swift @@ -31,6 +31,9 @@ extension AVPlayerViewController { } override open var supportedInterfaceOrientations: UIInterfaceOrientationMask { if UserDefaults.standard.bool(forKey: "ForceLandscape") { + if UserDefaults.standard.bool(forKey: "LandscapeCameraLeft") { + return .landscapeRight + } return .landscapeLeft } return .all diff --git a/ccViewer/ccViewer/NavigationControllerHide.swift b/ccViewer/ccViewer/NavigationControllerHide.swift index 7fed34b..f53038e 100644 --- a/ccViewer/ccViewer/NavigationControllerHide.swift +++ b/ccViewer/ccViewer/NavigationControllerHide.swift @@ -24,6 +24,23 @@ class NavigationControllerHide: UINavigationController { return topViewController ?? super.childForStatusBarHidden } + override open var shouldAutorotate: Bool { + if UserDefaults.standard.bool(forKey: "MediaViewerRotation") { + return false + } + return true + } + + override open var supportedInterfaceOrientations: UIInterfaceOrientationMask { + if UserDefaults.standard.bool(forKey: "ForceLandscape") { + if UserDefaults.standard.bool(forKey: "LandscapeCameraLeft") { + return .landscapeRight + } + return .landscapeLeft + } + return .all + } + /* // MARK: - Navigation diff --git a/ccViewer/ccViewer/TableViewControllerSetting.swift b/ccViewer/ccViewer/TableViewControllerSetting.swift index f737183..0785a6b 100644 --- a/ccViewer/ccViewer/TableViewControllerSetting.swift +++ b/ccViewer/ccViewer/TableViewControllerSetting.swift @@ -88,7 +88,8 @@ class TableViewControllerSetting: UITableViewController, UITextFieldDelegate { NSLocalizedString("Use PDF viewer", comment: ""), NSLocalizedString("Use Media viewer", comment: ""), NSLocalizedString("Lock rotation", comment: ""), - NSLocalizedString("Force landscape", comment: "")], + NSLocalizedString("Force landscape", comment: ""), + NSLocalizedString("Landscape with camera left", comment: "")], [NSLocalizedString("Use FFmpeg Media viewer", comment: ""), NSLocalizedString("Prior Media viewer is FFmpeg", comment: "")], [NSLocalizedString("Save last play position", comment: ""), @@ -182,6 +183,10 @@ class TableViewControllerSetting: UITableViewController, UITextFieldDelegate { aSwitch.isEnabled = UIDevice.current.userInterfaceIdiom == .phone aSwitch.isOn = UserDefaults.standard.bool(forKey: "ForceLandscape") aSwitch.tag = 11 + case 5: + aSwitch.isEnabled = UIDevice.current.userInterfaceIdiom == .phone && UserDefaults.standard.bool(forKey: "ForceLandscape") + aSwitch.isOn = UserDefaults.standard.bool(forKey: "LandscapeCameraLeft") + aSwitch.tag = 15 default: break } @@ -361,12 +366,20 @@ class TableViewControllerSetting: UITableViewController, UITextFieldDelegate { present(v, animated: false) { v.dismiss(animated: false, completion: nil) } + tableView.reloadData() case 12: UserDefaults.standard.set(value, forKey: "noOverlaySubtitles") case 13: UserDefaults.standard.set(value, forKey: "autoSelectStreams") case 14: UserDefaults.standard.set(value, forKey: "keepOpenWhenDone") + case 15: + UserDefaults.standard.set(value, forKey: "LandscapeCameraLeft") + let v = UIViewController() + v.modalPresentationStyle = .fullScreen + present(v, animated: false) { + v.dismiss(animated: false, completion: nil) + } default: break } diff --git a/ccViewer/ccViewer/ja.lproj/Localizable.strings b/ccViewer/ccViewer/ja.lproj/Localizable.strings index 8ffe09f..0709c29 100644 --- a/ccViewer/ccViewer/ja.lproj/Localizable.strings +++ b/ccViewer/ccViewer/ja.lproj/Localizable.strings @@ -24,6 +24,7 @@ "Use Media viewer" = "メディアで使用"; "Lock rotation" = "画面回転をロックする"; "Force landscape" = "強制的に横画面にする"; +"Landscape with camera left" = "横画面でカメラが左側"; "Software decode" = "ソフトウエア デコーダー"; "Use FFmpeg Media viewer" = "FFmpegプレーヤーを使用する"; "Prior Media viewer is FFmpeg" = "優先してFFmpegを使用する"; diff --git a/ffplayer/ffplayer/playerView.swift b/ffplayer/ffplayer/playerView.swift index b8380ef..464e848 100644 --- a/ffplayer/ffplayer/playerView.swift +++ b/ffplayer/ffplayer/playerView.swift @@ -353,6 +353,9 @@ public class FFPlayerViewController: UIViewController { override open var supportedInterfaceOrientations: UIInterfaceOrientationMask { if UserDefaults.standard.bool(forKey: "ForceLandscape") { + if UserDefaults.standard.bool(forKey: "LandscapeCameraLeft") { + return .landscapeRight + } return .landscapeLeft } return .all