Example #1
0
        Task <bool> PlatformOpenAsync(OpenFileRequest request)
        {
#pragma warning disable CA1416 // https://github.com/xamarin/xamarin-macios/issues/14619
            documentController = new UIDocumentInteractionController()
            {
                Name = request.File.FileName,
                Url  = NSUrl.FromFilename(request.File.FullPath),
                Uti  = request.File.ContentType
            };

            var view = Platform.GetCurrentUIViewController().View;

            CGRect rect;

            if (request.PresentationSourceBounds != Rect.Zero)
            {
                rect = request.PresentationSourceBounds.AsCGRect();
            }
            else
            {
                rect = DeviceInfo.Idiom == DeviceIdiom.Tablet
                                        ? new CGRect(new CGPoint(view.Bounds.Width / 2, view.Bounds.Height), CGRect.Empty.Size)
                                        : view.Bounds;
            }

            documentController.PresentOpenInMenu(rect, view, true);
#pragma warning restore CA1416
            return(Task.FromResult(true));
        }
Example #2
0
        public Task <bool> OpenAsync(OpenFileRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (request.File == null)
            {
                throw new ArgumentNullException(nameof(request.File));
            }

            return(PlatformOpenAsync(request));
        }
Example #3
0
        Task <bool> PlatformOpenAsync(OpenFileRequest request)
        {
            if (string.IsNullOrEmpty(request.File.FullPath))
            {
                throw new ArgumentNullException(nameof(request.File.FullPath));
            }

            Permissions.EnsureDeclared <Permissions.LaunchApp>();

            var appControl = new AppControl
            {
                Operation = AppControlOperations.View,
                Mime      = FileSystem.MimeTypes.All,
                Uri       = "file://" + request.File.FullPath,
            };

            AppControl.SendLaunchRequest(appControl);

            return(Task.FromResult(true));
        }
Example #4
0
        Task <bool> PlatformOpenAsync(OpenFileRequest request)
        {
            var contentUri = FileSystemUtils.GetShareableFileUri(request.File);

            var intent = new Intent(Intent.ActionView);

            intent.SetDataAndType(contentUri, request.File.ContentType);
            intent.SetFlags(ActivityFlags.GrantReadUriPermission);

            var chooserIntent = Intent.CreateChooser(intent, request.Title ?? string.Empty);
            var flags         = ActivityFlags.ClearTop | ActivityFlags.NewTask;

#if __ANDROID_24__
            if (OperatingSystem.IsAndroidVersionAtLeast(24))
            {
                flags |= ActivityFlags.LaunchAdjacent;
            }
#endif
            chooserIntent.SetFlags(flags);

            Application.Context.StartActivity(chooserIntent);

            return(Task.FromResult(true));
        }
 Task <bool> PlatformOpenAsync(OpenFileRequest request) =>
 throw ExceptionUtils.NotSupportedOrImplementedException;
Example #6
0
 Task PlatformOpenAsync(OpenFileRequest request) =>
 throw new FeatureNotSupportedException();
Example #7
0
 public static Task <bool> OpenAsync(OpenFileRequest request)
 => Current.OpenAsync(request);
Example #8
0
 Task <bool> PlatformOpenAsync(OpenFileRequest request) =>
 Task.FromResult(NSWorkspace.SharedWorkspace.OpenFile(request.File.FullPath));
Example #9
0
        async Task <bool> PlatformOpenAsync(OpenFileRequest request)
        {
            var storageFile = request.File.File ?? await StorageFile.GetFileFromPathAsync(request.File.FullPath);

            return(await WinLauncher.LaunchFileAsync(storageFile).AsTask());
        }