Skip to content

Commit

Permalink
AvaloniaUI#6110 resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
OmidID committed Aug 11, 2023
1 parent 323395b commit 83f278b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 78 deletions.
2 changes: 1 addition & 1 deletion src/Tizen/Avalonia.Tizen/NuiViewControlHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Avalonia.Tizen;
/// </summary>
public class NuiViewControlHandle : INativeControlHostDestroyableControlHandle
{
internal const string ViewDescriptor = nameof(View);
internal const string ViewDescriptor = "NuiView";

/// <summary>
/// Create handle with native view
Expand Down
40 changes: 0 additions & 40 deletions src/Tizen/Avalonia.Tizen/Platform/ScalingInfo.cs

This file was deleted.

39 changes: 3 additions & 36 deletions src/Tizen/Avalonia.Tizen/TizenStorageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,43 +71,10 @@ public async Task<IReadOnlyList<IStorageFile>> OpenFilePickerAsync(FilePickerOpe
return await tcs.Task;
}

public async Task<IReadOnlyList<IStorageFolder>> OpenFolderPickerAsync(FolderPickerOpenOptions options)
public Task<IReadOnlyList<IStorageFolder>> OpenFolderPickerAsync(FolderPickerOpenOptions options)
{
Permissions.EnsureDeclared(Permissions.AppManagerLaunchPrivilege);
if (await Permissions.RequestPrivilegeAsync(Permissions.MediaStoragePrivilege) == false)
{
throw new SecurityException("Application doesn't have storage permission.");
}

var tcs = new TaskCompletionSource<IReadOnlyList<IStorageFolder>>();

var appControl = new AppControl
{
Operation = AppControlOperations.Pick,
Mime = "inode/directory"
};
appControl.ExtraData.Add(AppControlData.SectionMode, options.AllowMultiple ? "multiple" : "single");
if (options.SuggestedStartLocation?.Path is { } startupPath)
appControl.ExtraData.Add(AppControlData.Path, startupPath.ToString());
appControl.LaunchMode = AppControlLaunchMode.Single;

var fileResults = new List<IStorageFolder>();

AppControl.SendLaunchRequest(appControl, (_, reply, result) =>
{
if (result == AppControlReplyResult.Succeeded)
{
if (reply.ExtraData.Count() > 0)
{
var selectedFiles = reply.ExtraData.Get<IEnumerable<string>>(AppControlData.Selected).ToList();
fileResults.AddRange(selectedFiles.Select(f => new BclStorageFolder(new System.IO.DirectoryInfo(f))));
}
}

tcs.TrySetResult(fileResults);
});

return await tcs.Task;
return Task.FromException<IReadOnlyList<IStorageFolder>>(
new PlatformNotSupportedException("Open folder is not supported by Tizen"));
}

public Task<IStorageBookmarkFolder?> OpenFolderBookmarkAsync(string bookmark)
Expand Down
4 changes: 3 additions & 1 deletion src/Tizen/Avalonia.Tizen/TizenThreadingInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ internal class TizenThreadingInterface : IPlatformThreadingInterface
internal event Action? TickExecuted;
private bool _signaled;

#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
internal static SynchronizationContext MainloopContext { get; set; }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.

public IDisposable StartTimer(DispatcherPriority priority, TimeSpan interval, Action tick)
{
Expand All @@ -22,7 +24,7 @@ private void EnsureInvokeOnMainThread(Action action)
if (SynchronizationContext.Current != null)
action();
else
MainloopContext.Post(_ => action(), null);
MainloopContext.Post(static arg => ((Action)arg!).Invoke(), action);
}

public void Signal(DispatcherPriority prio)
Expand Down

0 comments on commit 83f278b

Please sign in to comment.