|
|
@@ -21,7 +21,7 @@
|
|
|
* @APPPLANT_LICENSE_HEADER_END@
|
|
|
*/
|
|
|
|
|
|
-package de.appplant.cordova.plugin.notification;
|
|
|
+package de.appplant.cordova.plugin.notification.receiver;
|
|
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
import android.content.Context;
|
|
|
@@ -31,6 +31,12 @@ import org.json.JSONObject;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
+import de.appplant.cordova.plugin.notification.Builder;
|
|
|
+import de.appplant.cordova.plugin.notification.Manager;
|
|
|
+import de.appplant.cordova.plugin.notification.Notification;
|
|
|
+import de.appplant.cordova.plugin.notification.Options;
|
|
|
+import de.appplant.cordova.plugin.notification.Request;
|
|
|
+
|
|
|
/**
|
|
|
* This class is triggered upon reboot of the device. It needs to re-register
|
|
|
* the alarms with the AlarmManager since these alarms are lost in case of
|
|
|
@@ -41,42 +47,36 @@ abstract public class AbstractRestoreReceiver extends BroadcastReceiver {
|
|
|
/**
|
|
|
* Called on device reboot.
|
|
|
*
|
|
|
- * @param context
|
|
|
- * Application context
|
|
|
- * @param intent
|
|
|
- * Received intent with content data
|
|
|
+ * @param context Application context
|
|
|
+ * @param intent Received intent with content data
|
|
|
*/
|
|
|
@Override
|
|
|
public void onReceive (Context context, Intent intent) {
|
|
|
- Manager notificationMgr =
|
|
|
- Manager.getInstance(context);
|
|
|
-
|
|
|
- List<JSONObject> options =
|
|
|
- notificationMgr.getOptions();
|
|
|
-
|
|
|
- for (JSONObject data : options) {
|
|
|
- Builder builder = new Builder(context, data);
|
|
|
+ Manager mgr = Manager.getInstance(context);
|
|
|
+ List<JSONObject> toasts = mgr.getOptions();
|
|
|
|
|
|
- Notification notification =
|
|
|
- buildNotification(builder);
|
|
|
+ for (JSONObject data : toasts) {
|
|
|
+ Options options = new Options(context, data);
|
|
|
+ Request request = new Request(options);
|
|
|
+ Builder builder = new Builder(options);
|
|
|
+ Notification toast = buildNotification(builder);
|
|
|
|
|
|
- onRestore(notification);
|
|
|
+ onRestore(request, toast);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Called when a local notification need to be restored.
|
|
|
*
|
|
|
- * @param notification
|
|
|
- * Wrapper around the local notification
|
|
|
+ * @param request Set of notification options.
|
|
|
+ * @param toast Wrapper around the local notification.
|
|
|
*/
|
|
|
- abstract public void onRestore (Notification notification);
|
|
|
+ abstract public void onRestore (Request request, Notification toast);
|
|
|
|
|
|
/**
|
|
|
* Build notification specified by options.
|
|
|
*
|
|
|
- * @param builder
|
|
|
- * Notification builder
|
|
|
+ * @param builder Notification builder.
|
|
|
*/
|
|
|
abstract public Notification buildNotification (Builder builder);
|
|
|
|