Skip to content

Commit b42d6d7

Browse files
committed
ios custom share add
1 parent 182a5d2 commit b42d6d7

15 files changed

+357
-42
lines changed

plugin.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@
9090
<param name="onload" value="true" />
9191
</feature>
9292
</config-file>
93+
94+
<config-file target="*-Info.plist" parent="LSApplicationQueriesSchemes">
95+
<array>
96+
<string>googlechrome</string>
97+
</array>
98+
</config-file>
9399
<header-file src="src/ios/CDVInAppBrowserOptions.h" />
94100
<source-file src="src/ios/CDVInAppBrowserOptions.m" />
95101
<header-file src="src/ios/CDVInAppBrowserNavigationController.h" />
@@ -99,6 +105,19 @@
99105
<header-file src="src/ios/CDVWKInAppBrowserUIDelegate.h" />
100106
<source-file src="src/ios/CDVWKInAppBrowserUIDelegate.m" />
101107

108+
<header-file src="src/ios/SVWebViewControllerActivity.h" />
109+
<header-file src="src/ios/SVWebViewControllerActivityChrome.h" />
110+
<header-file src="src/ios/SVWebViewControllerActivitySafari.h" />
111+
<source-file src="src/ios/SVWebViewControllerActivity.m" />
112+
<source-file src="src/ios/SVWebViewControllerActivityChrome.m" />
113+
<source-file src="src/ios/SVWebViewControllerActivitySafari.m" />
114+
<resource-file src="src/ios/res/SVWebViewControllerActivityChrome-iPad.png" />
115+
<resource-file src="src/ios/res/[email protected]" />
116+
<resource-file src="src/ios/res/[email protected]" />
117+
<resource-file src="src/ios/res/SVWebViewControllerActivitySafari-iPad.png" />
118+
<resource-file src="src/ios/res/[email protected]" />
119+
<resource-file src="src/ios/res/[email protected]" />
120+
102121
<framework src="CoreGraphics.framework" />
103122
</platform>
104123

src/ios/CDVWKInAppBrowser.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
@property (nonatomic, strong) IBOutlet WKWebView* webView;
5959
@property (nonatomic, strong) IBOutlet WKWebViewConfiguration* configuration;
6060
@property (nonatomic, strong) IBOutlet UIBarButtonItem* closeButton;
61+
@property (nonatomic, strong) IBOutlet UIBarButtonItem* shareButton;
6162
@property (nonatomic, strong) IBOutlet UILabel* addressLabel;
6263
@property (nonatomic, strong) IBOutlet UIBarButtonItem* backButton;
6364
@property (nonatomic, strong) IBOutlet UIBarButtonItem* forwardButton;
@@ -71,10 +72,15 @@
7172

7273
- (void)close;
7374
- (void)navigateTo:(NSURL*)url;
74-
- (void)showLocationBar:(BOOL)show;
75-
- (void)showToolBar:(BOOL)show : (NSString *) toolbarPosition;
75+
// - (void)showLocationBar:(BOOL)show;
76+
// - (void)showToolBar:(BOOL)show : (NSString *) toolbarPosition;
7677
- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString : (int) buttonIndex;
78+
- (void)updateViews:(CDVInAppBrowserOptions*)browserOptions;
7779

7880
- (id)initWithBrowserOptions: (CDVInAppBrowserOptions*) browserOptions andSettings:(NSDictionary*) settings;
81+
- (id)createNavigationViewContoller;
7982

8083
@end
84+
85+
@interface CDWKEmptyViewController: UIViewController
86+
@end

src/ios/CDVWKInAppBrowser.m

Lines changed: 171 additions & 40 deletions
Large diffs are not rendered by default.

src/ios/SVWebViewControllerActivity.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// SVWebViewControllerActivity.h
3+
// SVWeb
4+
//
5+
// Created by Sam Vermette on 11/11/2013.
6+
//
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface SVWebViewControllerActivity : UIActivity
12+
13+
@property (nonatomic, strong) NSURL *URLToOpen;
14+
@property (nonatomic, strong) NSString *schemePrefix;
15+
16+
@end

src/ios/SVWebViewControllerActivity.m

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// SVWebViewControllerActivity.m
3+
// SVWeb
4+
//
5+
// Created by Sam Vermette on 11/11/2013.
6+
//
7+
//
8+
9+
#import "SVWebViewControllerActivity.h"
10+
11+
@implementation SVWebViewControllerActivity
12+
13+
- (NSString *)activityType {
14+
return NSStringFromClass([self class]);
15+
}
16+
17+
- (UIImage *)activityImage {
18+
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
19+
return [UIImage imageNamed:[self.activityType stringByAppendingString:@"-iPad"]];
20+
else
21+
return [UIImage imageNamed:self.activityType];
22+
}
23+
24+
- (void)prepareWithActivityItems:(NSArray *)activityItems {
25+
for (id activityItem in activityItems) {
26+
if ([activityItem isKindOfClass:[NSURL class]]) {
27+
self.URLToOpen = activityItem;
28+
}
29+
}
30+
}
31+
32+
@end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// SVWebViewControllerActivityChrome.h
3+
//
4+
// Created by Sam Vermette on 11 Nov, 2013.
5+
// Copyright 2013 Sam Vermette. All rights reserved.
6+
//
7+
// https://github.com/samvermette/SVWebViewController
8+
9+
#import "SVWebViewControllerActivity.h"
10+
11+
@interface SVWebViewControllerActivityChrome : SVWebViewControllerActivity
12+
13+
@end
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// SVWebViewControllerActivityChrome.h
3+
//
4+
// Created by Sam Vermette on 11 Nov, 2013.
5+
// Copyright 2013 Sam Vermette. All rights reserved.
6+
//
7+
// https://github.com/samvermette/SVWebViewController
8+
9+
#import "SVWebViewControllerActivityChrome.h"
10+
11+
@implementation SVWebViewControllerActivityChrome
12+
13+
- (NSString *)activityTitle {
14+
return @"Chrome에서 보기";
15+
}
16+
17+
- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems {
18+
for (id activityItem in activityItems) {
19+
if ([activityItem isKindOfClass:[NSURL class]] && [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"googlechrome://"]]) {
20+
return YES;
21+
}
22+
}
23+
return NO;
24+
}
25+
26+
- (void)performActivity {
27+
NSURL *inputURL = self.URLToOpen;
28+
NSString *scheme = inputURL.scheme;
29+
30+
// Replace the URL Scheme with the Chrome equivalent.
31+
NSString *chromeScheme = nil;
32+
if ([scheme isEqualToString:@"http"]) {
33+
chromeScheme = @"googlechrome";
34+
} else if ([scheme isEqualToString:@"https"]) {
35+
chromeScheme = @"googlechromes";
36+
}
37+
38+
// Proceed only if a valid Google Chrome URI Scheme is available.
39+
if (chromeScheme) {
40+
NSString *absoluteString = [inputURL absoluteString];
41+
NSRange rangeForScheme = [absoluteString rangeOfString:@":"];
42+
NSString *urlNoScheme =
43+
[absoluteString substringFromIndex:rangeForScheme.location];
44+
NSString *chromeURLString =
45+
[chromeScheme stringByAppendingString:urlNoScheme];
46+
NSURL *chromeURL = [NSURL URLWithString:chromeURLString];
47+
48+
// Open the URL with Chrome.
49+
[[UIApplication sharedApplication] openURL:chromeURL];
50+
}
51+
}
52+
53+
@end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// SVWebViewControllerActivitySafari.h
3+
//
4+
// Created by Sam Vermette on 11 Nov, 2013.
5+
// Copyright 2013 Sam Vermette. All rights reserved.
6+
//
7+
// https://github.com/samvermette/SVWebViewController
8+
9+
#import "SVWebViewControllerActivity.h"
10+
11+
@interface SVWebViewControllerActivitySafari : SVWebViewControllerActivity
12+
13+
@end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// SVWebViewControllerActivitySafari.m
3+
//
4+
// Created by Sam Vermette on 11 Nov, 2013.
5+
// Copyright 2013 Sam Vermette. All rights reserved.
6+
//
7+
// https://github.com/samvermette/SVWebViewController
8+
9+
10+
#import "SVWebViewControllerActivitySafari.h"
11+
12+
@implementation SVWebViewControllerActivitySafari
13+
14+
- (NSString *)activityTitle {
15+
return @"Safari에서 보기";
16+
}
17+
18+
- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems {
19+
for (id activityItem in activityItems) {
20+
if ([activityItem isKindOfClass:[NSURL class]] && [[UIApplication sharedApplication] canOpenURL:activityItem]) {
21+
return YES;
22+
}
23+
}
24+
return NO;
25+
}
26+
27+
- (void)performActivity {
28+
BOOL completed = [[UIApplication sharedApplication] openURL:self.URLToOpen];
29+
[self activityDidFinish:completed];
30+
}
31+
32+
@end
2.75 KB
Loading

0 commit comments

Comments
 (0)