From 8bff5cd84316cb49f1ed2d691f6c412f1fdfc596 Mon Sep 17 00:00:00 2001 From: mossroy Date: Mon, 7 Apr 2014 13:48:45 +0200 Subject: [PATCH] Remove backward compatibility with FxOS 1.0, to simplify the use of DeviceStorage API. Fixes #79 --- www/js/app.js | 24 +++++++----------------- www/js/lib/archive.js | 6 +++--- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index 301c7131..add3ae13 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -224,23 +224,13 @@ define(function(require) { evopediaArchive.LocalArchive.scanForArchives(storages, populateDropDownListOfArchives); } - if ($.isFunction(navigator.getDeviceStorage)) { - if ($.isFunction(navigator.getDeviceStorages)) { - // The method getDeviceStorages is available (FxOS>=1.1) - // We have to scan all the DeviceStorages, because getDeviceStorage - // only returns the default Device Storage. - // See https://bugzilla.mozilla.org/show_bug.cgi?id=885753 - storages = $.map(navigator.getDeviceStorages("sdcard"), function(s) { - return new osabstraction.StorageFirefoxOS(s); - }); - } - else { - // The method getDeviceStorages is not available (FxOS 1.0) - // The fallback is to use getDeviceStorage - storages[0] = new osabstraction.StorageFirefoxOS( - navigator.getDeviceStorage("sdcard")); - } - } else if ($.isFunction(window.requestFileSystem)) { // cordova + if ($.isFunction(navigator.getDeviceStorages)) { + // The method getDeviceStorages is available (FxOS>=1.1) + storages = $.map(navigator.getDeviceStorages("sdcard"), function(s) { + return new osabstraction.StorageFirefoxOS(s); + }); + } else if ($.isFunction(window.requestFileSystem)) { + // The requestFileSystem is available (Cordova) window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) { storages[0] = new osabstraction.StoragePhoneGap(fs); searchForArchivesInPreferencesOrStorage(); diff --git a/www/js/lib/archive.js b/www/js/lib/archive.js index 031e2602..a889d7c9 100644 --- a/www/js/lib/archive.js +++ b/www/js/lib/archive.js @@ -264,9 +264,9 @@ define(function(require) { } } else { - // This happens with FxOS 1.0 - // In this case, we use the first storage of the list - // (there should be only one) + // This happens when the archiveDirectory is not prefixed by the name of the storage + // (in the Simulator, or with FxOs 1.0, or probably on devices that only have one device storage) + // In this case, we use the first storage of the list (there should be only one) if (storages.length === 1) { selectedStorage = storages[0]; }