Skip to content

Commit

Permalink
Add landscape rotation lock direction
Browse files Browse the repository at this point in the history
  • Loading branch information
lithium0003 committed Jul 21, 2020
1 parent ceebd8d commit f74c556
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 19 deletions.
4 changes: 2 additions & 2 deletions ccViewer/CryptCloudViewer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 0 additions & 16 deletions ccViewer/ccViewer/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
3 changes: 3 additions & 0 deletions ccViewer/ccViewer/CustomPlayerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions ccViewer/ccViewer/NavigationControllerHide.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 14 additions & 1 deletion ccViewer/ccViewer/TableViewControllerSetting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""),
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions ccViewer/ccViewer/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -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を使用する";
Expand Down
3 changes: 3 additions & 0 deletions ffplayer/ffplayer/playerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f74c556

Please sign in to comment.