From d8621f4a7ecec121527a0630138e534d2c16822a Mon Sep 17 00:00:00 2001 From: Salman Alshamrani Date: Mon, 16 Dec 2024 05:02:42 -0500 Subject: [PATCH] Minor renames to make sense of code --- osu.Framework.iOS/IOSFilePresenter.cs | 22 +++++++++++----------- osu.Framework.iOS/IOSFileSelector.cs | 12 ++++++------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/osu.Framework.iOS/IOSFilePresenter.cs b/osu.Framework.iOS/IOSFilePresenter.cs index 5ce13e8b2..b697e897e 100644 --- a/osu.Framework.iOS/IOSFilePresenter.cs +++ b/osu.Framework.iOS/IOSFilePresenter.cs @@ -12,7 +12,7 @@ namespace osu.Framework.iOS public class IOSFilePresenter : UIDocumentInteractionControllerDelegate { private readonly IIOSWindow window; - private readonly UIDocumentInteractionController viewController = new UIDocumentInteractionController(); + private readonly UIDocumentInteractionController documentInteraction = new UIDocumentInteractionController(); public IOSFilePresenter(IIOSWindow window) { @@ -23,39 +23,39 @@ namespace osu.Framework.iOS { setupViewController(filename); - if (viewController.PresentPreview(true)) + if (documentInteraction.PresentPreview(true)) return true; - var gameView = window.UIWindow.RootViewController!.View!; - return viewController.PresentOpenInMenu(gameView.Bounds, gameView, true); + var gameView = window.ViewController.View!; + return documentInteraction.PresentOpenInMenu(gameView.Bounds, gameView, true); } public bool PresentFile(string filename) { setupViewController(filename); - var gameView = window.UIWindow.RootViewController!.View!; - return viewController.PresentOptionsMenu(gameView.Bounds, gameView, true); + var gameView = window.ViewController.View!; + return documentInteraction.PresentOptionsMenu(gameView.Bounds, gameView, true); } private void setupViewController(string filename) { var url = NSUrl.FromFilename(filename); - viewController.Url = url; - viewController.Delegate = this; + documentInteraction.Url = url; + documentInteraction.Delegate = this; if (OperatingSystem.IsIOSVersionAtLeast(14)) - viewController.Uti = UTType.CreateFromExtension(Path.GetExtension(filename))?.Identifier ?? UTTypes.Data.Identifier; + documentInteraction.Uti = UTType.CreateFromExtension(Path.GetExtension(filename))?.Identifier ?? UTTypes.Data.Identifier; } - public override UIViewController ViewControllerForPreview(UIDocumentInteractionController controller) => window.UIWindow.RootViewController!; + public override UIViewController ViewControllerForPreview(UIDocumentInteractionController controller) => window.ViewController; public override void WillBeginSendingToApplication(UIDocumentInteractionController controller, string? application) { // this path is triggered when a user opens the presented document in another application, // the menu does not dismiss afterward and locks the game indefinitely. dismiss it manually. - viewController.DismissMenu(true); + documentInteraction.DismissMenu(true); } } } diff --git a/osu.Framework.iOS/IOSFileSelector.cs b/osu.Framework.iOS/IOSFileSelector.cs index 756715432..c7bb6b39e 100644 --- a/osu.Framework.iOS/IOSFileSelector.cs +++ b/osu.Framework.iOS/IOSFileSelector.cs @@ -18,7 +18,7 @@ namespace osu.Framework.iOS private readonly IIOSWindow window; - private readonly UIDocumentPickerViewController viewController; + private readonly UIDocumentPickerViewController documentPicker; public IOSFileSelector(IIOSWindow window, string[] allowedExtensions) { @@ -38,7 +38,7 @@ namespace osu.Framework.iOS var type = UTType.CreateFromExtension(extension.Replace(".", string.Empty)); if (type == null) - throw new InvalidOperationException($"System failed to recognise extension \"{extension}\" when preparing the file selector.\n"); + throw new InvalidOperationException($"System failed to recognise extension \"{extension}\" while preparing the file selector.\n"); utTypes[i] = type; } @@ -47,15 +47,15 @@ namespace osu.Framework.iOS // files must be provided as copies, as they may be originally located in places that cannot be accessed freely (aka. iCloud Drive). // we can acquire access to those files via startAccessingSecurityScopedResource but we must know when the game has finished using them. // todo: refactor FileSelector/DirectorySelector to be aware when the game finished using a file/directory. - viewController = new UIDocumentPickerViewController(utTypes, true); - viewController.Delegate = this; + documentPicker = new UIDocumentPickerViewController(utTypes, true); + documentPicker.Delegate = this; } public void Present() { UIApplication.SharedApplication.InvokeOnMainThread(() => { - window.ViewController.PresentViewController(viewController, true, null); + window.ViewController.PresentViewController(documentPicker, true, null); }); } @@ -64,7 +64,7 @@ namespace osu.Framework.iOS protected override void Dispose(bool disposing) { - viewController.Dispose(); + documentPicker.Dispose(); base.Dispose(disposing); } }