diff options
| author | Arjun Roychowdhury <pliablepixels@gmail.com> | 2015-09-23 15:44:19 -0400 |
|---|---|---|
| committer | Arjun Roychowdhury <pliablepixels@gmail.com> | 2015-09-23 15:44:19 -0400 |
| commit | 26821696678cf84ee19f4eb803807e41a7b56780 (patch) | |
| tree | 1503bee984f7e70406e08c22c4fb9aeb0c902ec1 | |
| parent | fe8e827a86ce2304d5deefc4c969d9ea7ce2bd79 (diff) | |
IOS9 patch to remove callout
| -rw-r--r-- | plugins/cordova-plugin-ios-longpress-fix/LICENSE | 21 | ||||
| -rw-r--r-- | plugins/cordova-plugin-ios-longpress-fix/README.md | 37 | ||||
| -rw-r--r-- | plugins/cordova-plugin-ios-longpress-fix/package.json | 37 | ||||
| -rwxr-xr-x | plugins/cordova-plugin-ios-longpress-fix/plugin.xml | 38 | ||||
| -rw-r--r-- | plugins/cordova-plugin-ios-longpress-fix/screenshots/magnifying-glass.png | bin | 0 -> 67841 bytes | |||
| -rwxr-xr-x | plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.h | 7 | ||||
| -rwxr-xr-x | plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m | 35 |
7 files changed, 175 insertions, 0 deletions
diff --git a/plugins/cordova-plugin-ios-longpress-fix/LICENSE b/plugins/cordova-plugin-ios-longpress-fix/LICENSE new file mode 100644 index 00000000..02389508 --- /dev/null +++ b/plugins/cordova-plugin-ios-longpress-fix/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Telerik + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE.
\ No newline at end of file diff --git a/plugins/cordova-plugin-ios-longpress-fix/README.md b/plugins/cordova-plugin-ios-longpress-fix/README.md new file mode 100644 index 00000000..77f620a8 --- /dev/null +++ b/plugins/cordova-plugin-ios-longpress-fix/README.md @@ -0,0 +1,37 @@ +# Cordova iOS LongPress Fix Plugin +by [Eddy Verbruggen](http://twitter.com/eddyverbruggen) + + +## Description + +Apple thought it'd be nice to show a magnifying glass when longpressing the webview on iOS9. + +Don't like it? This plugin removes it! + +<img src="screenshots/magnifying-glass.png" width="375px" height="333px"/> + + +## Installation + +Cordova CLI +``` +$ cordova plugin add cordova-plugin-ios-longpress-fix +``` + +PhoneGap Build +```xml +<gap:plugin id="cordova-plugin-ios-longpress-fix" source="npm" /> +``` + + +## Usage +It just works, and will proudly shout that at the XCode console when it does. + + +## Limitations +Currently only works with UIWebView, not WKWebView, but you should be able to +suppress the magnifying glass on WKWebView with a few lines of CSS. + + +## Future +I'm working with Cordova guys to get this in their distribution as standard.
\ No newline at end of file diff --git a/plugins/cordova-plugin-ios-longpress-fix/package.json b/plugins/cordova-plugin-ios-longpress-fix/package.json new file mode 100644 index 00000000..085c61f9 --- /dev/null +++ b/plugins/cordova-plugin-ios-longpress-fix/package.json @@ -0,0 +1,37 @@ +{ + "name": "cordova-plugin-ios-longpress-fix", + "version": "1.0.1", + "description": "Suppresses the silly magnifying glass when longpressing your app on iOS9", + "cordova": { + "id": "cordova-plugin-ios-longpress-fix", + "platforms": [ + "ios" + ] + }, + "repository": { + "type": "git", + "url": "git+https://github.com/EddyVerbruggen/cordova-plugin-ios-longpress-fix.git" + }, + "keywords": [ + "LongPress", + "LongTap", + "Zoom", + "Magnification", + "Magnifying glass", + "iOS9", + "ecosystem:cordova", + "cordova-ios" + ], + "engines": [ + { + "name": "cordova", + "version": ">=3.0.0" + } + ], + "author": "Eddy Verbruggen <eddyverbruggen@gmail.com> (https://github.com/EddyVerbruggen)", + "license": "MIT", + "bugs": { + "url": "https://github.com/EddyVerbruggen/cordova-plugin-ios-longpress-fix/issues" + }, + "homepage": "https://github.com/EddyVerbruggen/cordova-plugin-ios-longpress-fix#readme" +}
\ No newline at end of file diff --git a/plugins/cordova-plugin-ios-longpress-fix/plugin.xml b/plugins/cordova-plugin-ios-longpress-fix/plugin.xml new file mode 100755 index 00000000..228eec60 --- /dev/null +++ b/plugins/cordova-plugin-ios-longpress-fix/plugin.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" + id="cordova-plugin-ios-longpress-fix" + version="1.0.1"> + + <name>iOS LongPress Fix</name> + + <description> + Suppresses the silly magnifying glass when longpressing your app on iOS9 + </description> + + <author>Eddy Verbruggen</author> + + <license>MIT</license> + + <keywords>LongPress, LongTap, Zoom, Magnification, Magnifying glass, iOS9</keywords> + + <repo>https://github.com/EddyVerbruggen/cordova-plugin-ios-longpress-fix.git</repo> + + <issue>https://github.com/EddyVerbruggen/cordova-plugin-ios-longpress-fix/issues</issue> + + <engines> + <engine name="cordova" version=">=3.0.0"/> + </engines> + + <platform name="ios"> + <config-file target="config.xml" parent="/*"> + <feature name="LongPressFix"> + <param name="ios-package" value="LongPressFix"/> + <param name="onload" value="true"/> + </feature> + </config-file> + + <header-file src="src/ios/LongPressFix.h"/> + <source-file src="src/ios/LongPressFix.m"/> + </platform> + +</plugin> diff --git a/plugins/cordova-plugin-ios-longpress-fix/screenshots/magnifying-glass.png b/plugins/cordova-plugin-ios-longpress-fix/screenshots/magnifying-glass.png Binary files differnew file mode 100644 index 00000000..5ab7c70e --- /dev/null +++ b/plugins/cordova-plugin-ios-longpress-fix/screenshots/magnifying-glass.png diff --git a/plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.h b/plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.h new file mode 100755 index 00000000..132bb8ad --- /dev/null +++ b/plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.h @@ -0,0 +1,7 @@ +#import <Cordova/CDVPlugin.h> + +@interface LongPressFix : CDVPlugin + +@property (nonatomic,strong) UILongPressGestureRecognizer *lpgr; + +@end
\ No newline at end of file diff --git a/plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m b/plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m new file mode 100755 index 00000000..9f3d8521 --- /dev/null +++ b/plugins/cordova-plugin-ios-longpress-fix/src/ios/LongPressFix.m @@ -0,0 +1,35 @@ +#import "LongPressFix.h" + +@implementation LongPressFix + +- (void)pluginInitialize { + self.lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGestures:)]; + self.lpgr.minimumPressDuration = 0.45f; + self.lpgr.allowableMovement = 100.0f; + + NSArray *views = self.webView.subviews; + if (views.count == 0) { + NSLog(@"No webview subviews found, not applying the longpress fix"); + return; + } + for (int i=0; i<views.count; i++) { + UIView *webViewScrollView = views[i]; + if ([webViewScrollView isKindOfClass:[UIScrollView class]]) { + NSArray *webViewScrollViewSubViews = webViewScrollView.subviews; + UIView *browser = webViewScrollViewSubViews[0]; + [browser addGestureRecognizer:self.lpgr]; + NSLog(@"Applied longpress fix"); + break; + } + } +} + +- (void)handleLongPressGestures:(UILongPressGestureRecognizer *)sender { + if ([sender isEqual:self.lpgr]) { + if (sender.state == UIGestureRecognizerStateBegan) { + NSLog(@"Ignoring a longpress in order to suppress the magnifying glass (iOS9 quirk)"); + } + } +} + +@end
\ No newline at end of file |
