summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/android
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/platforms/android')
-rwxr-xr-xStoneIsland/platforms/android/android.json18
-rwxr-xr-xStoneIsland/platforms/android/assets/www/cordova_plugins.js11
-rw-r--r--StoneIsland/platforms/android/assets/www/plugins/cordova-plugin-statusbar/www/statusbar.js116
-rwxr-xr-xStoneIsland/platforms/android/platform_www/cordova_plugins.js11
-rw-r--r--StoneIsland/platforms/android/platform_www/plugins/cordova-plugin-statusbar/www/statusbar.js116
-rw-r--r--StoneIsland/platforms/android/res/xml/config.xml4
-rw-r--r--StoneIsland/platforms/android/src/org/apache/cordova/statusbar/StatusBar.java201
7 files changed, 474 insertions, 3 deletions
diff --git a/StoneIsland/platforms/android/android.json b/StoneIsland/platforms/android/android.json
index d30b7891..df55a288 100755
--- a/StoneIsland/platforms/android/android.json
+++ b/StoneIsland/platforms/android/android.json
@@ -55,6 +55,10 @@
{
"xml": "<feature name=\"UniversalAnalytics\"><param name=\"android-package\" value=\"com.danielcwilson.plugins.analytics.UniversalAnalyticsPlugin\" /></feature>",
"count": 1
+ },
+ {
+ "xml": "<feature name=\"StatusBar\"><param name=\"android-package\" value=\"org.apache.cordova.statusbar.StatusBar\" /><param name=\"onload\" value=\"true\" /></feature>",
+ "count": 1
}
]
}
@@ -244,6 +248,9 @@
},
"cordova-plugin-google-analytics": {
"PACKAGE_NAME": "us.okfoc.stoneisland"
+ },
+ "cordova-plugin-statusbar": {
+ "PACKAGE_NAME": "us.okfoc.stoneisland"
}
},
"dependent_plugins": {},
@@ -361,6 +368,14 @@
"analytics",
"ga"
]
+ },
+ {
+ "id": "cordova-plugin-statusbar.statusbar",
+ "file": "plugins/cordova-plugin-statusbar/www/statusbar.js",
+ "pluginId": "cordova-plugin-statusbar",
+ "clobbers": [
+ "window.StatusBar"
+ ]
}
],
"plugin_metadata": {
@@ -377,6 +392,7 @@
"cordova-plugin-geolocation": "2.4.0",
"ionic-plugin-keyboard": "2.2.1",
"phonegap-plugin-push": "1.9.2",
- "cordova-plugin-google-analytics": "1.8.3"
+ "cordova-plugin-google-analytics": "1.8.3",
+ "cordova-plugin-statusbar": "2.2.3"
}
} \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/cordova_plugins.js b/StoneIsland/platforms/android/assets/www/cordova_plugins.js
index 564d770b..be2a17ab 100755
--- a/StoneIsland/platforms/android/assets/www/cordova_plugins.js
+++ b/StoneIsland/platforms/android/assets/www/cordova_plugins.js
@@ -113,6 +113,14 @@ module.exports = [
"analytics",
"ga"
]
+ },
+ {
+ "id": "cordova-plugin-statusbar.statusbar",
+ "file": "plugins/cordova-plugin-statusbar/www/statusbar.js",
+ "pluginId": "cordova-plugin-statusbar",
+ "clobbers": [
+ "window.StatusBar"
+ ]
}
];
module.exports.metadata =
@@ -131,7 +139,8 @@ module.exports.metadata =
"cordova-plugin-geolocation": "2.4.0",
"ionic-plugin-keyboard": "2.2.1",
"phonegap-plugin-push": "1.9.2",
- "cordova-plugin-google-analytics": "1.8.3"
+ "cordova-plugin-google-analytics": "1.8.3",
+ "cordova-plugin-statusbar": "2.2.3"
};
// BOTTOM OF METADATA
}); \ No newline at end of file
diff --git a/StoneIsland/platforms/android/assets/www/plugins/cordova-plugin-statusbar/www/statusbar.js b/StoneIsland/platforms/android/assets/www/plugins/cordova-plugin-statusbar/www/statusbar.js
new file mode 100644
index 00000000..708186f9
--- /dev/null
+++ b/StoneIsland/platforms/android/assets/www/plugins/cordova-plugin-statusbar/www/statusbar.js
@@ -0,0 +1,116 @@
+cordova.define("cordova-plugin-statusbar.statusbar", function(require, exports, module) {
+/*
+ *
+ * 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.
+ *
+*/
+
+/* global cordova */
+
+var exec = require('cordova/exec');
+
+var namedColors = {
+ "black": "#000000",
+ "darkGray": "#A9A9A9",
+ "lightGray": "#D3D3D3",
+ "white": "#FFFFFF",
+ "gray": "#808080",
+ "red": "#FF0000",
+ "green": "#00FF00",
+ "blue": "#0000FF",
+ "cyan": "#00FFFF",
+ "yellow": "#FFFF00",
+ "magenta": "#FF00FF",
+ "orange": "#FFA500",
+ "purple": "#800080",
+ "brown": "#A52A2A"
+};
+
+var StatusBar = {
+
+ isVisible: true,
+
+ overlaysWebView: function (doOverlay) {
+ exec(null, null, "StatusBar", "overlaysWebView", [doOverlay]);
+ },
+
+ styleDefault: function () {
+ // dark text ( to be used on a light background )
+ exec(null, null, "StatusBar", "styleDefault", []);
+ },
+
+ styleLightContent: function () {
+ // light text ( to be used on a dark background )
+ exec(null, null, "StatusBar", "styleLightContent", []);
+ },
+
+ styleBlackTranslucent: function () {
+ // #88000000 ? Apple says to use lightContent instead
+ exec(null, null, "StatusBar", "styleBlackTranslucent", []);
+ },
+
+ styleBlackOpaque: function () {
+ // #FF000000 ? Apple says to use lightContent instead
+ exec(null, null, "StatusBar", "styleBlackOpaque", []);
+ },
+
+ backgroundColorByName: function (colorname) {
+ return StatusBar.backgroundColorByHexString(namedColors[colorname]);
+ },
+
+ backgroundColorByHexString: function (hexString) {
+ if (hexString.charAt(0) !== "#") {
+ hexString = "#" + hexString;
+ }
+
+ if (hexString.length === 4) {
+ var split = hexString.split("");
+ hexString = "#" + split[1] + split[1] + split[2] + split[2] + split[3] + split[3];
+ }
+
+ exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);
+ },
+
+ hide: function () {
+ exec(null, null, "StatusBar", "hide", []);
+ StatusBar.isVisible = false;
+ },
+
+ show: function () {
+ exec(null, null, "StatusBar", "show", []);
+ StatusBar.isVisible = true;
+ }
+
+};
+
+// prime it. setTimeout so that proxy gets time to init
+window.setTimeout(function () {
+ exec(function (res) {
+ if (typeof res == 'object') {
+ if (res.type == 'tap') {
+ cordova.fireWindowEvent('statusTap');
+ }
+ } else {
+ StatusBar.isVisible = res;
+ }
+ }, null, "StatusBar", "_ready", []);
+}, 0);
+
+module.exports = StatusBar;
+
+});
diff --git a/StoneIsland/platforms/android/platform_www/cordova_plugins.js b/StoneIsland/platforms/android/platform_www/cordova_plugins.js
index 564d770b..be2a17ab 100755
--- a/StoneIsland/platforms/android/platform_www/cordova_plugins.js
+++ b/StoneIsland/platforms/android/platform_www/cordova_plugins.js
@@ -113,6 +113,14 @@ module.exports = [
"analytics",
"ga"
]
+ },
+ {
+ "id": "cordova-plugin-statusbar.statusbar",
+ "file": "plugins/cordova-plugin-statusbar/www/statusbar.js",
+ "pluginId": "cordova-plugin-statusbar",
+ "clobbers": [
+ "window.StatusBar"
+ ]
}
];
module.exports.metadata =
@@ -131,7 +139,8 @@ module.exports.metadata =
"cordova-plugin-geolocation": "2.4.0",
"ionic-plugin-keyboard": "2.2.1",
"phonegap-plugin-push": "1.9.2",
- "cordova-plugin-google-analytics": "1.8.3"
+ "cordova-plugin-google-analytics": "1.8.3",
+ "cordova-plugin-statusbar": "2.2.3"
};
// BOTTOM OF METADATA
}); \ No newline at end of file
diff --git a/StoneIsland/platforms/android/platform_www/plugins/cordova-plugin-statusbar/www/statusbar.js b/StoneIsland/platforms/android/platform_www/plugins/cordova-plugin-statusbar/www/statusbar.js
new file mode 100644
index 00000000..708186f9
--- /dev/null
+++ b/StoneIsland/platforms/android/platform_www/plugins/cordova-plugin-statusbar/www/statusbar.js
@@ -0,0 +1,116 @@
+cordova.define("cordova-plugin-statusbar.statusbar", function(require, exports, module) {
+/*
+ *
+ * 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.
+ *
+*/
+
+/* global cordova */
+
+var exec = require('cordova/exec');
+
+var namedColors = {
+ "black": "#000000",
+ "darkGray": "#A9A9A9",
+ "lightGray": "#D3D3D3",
+ "white": "#FFFFFF",
+ "gray": "#808080",
+ "red": "#FF0000",
+ "green": "#00FF00",
+ "blue": "#0000FF",
+ "cyan": "#00FFFF",
+ "yellow": "#FFFF00",
+ "magenta": "#FF00FF",
+ "orange": "#FFA500",
+ "purple": "#800080",
+ "brown": "#A52A2A"
+};
+
+var StatusBar = {
+
+ isVisible: true,
+
+ overlaysWebView: function (doOverlay) {
+ exec(null, null, "StatusBar", "overlaysWebView", [doOverlay]);
+ },
+
+ styleDefault: function () {
+ // dark text ( to be used on a light background )
+ exec(null, null, "StatusBar", "styleDefault", []);
+ },
+
+ styleLightContent: function () {
+ // light text ( to be used on a dark background )
+ exec(null, null, "StatusBar", "styleLightContent", []);
+ },
+
+ styleBlackTranslucent: function () {
+ // #88000000 ? Apple says to use lightContent instead
+ exec(null, null, "StatusBar", "styleBlackTranslucent", []);
+ },
+
+ styleBlackOpaque: function () {
+ // #FF000000 ? Apple says to use lightContent instead
+ exec(null, null, "StatusBar", "styleBlackOpaque", []);
+ },
+
+ backgroundColorByName: function (colorname) {
+ return StatusBar.backgroundColorByHexString(namedColors[colorname]);
+ },
+
+ backgroundColorByHexString: function (hexString) {
+ if (hexString.charAt(0) !== "#") {
+ hexString = "#" + hexString;
+ }
+
+ if (hexString.length === 4) {
+ var split = hexString.split("");
+ hexString = "#" + split[1] + split[1] + split[2] + split[2] + split[3] + split[3];
+ }
+
+ exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);
+ },
+
+ hide: function () {
+ exec(null, null, "StatusBar", "hide", []);
+ StatusBar.isVisible = false;
+ },
+
+ show: function () {
+ exec(null, null, "StatusBar", "show", []);
+ StatusBar.isVisible = true;
+ }
+
+};
+
+// prime it. setTimeout so that proxy gets time to init
+window.setTimeout(function () {
+ exec(function (res) {
+ if (typeof res == 'object') {
+ if (res.type == 'tap') {
+ cordova.fireWindowEvent('statusTap');
+ }
+ } else {
+ StatusBar.isVisible = res;
+ }
+ }, null, "StatusBar", "_ready", []);
+}, 0);
+
+module.exports = StatusBar;
+
+});
diff --git a/StoneIsland/platforms/android/res/xml/config.xml b/StoneIsland/platforms/android/res/xml/config.xml
index 1bcdbb83..49590cc4 100644
--- a/StoneIsland/platforms/android/res/xml/config.xml
+++ b/StoneIsland/platforms/android/res/xml/config.xml
@@ -72,4 +72,8 @@
<feature name="UniversalAnalytics">
<param name="android-package" value="com.danielcwilson.plugins.analytics.UniversalAnalyticsPlugin" />
</feature>
+ <feature name="StatusBar">
+ <param name="android-package" value="org.apache.cordova.statusbar.StatusBar" />
+ <param name="onload" value="true" />
+ </feature>
</widget>
diff --git a/StoneIsland/platforms/android/src/org/apache/cordova/statusbar/StatusBar.java b/StoneIsland/platforms/android/src/org/apache/cordova/statusbar/StatusBar.java
new file mode 100644
index 00000000..7b4d946a
--- /dev/null
+++ b/StoneIsland/platforms/android/src/org/apache/cordova/statusbar/StatusBar.java
@@ -0,0 +1,201 @@
+/*
+ * 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.
+ *
+*/
+package org.apache.cordova.statusbar;
+
+import android.app.Activity;
+import android.graphics.Color;
+import android.os.Build;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+
+import org.apache.cordova.CallbackContext;
+import org.apache.cordova.CordovaArgs;
+import org.apache.cordova.CordovaInterface;
+import org.apache.cordova.CordovaPlugin;
+import org.apache.cordova.CordovaWebView;
+import org.apache.cordova.LOG;
+import org.apache.cordova.PluginResult;
+import org.json.JSONException;
+
+public class StatusBar extends CordovaPlugin {
+ private static final String TAG = "StatusBar";
+
+ /**
+ * Sets the context of the Command. This can then be used to do things like
+ * get file paths associated with the Activity.
+ *
+ * @param cordova The context of the main Activity.
+ * @param webView The CordovaWebView Cordova is running in.
+ */
+ @Override
+ public void initialize(final CordovaInterface cordova, CordovaWebView webView) {
+ LOG.v(TAG, "StatusBar: initialization");
+ super.initialize(cordova, webView);
+
+ this.cordova.getActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ // Clear flag FLAG_FORCE_NOT_FULLSCREEN which is set initially
+ // by the Cordova.
+ Window window = cordova.getActivity().getWindow();
+ window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+
+ // Read 'StatusBarBackgroundColor' from config.xml, default is #000000.
+ setStatusBarBackgroundColor(preferences.getString("StatusBarBackgroundColor", "#000000"));
+ }
+ });
+ }
+
+ /**
+ * Executes the request and returns PluginResult.
+ *
+ * @param action The action to execute.
+ * @param args JSONArry of arguments for the plugin.
+ * @param callbackContext The callback id used when calling back into JavaScript.
+ * @return True if the action was valid, false otherwise.
+ */
+ @Override
+ public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
+ LOG.v(TAG, "Executing action: " + action);
+ final Activity activity = this.cordova.getActivity();
+ final Window window = activity.getWindow();
+
+ if ("_ready".equals(action)) {
+ boolean statusBarVisible = (window.getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0;
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible));
+ return true;
+ }
+
+ if ("show".equals(action)) {
+ this.cordova.getActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ // SYSTEM_UI_FLAG_FULLSCREEN is available since JellyBean, but we
+ // use KitKat here to be aligned with "Fullscreen" preference
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ int uiOptions = window.getDecorView().getSystemUiVisibility();
+ uiOptions &= ~View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
+ uiOptions &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
+
+ window.getDecorView().setSystemUiVisibility(uiOptions);
+ }
+
+ // CB-11197 We still need to update LayoutParams to force status bar
+ // to be hidden when entering e.g. text fields
+ window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
+ });
+ return true;
+ }
+
+ if ("hide".equals(action)) {
+ this.cordova.getActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ // SYSTEM_UI_FLAG_FULLSCREEN is available since JellyBean, but we
+ // use KitKat here to be aligned with "Fullscreen" preference
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ int uiOptions = window.getDecorView().getSystemUiVisibility()
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_FULLSCREEN;
+
+ window.getDecorView().setSystemUiVisibility(uiOptions);
+ }
+
+ // CB-11197 We still need to update LayoutParams to force status bar
+ // to be hidden when entering e.g. text fields
+ window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
+ });
+ return true;
+ }
+
+ if ("backgroundColorByHexString".equals(action)) {
+ this.cordova.getActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ setStatusBarBackgroundColor(args.getString(0));
+ } catch (JSONException ignore) {
+ LOG.e(TAG, "Invalid hexString argument, use f.i. '#777777'");
+ }
+ }
+ });
+ return true;
+ }
+
+ if ("overlaysWebView".equals(action)) {
+ if (Build.VERSION.SDK_INT >= 21) {
+ this.cordova.getActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ setStatusBarTransparent(args.getBoolean(0));
+ } catch (JSONException ignore) {
+ LOG.e(TAG, "Invalid boolean argument");
+ }
+ }
+ });
+ return true;
+ }
+ else return args.getBoolean(0) == false;
+ }
+
+ return false;
+ }
+
+ private void setStatusBarBackgroundColor(final String colorPref) {
+ if (Build.VERSION.SDK_INT >= 21) {
+ if (colorPref != null && !colorPref.isEmpty()) {
+ final Window window = cordova.getActivity().getWindow();
+ // Method and constants not available on all SDKs but we want to be able to compile this code with any SDK
+ window.clearFlags(0x04000000); // SDK 19: WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
+ window.addFlags(0x80000000); // SDK 21: WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+ try {
+ // Using reflection makes sure any 5.0+ device will work without having to compile with SDK level 21
+ window.getClass().getMethod("setStatusBarColor", int.class).invoke(window, Color.parseColor(colorPref));
+ } catch (IllegalArgumentException ignore) {
+ LOG.e(TAG, "Invalid hexString argument, use f.i. '#999999'");
+ } catch (Exception ignore) {
+ // this should not happen, only in case Android removes this method in a version > 21
+ LOG.w(TAG, "Method window.setStatusBarColor not found for SDK level " + Build.VERSION.SDK_INT);
+ }
+ }
+ }
+ }
+
+ private void setStatusBarTransparent(final boolean transparent) {
+ if (Build.VERSION.SDK_INT >= 21) {
+ final Window window = cordova.getActivity().getWindow();
+ if (transparent) {
+ window.getDecorView().setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
+ window.setStatusBarColor(Color.TRANSPARENT);
+ }
+ else {
+ window.getDecorView().setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_VISIBLE);
+ }
+ }
+ }
+}