diff --git a/app/src/main/java/com/jens/automation2/ActivityManageRule.java b/app/src/main/java/com/jens/automation2/ActivityManageRule.java
index 7d821f43..ccbf0c6f 100644
--- a/app/src/main/java/com/jens/automation2/ActivityManageRule.java
+++ b/app/src/main/java/com/jens/automation2/ActivityManageRule.java
@@ -258,6 +258,12 @@ public class ActivityManageRule extends Activity
notificationEditor.putExtra("edit", true);
startActivityForResult(notificationEditor, requestCodeTriggerNfcNotificationEdit);
break;
+ case phoneCall:
+ ActivityManageTriggerPhoneCall.editedPhoneCallTrigger = selectedTrigger;
+ Intent phoneCallEditor = new Intent(ActivityManageRule.this, ActivityManageTriggerPhoneCall.class);
+ phoneCallEditor.putExtra("edit", true);
+ startActivityForResult(phoneCallEditor, requestCodeTriggerPhoneCallEdit);
+ break;
default:
break;
}
diff --git a/app/src/main/java/com/jens/automation2/ActivityManageTriggerPhoneCall.java b/app/src/main/java/com/jens/automation2/ActivityManageTriggerPhoneCall.java
index e00e783b..c401f8c6 100644
--- a/app/src/main/java/com/jens/automation2/ActivityManageTriggerPhoneCall.java
+++ b/app/src/main/java/com/jens/automation2/ActivityManageTriggerPhoneCall.java
@@ -1,33 +1,13 @@
package com.jens.automation2;
import android.app.Activity;
-import android.app.AlertDialog;
import android.app.ProgressDialog;
-import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
-import android.widget.ArrayAdapter;
import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioButton;
-import android.widget.Spinner;
-import android.widget.TextView;
-
-import androidx.annotation.Nullable;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
import static com.jens.automation2.Trigger.triggerParameter2Split;
@@ -46,7 +26,7 @@ public class ActivityManageTriggerPhoneCall extends Activity
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_manage_trigger_notification);
+ setContentView(R.layout.activity_manage_trigger_phone_call);
etTriggerPhoneCallPhoneNumber = (EditText)findViewById(R.id.etTriggerPhoneCallPhoneNumber);
rbTriggerPhoneCallStateAny = (RadioButton)findViewById(R.id.rbTriggerPhoneCallStateAny);
@@ -80,7 +60,7 @@ public class ActivityManageTriggerPhoneCall extends Activity
if(rbTriggerPhoneCallDirectionAny.isChecked())
tp2Result += Trigger.triggerPhoneCallDirectionAny;
else if(rbTriggerPhoneCallDirectionIncoming.isChecked())
- tp2Result += Trigger.triggerPhoneCallDirectionImcoming;
+ tp2Result += Trigger.triggerPhoneCallDirectionIncoming;
else if(rbTriggerPhoneCallDirectionOutgoing.isChecked())
tp2Result += Trigger.triggerPhoneCallDirectionOutgoing;
@@ -132,9 +112,9 @@ public class ActivityManageTriggerPhoneCall extends Activity
if(parts[1].equals(Trigger.triggerPhoneCallDirectionAny))
rbTriggerPhoneCallDirectionAny.setChecked(true);
- else if(parts[0].equals(Trigger.triggerPhoneCallDirectionImcoming))
+ else if(parts[1].equals(Trigger.triggerPhoneCallDirectionIncoming))
rbTriggerPhoneCallDirectionIncoming.setChecked(true);
- else if(parts[0].equals(Trigger.triggerPhoneCallDirectionOutgoing))
+ else if(parts[1].equals(Trigger.triggerPhoneCallDirectionOutgoing))
rbTriggerPhoneCallDirectionOutgoing.setChecked(true);
if(!parts[2].equals(Trigger.triggerPhoneCallNumberAny))
diff --git a/app/src/main/java/com/jens/automation2/Trigger.java b/app/src/main/java/com/jens/automation2/Trigger.java
index 2c26d307..ca29fc34 100644
--- a/app/src/main/java/com/jens/automation2/Trigger.java
+++ b/app/src/main/java/com/jens/automation2/Trigger.java
@@ -81,7 +81,7 @@ public class Trigger
public static String triggerPhoneCallStateStarted = "started";
public static String triggerPhoneCallStateStopped = "stopped";
public static String triggerPhoneCallStateAny = "any";
- public static String triggerPhoneCallDirectionImcoming = "incoming";
+ public static String triggerPhoneCallDirectionIncoming = "incoming";
public static String triggerPhoneCallDirectionOutgoing = "outgoing";
public static String triggerPhoneCallDirectionAny = "any";
public static String triggerPhoneCallNumberAny = "any";
@@ -348,21 +348,47 @@ public class Trigger
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.roaming));
break;
case phoneCall:
- if(getPhoneDirection() == 1)
- returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.incomingAdjective) + " ");
- else if(getPhoneDirection() == 2)
- returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.outgoingAdjective) + " ");
+ String[] elements = triggerParameter2.split(triggerParameter2Split);
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.phoneCall));
- if(phoneNumber != null && !phoneNumber.equals("any"))
- returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.with) + " " + Miscellaneous.getAnyContext().getResources().getString(R.string.number) + " " + phoneNumber);
+
+ returnString.append(" ");
+
+ if(elements[1].equals(triggerPhoneCallDirectionAny))
+ returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.with));
+ else if(elements[1].equals(triggerPhoneCallDirectionIncoming))
+ returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.from));
+ else if(elements[1].equals(triggerPhoneCallDirectionOutgoing))
+ returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.to));
+
+ returnString.append(" ");
+
+ if(elements[2].equals(Trigger.triggerPhoneCallNumberAny))
+ returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.any) + " " + Miscellaneous.getAnyContext().getResources().getString(R.string.number));
else
- returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.with) + " " + Miscellaneous.getAnyContext().getResources().getString(R.string.anyNumber));
-
- if(getTriggerParameter())
- returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.started));
- else
- returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.stopped));
+ returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.number) + " " + Miscellaneous.getAnyContext().getResources().getString(R.string.matching) + " " + elements[2]);
+
+ returnString.append(" ");
+
+ if(elements[0].equals(Trigger.triggerPhoneCallStateAny))
+ returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.any) + " " + Miscellaneous.getAnyContext().getResources().getString(R.string.state));
+ else if(elements[0].equals(Trigger.triggerPhoneCallStateRinging))
+ returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.ringing));
+ else if(elements[0].equals(Trigger.triggerPhoneCallStateStarted))
+ returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.started));
+ else if(elements[0].equals(Trigger.triggerPhoneCallStateStopped))
+ returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.stopped));
+
+// returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.phoneCall));
+// if(phoneNumber != null && !phoneNumber.equals("any"))
+// returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.with) + " " + Miscellaneous.getAnyContext().getResources().getString(R.string.number) + " " + phoneNumber);
+// else
+// returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.with) + " " + Miscellaneous.getAnyContext().getResources().getString(R.string.anyNumber));
+//
+// if(getTriggerParameter())
+// returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.started));
+// else
+// returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.stopped));
break;
case nfcTag:
// This type doesn't have an activate/deactivate equivalent
diff --git a/app/src/main/java/com/jens/automation2/XmlFileInterface.java b/app/src/main/java/com/jens/automation2/XmlFileInterface.java
index 8092831e..1a60dfeb 100644
--- a/app/src/main/java/com/jens/automation2/XmlFileInterface.java
+++ b/app/src/main/java/com/jens/automation2/XmlFileInterface.java
@@ -23,6 +23,8 @@ import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.Collections;
+import static com.jens.automation2.Trigger.triggerParameter2Split;
+
public class XmlFileInterface
{
public static String settingsFileName = "Automation_settings.xml";
@@ -888,42 +890,90 @@ public class XmlFileInterface
Miscellaneous.logEvent("e", "XmlFileInterface", Log.getStackTraceString(e), 2);
Toast.makeText(context, "Error while writing file: " + Log.getStackTraceString(e), Toast.LENGTH_LONG).show();
}
+ newTrigger.setTriggerParameter2(triggerParameter2);
}
else if(newTrigger.getTriggerType() == Trigger_Enum.timeFrame)
{
newTrigger.setTimeFrame(new TimeFrame(triggerParameter2));
+ newTrigger.setTriggerParameter2(triggerParameter2);
}
else if(newTrigger.getTriggerType() == Trigger_Enum.batteryLevel)
{
newTrigger.setBatteryLevel(Integer.parseInt(triggerParameter2));
+ newTrigger.setTriggerParameter2(triggerParameter2);
}
else if(newTrigger.getTriggerType() == Trigger_Enum.speed)
{
newTrigger.setSpeed(Double.parseDouble(triggerParameter2));
+ newTrigger.setTriggerParameter2(triggerParameter2);
}
else if(newTrigger.getTriggerType() == Trigger_Enum.noiseLevel)
{
newTrigger.setNoiseLevelDb(Long.parseLong(triggerParameter2));
+ newTrigger.setTriggerParameter2(triggerParameter2);
}
else if(newTrigger.getTriggerType() == Trigger_Enum.wifiConnection)
{
newTrigger.setWifiName(triggerParameter2);
+ newTrigger.setTriggerParameter2(triggerParameter2);
}
else if(newTrigger.getTriggerType() == Trigger_Enum.process_started_stopped)
{
newTrigger.setProcessName(triggerParameter2);
+ newTrigger.setTriggerParameter2(triggerParameter2);
}
else if(newTrigger.getTriggerType() == Trigger_Enum.phoneCall)
{
- // 0/1/2,number
- int direction = Integer.parseInt(triggerParameter2.substring(0, 1));
- String number = triggerParameter2.substring(2);
- newTrigger.setPhoneDirection(direction);
- newTrigger.setPhoneNumber(number);
+ String[] elements = triggerParameter2.split(",");
+ if(elements.length < 3) //old format
+ {
+ // 0/1/2,number
+ int direction = Integer.parseInt(triggerParameter2.substring(0, 1));
+ String number = triggerParameter2.substring(2);
+ newTrigger.setPhoneDirection(direction);
+ newTrigger.setPhoneNumber(number);
+
+ String tp2String = "";
+
+ if(newTrigger.getTriggerParameter())
+ tp2String+= Trigger.triggerPhoneCallStateStarted;
+ else
+ tp2String+= Trigger.triggerPhoneCallStateStopped;
+
+ tp2String += triggerParameter2Split;
+
+ switch(direction)
+ {
+ case 0:
+ tp2String += Trigger.triggerPhoneCallDirectionAny;
+ break;
+ case 1:
+ tp2String += Trigger.triggerPhoneCallDirectionIncoming;
+ break;
+ case 2:
+ tp2String += Trigger.triggerPhoneCallDirectionOutgoing;
+ break;
+ }
+
+ tp2String += triggerParameter2Split;
+
+ tp2String += number;
+
+ newTrigger.setTriggerParameter2(tp2String);
+ }
+ /*else // new format
+ {
+ //tp1 is now irrelevant
+ elements = triggerParameter2.split(Trigger.triggerParameter2Split);
+ // state/direction/number
+ }*/
+ else
+ newTrigger.setTriggerParameter2(triggerParameter2);
}
else if(newTrigger.getTriggerType() == Trigger_Enum.nfcTag)
{
newTrigger.setNfcTagId(triggerParameter2);
+ newTrigger.setTriggerParameter2(triggerParameter2);
}
else if(newTrigger.getTriggerType() == Trigger_Enum.activityDetection)
{
@@ -935,6 +985,7 @@ public class XmlFileInterface
{
newTrigger.setActivityDetectionType(0);
}
+ newTrigger.setTriggerParameter2(triggerParameter2);
}
else if(newTrigger.getTriggerType() == Trigger_Enum.bluetoothConnection)
{
@@ -944,6 +995,7 @@ public class XmlFileInterface
newTrigger.setBluetoothEvent(substrings[0]);
newTrigger.setBluetoothDeviceAddress(substrings[1]);
}
+ newTrigger.setTriggerParameter2(triggerParameter2);
}
else if(newTrigger.getTriggerType() == Trigger_Enum.headsetPlugged)
{
@@ -955,9 +1007,10 @@ public class XmlFileInterface
{
newTrigger.setHeadphoneType(-1);
}
+ newTrigger.setTriggerParameter2(triggerParameter2);
}
-
- newTrigger.setTriggerParameter2(triggerParameter2);
+ else
+ newTrigger.setTriggerParameter2(triggerParameter2);
}
else
{
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 7fd4a9d2..711cfb00 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -668,5 +668,8 @@
Activity/action name
Warning
ringing
+ from
+ to
+ matching
\ No newline at end of file