1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:07:25 +08:00

Merge pull request #15156 from Susko3/use-ShowFileInNativeExplorer

Update usages of `OpenInNativeExplorer` to use `PresentFileExternally` / `PresentExternally`
This commit is contained in:
Dean Herbert 2021-10-26 15:53:03 +09:00 committed by GitHub
commit 5e5b86a1f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 34 additions and 26 deletions

View File

@ -52,7 +52,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.1015.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.1014.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2021.1026.0" />
</ItemGroup>
<ItemGroup Label="Transitive Dependencies">
<!-- Realm needs to be directly referenced in all Xamarin projects, as it will not pull in its transitive dependencies otherwise. -->

View File

@ -462,10 +462,12 @@ namespace osu.Game.Database
if (retrievedItem == null)
throw new ArgumentException(@"Specified model could not be found", nameof(item));
using (var outputStream = exportStorage.GetStream($"{getValidFilename(item.ToString())}{HandledExtensions.First()}", FileAccess.Write, FileMode.Create))
ExportModelTo(retrievedItem, outputStream);
string filename = $"{getValidFilename(item.ToString())}{HandledExtensions.First()}";
exportStorage.OpenInNativeExplorer();
using (var stream = exportStorage.GetStream(filename, FileAccess.Write, FileMode.Create))
ExportModelTo(retrievedItem, stream);
exportStorage.PresentFileExternally(filename);
}
/// <summary>

View File

@ -109,11 +109,12 @@ namespace osu.Game.Graphics
if (Interlocked.Decrement(ref screenShotTasks) == 0 && cursorVisibility.Value == false)
cursorVisibility.Value = true;
var fileName = getFileName();
if (fileName == null) return;
string filename = getFilename();
var stream = storage.GetStream(fileName, FileAccess.Write);
if (filename == null) return;
using (var stream = storage.GetStream(filename, FileAccess.Write))
{
switch (screenshotFormat.Value)
{
case ScreenshotFormat.Png:
@ -129,20 +130,21 @@ namespace osu.Game.Graphics
default:
throw new InvalidOperationException($"Unknown enum member {nameof(ScreenshotFormat)} {screenshotFormat.Value}.");
}
}
notificationOverlay.Post(new SimpleNotification
{
Text = $"{fileName} saved!",
Text = $"{filename} saved!",
Activated = () =>
{
storage.OpenInNativeExplorer();
storage.PresentFileExternally(filename);
return true;
}
});
}
});
private string getFileName()
private string getFilename()
{
var dt = DateTime.Now;
var fileExt = screenshotFormat.ToString().ToLowerInvariant();

View File

@ -70,7 +70,9 @@ namespace osu.Game.IO
public override Stream GetStream(string path, FileAccess access = FileAccess.Read, FileMode mode = FileMode.OpenOrCreate) =>
UnderlyingStorage.GetStream(MutatePath(path), access, mode);
public override void OpenPathInNativeExplorer(string path) => UnderlyingStorage.OpenPathInNativeExplorer(MutatePath(path));
public override void OpenFileExternally(string filename) => UnderlyingStorage.OpenFileExternally(MutatePath(filename));
public override void PresentFileExternally(string filename) => UnderlyingStorage.PresentFileExternally(MutatePath(filename));
public override Storage GetStorageForDirectory(string path)
{

View File

@ -913,13 +913,15 @@ namespace osu.Game
}
else if (recentLogCount == short_term_display_limit)
{
var logFile = $@"{entry.Target.ToString().ToLowerInvariant()}.log";
Schedule(() => Notifications.Post(new SimpleNotification
{
Icon = FontAwesome.Solid.EllipsisH,
Text = "Subsequent messages have been logged. Click to view log files.",
Activated = () =>
{
Storage.GetStorageForDirectory("logs").OpenInNativeExplorer();
Storage.GetStorageForDirectory(@"logs").PresentFileExternally(logFile);
return true;
}
}));

View File

@ -67,7 +67,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
Add(new SettingsButton
{
Text = GeneralSettingsStrings.OpenOsuFolder,
Action = storage.OpenInNativeExplorer,
Action = storage.PresentExternally,
});
Add(new SettingsButton

View File

@ -36,7 +36,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Realm" Version="10.6.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.1014.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.1026.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.1015.0" />
<PackageReference Include="Sentry" Version="3.9.4" />
<PackageReference Include="SharpCompress" Version="0.29.0" />

View File

@ -70,7 +70,7 @@
<Reference Include="System.Net.Http" />
</ItemGroup>
<ItemGroup Label="Package References">
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.1014.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2021.1026.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2021.1015.0" />
</ItemGroup>
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
@ -93,7 +93,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="ppy.osu.Framework" Version="2021.1014.0" />
<PackageReference Include="ppy.osu.Framework" Version="2021.1026.0" />
<PackageReference Include="SharpCompress" Version="0.28.3" />
<PackageReference Include="NUnit" Version="3.13.2" />
<PackageReference Include="SharpRaven" Version="2.4.0" />