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)); }
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); }
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); }
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); }
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); }
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)); }
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)); }
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)); }
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; }
public static Task RequestAsync(ShareTextRequest request) => PlatformRequestAsync(request);
static Task PlatformRequestAsync(ShareTextRequest request) => throw new NotImplementedInReferenceAssemblyException();
static Task PlatformRequestAsync(ShareTextRequest request) => throw ExceptionUtils.NotSupportedOrImplementedException;
static Task PlatformRequestAsync(ShareTextRequest request) => throw new System.PlatformNotSupportedException();