mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-13 11:20:31 +00:00
Minor renames to make sense of code
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user