Skip to content

TagSpaces is an offline, open source, document manager with tagging support

TS78 Added global isCordovaiOS

Borislav Sapundzhiev8eb60d6642d6
diff --git a/data/cordova/cordova.api.js b/data/cordova/cordova.api.js
index 95940de93..643fc7149 100644
--- a/data/cordova/cordova.api.js
+++ b/data/cordova/cordova.api.js
@@ -31,14 +31,14 @@ define(function(require, exports, module) {
}, false);
// iOS specific initialization
- if (cordova.platformId.match(/ios/i)) {
+ if (isCordovaiOS) {
window.plugins = window.plugins || {};
// TODO: use fileOpener2 plugin on all platforms
// https://build.phonegap.com/plugins/1117
window.plugins.fileOpener = cordova.plugins.fileOpener2;
}
- if (cordova.platformId.match(/Android/i)) {
+ if (isCordovaAndroid) {
if (window.plugins.webintent) {
window.plugins.webintent.getUri(function(url) {
@@ -171,8 +171,15 @@ define(function(require, exports, module) {
};
function normalizePath(path) {
- if (path.indexOf(fsRoot.fullPath) === 0) {
- path = path.substring(fsRoot.fullPath.length, path.length);
+ if (isCordovaiOS) {
+ if (path.indexOf(fsRoot.fullPath) === 0) {
+ path = path.substring(fsRoot.fullPath.length, path.length);
+ }
+ } else {
+ //Android
+ if (path.indexOf(fsRoot.fullPath) >= 0) {
+ path = path.substring(fsRoot.fullPath.length + 1, path.length);
+ }
}
return path;
}
@@ -269,8 +276,8 @@ define(function(require, exports, module) {
pendingCallbacks++;
entries[i].file(
function(entry) {
- //ios entry.fullPath is null
- if (!entry.fullPath) {
+
+ if (!entry.fullPath && isCordovaiOS) {
var URL = "cdvfile://localhost/persistent";
entry.fullPath = decodeURIComponent(entry.localURL);
entry.fullPath = entry.fullPath.substring(URL.length, entry.fullPath.length);
diff --git a/data/js/core.ui.js b/data/js/core.ui.js
index 0d88a798a..a3803bfb8 100644
--- a/data/js/core.ui.js
+++ b/data/js/core.ui.js
@@ -321,7 +321,7 @@ define(function(require, exports, module) {
function onFileReadComplete(event) {
console.log('Content on file read complete: ' + JSON.stringify(event));
//change name for ios fakepath
- if (navigator.isCordovaApp) {
+ if (isCordovaiOS) {
var parts = addFileInputName.split('.');
var ext = (parts.length > 1) ? '.' + parts.pop() : '';
addFileInputName = TSCORE.TagUtils.beginTagContainer + TSCORE.TagUtils.formatDateTime4Tag(new Date(), true) + TSCORE.TagUtils.endTagContainer + ext;
diff --git a/data/loader.js b/data/loader.js
index 8533056a5..ec9638242 100644
--- a/data/loader.js
+++ b/data/loader.js
@@ -17,7 +17,9 @@ var isFirefox = document.URL.indexOf( 'resource://' ) === 0;
var isFirefoxOS = document.URL.indexOf( 'app://' ) === 0;
var isChrome = document.URL.indexOf( 'chrome-extension://' ) === 0;
var isNode;
-var isCordova = document.URL.indexOf( 'file:///android_asset' ) === 0 || navigator.isCordovaApp == true;
+var isCordovaAndroid = document.URL.indexOf( 'file:///android_asset' ) === 0;
+var isCordovaiOS= navigator.isCordovaApp == true;
+var isCordova = isCordovaAndroid == true || isCordovaiOS == true;
var isWeb = document.URL.indexOf( 'http' ) === 0;
var isOSX = navigator.appVersion.indexOf("Mac")!==-1;
var isWin = navigator.appVersion.indexOf("Win")!==-1;