Skip to content

Commit

Permalink
Merge pull request #8219 from hansemannn/TIMOB-23519-5_5_X
Browse files Browse the repository at this point in the history
[TIMOB-23519] (5_5_X) iOS10: Expose new Ti.UI.Pasteboard APIs
  • Loading branch information
hansemannn committed Aug 14, 2016
2 parents 5f40bfc + ffa2fcb commit 10a5443
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 5 deletions.
28 changes: 26 additions & 2 deletions apidoc/Titanium/UI/Clipboard/Clipboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,32 @@ methods:
- name: hasText
summary: Indicates whether any text data is stored in the clipboard.
returns:
- type: Boolean
- type: Number
type: Boolean


- name: hasURLs
summary: Indicates whether any URLs are stored in the clipboard.
since: "5.5.0"
osver: {ios: {min: "10.0"}}
platforms: [iphone, ipad]
returns:
type: Boolean

- name: hasImages
summary: Indicates whether any images are stored in the clipboard.
since: "5.5.0"
osver: {ios: {min: "10.0"}}
platforms: [iphone, ipad]
returns:
type: Boolean

- name: hasColors
summary: Indicates whether any colors are stored in the clipboard.
since: "5.5.0"
osver: {ios: {min: "10.0"}}
platforms: [iphone, ipad]
returns:
type: Boolean

- name: setData
summary: Stores data of the specified MIME type in the clipboard.
Expand Down
2 changes: 1 addition & 1 deletion iphone/Classes/TiUIClipboardProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
-(id)getData:(id)args;
-(NSString *)getText:(id)args;
-(id)hasData:(id)args;
-(id)hasText:(id)args;
-(id)hasText:(id)unused;
-(void)setData:(id)args;
-(void)setText:(id)args;

Expand Down
48 changes: 46 additions & 2 deletions iphone/Classes/TiUIClipboardProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,54 @@ -(id)hasData:(id)args
}, YES);
return NUMBOOL(result);
}



-(id)hasText:(id)args
-(id)hasText:(id)unused
{
#if IS_XCODE_8
if ([TiUtils isIOS10OrGreater]) {
return NUMBOOL([[UIPasteboard generalPasteboard] hasStrings]);
}
#endif

return [self hasData: @"text/plain"];
}

-(id)hasColors:(id)unused
{
return [self hasData: @"text/plain"];
#if IS_XCODE_8
if ([TiUtils isIOS10OrGreater]) {
return NUMBOOL([[UIPasteboard generalPasteboard] hasColors]);
}
#endif

NSLog(@"[WARN] Ti.UI.Clipboard.hasColors() is only available on iOS 10 and later.");
return NUMBOOL(NO);
}

-(id)hasImages:(id)unused
{
#if IS_XCODE_8
if ([TiUtils isIOS10OrGreater]) {
return NUMBOOL([[UIPasteboard generalPasteboard] hasImages]);
}
#endif

NSLog(@"[WARN] Ti.UI.Clipboard.hasImages() is only available on iOS 10 and later.");
return NUMBOOL(NO);
}

-(id)hasURLs:(id)unused
{
#if IS_XCODE_8
if ([TiUtils isIOS10OrGreater]) {
return NUMBOOL([[UIPasteboard generalPasteboard] hasURLs]);
}
#endif

NSLog(@"[WARN] Ti.UI.Clipboard.hasURLs() is only available on iOS 10 and later.");
return NUMBOOL(NO);
}

-(void)setData:(id)args
Expand Down

0 comments on commit 10a5443

Please sign in to comment.