Skip to content

Commit

Permalink
Update to latest file plugin
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
eb1 committed Sep 21, 2023
1 parent ba77d8f commit 9816929
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 65 deletions.
2 changes: 0 additions & 2 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<content src="index.html" />
<access origin="*" />
<allow-intent href="aim:*" />
<preference name="cordova.plugins.diagnostic.modules" value="BLUETOOTH WIFI EXTERNAL_STORAGE" />
<preference name="android-build-tool" value="gradle" />
<preference name="Orientation" value="default" />
<preference name="DisallowOverscroll" value="true" />
Expand All @@ -36,7 +35,6 @@
<preference name="AndroidPersistentFileLocation" value="Internal" />
<config-file mode="replace" parent="/manifest" target="AndroidManifest.xml">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-feature android:name="android.hardware.bluetooth" android:required="false" />
<uses-feature android:name="android.hardware.faketouch" android:required="false" />
Expand Down
20 changes: 9 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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"
Expand Down Expand Up @@ -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": " ",
Expand All @@ -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",
Expand Down
63 changes: 11 additions & 52 deletions www/js/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9816929

Please sign in to comment.