Пример #1
0
        static Task PlatformRequestAsync(ShareTextRequest request)
        {
            var items = new List <NSObject>();

            if (!string.IsNullOrWhiteSpace(request.Text))
            {
                items.Add(new ShareActivityItemSource(new NSString(request.Text), request.Title));
            }

            if (!string.IsNullOrWhiteSpace(request.Uri))
            {
                items.Add(new ShareActivityItemSource(NSUrl.FromString(request.Uri), request.Title));
            }

            var activityController = new UIActivityViewController(items.ToArray(), null);

            var vc = Platform.GetCurrentViewController();

            if (activityController.PopoverPresentationController != null)
            {
                activityController.PopoverPresentationController.SourceView = vc.View;
            }

            return(vc.PresentViewControllerAsync(activityController, true));
        }
Пример #2
0
        static Task PlatformRequestAsync(ShareTextRequest request)
        {
            if (string.IsNullOrEmpty(request.Text) && string.IsNullOrEmpty(request.Uri))
            {
                throw new ArgumentNullException(nameof(request.Text));
            }

            Permissions.EnsureDeclared <Permissions.LaunchApp>();

            var appControl = new AppControl
            {
                Operation = AppControlOperations.ShareText,
            };

            if (!string.IsNullOrEmpty(request.Text))
            {
                appControl.ExtraData.Add("http://tizen.org/appcontrol/data/text", request.Text);
            }
            if (!string.IsNullOrEmpty(request.Uri))
            {
                appControl.ExtraData.Add("http://tizen.org/appcontrol/data/url", request.Uri);
            }
            if (!string.IsNullOrEmpty(request.Subject))
            {
                appControl.ExtraData.Add("http://tizen.org/appcontrol/data/subject", request.Subject);
            }
            if (!string.IsNullOrEmpty(request.Title))
            {
                appControl.ExtraData.Add("http://tizen.org/appcontrol/data/title", request.Title);
            }

            AppControl.SendLaunchRequest(appControl);

            return(Task.CompletedTask);
        }
Пример #3
0
        static Task PlatformRequestAsync(ShareTextRequest request)
        {
            Permissions.EnsureDeclared <Permissions.LaunchApp>();

            var appControl = new AppControl
            {
                Operation = AppControlOperations.ShareText,
            };

            if (!string.IsNullOrEmpty(request.Text))
            {
                appControl.ExtraData.Add(AppControlData.Text, request.Text);
            }
            if (!string.IsNullOrEmpty(request.Uri))
            {
                appControl.ExtraData.Add(AppControlData.Url, request.Uri);
            }
            if (!string.IsNullOrEmpty(request.Subject))
            {
                appControl.ExtraData.Add(AppControlData.Subject, request.Subject);
            }
            if (!string.IsNullOrEmpty(request.Title))
            {
                appControl.ExtraData.Add(AppControlData.Title, request.Title);
            }

            AppControl.SendLaunchRequest(appControl);

            return(Task.CompletedTask);
        }
Пример #4
0
        static Task PlatformRequestAsync(ShareTextRequest request)
        {
            var dataTransferManager = DataTransferManager.GetForCurrentView();

            dataTransferManager.DataRequested += ShareTextHandler;

            DataTransferManager.ShowShareUI();

            void ShareTextHandler(DataTransferManager sender, DataRequestedEventArgs e)
            {
                var newRequest = e.Request;

                newRequest.Data.Properties.Title = request.Title ?? AppInfo.Name;

                if (!string.IsNullOrWhiteSpace(request.Text))
                {
                    newRequest.Data.SetText(request.Text);
                }

                if (!string.IsNullOrWhiteSpace(request.Uri))
                {
                    newRequest.Data.SetWebLink(new Uri(request.Uri));
                }

                dataTransferManager.DataRequested -= ShareTextHandler;
            }

            return(Task.CompletedTask);
        }
Пример #5
0
        static Task PlatformRequestAsync(ShareTextRequest request)
        {
            var items = new List <string>();

            if (!string.IsNullOrWhiteSpace(request.Text))
            {
                items.Add(request.Text);
            }

            if (!string.IsNullOrWhiteSpace(request.Uri))
            {
                items.Add(request.Uri);
            }

            var intent = new Intent(Intent.ActionSend);

            intent.SetType("text/plain");
            intent.PutExtra(Intent.ExtraText, string.Join(Environment.NewLine, items));

            if (!string.IsNullOrWhiteSpace(request.Subject))
            {
                intent.PutExtra(Intent.ExtraSubject, request.Subject);
            }

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

            chooserIntent.SetFlags(flags);
            Platform.AppContext.StartActivity(chooserIntent);

            return(Task.CompletedTask);
        }
Пример #6
0
        static Task PlatformRequestAsync(ShareTextRequest request)
        {
            var items = new List <NSObject>();

            if (!string.IsNullOrWhiteSpace(request.Text))
            {
                items.Add(new ShareActivityItemSource(new NSString(request.Text), request.Title));
            }

            if (!string.IsNullOrWhiteSpace(request.Uri))
            {
                items.Add(new ShareActivityItemSource(NSUrl.FromString(request.Uri), request.Title));
            }

            var activityController = new UIActivityViewController(items.ToArray(), null);

            var vc = Platform.GetCurrentViewController();

            if (activityController.PopoverPresentationController != null)
            {
                activityController.PopoverPresentationController.SourceView = vc.View;
                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                {
                    var sr = new CoreGraphics.CGRect(vc.View.Bounds.Width, 20, 0, 0);
                    activityController.PopoverPresentationController.SourceRect = sr;
                }
            }

            return(vc.PresentViewControllerAsync(activityController, true));
        }
Пример #7
0
        public static Task RequestAsync(ShareTextRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (string.IsNullOrEmpty(request.Text) && string.IsNullOrEmpty(request.Uri))
            {
                throw new ArgumentException($"Both the {nameof(request.Text)} and {nameof(request.Uri)} are invalid. Make sure to include at least one of them in the request.");
            }

            return(PlatformRequestAsync(request));
        }
Пример #8
0
        static Task PlatformRequestAsync(ShareTextRequest request)
        {
            var items = new List <NSObject>();

            if (!string.IsNullOrWhiteSpace(request.Title))
            {
                items.Add(new NSString(request.Title));
            }
            if (!string.IsNullOrWhiteSpace(request.Text))
            {
                items.Add(new NSString(request.Text));
            }
            if (!string.IsNullOrWhiteSpace(request.Uri))
            {
                items.Add(NSUrl.FromString(request.Uri));
            }

            return(PlatformShowRequestAsync(request, items));
        }
Пример #9
0
        static async Task PlatformRequestAsync(ShareTextRequest request)
        {
            var src   = new TaskCompletionSource <bool>();
            var items = new List <NSObject>();

            if (!string.IsNullOrWhiteSpace(request.Text))
            {
                items.Add(new ShareActivityItemSource(new NSString(request.Text), request.Title));
            }

            if (!string.IsNullOrWhiteSpace(request.Uri))
            {
                items.Add(new ShareActivityItemSource(NSUrl.FromString(request.Uri), request.Title));
            }

            var activityController = new UIActivityViewController(items.ToArray(), null)
            {
                CompletionWithItemsHandler = (a, b, c, d) =>
                {
                    src.TrySetResult(true);
                }
            };

            var vc = Platform.GetCurrentViewController();

            if (activityController.PopoverPresentationController != null)
            {
                activityController.PopoverPresentationController.SourceView = vc.View;

                if (request.PresentationSourceBounds != Rectangle.Empty || Platform.HasOSVersion(13, 0))
                {
                    activityController.PopoverPresentationController.SourceRect = request.PresentationSourceBounds.ToPlatformRectangle();
                }
            }

            await vc.PresentViewControllerAsync(activityController, true);

            await src.Task;
        }
Пример #10
0
 public static Task RequestAsync(ShareTextRequest request) =>
 PlatformRequestAsync(request);
Пример #11
0
 static Task PlatformRequestAsync(ShareTextRequest request) =>
 throw new NotImplementedInReferenceAssemblyException();
Пример #12
0
 static Task PlatformRequestAsync(ShareTextRequest request) =>
 throw ExceptionUtils.NotSupportedOrImplementedException;
Пример #13
0
 static Task PlatformRequestAsync(ShareTextRequest request) =>
 throw new System.PlatformNotSupportedException();