From 2fdfde7a1a5fa577feb4e9d77a58d60f2da9b602 Mon Sep 17 00:00:00 2001 From: EddyVerbruggen Date: Sat, 27 Sep 2014 15:41:53 +0200 Subject: [PATCH] #18 - fixed cordova 3.6.0 deprecation warnings, so we're ready for Cordova 4.x --- plugin.xml | 2 +- src/android/nl/xservices/plugins/Toast.java | 8 ++++++++ src/ios/Toast.m | 8 ++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/plugin.xml b/plugin.xml index 643a0dd..229dd8b 100755 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="2.0.2"> Toast diff --git a/src/android/nl/xservices/plugins/Toast.java b/src/android/nl/xservices/plugins/Toast.java index 6d44a77..b8af6b6 100644 --- a/src/android/nl/xservices/plugins/Toast.java +++ b/src/android/nl/xservices/plugins/Toast.java @@ -6,6 +6,14 @@ import org.apache.cordova.CordovaPlugin; import org.json.JSONArray; import org.json.JSONException; +/* + // TODO nice way for the Toast plugin to offer a longer delay than the default short and long options + // TODO also look at https://github.com/JohnPersano/Supertoasts + new CountDownTimer(6000, 1000) { + public void onTick(long millisUntilFinished) {toast.show();} + public void onFinish() {toast.show();} + }.start(); + */ public class Toast extends CordovaPlugin { private static final String ACTION_SHOW_EVENT = "show"; diff --git a/src/ios/Toast.m b/src/ios/Toast.m index 3822b17..8c7d694 100644 --- a/src/ios/Toast.m +++ b/src/ios/Toast.m @@ -12,7 +12,7 @@ if (![position isEqual: @"top"] && ![position isEqual: @"center"] && ![position isEqual: @"bottom"]) { CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"invalid position. valid options are 'top', 'center' and 'bottom'"]; - [self writeJavascript:[pluginResult toErrorCallbackString:command.callbackId]]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; return; } @@ -23,14 +23,14 @@ durationInt = 5; } else { CDVPluginResult * pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"invalid duration. valid options are 'short' and 'long'"]; - [self writeJavascript:[pluginResult toErrorCallbackString:command.callbackId]]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; return; } [self.webView makeToast:message duration:durationInt position:position]; - + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK]; - [self writeJavascript:[pluginResult toSuccessCallbackString:command.callbackId]]; + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; } @end \ No newline at end of file