Skip to content

Commit ff68337

Browse files
committed
Updated to extend CordovaPlugin instead of deprecated Plugin.
1 parent ac02e81 commit ff68337

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

Android/StatusBarNotification/StatusBarNotification.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@
2727

2828
package com.phonegap.plugins.statusBarNotification;
2929

30-
import org.apache.cordova.api.Plugin;
31-
import org.apache.cordova.api.PluginResult;
32-
import org.apache.cordova.api.PluginResult.Status;
30+
import org.apache.cordova.api.CallbackContext;
31+
import org.apache.cordova.api.CordovaPlugin;
3332
import org.json.JSONArray;
3433
import org.json.JSONException;
3534

@@ -39,7 +38,7 @@
3938
import android.content.Intent;
4039
import android.util.Log;
4140

42-
public class StatusBarNotification extends Plugin {
41+
public class StatusBarNotification extends CordovaPlugin {
4342
// Action to execute
4443
public static final String NOTIFY = "notify";
4544
public static final String CLEAR = "clear";
@@ -49,13 +48,13 @@ public class StatusBarNotification extends Plugin {
4948
*
5049
* @param action Action to execute
5150
* @param data JSONArray of arguments to the plugin
52-
* @param callbackId The callback id used when calling back into JavaScript
51+
* @param callbackContext The callback context used when calling back into JavaScript.
5352
*
5453
* @return A PluginRequest object with a status
5554
* */
5655
@Override
57-
public PluginResult execute(String action, JSONArray data, String callbackId) {
58-
PluginResult result = null;
56+
public boolean execute(String action, JSONArray data, CallbackContext callbackContext) {
57+
boolean actionValid = true;
5958
if (NOTIFY.equals(action)) {
6059
try {
6160
String tag = data.getString(0);
@@ -65,27 +64,25 @@ public PluginResult execute(String action, JSONArray data, String callbackId) {
6564
Log.d("NotificationPlugin", "Notification: " + tag + ", " + title + ", " + body);
6665
int notificationFlag = getFlagValue(flag);
6766
showNotification(tag, title, body, notificationFlag);
68-
result = new PluginResult(Status.OK);
6967
} catch (JSONException jsonEx) {
7068
Log.d("NotificationPlugin", "Got JSON Exception "
7169
+ jsonEx.getMessage());
72-
result = new PluginResult(Status.JSON_EXCEPTION);
70+
actionValid = false;
7371
}
7472
} else if (CLEAR.equals(action)){
7573
try {
7674
String tag = data.getString(0);
7775
Log.d("NotificationPlugin", "Notification cancel: " + tag);
7876
clearNotification(tag);
79-
result = new PluginResult(Status.OK);
8077
} catch (JSONException jsonEx) {
8178
Log.d("NotificationPlugin", "Got JSON Exception " + jsonEx.getMessage());
82-
result = new PluginResult(Status.JSON_EXCEPTION);
79+
actionValid = false;
8380
}
8481
} else {
85-
result = new PluginResult(Status.INVALID_ACTION);
82+
actionValid = false;
8683
Log.d("NotificationPlugin", "Invalid action : "+action+" passed");
8784
}
88-
return result;
85+
return actionValid;
8986
}
9087

9188
/**
@@ -148,7 +145,7 @@ public void onNewIntent(Intent intent) {
148145
// The incoming Intent may or may not have been for a notification.
149146
String tag = intent.getStringExtra("notificationTag");
150147
if (tag != null) {
151-
sendJavascript("window.Notification.callOnclickByTag('"+ tag + "')");
148+
this.webView.sendJavascript("window.Notification.callOnclickByTag('"+ tag + "')");
152149
}
153150
}
154151

0 commit comments

Comments
 (0)