diff --git a/README.md b/README.md index 8884eb7..436202f 100644 --- a/README.md +++ b/README.md @@ -61,15 +61,17 @@ Windows Phone 8 ### Automatically (CLI / Plugman) Toast is compatible with [Cordova Plugman](https://github.com/apache/cordova-plugman), compatible with [PhoneGap 3.0 CLI](http://docs.phonegap.com/en/3.0.0/guide_cli_index.md.html#The%20Command-line%20Interface_add_features), here's how it works with the CLI (backup your project first!): +Using the Cordova CLI and the [Cordova Plugin Registry](http://plugins.cordova.io) ``` -$ phonegap local plugin add https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git -``` -or -``` -$ cordova plugin add https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git +$ cordova plugin add nl.x-services.plugins.toast $ cordova prepare ``` +Or using the phonegap CLI +``` +$ phonegap local plugin add nl.x-services.plugins.toast +``` + Toast.js is brought in automatically. There is no need to change or add anything in your html. ### Manually diff --git a/plugin.xml b/plugin.xml index 229dd8b..f4c955a 100755 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="2.0.3"> Toast @@ -11,8 +11,16 @@ A Toast is a little non intrusive buttonless popup which automatically disappears. + Eddy Verbruggen + MIT + Toast, Notification, Message, Alert + + https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git + + https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin/issues + diff --git a/src/android/nl/xservices/plugins/Toast.java b/src/android/nl/xservices/plugins/Toast.java index b8af6b6..6ccff6f 100644 --- a/src/android/nl/xservices/plugins/Toast.java +++ b/src/android/nl/xservices/plugins/Toast.java @@ -13,11 +13,15 @@ import org.json.JSONException; public void onTick(long millisUntilFinished) {toast.show();} public void onFinish() {toast.show();} }.start(); + + Also, check https://github.com/JohnPersano/SuperToasts */ public class Toast extends CordovaPlugin { private static final String ACTION_SHOW_EVENT = "show"; + private android.widget.Toast mostRecentToast; + @Override public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException { if (ACTION_SHOW_EVENT.equals(action)) { @@ -51,6 +55,7 @@ public class Toast extends CordovaPlugin { } toast.show(); + mostRecentToast = toast; callbackContext.success(); } }); @@ -61,4 +66,11 @@ public class Toast extends CordovaPlugin { return false; } } -} + + @Override + public void onPause(boolean multitasking) { + if (mostRecentToast != null) { + mostRecentToast.cancel(); + } + } +} \ No newline at end of file