summaryrefslogtreecommitdiff
path: root/StoneIsland/plugins/cordova-plugin-ionic-keyboard
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-08-31 23:07:20 +0200
committerJules Laplace <julescarbon@gmail.com>2020-08-31 23:07:20 +0200
commit22721a013bdd10d5eb395ba18453585f5f3f1f7f (patch)
tree5a920e31d6026ed5dc55265e5fd057febccc50e3 /StoneIsland/plugins/cordova-plugin-ionic-keyboard
parentd22d51a1ae49680015326857360eb699f31efced (diff)
rebuild the ios platform and the plugins
Diffstat (limited to 'StoneIsland/plugins/cordova-plugin-ionic-keyboard')
-rw-r--r--StoneIsland/plugins/cordova-plugin-ionic-keyboard/LICENSE23
-rw-r--r--StoneIsland/plugins/cordova-plugin-ionic-keyboard/README.md220
-rw-r--r--StoneIsland/plugins/cordova-plugin-ionic-keyboard/package.json59
-rw-r--r--StoneIsland/plugins/cordova-plugin-ionic-keyboard/plugin.xml47
-rw-r--r--StoneIsland/plugins/cordova-plugin-ionic-keyboard/src/android/CDVIonicKeyboard.java165
-rw-r--r--StoneIsland/plugins/cordova-plugin-ionic-keyboard/src/ios/CDVIonicKeyboard.h24
-rw-r--r--StoneIsland/plugins/cordova-plugin-ionic-keyboard/src/ios/CDVIonicKeyboard.m411
-rwxr-xr-xStoneIsland/plugins/cordova-plugin-ionic-keyboard/www/android/keyboard.js84
-rw-r--r--StoneIsland/plugins/cordova-plugin-ionic-keyboard/www/ios/keyboard.js103
9 files changed, 1136 insertions, 0 deletions
diff --git a/StoneIsland/plugins/cordova-plugin-ionic-keyboard/LICENSE b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/LICENSE
new file mode 100644
index 00000000..623c70a8
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/LICENSE
@@ -0,0 +1,23 @@
+Copyright 2015-present Drifty Co.
+http://drifty.com/
+
+MIT License
+
+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.
diff --git a/StoneIsland/plugins/cordova-plugin-ionic-keyboard/README.md b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/README.md
new file mode 100644
index 00000000..4674035d
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/README.md
@@ -0,0 +1,220 @@
+# cordova-plugin-ionic-keyboard
+
+This plugin has been designed to work seamlessly with `cordova-plugin-ionic-webview`, so make sure you have it installed first:
+
+ - https://github.com/ionic-team/cordova-plugin-ionic-webview
+ - https://ionicframework.com/docs/wkwebview/
+
+## Installation
+
+```
+cordova plugin add cordova-plugin-ionic-keyboard --save
+```
+
+## Preferences
+
+### KeyboardResize (for iOS only)
+
+> Boolean (true by default)
+
+#### Possible values
+- `true`: Showing/hiding the keyboard will trigger some kind of resizing of the app (see KeyboardResizeMode)
+- `false`: Web will not be resized when the keyboard shows up.
+
+```xml
+<preference name="KeyboardResize" value="true" />
+```
+
+### KeyboardResizeMode (for iOS only)
+
+> String ('native' by default)
+
+#### Possible values
+
+- `native`: The whole native webview will be resized when the keyboard shows/hides, it will affect the `vh` relative unit.
+- `body`: Only the html `<body>` element will be resized. Relative units are not affected, because the viewport does not change.
+- `ionic`: Only the html `ion-app` element will be resized. Only for ionic apps.
+
+```xml
+<preference name="KeyboardResizeMode" value="native" />
+```
+
+### KeyboardStyle (for iOS only)
+
+> String ('light' by default)
+
+#### Possible values
+
+- `light`
+- `dark`
+
+```xml
+<preference name="KeyboardStyle" value="dark" />
+```
+
+### HideKeyboardFormAccessoryBar (for iOS only)
+
+> Boolean (true by default)
+
+#### Possible values
+- `true`: hides the keyboard accessory bar.
+- `false`: shows the keyboard accessory bar.
+
+```xml
+<preference name="HideKeyboardFormAccessoryBar" value="false" />
+```
+
+### resizeOnFullScreen (for Android only)
+
+There is an Android bug that prevents the keyboard from resizing the WebView when the app is in full screen (i.e. if StatusBar plugin is used to hide the StatusBar). This setting, if set to true, add a workaround that resizes the WebView even when the app is in full screen.
+
+> Boolean (false by default)
+
+#### Possible values
+- `false`: doesn't resize the WebView when the app is in full screen.
+- `true`: resizes the WebView when the app is in full screen.
+
+
+```xml
+<preference name="resizeOnFullScreen" value="true" />
+```
+
+
+## Methods
+
+### Keyboard.hideFormAccessoryBar (for iOS only)
+
+> Hide the keyboard toolbar.
+
+Set to true to hide the additional toolbar that is on top of the keyboard. This toolbar features the Prev, Next, and Done buttons.
+
+```js
+Keyboard.hideFormAccessoryBar(value, successCallback);
+```
+
+#### Quick Example
+
+```js
+Keyboard.hideFormAccessoryBar(true);
+Keyboard.hideFormAccessoryBar(false);
+Keyboard.hideFormAccessoryBar(null, (currentValue) => { console.log(currentValue); });
+```
+
+### Keyboard.hide
+
+> Hide the keyboard
+
+Call this method to hide the keyboard
+
+```js
+Keyboard.hide();
+```
+
+### Keyboard.show (for Android only)
+
+> Show the keyboard
+
+Call this method to show the keyboard.
+
+```js
+Keyboard.show();
+```
+
+### Keyboard.setResizeMode (for iOS only)
+
+> Programmatically set the resize mode
+
+Call the method with parameter to set the resize mode.
+
+```js
+// Possible values are the same as for 'KeyboardResizeMode' preference
+Keyboard.setResizeMode('native');
+Keyboard.setResizeMode('body');
+Keyboard.setResizeMode('ionic');
+```
+
+### Keyboard.setKeyboardStyle (for iOS only)
+
+> Programmatically set the keyboard style
+
+```js
+// Possible values are the same as for 'KeyboardStyle' preference
+Keyboard.setKeyboardStyle('light'); // <- default
+Keyboard.setKeyboardStyle('dark');
+```
+
+### Keyboard.disableScroll (for iOS only)
+
+> Programmatically enable or disable the WebView scroll
+
+```js
+Keyboard.disableScroll(true); // <- default
+Keyboard.disableScroll(false);
+```
+
+
+## Properties
+
+### Keyboard.isVisible
+
+> Determine if the keyboard is visible.
+
+Read this property to determine if the keyboard is visible.
+
+```js
+if (Keyboard.isVisible) {
+ // do something
+}
+```
+
+## Events
+
+### keyboardDidHide
+
+> This event is fired when the keyboard is fully closed.
+
+Attach handler to this event to be able to receive notification when keyboard is closed.
+
+```js
+window.addEventListener('keyboardDidHide', () => {
+ // Describe your logic which will be run each time keyboard is closed.
+});
+```
+
+### keyboardDidShow
+
+> This event is fired when the keyboard is fully open.
+
+Attach handler to this event to be able to receive notification when keyboard is opened.
+
+```js
+window.addEventListener('keyboardDidShow', (event) => {
+ // Describe your logic which will be run each time when keyboard is about to be shown.
+ console.log(event.keyboardHeight);
+});
+```
+
+### keyboardWillShow
+
+> This event fires before keyboard will be shown.
+
+Attach handler to this event to be able to receive notification when keyboard is about to be shown on the screen.
+
+```js
+window.addEventListener('keyboardWillShow', (event) => {
+ // Describe your logic which will be run each time when keyboard is about to be shown.
+ console.log(event.keyboardHeight);
+});
+```
+
+### keyboardWillHide
+
+> This event fires before keyboard will be closed.
+
+Attach handler to this event to be able to receive notification when keyboard is about to be closed.
+
+```js
+window.addEventListener('keyboardWillHide', () => {
+ // Describe your logic which will be run each time when keyboard is about to be closed.
+});
+```
diff --git a/StoneIsland/plugins/cordova-plugin-ionic-keyboard/package.json b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/package.json
new file mode 100644
index 00000000..c987b845
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/package.json
@@ -0,0 +1,59 @@
+{
+ "_from": "cordova-plugin-ionic-keyboard",
+ "_id": "cordova-plugin-ionic-keyboard@2.2.0",
+ "_inBundle": false,
+ "_integrity": "sha512-yDUG+9ieKVRitq5mGlNxjaZh/MgEhFFIgTIPhqSbUaQ8UuZbawy5mhJAVClqY97q8/rcQtL6dCDa7x2sEtCLcA==",
+ "_location": "/cordova-plugin-ionic-keyboard",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "tag",
+ "registry": true,
+ "raw": "cordova-plugin-ionic-keyboard",
+ "name": "cordova-plugin-ionic-keyboard",
+ "escapedName": "cordova-plugin-ionic-keyboard",
+ "rawSpec": "",
+ "saveSpec": null,
+ "fetchSpec": "latest"
+ },
+ "_requiredBy": [
+ "#DEV:/",
+ "#USER"
+ ],
+ "_resolved": "https://registry.npmjs.org/cordova-plugin-ionic-keyboard/-/cordova-plugin-ionic-keyboard-2.2.0.tgz",
+ "_shasum": "53ba9ccd5e765165446a094cfe042a2ddd87d81d",
+ "_spec": "cordova-plugin-ionic-keyboard",
+ "_where": "/Users/user/work/stone-island/StoneIsland",
+ "author": {
+ "name": "Apache Software Foundation"
+ },
+ "bugs": {
+ "url": "https://github.com/ionic-team/cordova-plugin-ionic-keyboard/issues"
+ },
+ "bundleDependencies": false,
+ "deprecated": false,
+ "description": "Ionic Keyboard Plugin",
+ "devDependencies": {
+ "np": "^5.0.3",
+ "sync-cordova-xml": "^0.4.0"
+ },
+ "homepage": "https://github.com/ionic-team/cordova-plugin-ionic-keyboard#readme",
+ "keywords": [
+ "cordova",
+ "keyboard",
+ "ecosystem:cordova",
+ "cordova-ios",
+ "cordova-android"
+ ],
+ "license": "Apache 2.0",
+ "name": "cordova-plugin-ionic-keyboard",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/ionic-team/cordova-plugin-ionic-keyboard.git"
+ },
+ "scripts": {
+ "deploy": "np --yolo",
+ "sync_plugin_xml": "sync-cordova-xml package.json plugin.xml --output=plugin.xml",
+ "version": "npm run sync_plugin_xml && git add plugin.xml"
+ },
+ "version": "2.2.0"
+}
diff --git a/StoneIsland/plugins/cordova-plugin-ionic-keyboard/plugin.xml b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/plugin.xml
new file mode 100644
index 00000000..5badf01c
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/plugin.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:rim="http://www.blackberry.com/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-ionic-keyboard" version="2.2.0">
+ <name>cordova-plugin-ionic-keyboard</name>
+ <description>Ionic Keyboard Plugin</description>
+ <license>Apache 2.0</license>
+ <keywords>cordova,keyboard,ecosystem:cordova,cordova-ios,cordova-android</keywords>
+ <repo>https://github.com/ionic-team/cordova-plugin-ionic-keyboard.git</repo>
+ <issue>https://github.com/ionic-team/cordova-plugin-ionic-keyboard/issues</issue>
+ <author>Apache Software Foundation</author>
+
+ <engines>
+ <engine name="cordova" version=">=3.2.0"/>
+ </engines>
+
+ <!-- ios -->
+ <platform name="ios">
+
+ <js-module src="www/ios/keyboard.js" name="keyboard">
+ <clobbers target="window.Keyboard"/>
+ </js-module>
+
+ <config-file target="config.xml" parent="/*">
+ <feature name="CDVIonicKeyboard">
+ <param name="ios-package" value="CDVIonicKeyboard" onload="true"/>
+ </feature>
+ </config-file>
+
+ <header-file src="src/ios/CDVIonicKeyboard.h"/>
+ <source-file src="src/ios/CDVIonicKeyboard.m"/>
+ </platform>
+
+ <!-- android -->
+ <platform name="android">
+ <js-module src="www/android/keyboard.js" name="keyboard">
+ <clobbers target="window.Keyboard"/>
+ </js-module>
+ <config-file target="config.xml" parent="/*">
+ <feature name="CDVIonicKeyboard">
+ <param name="android-package" value="io.ionic.keyboard.CDVIonicKeyboard" onload="true"/>
+ </feature>
+ </config-file>
+
+ <source-file src="src/android/CDVIonicKeyboard.java" target-dir="src/io/ionic/keyboard"/>
+ </platform>
+
+</plugin>
diff --git a/StoneIsland/plugins/cordova-plugin-ionic-keyboard/src/android/CDVIonicKeyboard.java b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/src/android/CDVIonicKeyboard.java
new file mode 100644
index 00000000..b7ec4556
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/src/android/CDVIonicKeyboard.java
@@ -0,0 +1,165 @@
+package io.ionic.keyboard;
+
+import org.apache.cordova.CallbackContext;
+import org.apache.cordova.CordovaInterface;
+import org.apache.cordova.CordovaPlugin;
+import org.apache.cordova.CordovaWebView;
+import org.apache.cordova.PluginResult;
+import org.apache.cordova.PluginResult.Status;
+import org.json.JSONArray;
+import org.json.JSONException;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.util.DisplayMetrics;
+import android.view.View;
+import android.view.ViewTreeObserver;
+import android.view.ViewTreeObserver.OnGlobalLayoutListener;
+import android.view.inputmethod.InputMethodManager;
+
+// import additionally required classes for calculating screen height
+import android.view.Display;
+import android.graphics.Point;
+import android.os.Build;
+import android.widget.FrameLayout;
+
+public class CDVIonicKeyboard extends CordovaPlugin {
+ private OnGlobalLayoutListener list;
+ private View rootView;
+ private View mChildOfContent;
+ private int usableHeightPrevious;
+ private FrameLayout.LayoutParams frameLayoutParams;
+
+ public void initialize(CordovaInterface cordova, CordovaWebView webView) {
+ super.initialize(cordova, webView);
+ }
+
+ public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
+ if ("hide".equals(action)) {
+ cordova.getThreadPool().execute(new Runnable() {
+ public void run() {
+ //http://stackoverflow.com/a/7696791/1091751
+ InputMethodManager inputManager = (InputMethodManager) cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
+ View v = cordova.getActivity().getCurrentFocus();
+
+ if (v == null) {
+ callbackContext.error("No current focus");
+ } else {
+ inputManager.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
+ callbackContext.success(); // Thread-safe.
+ }
+ }
+ });
+ return true;
+ }
+ if ("show".equals(action)) {
+ cordova.getThreadPool().execute(new Runnable() {
+ public void run() {
+ ((InputMethodManager) cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY);
+ callbackContext.success(); // Thread-safe.
+ }
+ });
+ return true;
+ }
+ if ("init".equals(action)) {
+ cordova.getThreadPool().execute(new Runnable() {
+ public void run() {
+ //calculate density-independent pixels (dp)
+ //http://developer.android.com/guide/practices/screens_support.html
+ DisplayMetrics dm = new DisplayMetrics();
+ cordova.getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
+ final float density = dm.density;
+
+ //http://stackoverflow.com/a/4737265/1091751 detect if keyboard is showing
+ FrameLayout content = (FrameLayout) cordova.getActivity().findViewById(android.R.id.content);
+ rootView = content.getRootView();
+ list = new OnGlobalLayoutListener() {
+ int previousHeightDiff = 0;
+ @Override
+ public void onGlobalLayout() {
+ boolean resize = preferences.getBoolean("resizeOnFullScreen", false);
+ if (resize) {
+ possiblyResizeChildOfContent();
+ }
+ Rect r = new Rect();
+ //r will be populated with the coordinates of your view that area still visible.
+ rootView.getWindowVisibleDisplayFrame(r);
+
+ PluginResult result;
+
+ // cache properties for later use
+ int rootViewHeight = rootView.getRootView().getHeight();
+ int resultBottom = r.bottom;
+
+ // calculate screen height differently for android versions >= 21: Lollipop 5.x, Marshmallow 6.x
+ //http://stackoverflow.com/a/29257533/3642890 beware of nexus 5
+ int screenHeight;
+
+ if (Build.VERSION.SDK_INT >= 21) {
+ Display display = cordova.getActivity().getWindowManager().getDefaultDisplay();
+ Point size = new Point();
+ display.getSize(size);
+ screenHeight = size.y;
+ } else {
+ screenHeight = rootViewHeight;
+ }
+
+ int heightDiff = screenHeight - resultBottom;
+
+ int pixelHeightDiff = (int)(heightDiff / density);
+ if (pixelHeightDiff > 100 && pixelHeightDiff != previousHeightDiff) { // if more than 100 pixels, its probably a keyboard...
+ String msg = "S" + Integer.toString(pixelHeightDiff);
+ result = new PluginResult(PluginResult.Status.OK, msg);
+ result.setKeepCallback(true);
+ callbackContext.sendPluginResult(result);
+ }
+ else if ( pixelHeightDiff != previousHeightDiff && ( previousHeightDiff - pixelHeightDiff ) > 100 ){
+ String msg = "H";
+ result = new PluginResult(PluginResult.Status.OK, msg);
+ result.setKeepCallback(true);
+ callbackContext.sendPluginResult(result);
+ }
+ previousHeightDiff = pixelHeightDiff;
+ }
+
+ private void possiblyResizeChildOfContent() {
+ int usableHeightNow = computeUsableHeight();
+ if (usableHeightNow != usableHeightPrevious) {
+ int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
+ int heightDifference = usableHeightSansKeyboard - usableHeightNow;
+ if (heightDifference > (usableHeightSansKeyboard/4)) {
+ frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
+ } else {
+ frameLayoutParams.height = usableHeightSansKeyboard;
+ }
+ mChildOfContent.requestLayout();
+ usableHeightPrevious = usableHeightNow;
+ }
+ }
+
+ private int computeUsableHeight() {
+ Rect r = new Rect();
+ mChildOfContent.getWindowVisibleDisplayFrame(r);
+ return (r.bottom - r.top);
+ }
+ };
+
+ mChildOfContent = content.getChildAt(0);
+ rootView.getViewTreeObserver().addOnGlobalLayoutListener(list);
+ frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
+ PluginResult dataResult = new PluginResult(PluginResult.Status.OK);
+ dataResult.setKeepCallback(true);
+ callbackContext.sendPluginResult(dataResult);
+ }
+ });
+ return true;
+ }
+ return false; // Returning false results in a "MethodNotFound" error.
+ }
+
+ @Override
+ public void onDestroy() {
+ rootView.getViewTreeObserver().removeOnGlobalLayoutListener(list);
+ }
+
+}
diff --git a/StoneIsland/plugins/cordova-plugin-ionic-keyboard/src/ios/CDVIonicKeyboard.h b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/src/ios/CDVIonicKeyboard.h
new file mode 100644
index 00000000..aae6766a
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/src/ios/CDVIonicKeyboard.h
@@ -0,0 +1,24 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import <Cordova/CDVPlugin.h>
+
+@interface CDVIonicKeyboard : CDVPlugin
+
+@end
diff --git a/StoneIsland/plugins/cordova-plugin-ionic-keyboard/src/ios/CDVIonicKeyboard.m b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/src/ios/CDVIonicKeyboard.m
new file mode 100644
index 00000000..e4615a84
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/src/ios/CDVIonicKeyboard.m
@@ -0,0 +1,411 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import "CDVIonicKeyboard.h"
+#import <Cordova/CDVAvailability.h>
+#import <Cordova/NSDictionary+CordovaPreferences.h>
+#import <objc/runtime.h>
+
+typedef enum : NSUInteger {
+ ResizeNone,
+ ResizeNative,
+ ResizeBody,
+ ResizeIonic,
+} ResizePolicy;
+
+#ifndef __CORDOVA_3_2_0
+#warning "The keyboard plugin is only supported in Cordova 3.2 or greater, it may not work properly in an older version. If you do use this plugin in an older version, make sure the HideKeyboardFormAccessoryBar and KeyboardShrinksView preference values are false."
+#endif
+
+@interface CDVIonicKeyboard () <UIScrollViewDelegate>
+
+@property (readwrite, assign, nonatomic) BOOL disableScroll;
+@property (readwrite, assign, nonatomic) BOOL hideFormAccessoryBar;
+@property (readwrite, assign, nonatomic) BOOL keyboardIsVisible;
+@property (nonatomic, readwrite) ResizePolicy keyboardResizes;
+@property (readwrite, assign, nonatomic) NSString* keyboardStyle;
+@property (nonatomic, readwrite) BOOL isWK;
+@property (nonatomic, readwrite) int paddingBottom;
+
+@end
+
+@implementation CDVIonicKeyboard
+
+NSTimer *hideTimer;
+
+- (id)settingForKey:(NSString *)key
+{
+ return [self.commandDelegate.settings objectForKey:[key lowercaseString]];
+}
+
+#pragma mark Initialize
+
+NSString* UIClassString;
+NSString* WKClassString;
+NSString* UITraitsClassString;
+
+- (void)pluginInitialize
+{
+ UIClassString = [@[@"UI", @"Web", @"Browser", @"View"] componentsJoinedByString:@""];
+ WKClassString = [@[@"WK", @"Content", @"View"] componentsJoinedByString:@""];
+ UITraitsClassString = [@[@"UI", @"Text", @"Input", @"Traits"] componentsJoinedByString:@""];
+
+ NSDictionary *settings = self.commandDelegate.settings;
+
+ self.disableScroll = ![settings cordovaBoolSettingForKey:@"ScrollEnabled" defaultValue:NO];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarDidChangeFrame:) name: UIApplicationDidChangeStatusBarFrameNotification object:nil];
+
+ self.keyboardResizes = ResizeNative;
+ BOOL doesResize = [settings cordovaBoolSettingForKey:@"KeyboardResize" defaultValue:YES];
+ if (!doesResize) {
+ self.keyboardResizes = ResizeNone;
+ NSLog(@"CDVIonicKeyboard: no resize");
+
+ } else {
+ NSString *resizeMode = [settings cordovaSettingForKey:@"KeyboardResizeMode"];
+ if (resizeMode) {
+ if ([resizeMode isEqualToString:@"ionic"]) {
+ self.keyboardResizes = ResizeIonic;
+ } else if ([resizeMode isEqualToString:@"body"]) {
+ self.keyboardResizes = ResizeBody;
+ }
+ }
+ NSLog(@"CDVIonicKeyboard: resize mode %lu", (unsigned long)self.keyboardResizes);
+ }
+ self.hideFormAccessoryBar = [settings cordovaBoolSettingForKey:@"HideKeyboardFormAccessoryBar" defaultValue:YES];
+
+ NSString *keyboardStyle = [settings cordovaSettingForKey:@"KeyboardStyle"];
+ if (keyboardStyle) {
+ [self setKeyboardStyle:keyboardStyle];
+ }
+
+ if ([settings cordovaBoolSettingForKey:@"KeyboardAppearanceDark" defaultValue:NO]) {
+ [self setKeyboardStyle:@"dark"];
+ }
+
+ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
+
+ [nc addObserver:self selector:@selector(onKeyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
+ [nc addObserver:self selector:@selector(onKeyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];
+ [nc addObserver:self selector:@selector(onKeyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
+ [nc addObserver:self selector:@selector(onKeyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
+
+ // Prevent WKWebView to resize window
+ BOOL isWK = self.isWK = [self.webView isKindOfClass:NSClassFromString(@"WKWebView")];
+ if (!isWK) {
+ NSLog(@"CDVIonicKeyboard: WARNING!!: Keyboard plugin works better with WK");
+ }
+
+ if (isWK) {
+ [nc removeObserver:self.webView name:UIKeyboardWillHideNotification object:nil];
+ [nc removeObserver:self.webView name:UIKeyboardWillShowNotification object:nil];
+ [nc removeObserver:self.webView name:UIKeyboardWillChangeFrameNotification object:nil];
+ [nc removeObserver:self.webView name:UIKeyboardDidChangeFrameNotification object:nil];
+ }
+}
+
+-(void)statusBarDidChangeFrame:(NSNotification*)notification
+{
+ [self _updateFrame];
+}
+
+
+#pragma mark Keyboard events
+
+- (void)resetScrollView
+{
+ UIScrollView *scrollView = [self.webView scrollView];
+ [scrollView setContentInset:UIEdgeInsetsZero];
+}
+
+- (void)onKeyboardWillHide:(NSNotification *)sender
+{
+ if (self.isWK) {
+ [self setKeyboardHeight:0 delay:0.01];
+ [self resetScrollView];
+ }
+ hideTimer = [NSTimer scheduledTimerWithTimeInterval:0 target:self selector:@selector(fireOnHiding) userInfo:nil repeats:NO];
+}
+
+- (void)fireOnHiding {
+ [self.commandDelegate evalJs:@"Keyboard.fireOnHiding();"];
+}
+
+- (void)onKeyboardWillShow:(NSNotification *)note
+{
+ if (hideTimer != nil) {
+ [hideTimer invalidate];
+ }
+ CGRect rect = [[note.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
+ double height = rect.size.height;
+
+ if (self.isWK) {
+ double duration = [[note.userInfo valueForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
+ [self setKeyboardHeight:height delay:duration+0.2];
+ [self resetScrollView];
+ }
+
+ [self setKeyboardStyle:self.keyboardStyle];
+
+ NSString *js = [NSString stringWithFormat:@"Keyboard.fireOnShowing(%d);", (int)height];
+ [self.commandDelegate evalJs:js];
+}
+
+- (void)onKeyboardDidShow:(NSNotification *)note
+{
+ CGRect rect = [[note.userInfo valueForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
+ double height = rect.size.height;
+
+ if (self.isWK) {
+ [self resetScrollView];
+ }
+
+ NSString *js = [NSString stringWithFormat:@"Keyboard.fireOnShow(%d);", (int)height];
+ [self.commandDelegate evalJs:js];
+}
+
+- (void)onKeyboardDidHide:(NSNotification *)sender
+{
+ [self.commandDelegate evalJs:@"Keyboard.fireOnHide();"];
+ [self resetScrollView];
+}
+
+- (void)setKeyboardHeight:(int)height delay:(NSTimeInterval)delay
+{
+ if (self.keyboardResizes != ResizeNone) {
+ [self setPaddingBottom: height delay:delay];
+ }
+}
+
+- (void)setPaddingBottom:(int)paddingBottom delay:(NSTimeInterval)delay
+{
+ if (self.paddingBottom == paddingBottom) {
+ return;
+ }
+
+ self.paddingBottom = paddingBottom;
+
+ __weak CDVIonicKeyboard* weakSelf = self;
+ SEL action = @selector(_updateFrame);
+ [NSObject cancelPreviousPerformRequestsWithTarget:weakSelf selector:action object:nil];
+ if (delay == 0) {
+ [self _updateFrame];
+ } else {
+ [weakSelf performSelector:action withObject:nil afterDelay:delay];
+ }
+}
+
+- (void)_updateFrame
+{
+ CGSize statusBarSize = [[UIApplication sharedApplication] statusBarFrame].size;
+ int statusBarHeight = MIN(statusBarSize.width, statusBarSize.height);
+
+ int _paddingBottom = (int)self.paddingBottom;
+
+ if (statusBarHeight == 40) {
+ _paddingBottom = _paddingBottom + 20;
+ }
+ NSLog(@"CDVIonicKeyboard: updating frame");
+ // NOTE: to handle split screen correctly, the application's window bounds must be used as opposed to the screen's bounds.
+ CGRect f = [[[[UIApplication sharedApplication] delegate] window] bounds];
+ CGRect wf = self.webView.frame;
+ switch (self.keyboardResizes) {
+ case ResizeBody:
+ {
+ NSString *js = [NSString stringWithFormat:@"Keyboard.fireOnResize(%d, %d, document.body);",
+ _paddingBottom, (int)f.size.height];
+ [self.commandDelegate evalJs:js];
+ break;
+ }
+ case ResizeIonic:
+ {
+ NSString *js = [NSString stringWithFormat:@"Keyboard.fireOnResize(%d, %d, document.querySelector('ion-app'));",
+ _paddingBottom, (int)f.size.height];
+ [self.commandDelegate evalJs:js];
+ break;
+ }
+ case ResizeNative:
+ {
+ [self.webView setFrame:CGRectMake(wf.origin.x, wf.origin.y, f.size.width - wf.origin.x, f.size.height - wf.origin.y - self.paddingBottom)];
+ break;
+ }
+ default:
+ break;
+ }
+ [self resetScrollView];
+}
+
+#pragma mark Keyboard Style
+
+ - (void)setKeyboardStyle:(NSString*)style
+{
+ IMP newImp = [style isEqualToString:@"dark"] ? imp_implementationWithBlock(^(id _s) {
+ return UIKeyboardAppearanceDark;
+ }) : imp_implementationWithBlock(^(id _s) {
+ return UIKeyboardAppearanceLight;
+ });
+
+ if (self.isWK) {
+ for (NSString* classString in @[WKClassString, UITraitsClassString]) {
+ Class c = NSClassFromString(classString);
+ Method m = class_getInstanceMethod(c, @selector(keyboardAppearance));
+
+ if (m != NULL) {
+ method_setImplementation(m, newImp);
+ } else {
+ class_addMethod(c, @selector(keyboardAppearance), newImp, "l@:");
+ }
+ }
+ }
+ else {
+ for (NSString* classString in @[UIClassString, UITraitsClassString]) {
+ Class c = NSClassFromString(classString);
+ Method m = class_getInstanceMethod(c, @selector(keyboardAppearance));
+
+ if (m != NULL) {
+ method_setImplementation(m, newImp);
+ } else {
+ class_addMethod(c, @selector(keyboardAppearance), newImp, "l@:");
+ }
+ }
+ }
+
+ _keyboardStyle = style;
+}
+
+#pragma mark HideFormAccessoryBar
+
+static IMP UIOriginalImp;
+static IMP WKOriginalImp;
+
+- (void)setHideFormAccessoryBar:(BOOL)hideFormAccessoryBar
+{
+ if (hideFormAccessoryBar == _hideFormAccessoryBar) {
+ return;
+ }
+
+ Method UIMethod = class_getInstanceMethod(NSClassFromString(UIClassString), @selector(inputAccessoryView));
+ Method WKMethod = class_getInstanceMethod(NSClassFromString(WKClassString), @selector(inputAccessoryView));
+
+ if (hideFormAccessoryBar) {
+ UIOriginalImp = method_getImplementation(UIMethod);
+ WKOriginalImp = method_getImplementation(WKMethod);
+
+ IMP newImp = imp_implementationWithBlock(^(id _s) {
+ return nil;
+ });
+
+ method_setImplementation(UIMethod, newImp);
+ method_setImplementation(WKMethod, newImp);
+ } else {
+ method_setImplementation(UIMethod, UIOriginalImp);
+ method_setImplementation(WKMethod, WKOriginalImp);
+ }
+
+ _hideFormAccessoryBar = hideFormAccessoryBar;
+}
+
+#pragma mark scroll
+
+- (void)setDisableScroll:(BOOL)disableScroll {
+ if (disableScroll == _disableScroll) {
+ return;
+ }
+ if (disableScroll) {
+ self.webView.scrollView.scrollEnabled = NO;
+ self.webView.scrollView.delegate = self;
+ }
+ else {
+ self.webView.scrollView.scrollEnabled = YES;
+ self.webView.scrollView.delegate = nil;
+ }
+ _disableScroll = disableScroll;
+}
+
+- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
+ [scrollView setContentOffset: CGPointZero];
+}
+
+#pragma mark Plugin interface
+
+- (void)hideFormAccessoryBar:(CDVInvokedUrlCommand *)command
+{
+ if (command.arguments.count > 0) {
+ id value = [command.arguments objectAtIndex:0];
+ if (!([value isKindOfClass:[NSNumber class]])) {
+ value = [NSNumber numberWithBool:NO];
+ }
+
+ self.hideFormAccessoryBar = [value boolValue];
+ }
+
+ [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsBool:self.hideFormAccessoryBar]
+ callbackId:command.callbackId];
+}
+
+- (void)hide:(CDVInvokedUrlCommand *)command
+{
+ [self.webView endEditing:YES];
+}
+
+- (void)setResizeMode:(CDVInvokedUrlCommand *)command
+{
+ NSString * mode = [command.arguments objectAtIndex:0];
+ if ([mode isEqualToString:@"ionic"]) {
+ self.keyboardResizes = ResizeIonic;
+ } else if ([mode isEqualToString:@"body"]) {
+ self.keyboardResizes = ResizeBody;
+ } else if ([mode isEqualToString:@"native"]) {
+ self.keyboardResizes = ResizeNative;
+ } else {
+ self.keyboardResizes = ResizeNone;
+ }
+}
+
+- (void)keyboardStyle:(CDVInvokedUrlCommand*)command
+{
+ id value = [command.arguments objectAtIndex:0];
+ if ([value isKindOfClass:[NSString class]]) {
+ value = [(NSString*)value lowercaseString];
+ } else {
+ value = @"light";
+ }
+
+ self.keyboardStyle = value;
+}
+
+- (void)disableScroll:(CDVInvokedUrlCommand*)command {
+ if (!command.arguments || ![command.arguments count]){
+ return;
+ }
+ id value = [command.arguments objectAtIndex:0];
+ if (value != [NSNull null]) {
+ self.disableScroll = [value boolValue];
+ }
+}
+
+#pragma mark dealloc
+
+- (void)dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
+
+@end
diff --git a/StoneIsland/plugins/cordova-plugin-ionic-keyboard/www/android/keyboard.js b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/www/android/keyboard.js
new file mode 100755
index 00000000..ac68cfc6
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/www/android/keyboard.js
@@ -0,0 +1,84 @@
+var argscheck = require('cordova/argscheck'),
+ utils = require('cordova/utils'),
+ exec = require('cordova/exec'),
+ channel = require('cordova/channel');
+
+var Keyboard = function () {};
+
+Keyboard.fireOnShow = function (height) {
+ Keyboard.isVisible = true;
+ cordova.fireWindowEvent('keyboardDidShow', {
+ 'keyboardHeight': height
+ });
+
+ // To support the keyboardAttach directive listening events
+ // inside Ionic's main bundle
+ cordova.fireWindowEvent('native.keyboardshow', {
+ 'keyboardHeight': height
+ });
+};
+
+Keyboard.fireOnHide = function () {
+ Keyboard.isVisible = false;
+ cordova.fireWindowEvent('keyboardDidHide');
+
+ // To support the keyboardAttach directive listening events
+ // inside Ionic's main bundle
+ cordova.fireWindowEvent('native.keyboardhide');
+};
+
+Keyboard.fireOnHiding = function () {
+ cordova.fireWindowEvent('keyboardWillHide');
+};
+
+Keyboard.fireOnShowing = function (height) {
+ cordova.fireWindowEvent('keyboardWillShow', {
+ 'keyboardHeight': height
+ });
+};
+
+Keyboard.hideFormAccessoryBar = Keyboard.hideKeyboardAccessoryBar = function (hide) {
+ console.warn("Keyboard.hideKeyboardAccessoryBar() not supported in Android");
+};
+
+Keyboard.hide = function () {
+ exec(null, null, "CDVIonicKeyboard", "hide", []);
+};
+
+Keyboard.show = function () {
+ exec(null, null, "CDVIonicKeyboard", "show", []);
+};
+
+Keyboard.disableScroll = function (disable) {
+ console.warn("Keyboard.disableScroll() not supported in Android");
+};
+
+Keyboard.setResizeMode = function (mode) {
+ console.warn("Keyboard.setResizeMode() not supported in Android");
+}
+
+Keyboard.setKeyboardStyle = function(style) {
+ console.warn("Keyboard.setKeyboardStyle() not supported in Android");
+};
+
+channel.onCordovaReady.subscribe(function () {
+ exec(success, null, 'CDVIonicKeyboard', 'init', []);
+
+ function success(msg) {
+ var action = msg.charAt(0);
+ if (action === 'S') {
+ var keyboardHeight = parseInt(msg.substr(1));
+ Keyboard.fireOnShowing(keyboardHeight);
+ Keyboard.fireOnShow(keyboardHeight);
+
+ } else if (action === 'H') {
+ Keyboard.fireOnHiding();
+ Keyboard.fireOnHide();
+ }
+ }
+});
+
+
+Keyboard.isVisible = false;
+
+module.exports = Keyboard;
diff --git a/StoneIsland/plugins/cordova-plugin-ionic-keyboard/www/ios/keyboard.js b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/www/ios/keyboard.js
new file mode 100644
index 00000000..e9c8cb1e
--- /dev/null
+++ b/StoneIsland/plugins/cordova-plugin-ionic-keyboard/www/ios/keyboard.js
@@ -0,0 +1,103 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+var argscheck = require('cordova/argscheck'),
+ utils = require('cordova/utils'),
+ exec = require('cordova/exec');
+
+var Keyboard = function () {};
+
+Keyboard.fireOnShow = function (height) {
+ Keyboard.isVisible = true;
+ cordova.fireWindowEvent('keyboardDidShow', {
+ 'keyboardHeight': height
+ });
+
+ // To support the keyboardAttach directive listening events
+ // inside Ionic's main bundle
+ cordova.fireWindowEvent('native.keyboardshow', {
+ 'keyboardHeight': height
+ });
+};
+
+Keyboard.fireOnHide = function () {
+ Keyboard.isVisible = false;
+ cordova.fireWindowEvent('keyboardDidHide');
+
+ // To support the keyboardAttach directive listening events
+ // inside Ionic's main bundle
+ cordova.fireWindowEvent('native.keyboardhide');
+};
+
+Keyboard.fireOnHiding = function () {
+ cordova.fireWindowEvent('keyboardWillHide');
+};
+
+Keyboard.fireOnShowing = function (height) {
+ cordova.fireWindowEvent('keyboardWillShow', {
+ 'keyboardHeight': height
+ });
+};
+
+Keyboard.fireOnResize = function (height, screenHeight, ele) {
+ if (!ele) {
+ return;
+ }
+ if (height === 0) {
+ ele.style.height = null;
+ } else {
+ ele.style.height = (screenHeight - height) + 'px';
+ }
+};
+
+Keyboard.hideFormAccessoryBar = function (hide, success) {
+ if (hide !== null && hide !== undefined) {
+ exec(success, null, "CDVIonicKeyboard", "hideFormAccessoryBar", [hide]);
+ } else {
+ exec(success, null, "CDVIonicKeyboard", "hideFormAccessoryBar", []);
+ }
+};
+
+Keyboard.hide = function () {
+ exec(null, null, "CDVIonicKeyboard", "hide", []);
+};
+
+Keyboard.show = function () {
+ console.warn('Showing keyboard not supported in iOS due to platform limitations.');
+ console.warn('Instead, use input.focus(), and ensure that you have the following setting in your config.xml: \n');
+ console.warn(' <preference name="KeyboardDisplayRequiresUserAction" value="false"/>\n');
+};
+
+Keyboard.disableScroll = function (disable) {
+ exec(null, null, "CDVIonicKeyboard", "disableScroll", [disable]);
+};
+
+Keyboard.setResizeMode = function (mode) {
+ exec(null, null, "CDVIonicKeyboard", "setResizeMode", [mode]);
+}
+
+Keyboard.setKeyboardStyle = function(style) {
+ exec(null, null, "CDVIonicKeyboard", "keyboardStyle", [style]);
+};
+
+Keyboard.isVisible = false;
+
+module.exports = Keyboard; \ No newline at end of file