From 9816929e2c0345b8d1a8bf987a69627a7322dfd1 Mon Sep 17 00:00:00 2001 From: Erik Brommers Date: Thu, 21 Sep 2023 13:57:25 -0700 Subject: [PATCH] Update to latest file plugin This one was tricky. The file plugin changed the toURL() call for Android, which the sqlite db open call needed. There's now a nativeurl property on the directoryEntry object that returns what used to come through the toURL() method. --- config.xml | 2 -- package.json | 20 +++++++------- www/js/Application.js | 63 ++++++++----------------------------------- 3 files changed, 20 insertions(+), 65 deletions(-) diff --git a/config.xml b/config.xml index babbf3f4..aace9fed 100644 --- a/config.xml +++ b/config.xml @@ -10,7 +10,6 @@ - @@ -36,7 +35,6 @@ - diff --git a/package.json b/package.json index 217fdd2f..91ea2dff 100644 --- a/package.json +++ b/package.json @@ -21,19 +21,19 @@ "cordova-clipboard": "github:ihadeed/cordova-clipboard", "cordova-ios": "^7.0.1", "cordova-plugin-customurlscheme": "^5.0.2", - "cordova-plugin-device": "^2.0.3", + "cordova-plugin-device": "github:apache/cordova-plugin-device", "cordova-plugin-dialogs": "^2.0.2", - "cordova-plugin-file": "^6.0.2", + "cordova-plugin-file": "^8.0.0", "cordova-plugin-filepath": "github:VIAVI-Solutions/cordova-plugin-filepath", - "cordova-plugin-keyboard": "git+https://github.com/sinn1/cordova-plugin-keyboard.git", - "cordova-plugin-network-information": "^3.0.0", + "cordova-plugin-keyboard": "github:sinn1/cordova-plugin-keyboard", + "cordova-plugin-network-information": "github:apache/cordova-plugin-network-information", "cordova-plugin-x-socialsharing-android12": "github:IsraelHikingMap/corodova-plugin-socialsharing-android12", "cordova-sqlite-evcore-extbuild-free": "^0.18.0", "cordova-uglify": "^0.0.8", - "cordova.plugins.diagnostic": "^3.9.2", "fs": "0.0.2", "gulp": "^3.9.1", "path": "^0.12.7", + "phonegap-plugin-mobile-accessibility": "github:phonegap/phonegap-mobile-accessibility", "plist": "^3.0.1" }, "dependencies": { @@ -44,8 +44,7 @@ "crypto-randomuuid": "^1.0.0", "electron-builder": "^23.0.3", "gulp-uglify": "^3.0.2", - "npx": "^3.0.0", - "phonegap-plugin-mobile-accessibility": "https://github.com/phonegap/phonegap-mobile-accessibility.git" + "npx": "^3.0.0" }, "bugs": { "url": "https://github.com/adapt-it/adapt-it-mobile/issues" @@ -74,9 +73,6 @@ "cordova-plugin-device": {}, "cordova-plugin-dialogs": {}, "cordova-plugin-network-information": {}, - "cordova.plugins.diagnostic": { - "ANDROIDX_VERSION": "1.0.0" - }, "cordova-plugin-customurlscheme": { "URL_SCHEME": "aim", "ANDROID_SCHEME": " ", @@ -91,7 +87,9 @@ "cordova-clipboard": {}, "cordova-plugin-filepath": {}, "cordova-sqlite-evcore-extbuild-free": {}, - "cordova-plugin-file": {} + "cordova-plugin-file": { + "ANDROIDX_WEBKIT_VERSION": "1.4.0" + } }, "platforms": [ "ios", diff --git a/www/js/Application.js b/www/js/Application.js index ab229637..a63bddb6 100755 --- a/www/js/Application.js +++ b/www/js/Application.js @@ -189,51 +189,6 @@ define(function (require) { cordova.file.dataDirectory, cordova.file.syncedDataDirectory ]; - // if (device.platform === "Android") { - // // request read access to the external storage if we don't have it - // cordova.plugins.diagnostic.getExternalStorageAuthorizationStatus(function (status) { - // if (status === cordova.plugins.diagnostic.permissionStatus.GRANTED) { - // console.log("External storage use is authorized"); - // } else { - // cordova.plugins.diagnostic.requestExternalStorageAuthorization(function (result) { - // console.log("Authorization request for external storage use was " + (result === cordova.plugins.diagnostic.permissionStatus.GRANTED ? "granted" : "denied")); - // }, function (error) { - // console.error(error); - // }); - // } - // }, function (error) { - // console.error("The following error occurred: " + error); - // }); - // // request runtime permissions if needed - // cordova.plugins.diagnostic.getPermissionsAuthorizationStatus(function(statuses){ - // for (var permission in statuses){ - // switch(statuses[permission]){ - // case cordova.plugins.diagnostic.permissionStatus.GRANTED: - // console.log("Permission granted to use "+permission); - // break; - // case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED: - // console.log("Permission to use "+permission+" has not been requested yet; asking now"); - // cordova.plugins.diagnostic.requestRuntimePermission(function(status){ - // console.log("Runtime permission request result: " + status.toString()); - // }, function(error){ - // console.error("The following error occurred: "+error); - // }, permission); - // break; - // case cordova.plugins.diagnostic.permissionStatus.DENIED_ONCE: - // console.log("Permission denied to use "+permission+" - ask again?"); - // break; - // case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS: - // console.log("Permission permanently denied to use "+permission+" - guess we won't be using it then!"); - // break; - // } - // } - // }, function(error){ - // console.error("The following error occurred: "+error); - // },[ - // cordova.plugins.diagnostic.permission.WRITE_EXTERNAL_STORAGE, - // cordova.plugins.diagnostic.permission.READ_EXTERNAL_STORAGE - // ]); - // } } // social sharing plugin / iPad popover coords if (device && (device.platform !== "browser")) { @@ -263,15 +218,19 @@ define(function (require) { this.onInitDB(); } else if (device.platform === "Android") { - // Android -- use the device itself + // Android -- scoped storage wonkiness introduced in stages starting with API 30 + // first check the data directory, then check the "default" location db_dir = cordova.file.dataDirectory; - // now attempt to get the directory + console.log("db_dir: " + db_dir); + // // now attempt to get the directory window.resolveLocalFileSystemURL(db_dir, function (directoryEntry) { - console.log("Got directoryEntry. Attempting to create / open AIM DB at: " + directoryEntry.toURL()); + console.log("Got directoryEntry. Attempting to create / open AIM DB at: " + directoryEntry.nativeURL); // Attempt to create / open our AIM database now - window.Application.db = window.sqlitePlugin.openDatabase({name: DB_NAME, androidDatabaseLocation: directoryEntry.toURL()}); - window.Application.checkDBSchema().then(window.Application.onInitDB()); // Android only (iOS calls directly) - // window.Application.onInitDB(); + window.Application.db = window.sqlitePlugin.openDatabase({name: DB_NAME, androidDatabaseLocation: directoryEntry.nativeURL}, function(db) { + window.Application.checkDBSchema().then(window.Application.onInitDB()); // Android only (iOS calls directly) + }, function (err) { + console.log("Open database ERROR: " + JSON.stringify(err)); + }); }, function (err) { console.log("resolveLocalFileSustemURL error: " + err.message); }); @@ -370,7 +329,7 @@ define(function (require) { onStart: function (app, options) { // check the database schema now that we've created / opened it - this.checkDBSchema(); + // this.checkDBSchema(); }, // Routes from AppRouter (router.js)