Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Kodi Remote.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
0FEA79FC165FBBED00BB281F /* XBMCVirtualKeyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 0FEA79FB165FBBEC00BB281F /* XBMCVirtualKeyboard.m */; };
0FEAE76816EA632800387DED /* ActorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 0FEAE76716EA632800387DED /* ActorCell.m */; };
0FEE08161704819A00EC9BC7 /* FloatingHeaderFlowLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 0FEE08151704819A00EC9BC7 /* FloatingHeaderFlowLayout.m */; };
C70B9C7C2DE1CB6900F14093 /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C70B9C7B2DE1CB6900F14093 /* SceneDelegate.m */; };
C7106D792D33C25400A96C93 /* BroadcastProgressView.m in Sources */ = {isa = PBXBuildFile; fileRef = C7106D782D33C25400A96C93 /* BroadcastProgressView.m */; };
C7106D7B2D33EEE000A96C93 /* ProgressBarView.m in Sources */ = {isa = PBXBuildFile; fileRef = C7106D7A2D33EEE000A96C93 /* ProgressBarView.m */; };
C7106D842D33FBCE00A96C93 /* PlaylistProgressView.m in Sources */ = {isa = PBXBuildFile; fileRef = C7106D832D33FBCE00A96C93 /* PlaylistProgressView.m */; };
Expand Down Expand Up @@ -266,6 +267,8 @@
B1FF37DE1709D1EB005473FF /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
B1FF37DF1709D1ED005473FF /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
C703692827148CEF0049F9BF /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
C70B9C7B2DE1CB6900F14093 /* SceneDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = "<group>"; };
C70B9C7D2DE1CBA300F14093 /* SceneDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = "<group>"; };
C70F41D02BA4D98E00847C75 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
C7106D752D2FC9BC00A96C93 /* af-ZA */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "af-ZA"; path = "af-ZA.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
C7106D762D2FC9BC00A96C93 /* af-ZA */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "af-ZA"; path = "af-ZA.lproj/Localizable.strings"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -558,6 +561,8 @@
0FDFC67C15377CE9000BE837 /* Settings.bundle */,
0F554909151D1187007E633F /* AppDelegate.h */,
0F55490A151D1187007E633F /* AppDelegate.m */,
C70B9C7D2DE1CBA300F14093 /* SceneDelegate.h */,
C70B9C7B2DE1CB6900F14093 /* SceneDelegate.m */,
C79B0EA62DF0CF8C00046334 /* BaseMasterViewController.h */,
C79B0EA42DF0CF6900046334 /* BaseMasterViewController.m */,
0F554C1E151D14DA007E633F /* mainMenu.h */,
Expand Down Expand Up @@ -900,6 +905,7 @@
0F5A504C155FA8640062FD6E /* HostManagementViewController.m in Sources */,
0F545D0B1575563100B6320D /* OBShapedButton.m in Sources */,
0F545D0C1575563100B6320D /* UIImage+ColorAtPixel.m in Sources */,
C70B9C7C2DE1CB6900F14093 /* SceneDelegate.m in Sources */,
0F4063351578C6CD00596B61 /* MoreItemsViewController.m in Sources */,
0F540662160C82E900853B02 /* CustomNavigationController.m in Sources */,
C72CDAF22DD27AB800AFB2FA /* LocalNetworkAlert.swift in Sources */,
Expand Down
6 changes: 5 additions & 1 deletion XBMC Remote/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,20 @@
#define WOL_PORT 9

+ (AppDelegate*)instance;
+ (UIWindowScene*)scene;
+ (UIWindow*)keyWindow;
+ (UIStatusBarManager*)statusBarManager;
+ (UIInterfaceOrientation)interfaceOrientation;

- (void)saveServerList;
- (void)clearAppDiskCache;
- (void)sendWOL:(NSString*)MAC withPort:(NSInteger)WOLport;
- (NSURL*)getServerJSONEndPoint;
- (NSDictionary*)getServerHTTPHeaders;

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) CustomNavigationController *navigationController;
@property (nonatomic, strong) ViewControllerIPad *windowController;
@property (nonatomic, strong) UIViewController *appRootController;
@property (strong, nonatomic) NSString *dataFilePath;
@property (strong, nonatomic) NSString *libraryCachePath;
@property (strong, nonatomic) NSString *epgCachePath;
Expand Down
71 changes: 27 additions & 44 deletions XBMC Remote/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@
#import "InitialSlidingViewController.h"
#import "UIImageView+WebCache.h"
#import "Utilities.h"
#import "Kodi_Remote-Swift.h"

#include <arpa/inet.h>
#include <net/if.h>
#include <ifaddrs.h>

@implementation AppDelegate

@synthesize window = _window;
@synthesize navigationController = _navigationController;
@synthesize windowController = _windowController;
@synthesize appRootController;
@synthesize dataFilePath;
@synthesize arrayServerList;
@synthesize serverOnLine;
Expand Down Expand Up @@ -124,12 +123,7 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N
// Load user defaults, if not yet set. Avoids need to check for nil.
[self registerDefaultsFromSettingsBundle];

[self setIdleTimerFromUserDefaults];

// Create and set interface style for window
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
[self setInterfaceStyleFromUserDefaults];
[self.window makeKeyAndVisible];
[Utilities setIdleTimerFromUserDefaults];

// Create GlobalDate which holds the Kodi server parameters
obj = [GlobalData getInstance];
Expand All @@ -142,12 +136,12 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N
if (IS_IPHONE) {
InitialSlidingViewController *initialSlidingViewController = [[InitialSlidingViewController alloc] initWithNibName:@"InitialSlidingViewController" bundle:nil];
initialSlidingViewController.mainMenu = mainMenuItems;
self.window.rootViewController = initialSlidingViewController;
appRootController = initialSlidingViewController;
}
else {
self.windowController = [[ViewControllerIPad alloc] initWithNibName:@"ViewControllerIPad" bundle:nil];
self.windowController.mainMenu = mainMenuItems;
self.window.rootViewController = self.windowController;
appRootController = self.windowController;
}
return YES;
}
Expand All @@ -170,27 +164,6 @@ - (NSDictionary*)getServerHTTPHeaders {

#pragma mark - Helper

- (void)setIdleTimerFromUserDefaults {
UIApplication.sharedApplication.idleTimerDisabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"lockscreen_preference"];
}

- (void)setInterfaceStyleFromUserDefaults {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSString *mode = [userDefaults stringForKey:@"theme_mode"];
if (@available(iOS 13.0, *)) {
UIUserInterfaceStyle style = UIUserInterfaceStyleUnspecified;
if (mode.length) {
if ([mode isEqualToString:@"dark_mode"]) {
style = UIUserInterfaceStyleDark;
}
else if ([mode isEqualToString:@"light_mode"]) {
style = UIUserInterfaceStyleLight;
}
}
self.window.overrideUserInterfaceStyle = style;
}
}

- (void)sendWOL:(NSString*)MAC withPort:(NSInteger)WOLport {
CFSocketRef WOLsocket;
WOLsocket = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_DGRAM, IPPROTO_UDP, 0, NULL, NULL);
Expand Down Expand Up @@ -266,19 +239,6 @@ - (void)sendWOL:(NSString*)MAC withPort:(NSInteger)WOLport {
}
}

- (void)applicationWillEnterForeground:(UIApplication*)application {
[self setIdleTimerFromUserDefaults];
}

- (void)applicationDidBecomeActive:(UIApplication*)application {
// Trigger Local Network Privacy Alert once after app launch
static dispatch_once_t once;
dispatch_once(&once, ^{
LocalNetworkAlertClass *localNetworkAlert = [LocalNetworkAlertClass new];
[localNetworkAlert triggerLocalNetworkPrivacyAlert];
});
}

- (void)applicationDidReceiveMemoryWarning:(UIApplication*)application {
[[SDImageCache sharedImageCache] clearMemory];
}
Expand Down Expand Up @@ -309,4 +269,27 @@ - (void)clearAppDiskCache {
[[NSURLCache sharedURLCache] removeAllCachedResponses];
}

+ (UIWindowScene*)scene {
NSArray *scenes= UIApplication.sharedApplication.connectedScenes.allObjects;
UIWindowScene *scene = scenes[0];
return scene;
}

+ (UIWindow*)keyWindow {
/* WORKAROUND: Instead of keyWindow we return the first window. As this app only supports
* a single window, this works and avoids a problem caused by the implementation of most app's
* UIViewControllers which use keyWindow.safeAreaInset in viewDidLoad instead of willLayoutSubView.
return AppDelegate.scene.keyWindow;
*/
return AppDelegate.scene.windows.firstObject;
}

+ (UIStatusBarManager*)statusBarManager {
return AppDelegate.scene.statusBarManager;
}

+ (UIInterfaceOrientation)interfaceOrientation {
return AppDelegate.scene.interfaceOrientation;
}

@end
4 changes: 2 additions & 2 deletions XBMC Remote/BaseMasterViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ - (void)viewDidLoad {

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification
name:UISceneDidEnterBackgroundNotification
object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleEnterForeground:)
name:UIApplicationWillEnterForegroundNotification
name:UISceneWillEnterForegroundNotification
object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self
Expand Down
4 changes: 2 additions & 2 deletions XBMC Remote/ConvenienceMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*/
#define IS_IPHONE (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone)
#define IS_IPAD (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
#define IS_PORTRAIT UIInterfaceOrientationIsPortrait(UIApplication.sharedApplication.statusBarOrientation)
#define IS_LANDSCAPE UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication.statusBarOrientation)
#define IS_PORTRAIT UIInterfaceOrientationIsPortrait(AppDelegate.interfaceOrientation)
#define IS_LANDSCAPE UIInterfaceOrientationIsLandscape(AppDelegate.interfaceOrientation)

/*
* Color defines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ - (CGFloat)screenWidth {

- (CGFloat)screenWidthForOrientation:(BOOL)isLandscape {
CGSize size = UIScreen.mainScreen.bounds.size;
UIApplication *application = UIApplication.sharedApplication;
UIStatusBarManager *application = AppDelegate.statusBarManager;
if (isLandscape) {
size = CGSizeMake(size.height, size.width);
}
Expand Down
2 changes: 1 addition & 1 deletion XBMC Remote/HostManagementViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ - (void)enableTCPconnection {
withParameters:parameters
onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *error) {
if (error == nil && methodError == nil) {
[[NSNotificationCenter defaultCenter] postNotificationName:UIApplicationWillEnterForegroundNotification object:nil userInfo:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:UISceneWillEnterForegroundNotification object:nil userInfo:nil];
}
else {
UIAlertController *alertCtrl = [Utilities createAlertOK:LOCALIZED_STR(@"Cannot do that") message:nil];
Expand Down
12 changes: 11 additions & 1 deletion XBMC Remote/Kodi Remote-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,17 @@
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict/>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
<key>UILaunchStoryboardName</key>
<string>Launch Screen</string>
Expand Down
2 changes: 1 addition & 1 deletion XBMC Remote/MasterViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ - (void)addMessagesToRootView {

- (void)addConnectionStatusToRootView {
// Add connection status icon to root view of new controller
UIView *rootView = UIApplication.sharedApplication.keyWindow.rootViewController.view;
UIView *rootView = AppDelegate.keyWindow.rootViewController.view;
[rootView addSubview:globalConnectionStatus];
}

Expand Down
4 changes: 2 additions & 2 deletions XBMC Remote/NowPlaying.m
Original file line number Diff line number Diff line change
Expand Up @@ -2569,12 +2569,12 @@ - (void)viewWillAppear:(BOOL)animated {

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleEnterForeground:)
name:UIApplicationWillEnterForegroundNotification
name:UISceneWillEnterForegroundNotification
object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification
name:UISceneDidEnterBackgroundNotification
object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self
Expand Down
2 changes: 1 addition & 1 deletion XBMC Remote/RightMenuViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ - (void)addButtonToList:(id)sender {
[[NSNotificationCenter defaultCenter] postNotificationName:@"LeaveFullscreen" object:nil userInfo:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"StackScrollOnScreen" object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"MainMenuDeselectSection" object:nil userInfo:nil];
[UIApplication.sharedApplication.keyWindow.rootViewController dismissViewControllerAnimated:YES completion:nil];
[AppDelegate.keyWindow.rootViewController dismissViewControllerAnimated:YES completion:nil];
detailViewController.view.frame = CGRectMake(0, 0, STACKSCROLL_WIDTH, self.view.frame.size.height);
[AppDelegate.instance.windowController.stackScrollViewController addViewInSlider:detailViewController invokeByController:self isStackStartView:YES];
}
Expand Down
2 changes: 1 addition & 1 deletion XBMC Remote/SDWebImage/SDImageCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ - (id)initWithNamespace:(NSString *)ns diskCacheDirectory:(NSString *)directory

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(backgroundCleanDisk)
name:UIApplicationDidEnterBackgroundNotification
name:UISceneDidEnterBackgroundNotification
object:nil];
#endif
}
Expand Down
15 changes: 15 additions & 0 deletions XBMC Remote/SceneDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// SceneDelegate.h
// Kodi Remote
//
// Created by Buschmann on 24.05.25.
// Copyright © 2025 Team Kodi. All rights reserved.
//

@import UIKit;

@interface SceneDelegate : UIResponder <UIWindowSceneDelegate> {}

@property (strong, nonatomic) UIWindow *window;

@end
59 changes: 59 additions & 0 deletions XBMC Remote/SceneDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// SceneDelegate.m
// Kodi Remote
//
// Created by Buschmann on 24.05.25.
// Copyright © 2025 Team Kodi. All rights reserved.
//

#import "SceneDelegate.h"
#import "AppDelegate.h"
#import "Utilities.h"
#import "Kodi_Remote-Swift.h"

@implementation SceneDelegate

@synthesize window;

- (void)scene:(UIScene*)scene willConnectToSession:(UISceneSession*)session options:(UISceneConnectionOptions*)connectionOptions {
// Create window using AppDelegate's controllers
window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
window.windowScene = (UIWindowScene*)scene;
window.rootViewController = AppDelegate.instance.appRootController;
[window makeKeyAndVisible];

// Set interface style for window
[self setInterfaceStyleFromUserDefaults];
}

- (void)sceneWillEnterForeground:(UIScene*)scene {
[Utilities setIdleTimerFromUserDefaults];
}

- (void)sceneDidBecomeActive:(UIScene*)scene {
// Trigger Local Network Privacy Alert once after app launch
static dispatch_once_t once;
dispatch_once(&once, ^{
LocalNetworkAlertClass *localNetworkAlert = [LocalNetworkAlertClass new];
[localNetworkAlert triggerLocalNetworkPrivacyAlert];
});
}

- (void)setInterfaceStyleFromUserDefaults {
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSString *mode = [userDefaults stringForKey:@"theme_mode"];
if (@available(iOS 13.0, *)) {
UIUserInterfaceStyle style = UIUserInterfaceStyleUnspecified;
if (mode.length) {
if ([mode isEqualToString:@"dark_mode"]) {
style = UIUserInterfaceStyleDark;
}
else if ([mode isEqualToString:@"light_mode"]) {
style = UIUserInterfaceStyleLight;
}
}
window.overrideUserInterfaceStyle = style;
}
}

@end
1 change: 1 addition & 0 deletions XBMC Remote/Utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,6 @@ typedef NS_ENUM(NSInteger, LogoBackgroundType) {
+ (void)saveLastServerIndex:(NSIndexPath*)indexPath;
+ (void)readKodiServerParameters;
+ (void)resetKodiServerParameters;
+ (void)setIdleTimerFromUserDefaults;

@end
Loading