Open URLs in external browser.
This commit is contained in:
parent
774f183ac0
commit
10b205c541
@ -76,8 +76,8 @@
|
|||||||
wrn( @"Couldn't synchronize thanks tip." );
|
wrn( @"Couldn't synchronize thanks tip." );
|
||||||
}
|
}
|
||||||
|
|
||||||
[self.webNavigationItem setLeftBarButtonItem:[webView canGoBack]? [[UIBarButtonItem alloc]
|
[self.webNavigationItem setLeftBarButtonItem:[[UIBarButtonItem alloc]
|
||||||
initWithTitle:@"⬅︎" style:UIBarButtonItemStylePlain target:webView action:@selector( goBack )]: nil];
|
initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(openURL:)]];
|
||||||
[webView evaluateJavaScript:@"document.title" completionHandler:^(id o, NSError *error) {
|
[webView evaluateJavaScript:@"document.title" completionHandler:^(id o, NSError *error) {
|
||||||
self.webNavigationItem.prompt = [o description];
|
self.webNavigationItem.prompt = [o description];
|
||||||
}];
|
}];
|
||||||
@ -85,6 +85,39 @@
|
|||||||
|
|
||||||
#pragma mark - Actions
|
#pragma mark - Actions
|
||||||
|
|
||||||
|
- (IBAction)openURL:(id)sender {
|
||||||
|
|
||||||
|
UIAlertController *controller = [UIAlertController new];
|
||||||
|
controller.title = self.webView.URL.host;
|
||||||
|
controller.message = self.webView.URL.absoluteString;
|
||||||
|
[controller addAction:[UIAlertAction actionWithTitle:@"Safari" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
||||||
|
[UIApp openURL:self.webView.URL];
|
||||||
|
}]];
|
||||||
|
if ([UIApp canOpenURL:[NSURL URLWithString:@"firefox:"]]) {
|
||||||
|
[controller addAction:[UIAlertAction actionWithTitle:@"Firefox" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
||||||
|
[UIApp openURL:[NSURL URLWithString:strf( @"firefox://open-url?url=%@",
|
||||||
|
[self.webView.URL.absoluteString stringByAddingPercentEncodingWithAllowedCharacters:
|
||||||
|
[NSCharacterSet URLQueryAllowedCharacterSet]] )]];
|
||||||
|
}]];
|
||||||
|
}
|
||||||
|
if ([UIApp canOpenURL:[NSURL URLWithString:@"googlechrome:"]]) {
|
||||||
|
NSURL *url = [[NSURL alloc] initWithScheme:[self.webView.URL.scheme isEqualToString:@"http"]? @"googlechrome": @"googlechromes"
|
||||||
|
host:self.webView.URL.host path:self.webView.URL.path];
|
||||||
|
[controller addAction:[UIAlertAction actionWithTitle:@"Chrome" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
||||||
|
[UIApp openURL:url];
|
||||||
|
}]];
|
||||||
|
}
|
||||||
|
if ([UIApp canOpenURL:[NSURL URLWithString:@"opera-http:"]]) {
|
||||||
|
NSURL *url = [[NSURL alloc] initWithScheme:[self.webView.URL.scheme isEqualToString:@"http"]? @"opera-http": @"opera-https"
|
||||||
|
host:self.webView.URL.host path:self.webView.URL.path];
|
||||||
|
[controller addAction:[UIAlertAction actionWithTitle:@"Opera" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
||||||
|
[UIApp openURL:url];
|
||||||
|
}]];
|
||||||
|
}
|
||||||
|
[controller addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
|
||||||
|
[self presentViewController:controller animated:YES completion:nil];
|
||||||
|
}
|
||||||
|
|
||||||
- (IBAction)done:(id)sender {
|
- (IBAction)done:(id)sender {
|
||||||
|
|
||||||
[self dismissViewControllerAnimated:YES completion:nil];
|
[self dismissViewControllerAnimated:YES completion:nil];
|
||||||
|
@ -39,6 +39,12 @@
|
|||||||
<string>[auto]</string>
|
<string>[auto]</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>[auto]</string>
|
<string>[auto]</string>
|
||||||
|
<key>LSApplicationQueriesSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>firefox</string>
|
||||||
|
<string>googlechrome</string>
|
||||||
|
<string>opera-http</string>
|
||||||
|
</array>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>LSSupportsOpeningDocumentsInPlace</key>
|
<key>LSSupportsOpeningDocumentsInPlace</key>
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
</collectionViewFlowLayout>
|
</collectionViewFlowLayout>
|
||||||
<cells>
|
<cells>
|
||||||
<collectionViewCell opaque="NO" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="MPAvatarCell" id="Zab-uQ-uk9" customClass="MPAvatarCell">
|
<collectionViewCell opaque="NO" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="MPAvatarCell" id="Zab-uQ-uk9" customClass="MPAvatarCell">
|
||||||
<rect key="frame" x="80" y="115" width="215" height="667"/>
|
<rect key="frame" x="80" y="114.5" width="215" height="667"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
||||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="215" height="667"/>
|
<rect key="frame" x="0.0" y="0.0" width="215" height="667"/>
|
||||||
@ -476,6 +476,7 @@
|
|||||||
<rect key="frame" x="0.0" y="0.0" width="414" height="90"/>
|
<rect key="frame" x="0.0" y="0.0" width="414" height="90"/>
|
||||||
<items>
|
<items>
|
||||||
<navigationItem title="masterpassword.app" prompt="Loading" id="Wpf-6b-UJb">
|
<navigationItem title="masterpassword.app" prompt="Loading" id="Wpf-6b-UJb">
|
||||||
|
<barButtonItem key="leftBarButtonItem" systemItem="action" id="d9P-Hd-rdw"/>
|
||||||
<barButtonItem key="rightBarButtonItem" systemItem="done" id="Tbg-c3-qOh">
|
<barButtonItem key="rightBarButtonItem" systemItem="done" id="Tbg-c3-qOh">
|
||||||
<connections>
|
<connections>
|
||||||
<action selector="done:" destination="Sd5-eW-Cx2" id="cuN-bV-cwl"/>
|
<action selector="done:" destination="Sd5-eW-Cx2" id="cuN-bV-cwl"/>
|
||||||
@ -3257,7 +3258,7 @@ Ut in geometria, prima si dederis, danda sunt omnia. Nonne igitur tibi videntur,
|
|||||||
</scenes>
|
</scenes>
|
||||||
<inferredMetricsTieBreakers>
|
<inferredMetricsTieBreakers>
|
||||||
<segue reference="k2G-nL-x3l"/>
|
<segue reference="k2G-nL-x3l"/>
|
||||||
<segue reference="GZk-I4-JyH"/>
|
<segue reference="gtb-zE-u9H"/>
|
||||||
</inferredMetricsTieBreakers>
|
</inferredMetricsTieBreakers>
|
||||||
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
<color key="tintColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||||
<resources>
|
<resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user