From 128116025f70ec35652a419d8af105e6bd487646 Mon Sep 17 00:00:00 2001 From: jens Date: Tue, 7 Dec 2021 16:45:05 +0100 Subject: [PATCH] Rework --- .../java/com/jens/automation2/Trigger.java | 26 ++++++++++++------- app/src/main/res/values/strings.xml | 18 ++++++------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/jens/automation2/Trigger.java b/app/src/main/java/com/jens/automation2/Trigger.java index d38a0ca5..14c9523d 100644 --- a/app/src/main/java/com/jens/automation2/Trigger.java +++ b/app/src/main/java/com/jens/automation2/Trigger.java @@ -297,6 +297,7 @@ public class Trigger ) ) { + Miscellaneous.logEvent("i", "DevicePosition", "Trigger doesn\'t apply. Azimuth outside of tolerance area.", 5); return false; } @@ -308,6 +309,7 @@ public class Trigger ) ) { + Miscellaneous.logEvent("i", "DevicePosition", "Trigger doesn\'t apply. Pitch outside of tolerance area.", 5); return false; } @@ -319,6 +321,7 @@ public class Trigger ) ) { + Miscellaneous.logEvent("i", "DevicePosition", "Trigger doesn\'t apply. Roll outside of tolerance area.", 5); return false; } @@ -453,19 +456,19 @@ public class Trigger } else { - Miscellaneous.logEvent("i", "Rule", "Rule doesn't apply. Wrong direction. Demanded: " + String.valueOf(this.getPhoneDirection()) + ", got: " + String.valueOf(PhoneStatusListener.getLastPhoneDirection()), 4); + Miscellaneous.logEvent("i", "Rule", "A trigger of rule " + getParentRule().getName() + " doesn't apply. Wrong direction. Demanded: " + String.valueOf(this.getPhoneDirection()) + ", got: " + String.valueOf(PhoneStatusListener.getLastPhoneDirection()), 4); return false; } } else { - Miscellaneous.logEvent("i", "Rule", "Rule doesn't apply. Wrong call status. Demanded: " + String.valueOf(this.getTriggerParameter()) + ", got: " + String.valueOf(PhoneStatusListener.isInACall()), 4); + Miscellaneous.logEvent("i", "Rule", "A trigger of rule " + getParentRule().getName() + " doesn't apply. Wrong call status. Demanded: " + String.valueOf(this.getTriggerParameter()) + ", got: " + String.valueOf(PhoneStatusListener.isInACall()), 4); return false; } } else { - Miscellaneous.logEvent("i", "Rule", "Rule doesn't apply. Wrong phone number. Demanded: " + this.getPhoneNumber() + ", got: " + PhoneStatusListener.getLastPhoneNumber(), 4); + Miscellaneous.logEvent("i", "Rule", "A trigger of rule " + getParentRule().getName() + " doesn't apply. Wrong phone number. Demanded: " + this.getPhoneNumber() + ", got: " + PhoneStatusListener.getLastPhoneNumber(), 4); return false; } @@ -522,7 +525,7 @@ public class Trigger Miscellaneous.logEvent("i", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), this.getParentRule().getName()), "Wifi name specified, checking that.", 4); if(!WifiBroadcastReceiver.getLastWifiSsid().equals(this.getTriggerParameter2())) { - Miscellaneous.logEvent("i", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), this.getParentRule().getName()), String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyNotTheCorrectSsid), this.getTriggerParameter2(), WifiBroadcastReceiver.getLastWifiSsid()), 3); + Miscellaneous.logEvent("i", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), this.getParentRule().getName()), String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyNotTheCorrectSsid), getParentRule().getName(), this.getTriggerParameter2(), WifiBroadcastReceiver.getLastWifiSsid()), 3); return false; } else @@ -690,6 +693,7 @@ public class Trigger } } + Miscellaneous.logEvent("i", "Trigger", "Trigger " + this.toString() + " of rule " + getParentRule().getName() + " may apply currently, but has not NOT applied since the rule\'s last execution.", 5); return false; } @@ -1387,21 +1391,25 @@ public class Trigger } catch(NullPointerException e) { - device = Miscellaneous.getAnyContext().getResources().getString(R.string.invalidDevice); - Miscellaneous.logEvent("w", "Trigger", Miscellaneous.getAnyContext().getResources().getString(R.string.invalidDevice), 3); + device = Miscellaneous.getAnyContext().getResources().getString(R.string.invalidDevice) + ": " + device; + Miscellaneous.logEvent("w", "Trigger", Miscellaneous.getAnyContext().getResources().getString(R.string.invalidDevice) + ": " + device, 3); } } - if(bluetoothEvent.equals(BluetoothDevice.ACTION_ACL_CONNECTED) | bluetoothEvent.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) - if(this.triggerParameter) + if(bluetoothEvent.equals(BluetoothDevice.ACTION_ACL_CONNECTED) || bluetoothEvent.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) + { + if (this.triggerParameter) returnString.append(String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.bluetoothConnectionTo), device)); else returnString.append(String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.bluetoothDisconnectFrom), device)); + } else if(bluetoothEvent.equals(BluetoothDevice.ACTION_FOUND)) - if(this.triggerParameter) + { + if (this.triggerParameter) returnString.append(String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.bluetoothDeviceInRange), device)); else returnString.append(String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.bluetoothDeviceOutOfRange), device)); + } // } break; case headsetPlugged: diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 925c4d3f..689963f8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -212,15 +212,15 @@ Wifi name Enter a wifi name. Leave empty for any wifi. Cancel - Rule doesn\'t apply. We are slower than - Rule doesn\'t apply. We are faster than - Rule doesn\'t apply. It\'s quieter than - Rule doesn\'t apply. It\'s louder than - Rule doesn\'t apply. Battery level is lower than - Rule doesn\'t apply. Battery level is higher than - Rule doesn\'t apply. Not the correct SSID (demanded: \"%1$s\", given: \"%2$s\"). - Rule doesn\'t apply. There is no tag label or not tag at all. - Rule doesn\'t apply. Wrong tag label. + Rule %1$s doesn\'t apply. We are slower than + Rule %1$s doesn\'t apply. We are faster than + Rule %1$s doesn\'t apply. It\'s quieter than + Rule %1$s doesn\'t apply. It\'s louder than + Rule %1$s doesn\'t apply. Battery level is lower than + Rule %1$s doesn\'t apply. Battery level is higher than + Rule %1$s doesn\'t apply. Not the correct SSID (demanded: \"%2$s\", given: \"%3$s\"). + Rule %1$s doesn\'t apply. There is no tag label or not tag at all. + Rule %1$s doesn\'t apply. Wrong tag label. Rule %1$s is deactivated, can\'t apply. starting stopping