feature: export video to gallery for iOS
This commit is contained in:
@@ -523,26 +523,37 @@ namespace Pixiview.Illust
|
||||
}
|
||||
|
||||
var item = illusts[p];
|
||||
|
||||
List<string> extras = new List<string>();
|
||||
|
||||
var share = ResourceHelper.Share;
|
||||
var preview = Stores.GetPreviewImagePath(item.PreviewUrl);
|
||||
if (preview != null)
|
||||
{
|
||||
extras.Add(share);
|
||||
}
|
||||
|
||||
var userDetail = ResourceHelper.UserDetail;
|
||||
extras.Add(userDetail);
|
||||
|
||||
var related = ResourceHelper.RelatedIllusts;
|
||||
extras.Add(related);
|
||||
var saveOriginal = ResourceHelper.SaveOriginal;
|
||||
|
||||
#if __IOS__
|
||||
var exportVideo = ResourceHelper.ExportVideo;
|
||||
if (IsAnimateSliderVisible)
|
||||
{
|
||||
extras.Add(exportVideo);
|
||||
}
|
||||
#endif
|
||||
|
||||
var saveOriginal = ResourceHelper.SaveOriginal;
|
||||
var illustItem = IllustItem;
|
||||
var result = await DisplayActionSheet(
|
||||
$"{illustItem.Title} (id: {illustItem.Id})",
|
||||
ResourceHelper.Cancel,
|
||||
saveOriginal,
|
||||
extras.ToArray());
|
||||
|
||||
if (result == saveOriginal)
|
||||
{
|
||||
SaveOriginalImage(item);
|
||||
@@ -565,8 +576,57 @@ namespace Pixiview.Illust
|
||||
var page = new RelatedIllustsPage(illustItem);
|
||||
await Navigation.PushAsync(page);
|
||||
}
|
||||
#if __IOS__
|
||||
else if (result == exportVideo)
|
||||
{
|
||||
ExportVideo();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if __IOS__
|
||||
private async void ExportVideo()
|
||||
{
|
||||
string msg = ResourceHelper.CantExportVideo;
|
||||
|
||||
if (ugoira != null && ugoiraData != null && ugoiraData.body != null)
|
||||
{
|
||||
if (Stores.CheckUgoiraVideo(ugoiraData.body.originalSrc))
|
||||
{
|
||||
var flag = await DisplayAlert(ResourceHelper.Operation,
|
||||
ResourceHelper.AlreadySavedVideo,
|
||||
ResourceHelper.Yes,
|
||||
ResourceHelper.No);
|
||||
if (!flag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var status = await Permissions.CheckStatusAsync<Permissions.Photos>();
|
||||
if (status != PermissionStatus.Granted)
|
||||
{
|
||||
status = await Permissions.RequestAsync<Permissions.Photos>();
|
||||
if (status != PermissionStatus.Granted)
|
||||
{
|
||||
App.DebugPrint("access denied to gallery.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var success = await Task.Run(ugoira.ExportVideo);
|
||||
if (success != null)
|
||||
{
|
||||
var result = await FileStore.SaveVideoToGalleryAsync(success);
|
||||
|
||||
msg = result ?? ResourceHelper.ExportSuccess;
|
||||
}
|
||||
}
|
||||
|
||||
await DisplayAlert(ResourceHelper.Title, msg, ResourceHelper.Ok);
|
||||
}
|
||||
#endif
|
||||
|
||||
private async void SaveOriginalImage(IllustDetailItem item)
|
||||
{
|
||||
if (Stores.CheckIllustImage(item.OriginalUrl))
|
||||
|
Reference in New Issue
Block a user