Commit 01f6338a authored by Carola Nitz's avatar Carola Nitz

Firststeps: Lock orientation to portrait on iPhone

parent 41836cab
......@@ -17,5 +17,6 @@
@interface VLCAppDelegate : UIResponder <UIApplicationDelegate>
@property (nonatomic, strong) UIWindow *window;
@property (nonatomic, assign) UIInterfaceOrientationMask orientationLock;
@end
......@@ -109,6 +109,7 @@
[ODClient setMicrosoftAccountAppId:kVLCOneDriveClientID scopes:@[@"onedrive.readwrite", @"offline_access"]];
[VLCApperanceManager setupAppearanceWithTheme:PresentationTheme.current];
self.orientationLock = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape;
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
rootViewController = [UITabBarController new];
......@@ -243,4 +244,9 @@ didFailToContinueUserActivityWithType:(NSString *)userActivityType
}
}
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return self.orientationLock;
}
@end
......@@ -50,6 +50,22 @@
[self updateTheme];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
[AppUtility lockOrientation:UIInterfaceOrientationMaskPortrait];
}
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) {
[AppUtility lockOrientation: UIInterfaceOrientationMaskLandscape | UIInterfaceOrientationMaskPortrait];
}
}
- (void)updateTheme
{
self.view.backgroundColor = PresentationTheme.current.colors.background;
......
......@@ -20,6 +20,7 @@
41251ED01FD0CF7900099110 /* AppCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41251ECE1FD0CF7900099110 /* AppCoordinator.swift */; };
41273A3C1A955C4100A2EF77 /* VLCMigrationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 41273A3A1A955C4100A2EF77 /* VLCMigrationViewController.m */; };
41273A3D1A955C4100A2EF77 /* VLCMigrationViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 41273A3B1A955C4100A2EF77 /* VLCMigrationViewController.xib */; };
4129CF2F22D5E498005EF5E8 /* AppUtitlity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4129CF2E22D5E498005EF5E8 /* AppUtitlity.swift */; };
413EC987201A329D00BF412F /* SortModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 413EC986201A329D00BF412F /* SortModel.swift */; };
413EC98B201B4F2C00BF412F /* PresentationTheme.swift in Sources */ = {isa = PBXBuildFile; fileRef = 413EC98A201B4F2B00BF412F /* PresentationTheme.swift */; };
414327A521B6E55700B061F6 /* PlaybackSpeedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 414327A421B6E55700B061F6 /* PlaybackSpeedView.swift */; };
......@@ -420,6 +421,7 @@
41273A391A955C4100A2EF77 /* VLCMigrationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VLCMigrationViewController.h; path = Sources/VLCMigrationViewController.h; sourceTree = SOURCE_ROOT; };
41273A3A1A955C4100A2EF77 /* VLCMigrationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = VLCMigrationViewController.m; path = Sources/VLCMigrationViewController.m; sourceTree = SOURCE_ROOT; };
41273A3B1A955C4100A2EF77 /* VLCMigrationViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = VLCMigrationViewController.xib; path = Sources/VLCMigrationViewController.xib; sourceTree = SOURCE_ROOT; };
4129CF2E22D5E498005EF5E8 /* AppUtitlity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppUtitlity.swift; sourceTree = "<group>"; };
412BE7521FC4947400ACCC42 /* VLCMediaSubcategory+VLCDragAndDrop.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = "VLCMediaSubcategory+VLCDragAndDrop.swift"; path = "Sources/VLCMediaSubcategory+VLCDragAndDrop.swift"; sourceTree = SOURCE_ROOT; };
413EC986201A329D00BF412F /* SortModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SortModel.swift; path = Sources/Coordinators/SortModel.swift; sourceTree = SOURCE_ROOT; };
413EC98A201B4F2B00BF412F /* PresentationTheme.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentationTheme.swift; sourceTree = "<group>"; };
......@@ -1543,6 +1545,7 @@
7D3784EA183A9A1E009EE944 /* VLC for iOS-Info.plist */,
41251ECB1FD0C5C100099110 /* VLC-iOS-Bridging-Header.h */,
7D3784EB183A9A1E009EE944 /* VLC for iOS-Prefix.pch */,
4129CF2E22D5E498005EF5E8 /* AppUtitlity.swift */,
);
name = "iOS Supporting Files";
path = "vlc-ios";
......@@ -2970,6 +2973,7 @@
8DE18894210B5F8200A091D2 /* AlbumModel.swift in Sources */,
7D3784E9183A9A15009EE944 /* main.m in Sources */,
7D30F3C2183AB24C00FFC021 /* VLCHTTPConnection.m in Sources */,
4129CF2F22D5E498005EF5E8 /* AppUtitlity.swift in Sources */,
DD3EFF371BDEBCE500B68579 /* VLCLocalNetworkServiceNetService.m in Sources */,
DD3EFF511BDEBCE500B68579 /* VLCPlexWebAPI.m in Sources */,
41D7DD0520C1853E00AD94F6 /* ButtonBarView.swift in Sources */,
......
//
// AppUtitlity.swift
// VLC-iOS
//
// Created by Carola Nitz on 10.07.19.
// Copyright © 2019 VideoLAN. All rights reserved.
//
import Foundation
@objcMembers
class AppUtility: NSObject {
static func lockOrientation(_ orientation: UIInterfaceOrientationMask) {
if let delegate = UIApplication.shared.delegate as? VLCAppDelegate {
delegate.orientationLock = orientation
}
}
/// OPTIONAL Added method to adjust lock and rotate to the desired orientation
static func lockOrientation(_ orientation: UIInterfaceOrientationMask, andRotateTo rotateOrientation: UIInterfaceOrientation) {
self.lockOrientation(orientation)
UIDevice.current.setValue(rotateOrientation.rawValue, forKey: "orientation")
UINavigationController.attemptRotationToDeviceOrientation()
}
}
......@@ -8,6 +8,7 @@
#import "VLCExternalDisplayController.h"
#import "UIColor+Presets.h"
#import "VLCAboutViewController.h"
#import "VLCAppDelegate.h"
#import "VLCCloudServicesTableViewController.h"
#import "VLCConstants.h"
#import "VLCDownloadViewController.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment