Merge branch 'develop' into featureHapticFeedback
This commit is contained in:
Коммит
579dc8f39b
|
@ -11,10 +11,10 @@ namespace Xamarin.Essentials
|
|||
{
|
||||
public static partial class FilePicker
|
||||
{
|
||||
static Task<IEnumerable<FilePickerResult>> PlatformPickAsync(PickOptions options, bool allowMultiple = false)
|
||||
static async Task<IEnumerable<FilePickerResult>> PlatformPickAsync(PickOptions options, bool allowMultiple = false)
|
||||
{
|
||||
Permissions.EnsureDeclared<Permissions.LaunchApp>();
|
||||
Permissions.EnsureDeclared<Permissions.StorageRead>();
|
||||
await Permissions.EnsureGrantedAsync<Permissions.StorageRead>();
|
||||
|
||||
var tcs = new TaskCompletionSource<IEnumerable<FilePickerResult>>();
|
||||
|
||||
|
@ -30,21 +30,19 @@ namespace Xamarin.Essentials
|
|||
|
||||
AppControl.SendLaunchRequest(appControl, (request, reply, result) =>
|
||||
{
|
||||
var resultFiles = new List<FilePickerResult>();
|
||||
|
||||
if (result == AppControlReplyResult.Succeeded)
|
||||
{
|
||||
if (reply.ExtraData.Count() > 0)
|
||||
{
|
||||
var info = reply.ExtraData.Get<IEnumerable<string>>(AppControlData.Selected).ToList();
|
||||
resultFiles.Add(new FilePickerResult(info));
|
||||
var selectedFiles = reply.ExtraData.Get<IEnumerable<string>>(AppControlData.Selected).ToList();
|
||||
fileResults.AddRange(selectedFiles.Select(f => new FilePickerResult(f)));
|
||||
}
|
||||
}
|
||||
|
||||
tcs.TrySetResult(resultFiles);
|
||||
tcs.TrySetResult(fileResults);
|
||||
});
|
||||
|
||||
return tcs.Task;
|
||||
return await tcs.Task;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,33 +63,16 @@ namespace Xamarin.Essentials
|
|||
|
||||
public partial class FilePickerResult
|
||||
{
|
||||
readonly string fullPath;
|
||||
|
||||
internal FilePickerResult(IList<string> list)
|
||||
: base()
|
||||
internal FilePickerResult(string fullPath)
|
||||
: base(fullPath)
|
||||
{
|
||||
if (list == null || list.Count <= 0)
|
||||
throw new ArgumentNullException(nameof(list));
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
foreach (var path in list)
|
||||
{
|
||||
fullPath = path;
|
||||
FileName = string.Empty;
|
||||
if (path.Count() > 0)
|
||||
{
|
||||
FileName = Path.GetFileName(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async Task<Stream> PlatformOpenReadStreamAsync()
|
||||
{
|
||||
await Permissions.RequestAsync<Permissions.StorageRead>();
|
||||
|
||||
var stream = File.Open(fullPath, FileMode.Open, FileAccess.Read);
|
||||
var stream = File.Open(FullPath, FileMode.Open, FileAccess.Read);
|
||||
return Task.FromResult<Stream>(stream).Result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Tizen.Security;
|
||||
|
||||
|
@ -43,7 +42,8 @@ namespace Xamarin.Essentials
|
|||
|
||||
foreach (var (tizenPrivilege, isRuntime) in tizenPrivileges)
|
||||
{
|
||||
if (PrivacyPrivilegeManager.CheckPermission(tizenPrivilege) == CheckResult.Ask)
|
||||
var checkResult = PrivacyPrivilegeManager.CheckPermission(tizenPrivilege);
|
||||
if (checkResult == CheckResult.Ask)
|
||||
{
|
||||
if (ask)
|
||||
{
|
||||
|
@ -63,7 +63,7 @@ namespace Xamarin.Essentials
|
|||
}
|
||||
return PermissionStatus.Denied;
|
||||
}
|
||||
else if (PrivacyPrivilegeManager.CheckPermission(tizenPrivilege) == CheckResult.Deny)
|
||||
else if (checkResult == CheckResult.Deny)
|
||||
{
|
||||
return PermissionStatus.Denied;
|
||||
}
|
||||
|
@ -193,10 +193,14 @@ namespace Xamarin.Essentials
|
|||
|
||||
public partial class StorageRead : BasePlatformPermission
|
||||
{
|
||||
public override (string tizenPrivilege, bool isRuntime)[] RequiredPrivileges =>
|
||||
new[] { ("http://tizen.org/privilege/mediastorage", true) };
|
||||
}
|
||||
|
||||
public partial class StorageWrite : BasePlatformPermission
|
||||
{
|
||||
public override (string tizenPrivilege, bool isRuntime)[] RequiredPrivileges =>
|
||||
new[] { ("http://tizen.org/privilege/mediastorage", true) };
|
||||
}
|
||||
|
||||
public partial class Vibrate : BasePlatformPermission
|
||||
|
|
Загрузка…
Ссылка в новой задаче