diff --git a/config.xml b/config.xml index d8c98d0..751e01b 100644 --- a/config.xml +++ b/config.xml @@ -1,5 +1,5 @@ - + @@ -25,7 +25,12 @@ + + + + + OMORI diff --git a/package-lock.json b/package-lock.json index 27c0315..06b5896 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "Apache-2.0", "devDependencies": { "cordova-android": "^12.0.1", + "cordova-plugin-android-permissions": "^1.1.5", "cordova-plugin-file": "^8.0.1", "cordova-plugin-fullscreen": "^1.3.0", "cordova-plugin-gamepad": "github:OleSTEEP/cordova-plugin-gamepad", @@ -242,6 +243,18 @@ "node": ">=16.0.0" } }, + "node_modules/cordova-plugin-android-permissions": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/cordova-plugin-android-permissions/-/cordova-plugin-android-permissions-1.1.5.tgz", + "integrity": "sha512-oTTV9cCMBqXTCmU+nYRebsP2IQfrtdvl2vYXHjoJgv5NHCIDgY4KFg6kJTcwXQOiymeGXuw0+MTvJJOueAdleA==", + "dev": true, + "engines": [ + { + "name": "cordova", + "version": ">=5.0.0" + } + ] + }, "node_modules/cordova-plugin-file": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/cordova-plugin-file/-/cordova-plugin-file-8.0.1.tgz", diff --git a/package.json b/package.json index d78f09e..82f461e 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "license": "Apache-2.0", "devDependencies": { "cordova-android": "^12.0.1", + "cordova-plugin-android-permissions": "^1.1.5", "cordova-plugin-file": "^8.0.1", "cordova-plugin-fullscreen": "^1.3.0", "cordova-plugin-gamepad": "github:OleSTEEP/cordova-plugin-gamepad", @@ -29,7 +30,8 @@ "cordova-plugin-gamepad": {}, "cordova-plugin-file": { "ANDROIDX_WEBKIT_VERSION": "1.4.0" - } + }, + "cordova-plugin-android-permissions": {} } } } \ No newline at end of file diff --git a/www.eng/js/plugins/VND_CordovaFixes.js b/www.eng/js/plugins/VND_CordovaFixes.js index 1daa496..cbd8193 100644 --- a/www.eng/js/plugins/VND_CordovaFixes.js +++ b/www.eng/js/plugins/VND_CordovaFixes.js @@ -350,13 +350,13 @@ document.addEventListener("deviceready", () => { fileEntry.createWriter(function (fileWriter) { fileWriter.onerror = function (e) { - console.log("Failed file write: " + e.toString()); + console.log(`Failed file write: Error ${e.code}`); }; fileWriter.write(data); }); }, (e) => { - console.log("Error to create external save file: " + e.toString()); + console.log(`Error to create external save file: Error ${e.code}`); }); }); }); @@ -372,13 +372,13 @@ document.addEventListener("deviceready", () => { fileEntry.createWriter(function (fileWriter) { fileWriter.onerror = function (e) { - console.log("Failed file write: " + e.toString()); + console.log(`Failed file write: Error ${e.code}`); }; fileWriter.write(data); }); }, (e) => { - console.log("Error to create external file: " + e.toString()); + console.log(`Error to create external file: Error ${e.code}`); }); }); } @@ -394,4 +394,16 @@ SceneManager.terminate = function () { window.close = function() { navigator.app.exitApp(); -} \ No newline at end of file +} + +// ========================================== +// Request storage permissions on startup +// ========================================== +document.addEventListener("deviceready", () => { + var permissions = cordova.plugins.permissions; + permissions.checkPermission(permissions.WRITE_EXTERNAL_STORAGE, (status) => { + if (status.hasPermission === false) { + permissions.requestPermission(permissions.WRITE_EXTERNAL_STORAGE); + } + }); +}) \ No newline at end of file diff --git a/www.rus/js/plugins/VND_CordovaFixes.js b/www.rus/js/plugins/VND_CordovaFixes.js index 47f0cef..c061ed9 100644 --- a/www.rus/js/plugins/VND_CordovaFixes.js +++ b/www.rus/js/plugins/VND_CordovaFixes.js @@ -353,13 +353,13 @@ document.addEventListener("deviceready", () => { fileEntry.createWriter(function (fileWriter) { fileWriter.onerror = function (e) { - console.log("Failed file write: " + e.toString()); + console.log(`Failed file write: Error ${e.code}`); }; fileWriter.write(data); }); }, (e) => { - console.log("Error to create external save file: " + e.toString()); + console.log(`Error to create external save file: Error ${e.code}`); }); }); }); @@ -375,13 +375,13 @@ document.addEventListener("deviceready", () => { fileEntry.createWriter(function (fileWriter) { fileWriter.onerror = function (e) { - console.log("Failed file write: " + e.toString()); + console.log(`Failed file write: Error ${e.code}`); }; fileWriter.write(data); }); }, (e) => { - console.log("Error to create external file: " + e.toString()); + console.log(`Error to create external file: Error ${e.code}`); }); }); } @@ -397,4 +397,16 @@ SceneManager.terminate = function () { window.close = function() { navigator.app.exitApp(); -} \ No newline at end of file +} + +// ========================================== +// Request storage permissions on startup +// ========================================== +document.addEventListener("deviceready", () => { + var permissions = cordova.plugins.permissions; + permissions.checkPermission(permissions.WRITE_EXTERNAL_STORAGE, (status) => { + if (status.hasPermission === false) { + permissions.requestPermission(permissions.WRITE_EXTERNAL_STORAGE); + } + }); +}) \ No newline at end of file