|
@@ -1,14 +1,20 @@
|
|
|
package com.example.david.libretasker;
|
|
package com.example.david.libretasker;
|
|
|
|
|
|
|
|
|
|
+import android.annotation.TargetApi;
|
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.BroadcastReceiver;
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
import android.content.Intent;
|
|
|
import android.net.ConnectivityManager;
|
|
import android.net.ConnectivityManager;
|
|
|
|
|
+import android.os.Build;
|
|
|
|
|
+import android.os.Bundle;
|
|
|
|
|
+import android.provider.Telephony;
|
|
|
|
|
+import android.telephony.SmsMessage;
|
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
import com.example.david.libretasker.Actions.Actions;
|
|
import com.example.david.libretasker.Actions.Actions;
|
|
|
import com.example.david.libretasker.Events.Event;
|
|
import com.example.david.libretasker.Events.Event;
|
|
|
import com.example.david.libretasker.Events.NetworkEvent;
|
|
import com.example.david.libretasker.Events.NetworkEvent;
|
|
|
|
|
+import com.example.david.libretasker.Events.SMSEvent;
|
|
|
import com.example.david.libretasker.Events.ScreenEvent;
|
|
import com.example.david.libretasker.Events.ScreenEvent;
|
|
|
import com.example.david.libretasker.Events.StateEvent;
|
|
import com.example.david.libretasker.Events.StateEvent;
|
|
|
import com.example.david.libretasker.Events.TimeEvent;
|
|
import com.example.david.libretasker.Events.TimeEvent;
|
|
@@ -47,6 +53,10 @@ public class EventReceiver extends BroadcastReceiver {
|
|
|
e = new ScreenEvent();
|
|
e = new ScreenEvent();
|
|
|
data = UserData.getData("Screen");
|
|
data = UserData.getData("Screen");
|
|
|
break;
|
|
break;
|
|
|
|
|
+ case Telephony.Sms.Intents.SMS_RECEIVED_ACTION:
|
|
|
|
|
+ e = new SMSEvent();
|
|
|
|
|
+ data = UserData.getData("SMS");
|
|
|
|
|
+ break;
|
|
|
case Event.STATE_CHANGED:
|
|
case Event.STATE_CHANGED:
|
|
|
e = new StateEvent();
|
|
e = new StateEvent();
|
|
|
String s = intent.getDataString();
|
|
String s = intent.getDataString();
|
|
@@ -61,6 +71,7 @@ public class EventReceiver extends BroadcastReceiver {
|
|
|
|
|
|
|
|
actions = (ArrayList<HashMap<String, Object>>)data.get("Actions");
|
|
actions = (ArrayList<HashMap<String, Object>>)data.get("Actions");
|
|
|
eventData = (HashMap<String, Object>)data.get("Event");
|
|
eventData = (HashMap<String, Object>)data.get("Event");
|
|
|
|
|
+ eventData.put("Intent", intent);
|
|
|
if (e.trigger(context, eventData)) {
|
|
if (e.trigger(context, eventData)) {
|
|
|
for (HashMap<String, Object> a : actions) {
|
|
for (HashMap<String, Object> a : actions) {
|
|
|
Actions.Launch(context, (String) a.get("Type"), a.get("Value"));
|
|
Actions.Launch(context, (String) a.get("Type"), a.get("Value"));
|