Commit 86216d81 authored by Troy A. Griffitts's avatar Troy A. Griffitts

better permissions checks and re-init of SWORD after request for permissions

parent 7166f39f
......@@ -236,12 +236,18 @@ console.log('**** mod doesn\'t exist: ' + mods[i]);
);
}
};
var afterAskingPermission = function() {
// reInit SWORD after gaining permissions
app.reInitSWORD(function () {
afterPermissions();
});
}
// before anything, ask for permissions
console.log('*********** checking permissions ***********************');
cordova.plugins.permissions.checkPermission(cordova.plugins.permissions.WRITE_EXTERNAL_STORAGE, function(permStatus) {
if (!permStatus.hasPermission) {
console.log('*********** asking for permissions ***********************');
cordova.plugins.permissions.requestPermission(cordova.plugins.permissions.WRITE_EXTERNAL_STORAGE, afterPermissions, afterPermissions);
cordova.plugins.permissions.requestPermission(cordova.plugins.permissions.WRITE_EXTERNAL_STORAGE, afterAskingPermission, afterAskingPermission);
}
else afterPermissions();
});
......@@ -646,6 +652,21 @@ console.log('*********** mainMod: ' + mainMod);
else firstCheck();
});
},
reInitSWORD : function(callback) {
console.log('******************** SWORD reInit ********************************');
// until we have a SWORD.mgr.reInit
// setting an extraConfig forces a re-init and will pick up newly copied resources
var buffer = '[bishop]\n';
buffer += 'reInitOn=' + new Date();
SWORD.mgr.addExtraConfig(buffer, function() {
SWORD.mgr.getModInfoList(function(mods) {
app.mods = mods;
if (callback) callback();
});
});
},
setLastAppVersion : function(callback) {
console.log('**** setting lastAppVersion: ' + app.version);
var buffer = '[bishop]\n';
......@@ -654,12 +675,14 @@ console.log('**** setting lastAppVersion: ' + app.version);
if (callback) callback();
});
},
getLastAppVersion : function(callback) {
SWORD.mgr.getExtraConfigValue('bishop', 'Version', function(value) {
console.log('**** retrieving lastAppVersion: ' + value);
if (callback) callback(value);
});
},
copyBundledResources: function(source, dest, callback) {
if (typeof cordova == 'undefined') return callback?callback():0;
var resPath = cordova.file.applicationDirectory + 'www/bundledResources/' + source;
......@@ -1924,8 +1947,7 @@ console.log('Setting tr key '+trKey+' to: ' + translated);
});
};
if (reInit) {
// setting an extraConfig forces a re-init and will pick up newly copied resources
app.setLastAppVersion(function() {
app.reInitSWORD(function() {
app.setCurrentKey(app.getCurrentKey(), function() {
setHTMLControls();
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment