/**
 *  LocalNotificationRestore.java
 *  Cordova LocalNotification Plugin
 *
 *  Created by Sebastian Katzer (github.com/katzer) on 31/08/2013.
 *  Copyright 2013 Sebastian Katzer. All rights reserved.
 *  GPL v2 licensed
 */

package de.appplant.cordova.plugin.localnotification;

import java.util.Set;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;

/**
 * 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
 * reboot.
 */
public class LocalNotificationRestore extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		String pluginName = LocalNotification.PLUGIN_NAME;

		if (LocalNotification.cordova == null) {
			return;
		}

		// Obtain alarm details form Shared Preferences
		SharedPreferences alarms = context.getSharedPreferences(pluginName, Context.MODE_PRIVATE);
		Set<String> alarmIds     = alarms.getAll().keySet();

		/*
		 * For each alarm, parse its alarm options and register is again with
		 * the Alarm Manager
		 */
		for (String alarmId : alarmIds) {
			LocalNotificationOptions options;
			JSONObject args;

			try {
				args    = new JSONObject(alarms.getString(alarmId, ""));
				options = new LocalNotificationOptions(args, context);

				LocalNotification.add(options);
			} catch (JSONException e) {}
		}
	}
}

@@ -746,17 +746,20 @@
 iver %7B%0A%0A
-%09
+    
 @Overrid
@@ -760,17 +760,20 @@
 verride%0A
-%09
+    
 public v
@@ -820,18 +820,24 @@
 tent) %7B%0A
-%09%09
+        
 String p
@@ -880,18 +880,24 @@
 _NAME;%0A%0A
-%09%09
+        
 if (Loca
@@ -933,26 +933,47 @@
 ) %7B%0A
-%09%09%09return;%0A%09%09%7D%0A%0A%09%09
+            return;%0A        %7D%0A%0A        
 // O
@@ -1016,18 +1016,24 @@
 erences%0A
-%09%09
+        
 SharedPr
@@ -1115,18 +1115,24 @@
 IVATE);%0A
-%09%09
+        
 Set%3CStri
@@ -1181,15 +1181,27 @@
 );%0A%0A
-%09%09/*%0A%09%09
+        /*%0A        
  * F
@@ -1266,18 +1266,24 @@
 in with%0A
-%09%09
+        
  * the A
@@ -1299,16 +1299,28 @@
 ger%0A
-%09%09 */%0A%09%09
+         */%0A        
 for 
@@ -1349,19 +1349,28 @@
 mIds) %7B%0A
-%09%09%09
+            
 LocalNot
@@ -1395,19 +1395,28 @@
 ptions;%0A
-%09%09%09
+            
 JSONObje
@@ -1429,21 +1429,42 @@
 s;%0A%0A
-%09%09%09try %7B%0A%09%09%09%09
+            try %7B%0A                
 args
@@ -1516,20 +1516,32 @@
 , %22%22));%0A
-%09%09%09%09
+                
 options 
@@ -1592,12 +1592,24 @@
 );%0A%0A
-%09%09%09%09
+                
 Loca
@@ -1640,11 +1640,20 @@
 s);%0A
-%09%09%09
+            
 %7D ca
@@ -1681,13 +1681,22 @@
  %7B%7D%0A
-%09%09%7D%0A%09
+        %7D%0A    
 %7D%0A%7D%0A

Convert indentations to spaces.