You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/05/05 21:39:20 UTC
[2/3] git commit: Fix Android updates not working due to typo in
CacheClear plugin
Fix Android updates not working due to typo in CacheClear plugin
Project: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/commit/a1112161
Tree: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/tree/a1112161
Diff: http://git-wip-us.apache.org/repos/asf/cordova-app-harness/diff/a1112161
Branch: refs/heads/master
Commit: a1112161a14282d88a94b52cdffae9d48f06c7ca
Parents: 419236a
Author: Andrew Grieve <ag...@chromium.org>
Authored: Mon May 5 13:26:26 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Mon May 5 15:38:46 2014 -0400
----------------------------------------------------------------------
CacheClear/cacheclear.js | 4 ++--
CacheClear/src/android/CacheClear.java | 10 +++++++---
CacheClear/src/ios/CacheClear.m | 4 +++-
www/cdvah/index.html | 1 +
www/cdvah/js/CacheClear.js | 14 ++++++++++++++
www/cdvah/js/Installer.js | 9 +++++----
6 files changed, 32 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/a1112161/CacheClear/cacheclear.js
----------------------------------------------------------------------
diff --git a/CacheClear/cacheclear.js b/CacheClear/cacheclear.js
index 5133d6c..10461e1 100644
--- a/CacheClear/cacheclear.js
+++ b/CacheClear/cacheclear.js
@@ -19,6 +19,6 @@
*/
var exec = cordova.require('cordova/exec');
-exports.clearCache = function() {
- exec(null, null, 'CacheClear', 'clearCache', []);
+exports.clear = function(win, fail) {
+ exec(win, fail, 'CacheClear', 'clear', []);
};
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/a1112161/CacheClear/src/android/CacheClear.java
----------------------------------------------------------------------
diff --git a/CacheClear/src/android/CacheClear.java b/CacheClear/src/android/CacheClear.java
index 60e04c4..7185095 100644
--- a/CacheClear/src/android/CacheClear.java
+++ b/CacheClear/src/android/CacheClear.java
@@ -26,9 +26,13 @@ import org.json.JSONException;
public class CacheClear extends CordovaPlugin {
@Override
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
- if ("cacheClear".equals(action)) {
- webView.clearCache(true);
- callbackContext.success();
+ if ("clear".equals(action)) {
+ this.cordova.getActivity().runOnUiThread(new Runnable() {
+ public void run() {
+ webView.clearCache(true);
+ callbackContext.success();
+ }
+ });
} else {
return false;
}
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/a1112161/CacheClear/src/ios/CacheClear.m
----------------------------------------------------------------------
diff --git a/CacheClear/src/ios/CacheClear.m b/CacheClear/src/ios/CacheClear.m
index d093cc4..83d8671 100644
--- a/CacheClear/src/ios/CacheClear.m
+++ b/CacheClear/src/ios/CacheClear.m
@@ -24,8 +24,10 @@
@implementation CacheClear
-- (void)clearCache:(CDVInvokedUrlCommand*)command {
+- (void)clear:(CDVInvokedUrlCommand*)command {
[[NSURLCache sharedURLCache] removeAllCachedResponses];
+ CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
@end
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/a1112161/www/cdvah/index.html
----------------------------------------------------------------------
diff --git a/www/cdvah/index.html b/www/cdvah/index.html
index 157623a..0d2ada0 100644
--- a/www/cdvah/index.html
+++ b/www/cdvah/index.html
@@ -6,6 +6,7 @@
<script type="text/javascript" src="js/libs/angular.js"></script>
<script type="text/javascript" src="js/libs/angular-route.js"></script>
<script type="text/javascript" src="js/app.js"></script>
+ <script type="text/javascript" src="js/CacheClear.js"></script>
<script type="text/javascript" src="js/ContextMenuInjectScript.js"></script>
<script type="text/javascript" src="js/Installer.js"></script>
<script type="text/javascript" src="js/ServeInstaller.js"></script>
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/a1112161/www/cdvah/js/CacheClear.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/CacheClear.js b/www/cdvah/js/CacheClear.js
new file mode 100644
index 0000000..b3b298d
--- /dev/null
+++ b/www/cdvah/js/CacheClear.js
@@ -0,0 +1,14 @@
+(function() {
+ 'use strict';
+ /* global myApp */
+ myApp.factory('CacheClear', ['$q', function($q) {
+ function clear() {
+ var deferred = $q.defer();
+ cordova.plugins.cacheclear.clear(deferred.resolve, deferred.reject);
+ return deferred.promise;
+ }
+ return {
+ clear: clear
+ };
+ }]);
+})();
http://git-wip-us.apache.org/repos/asf/cordova-app-harness/blob/a1112161/www/cdvah/js/Installer.js
----------------------------------------------------------------------
diff --git a/www/cdvah/js/Installer.js b/www/cdvah/js/Installer.js
index 76894c2..2f04622 100644
--- a/www/cdvah/js/Installer.js
+++ b/www/cdvah/js/Installer.js
@@ -1,7 +1,7 @@
(function(){
'use strict';
/* global myApp, cordova */
- myApp.factory('Installer', ['$q', 'UrlRemap', 'ResourcesLoader', 'ContextMenuInjectScript', 'PluginMetadata', function($q, UrlRemap, ResourcesLoader, ContextMenuInjectScript, PluginMetadata) {
+ myApp.factory('Installer', ['$q', 'UrlRemap', 'ResourcesLoader', 'ContextMenuInjectScript', 'PluginMetadata', 'CacheClear', function($q, UrlRemap, ResourcesLoader, ContextMenuInjectScript, PluginMetadata, CacheClear) {
function getAppStartPageFromConfig(configFile) {
return ResourcesLoader.readFileContents(configFile)
@@ -47,9 +47,10 @@
this.updatingStatus = 0;
this.installPath = installPath;
// Cache clearing necessary only for Android.
- cordova.plugins.cacheclear.clearCache();
-
- return this.doUpdateApp()
+ return CacheClear.clear()
+ .then(function() {
+ return self.doUpdateApp();
+ })
.then(function() {
self.lastUpdated = new Date();
return self.getPluginMetadata();