Commit b9387a0d by Sebastián Katzer

Added back clearAll on Android

parent a82fa397
...@@ -23,7 +23,6 @@ package de.appplant.cordova.plugin.localnotification; ...@@ -23,7 +23,6 @@ package de.appplant.cordova.plugin.localnotification;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.util.Log;
import android.util.Pair; import android.util.Pair;
import org.apache.cordova.CallbackContext; import org.apache.cordova.CallbackContext;
...@@ -35,9 +34,7 @@ import org.json.JSONArray; ...@@ -35,9 +34,7 @@ import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.lang.Exception;
import de.appplant.cordova.plugin.notification.action.ActionGroup; import de.appplant.cordova.plugin.notification.action.ActionGroup;
import de.appplant.cordova.plugin.notification.Manager; import de.appplant.cordova.plugin.notification.Manager;
...@@ -155,7 +152,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -155,7 +152,7 @@ public class LocalNotification extends CordovaPlugin {
if (action.equalsIgnoreCase("schedule")) { if (action.equalsIgnoreCase("schedule")) {
schedule(args); schedule(args);
command.success(); command.success();
} } else
// if (action.equals("update")) { // if (action.equals("update")) {
// update(args); // update(args);
// command.success(); // command.success();
...@@ -172,10 +169,10 @@ public class LocalNotification extends CordovaPlugin { ...@@ -172,10 +169,10 @@ public class LocalNotification extends CordovaPlugin {
// clear(args); // clear(args);
// command.success(); // command.success();
// } else // } else
// if (action.equals("clearAll")) { if (action.equals("clearAll")) {
// clearAll(); clearAll();
// command.success(); command.success();
// } else }
// if (action.equals("isPresent")) { // if (action.equals("isPresent")) {
// isPresent(args.optInt(0), command); // isPresent(args.optInt(0), command);
// } else // } else
...@@ -250,7 +247,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -250,7 +247,7 @@ public class LocalNotification extends CordovaPlugin {
* JavaScript. * JavaScript.
*/ */
private void check (CallbackContext command) { private void check (CallbackContext command) {
boolean allowed = getNotificationMgr().hasPermission(); boolean allowed = getNotMgr().hasPermission();
PluginResult result = new PluginResult(PluginResult.Status.OK, allowed); PluginResult result = new PluginResult(PluginResult.Status.OK, allowed);
command.sendPluginResult(result); command.sendPluginResult(result);
...@@ -285,7 +282,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -285,7 +282,7 @@ public class LocalNotification extends CordovaPlugin {
* @param notifications The notifications to schedule. * @param notifications The notifications to schedule.
*/ */
private void schedule (JSONArray notifications) { private void schedule (JSONArray notifications) {
Manager mgr = getNotificationMgr(); Manager mgr = getNotMgr();
for (int i = 0; i < notifications.length(); i++) { for (int i = 0; i < notifications.length(); i++) {
JSONObject dict = notifications.optJSONObject(i); JSONObject dict = notifications.optJSONObject(i);
...@@ -311,7 +308,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -311,7 +308,7 @@ public class LocalNotification extends CordovaPlugin {
// int id = update.optInt("id", 0); // int id = update.optInt("id", 0);
// Notification notification = // Notification notification =
// getNotificationMgr().update(id, update, TriggerReceiver.class); // getNotMgr().update(id, update, TriggerReceiver.class);
// if (notification == null) // if (notification == null)
// continue; // continue;
...@@ -331,7 +328,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -331,7 +328,7 @@ public class LocalNotification extends CordovaPlugin {
// int id = ids.optInt(i, 0); // int id = ids.optInt(i, 0);
// Notification notification = // Notification notification =
// getNotificationMgr().cancel(id); // getNotMgr().cancel(id);
// if (notification == null) // if (notification == null)
// continue; // continue;
...@@ -344,7 +341,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -344,7 +341,7 @@ public class LocalNotification extends CordovaPlugin {
// * Cancel all scheduled notifications. // * Cancel all scheduled notifications.
// */ // */
// private void cancelAll() { // private void cancelAll() {
// getNotificationMgr().cancelAll(); // getNotMgr().cancelAll();
// fireEvent("cancelall"); // fireEvent("cancelall");
// } // }
...@@ -359,7 +356,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -359,7 +356,7 @@ public class LocalNotification extends CordovaPlugin {
// int id = ids.optInt(i, 0); // int id = ids.optInt(i, 0);
// Notification notification = // Notification notification =
// getNotificationMgr().clear(id); // getNotMgr().clear(id);
// if (notification == null) // if (notification == null)
// continue; // continue;
...@@ -368,13 +365,13 @@ public class LocalNotification extends CordovaPlugin { ...@@ -368,13 +365,13 @@ public class LocalNotification extends CordovaPlugin {
// } // }
// } // }
// /** /**
// * Clear all triggered notifications without canceling them. * Clear all triggered notifications without canceling them.
// */ */
// private void clearAll() { private void clearAll() {
// getNotificationMgr().clearAll(); getNotMgr().clearAll();
// fireEvent("clearall"); fireEvent("clearall");
// } }
// /** // /**
// * If a notification with an ID is present. // * If a notification with an ID is present.
...@@ -385,7 +382,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -385,7 +382,7 @@ public class LocalNotification extends CordovaPlugin {
// * The callback context used when calling back into JavaScript. // * The callback context used when calling back into JavaScript.
// */ // */
// private void isPresent (int id, CallbackContext command) { // private void isPresent (int id, CallbackContext command) {
// boolean exist = getNotificationMgr().exist(id); // boolean exist = getNotMgr().exist(id);
// PluginResult result = new PluginResult( // PluginResult result = new PluginResult(
// PluginResult.Status.OK, exist); // PluginResult.Status.OK, exist);
...@@ -402,7 +399,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -402,7 +399,7 @@ public class LocalNotification extends CordovaPlugin {
// * The callback context used when calling back into JavaScript. // * The callback context used when calling back into JavaScript.
// */ // */
// private void isScheduled (int id, CallbackContext command) { // private void isScheduled (int id, CallbackContext command) {
// boolean exist = getNotificationMgr().exist( // boolean exist = getNotMgr().exist(
// id, Notification.Type.SCHEDULED); // id, Notification.Type.SCHEDULED);
// PluginResult result = new PluginResult( // PluginResult result = new PluginResult(
...@@ -420,7 +417,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -420,7 +417,7 @@ public class LocalNotification extends CordovaPlugin {
// * The callback context used when calling back into JavaScript. // * The callback context used when calling back into JavaScript.
// */ // */
// private void isTriggered (int id, CallbackContext command) { // private void isTriggered (int id, CallbackContext command) {
// boolean exist = getNotificationMgr().exist( // boolean exist = getNotMgr().exist(
// id, Notification.Type.TRIGGERED); // id, Notification.Type.TRIGGERED);
// PluginResult result = new PluginResult( // PluginResult result = new PluginResult(
...@@ -436,7 +433,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -436,7 +433,7 @@ public class LocalNotification extends CordovaPlugin {
// * The callback context used when calling back into JavaScript. // * The callback context used when calling back into JavaScript.
// */ // */
// private void getAllIds (CallbackContext command) { // private void getAllIds (CallbackContext command) {
// List<Integer> ids = getNotificationMgr().getIds(); // List<Integer> ids = getNotMgr().getIds();
// command.success(new JSONArray(ids)); // command.success(new JSONArray(ids));
// } // }
...@@ -448,7 +445,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -448,7 +445,7 @@ public class LocalNotification extends CordovaPlugin {
// * The callback context used when calling back into JavaScript. // * The callback context used when calling back into JavaScript.
// */ // */
// private void getScheduledIds (CallbackContext command) { // private void getScheduledIds (CallbackContext command) {
// List<Integer> ids = getNotificationMgr().getIdsByType( // List<Integer> ids = getNotMgr().getIdsByType(
// Notification.Type.SCHEDULED); // Notification.Type.SCHEDULED);
// command.success(new JSONArray(ids)); // command.success(new JSONArray(ids));
...@@ -461,7 +458,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -461,7 +458,7 @@ public class LocalNotification extends CordovaPlugin {
// * The callback context used when calling back into JavaScript. // * The callback context used when calling back into JavaScript.
// */ // */
// private void getTriggeredIds (CallbackContext command) { // private void getTriggeredIds (CallbackContext command) {
// List<Integer> ids = getNotificationMgr().getIdsByType( // List<Integer> ids = getNotMgr().getIdsByType(
// Notification.Type.TRIGGERED); // Notification.Type.TRIGGERED);
// command.success(new JSONArray(ids)); // command.success(new JSONArray(ids));
...@@ -556,7 +553,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -556,7 +553,7 @@ public class LocalNotification extends CordovaPlugin {
// PluginResult result; // PluginResult result;
// List<JSONObject> options = // List<JSONObject> options =
// getNotificationMgr().getOptionsBy(type, toList(ids)); // getNotMgr().getOptionsBy(type, toList(ids));
// if (options.isEmpty()) { // if (options.isEmpty()) {
// // Status.NO_RESULT led to no callback invocation :( // // Status.NO_RESULT led to no callback invocation :(
...@@ -585,9 +582,9 @@ public class LocalNotification extends CordovaPlugin { ...@@ -585,9 +582,9 @@ public class LocalNotification extends CordovaPlugin {
// List<JSONObject> options; // List<JSONObject> options;
// if (ids.length() == 0) { // if (ids.length() == 0) {
// options = getNotificationMgr().getOptionsByType(type); // options = getNotMgr().getOptionsByType(type);
// } else { // } else {
// options = getNotificationMgr().getOptionsBy(type, toList(ids)); // options = getNotMgr().getOptionsBy(type, toList(ids));
// } // }
// command.success(new JSONArray(options)); // command.success(new JSONArray(options));
...@@ -702,7 +699,7 @@ public class LocalNotification extends CordovaPlugin { ...@@ -702,7 +699,7 @@ public class LocalNotification extends CordovaPlugin {
/** /**
* Notification manager instance. * Notification manager instance.
*/ */
private Manager getNotificationMgr() { private Manager getNotMgr() {
return Manager.getInstance(cordova.getActivity()); return Manager.getInstance(cordova.getActivity());
} }
......
...@@ -205,6 +205,13 @@ public final class Manager { ...@@ -205,6 +205,13 @@ public final class Manager {
// return notification; // return notification;
// } // }
/**
* Clear all local notifications.
*/
public void clearAll () {
getNotMgr().cancelAll();
}
// /** // /**
// * Clear local notification specified by ID. // * Clear local notification specified by ID.
// * // *
...@@ -222,19 +229,6 @@ public final class Manager { ...@@ -222,19 +229,6 @@ public final class Manager {
// } // }
// /** // /**
// * Clear all local notifications.
// */
// public void clearAll () {
// List<Notification> notifications = getAll();
// for (Notification notification : notifications) {
// notification.clear();
// }
// getNotMgr().cancelAll();
// }
// /**
// * Cancel all local notifications. // * Cancel all local notifications.
// */ // */
// public void cancelAll () { // public void cancelAll () {
......
...@@ -49,10 +49,11 @@ ...@@ -49,10 +49,11 @@
*/ */
- (void) launch:(CDVInvokedUrlCommand*)command - (void) launch:(CDVInvokedUrlCommand*)command
{ {
NSString* js;
if (!_launchDetails) if (!_launchDetails)
return; return;
NSString* js;
js = [NSString stringWithFormat: js = [NSString stringWithFormat:
@"cordova.plugins.notification.local.launchDetails = {id:%@, action:'%@'}", @"cordova.plugins.notification.local.launchDetails = {id:%@, action:'%@'}",
_launchDetails[0], _launchDetails[1]]; _launchDetails[0], _launchDetails[1]];
......
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