regex where comparisons are made

This commit is contained in:
Jens
2022-06-27 23:02:53 +02:00
parent f1f3be56cb
commit efb4919a1e
7 changed files with 28 additions and 12 deletions

View File

@ -476,7 +476,10 @@ public class Miscellaneous extends Service
switch(direction)
{
case Trigger.directionEquals:
return haystack.equalsIgnoreCase(needle);
if(Miscellaneous.isRegularExpression(needle))
return haystack.matches(needle);
else
return haystack.equalsIgnoreCase(needle);
case Trigger.directionNotEquals:
return !haystack.equalsIgnoreCase(needle);
case Trigger.directionContains:
@ -1753,13 +1756,12 @@ public class Miscellaneous extends Service
public static boolean comparePhoneNumbers(String number1, String number2)
{
/* To be activated when Android S SDK comes out
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.Q)
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.S)
{
TelephonyManager tm = (TelephonyManager)Miscellaneous.getAnyContext().getSystemService(Context.TELEPHONY_SERVICE);
return PhoneNumberUtils.areSamePhoneNumber(number1, number2, tm.getNetworkCountryIso());
}
else*/
else
return PhoneNumberUtils.compare(number1, number2);
}

View File

@ -22,8 +22,6 @@ import java.util.ArrayList;
public class PhoneStatusListener implements AutomationListenerInterface
{
// protected static int currentStateIncoming = -1;
// protected static int currentStateOutgoing = -1;
protected static String lastPhoneNumber="";
protected static int lastPhoneDirection = -1; //0=incoming, 1=outgoing
protected static int currentState = -1;
@ -120,8 +118,6 @@ public class PhoneStatusListener implements AutomationListenerInterface
}
else
{
// state != TelephonyManager.CALL_STATE_IDLE &&
setCurrentState(state);
setLastPhoneDirection(1);
@ -175,12 +171,12 @@ public class PhoneStatusListener implements AutomationListenerInterface
Miscellaneous.logEvent("i", "Call state", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.outgoingCallTo), getLastPhoneNumber()), 4);
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.phoneCall);
for(int i=0; i<ruleCandidates.size(); i++)
for(int i = 0; i < ruleCandidates.size(); i++)
{
AutomationService asInstance = AutomationService.getInstance();
if(asInstance != null)
if(ruleCandidates.get(i).getsGreenLight(asInstance))
ruleCandidates.get(i).activate(asInstance, false);
ruleCandidates.get(i).activate(asInstance, false);
}
}
}
@ -289,4 +285,4 @@ public class PhoneStatusListener implements AutomationListenerInterface
{
return new Trigger_Enum[] { Trigger_Enum.phoneCall };
}
}
}