Skip to content

Commit

Permalink
[uikit] Add UIPasteConfigurationSupporting and UITextPasteConfigurati…
Browse files Browse the repository at this point in the history
…onSupporting

- Fixes bug #59363: Missing UIPasteConfigurationSupporting, UITextPasteConfigurationSupporting, UITextDraggable and UITextDroppable on a couple of types
(https://bugzilla.xamarin.com/show_bug.cgi?id=59363)
  • Loading branch information
VincentDondain committed Sep 12, 2017
1 parent 343c0b3 commit 8d0d884
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/UIKit/UIResponder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public virtual void Cut ()
[Obsolete ("Override Paste(NSObject)")]
public virtual void Paste ()
{
Paste (null);
Paste ((NSObject)null);
}

[Obsolete ("Override Delete(NSObject)")]
Expand Down
19 changes: 15 additions & 4 deletions src/uikit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9798,6 +9798,9 @@ interface UIResponder : UIAccessibilityAction, UIAccessibilityFocus
#if !TVOS
, UIAccessibilityDragging
#endif // !TVOS
#if IOS
, UIPasteConfigurationSupporting
#endif // IOS
{

[Export ("nextResponder")]
Expand Down Expand Up @@ -12475,7 +12478,11 @@ interface UITableViewRowAction : NSCopying {

[BaseType (typeof (UIControl), Delegates=new string [] { "WeakDelegate" })]
// , Events=new Type [] {typeof(UITextFieldDelegate)})] custom logic needed, see https://bugzilla.xamarin.com/show_bug.cgi?id=53174
interface UITextField : UITextInput, UIContentSizeCategoryAdjusting {
interface UITextField : UITextInput, UIContentSizeCategoryAdjusting
#if IOS
, UITextDraggable, UITextDroppable, UITextPasteConfigurationSupporting
#endif // IOS
{
[Export ("initWithFrame:")]
IntPtr Constructor (CGRect frame);

Expand Down Expand Up @@ -12655,7 +12662,11 @@ interface UITextFieldDelegate {
}

[BaseType (typeof (UIScrollView), Delegates=new string [] { "WeakDelegate" }, Events=new Type [] {typeof(UITextViewDelegate)})]
interface UITextView : UITextInput, NSCoding, UIContentSizeCategoryAdjusting {
interface UITextView : UITextInput, NSCoding, UIContentSizeCategoryAdjusting
#if IOS
, UITextDraggable, UITextDroppable, UITextPasteConfigurationSupporting
#endif // IOS
{
[Export ("initWithFrame:")]
IntPtr Constructor (CGRect frame);

Expand Down Expand Up @@ -18296,10 +18307,10 @@ interface UIPasteConfigurationSupporting {
UIPasteConfiguration PasteConfiguration { get; set; }

[Export ("pasteItemProviders:")]
void PasteItemProviders (NSItemProvider[] itemProviders);
void Paste (NSItemProvider[] itemProviders);

[Export ("canPasteItemProviders:")]
bool CanPasteItemProviders (NSItemProvider[] itemProviders);
bool CanPaste (NSItemProvider[] itemProviders);
}

[NoTV, NoWatch]
Expand Down
135 changes: 135 additions & 0 deletions tests/introspection/iOS/iOSApiProtocolTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,141 @@ protected override bool Skip (Type type, string protocolName)
return true;
}
break;

case "UIPasteConfigurationSupporting":
switch (type.Name) {
case "WKWebView":
case "MKMapView":
case "PdfThumbnailView":
case "MKMarkerAnnotationView":
case "PdfView":
case "AVPlayerViewController":
case "MKPinAnnotationView":
case "AVRoutePickerView":
case "MKScaleView":
case "HKActivityRingView":
case "MKUserTrackingButton":
case "SKNode":
case "SKFieldNode":
case "SKShapeNode":
case "SKVideoNode":
case "HMCameraView":
case "MPMediaPickerController":
case "PHLivePhotoView":
case "UIImagePickerController":
case "QLPreviewController":
case "UIImageView":
case "RPBroadcastActivityViewController":
case "UIInputView":
case "UIInputViewController":
case "RPPreviewViewController":
case "SFSafariViewController":
case "UILabel":
case "UINavigationBar":
case "UINavigationController":
case "UIPageControl":
case "UIPageViewController":
case "MFMailComposeViewController":
case "MFMessageComposeViewController":
case "UIPickerView":
case "MPVolumeView":
case "MSMessagesAppViewController":
case "MSStickerBrowserView":
case "MSStickerBrowserViewController":
case "MSStickerView":
case "UIPopoverBackgroundView":
case "CNContactPickerViewController":
case "CNContactViewController":
case "UIActionSheet":
case "UIActivityViewController":
case "UIApplication":
case "UIButton":
case "EKCalendarChooser":
case "UICollectionView":
case "EKEventEditViewController":
case "UIControl":
case "EKEventViewController":
case "UIDocumentPickerViewController":
case "SLComposeViewController":
case "UISearchBar":
case "UIProgressView":
case "UITableView":
case "UISearchController":
case "FPUIActionExtensionViewController":
case "UITableViewCell":
case "UISegmentedControl":
case "UIToolbar":
case "UIReferenceLibraryViewController":
case "UIRefreshControl":
case "UIView":
case "UIViewController":
case "UIWindow":
case "UIResponder":
case "AUViewController":
case "CABTMidiCentralViewController":
case "CABTMidiLocalPeripheralViewController":
case "CAInterAppAudioSwitcherView":
case "CAInterAppAudioTransportView":
case "UIScrollView":
case "ARSCNView":
case "ARSKView":
case "UISearchContainerViewController":
case "UISlider":
case "UISplitViewController":
case "UIStackView":
case "UIStepper":
case "UISwitch":
case "UITabBar":
case "UITabBarController":
case "SCNView":
case "UITableViewController":
case "SLComposeServiceViewController":
case "SK3DNode":
case "SKAudioNode":
case "SKCameraNode":
case "SKCropNode":
case "SKEffectNode":
case "SKEmitterNode":
case "UITableViewHeaderFooterView":
case "SKLabelNode":
case "SKLightNode":
case "SKReferenceNode":
case "SKScene":
case "MCBrowserViewController":
case "SKSpriteNode":
case "GCEventViewController":
case "SKTileMapNode":
case "SKTransformNode":
case "GKMatchmakerViewController":
case "GKGameCenterViewController":
case "SKView":
case "SKCloudServiceSetupViewController":
case "GKTurnBasedMatchmakerViewController":
case "SKStoreProductViewController":
case "UIVideoEditorController":
case "GLKView":
case "GLKViewController":
case "MKCompassButton":
case "PKAddPassButton":
case "PKAddPassesViewController":
case "PKAddPaymentPassViewController":
case "MKAnnotationView":
case "UIActivityIndicatorView":
case "PKPaymentAuthorizationViewController":
case "UIAlertController":
case "UIVisualEffectView":
case "UICollectionReusableView":
case "PKPaymentButton":
case "UIDatePicker":
case "UIDocumentBrowserViewController":
case "UICollectionViewCell":
case "UIDocumentPickerExtensionViewController":
case "UIWebView":
case "UICloudSharingController":
case "UICollectionViewController":
return true;
}
break;
}
return base.Skip (type, protocolName);
}
Expand Down
90 changes: 90 additions & 0 deletions tests/monotouch-test/UIKit/UIPasteConfigurationSupportingTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//
// Unit tests for UIPasteConfigurationSupportingTest
//
// Authors:
// Vincent Dondain <[email protected]>
//
//
// Copyright 2017 Microsoft.
//

#if !__TVOS__ && !__WATCHOS__

using System;
#if XAMCORE_2_0
using CoreGraphics;
using Foundation;
using SpriteKit;
using ObjCRuntime;
using UIKit;
#else
using MonoTouch.CoreGraphics;
using MonoTouch.Foundation;
using MonoTouch.SpriteKit;
using MonoTouch.ObjCRuntime;
using MonoTouch.UIKit;
#endif
using NUnit.Framework;

namespace MonoTouchFixtures.UIKit {
[TestFixture]
[Preserve (AllMembers = true)]
public class UIPasteConfigurationSupportingTest {

[SetUp]
public void Setup ()
{
TestRuntime.AssertXcodeVersion (9, 0);
}

[Test]
public void UIViewControllerPasteTest ()
{
var viewController = new ViewControllerPoker ();
viewController.PasteConfiguration = new UIPasteConfiguration (typeof (UIImage));
viewController.Paste (new NSItemProvider [] { new NSItemProvider (new UIImage ()) });
}

[Test]
public void UIViewPasteTest ()
{
var view = new ViewPoker ();
view.PasteConfiguration = new UIPasteConfiguration (typeof (UIImage));
view.Paste (new NSItemProvider [] { new NSItemProvider (new UIImage ()) });
}

[Test]
public void SKNodeTest ()
{
var node = new NodePoker ();
node.PasteConfiguration = new UIPasteConfiguration (typeof (UIImage));
node.Paste (new NSItemProvider [] { new NSItemProvider (new UIImage ()) });
}

class ViewControllerPoker : UIViewController {

public override void Paste (NSItemProvider [] itemProviders)
{
Assert.IsTrue (itemProviders [0].CanLoadObject (typeof (UIImage)));
}
}

class ViewPoker : UIView {

public override void Paste (NSItemProvider [] itemProviders)
{
Assert.IsTrue (itemProviders [0].CanLoadObject (typeof (UIImage)));
}
}

class NodePoker : SKNode {

public override void Paste (NSItemProvider [] itemProviders)
{
Assert.IsTrue (itemProviders [0].CanLoadObject (typeof (UIImage)));
}
}
}
}

#endif // !__TVOS__ && !__WATCHOS__
1 change: 1 addition & 0 deletions tests/monotouch-test/monotouch-test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@
<Compile Include="UIKit\UISpringLoadedInteractionSupportingTest.cs" />
<Compile Include="PdfKit\PdfAnnotationTest.cs" />
<Compile Include="FileProvider\NSFileProviderPageTest.cs" />
<Compile Include="UIKit\UIPasteConfigurationSupportingTest.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
<ItemGroup>
Expand Down

0 comments on commit 8d0d884

Please sign in to comment.