diff --git a/app/src/main/java/com/jens/automation2/ActivityMainRules.java b/app/src/main/java/com/jens/automation2/ActivityMainRules.java index 0232e7f..8c1d104 100644 --- a/app/src/main/java/com/jens/automation2/ActivityMainRules.java +++ b/app/src/main/java/com/jens/automation2/ActivityMainRules.java @@ -196,7 +196,14 @@ public class ActivityMainRules extends ActivityGeneric { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle(getResources().getString(R.string.whatToDoWithRule)); - alertDialogBuilder.setItems(new String[]{ getResources().getString(R.string.runManually), getResources().getString(R.string.edit), getResources().getString(R.string.deleteCapital), getResources().getString(R.string.clone) }, new DialogInterface.OnClickListener() + + String toggleEnabled; + if(ruleThisIsAbout.isRuleActive()) + toggleEnabled = getResources().getString(R.string.disable); + else + toggleEnabled = getResources().getString(R.string.enable); + + alertDialogBuilder.setItems(new String[]{ getResources().getString(R.string.runManually), getResources().getString(R.string.edit), getResources().getString(R.string.deleteCapital), toggleEnabled, getResources().getString(R.string.clone) }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) @@ -248,6 +255,19 @@ public class ActivityMainRules extends ActivityGeneric deleteDialog.show(); break; case 3: + ruleToEdit = ruleThisIsAbout; + if(ruleToEdit.isRuleActive()) + ruleToEdit.setRuleActive(false); + else + ruleToEdit.setRuleActive(true); + + if(ruleToEdit.change(ActivityMainRules.this)) + { + ruleToEdit = null; //clear cache + updateListView(); + } + break; + case 4: ruleToEdit = ruleThisIsAbout; if(ruleToEdit.cloneRule(ActivityMainRules.this)) { diff --git a/app/src/main/java/com/jens/automation2/Trigger.java b/app/src/main/java/com/jens/automation2/Trigger.java index e43ceb1..43e074c 100644 --- a/app/src/main/java/com/jens/automation2/Trigger.java +++ b/app/src/main/java/com/jens/automation2/Trigger.java @@ -592,16 +592,42 @@ public class Trigger boolean checkHeadsetPlugged() { - if(HeadphoneJackListener.isHeadsetConnected() != this.getTriggerParameter()) - return false; - else - if(this.getHeadphoneType() != 2 && this.getHeadphoneType() != HeadphoneJackListener.getHeadphoneType()) + /* + Wenn verbunden: + - either -> true + - headphone -> true + - mikro -> wenn tatsächlich mikro + + Wenn nicht verbunden: + - either -> true + - headphone -> true + - mikro -> true + */ + + if(HeadphoneJackListener.isHeadsetConnected()) // connection detected { - Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyWrongHeadphoneType), this.getParentRule().getName()), 3); - return false; + if(this.getTriggerParameter()) // connection demanded + { + if (this.getHeadphoneType() == 1) + { + if (this.getHeadphoneType() == HeadphoneJackListener.getHeadphoneType()) // Microphone demanded + return true; + else + Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyWrongHeadphoneType), this.getParentRule().getName()), 3); + } + else + return true; + } + } + else // disconnection detected + { + // Type doesn't matter here + + if(!this.getTriggerParameter()) // disconnection demanded + return true; } - return true; + return false; } boolean checkSubSystemState() diff --git a/app/src/main/java/com/jens/automation2/receivers/HeadphoneJackListener.java b/app/src/main/java/com/jens/automation2/receivers/HeadphoneJackListener.java index bf8754d..8608c6b 100644 --- a/app/src/main/java/com/jens/automation2/receivers/HeadphoneJackListener.java +++ b/app/src/main/java/com/jens/automation2/receivers/HeadphoneJackListener.java @@ -53,12 +53,14 @@ public class HeadphoneJackListener extends BroadcastReceiver implements Automati { try { - /*Broadcast Action: Wired Headset plugged in or unplugged. - The intent will have the following extra values: - - state - 0 for unplugged, 1 for plugged. - name - Headset type, human readable string - microphone - 1 if headset has a microphone, 0 otherwise*/ + /* + Broadcast Action: Wired Headset plugged in or unplugged. + The intent will have the following extra values: + + state - 0 for unplugged, 1 for plugged. + name - Headset type, human readable string + microphone - 1 if headset has a microphone, 0 otherwise + */ int state = intent.getExtras().getInt("state"); String name = intent.getExtras().getString("name"); diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 59be9da..5f7ea99 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -368,7 +368,7 @@ Headset (Art: %1$s) verbunden Headset (type: %1$s) getrennt Kopfhörer - Mikrofon + mit Mikrofon Egal Kopfhörer Typ auswählen Was ist das? diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 818aecc..68ece34 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -32,7 +32,7 @@ Jueves Viernes Sábado - Micrófono + con micrófono Qué es esto? Solo usar localización privada Alarmas diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 9662c88..5a6ffaa 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -371,7 +371,7 @@ Écouteurs (type : %1$s) est connecté Écouteurs (type : %1$s) est déconnecté Écouteurs - Microphone + avec microphone Tous Choisissez le type d’écouteurs Qu’est ce que c’est ? diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index ad48a0d..29f36e7 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -219,7 +219,7 @@ Confronto del GPS Riscontro tattile (vibra al tocco) Uno dei due - Microfono + con microfono Seleziona il tipo di auricolare Auricolari "Connessi auricolari (tipo: %1$s) " diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index a2f2e90..af75961 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -365,8 +365,8 @@ Muziekspeler openen Headset (type: %1$s) aangesloten Headset (type: %1$s) ontkoppeld - Headphone - Microphone + hoofdtelefoon + met microfoon willekeurige Selecteer type hoofdtelefoon Wat is dit? diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index e9ef61e..e82f000 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -443,7 +443,7 @@ Zestaw słuchawkowy (typ: %1$s) podłączony Zestaw słuchawkowy (typ: %1$s) rozłączony Słuchawki - Mikrofon + z mikrofonem Albo Wybierz typ słuchawek Rule \"%1$s\" doesn\'t apply. Wrong headphone type. diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index d2c2f2a..e18941b 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -412,7 +412,7 @@ Гарнитура (тип: %1$s) подключена Гарнитура (тип: %1$s) отключена Наушники - Микрофон + с микрофоном Любой Выберите тип гарнитуры Правило %1$s не применится. Неверный тип гарнитуры. diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 550dae6..0bcca1d 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -362,7 +362,7 @@ 耳机(类型:%1$s)已连接 耳机(类型:%1$s)已断开连接 无麦克风 - 有麦克风 + 带麦克风 均可 选择耳机类型 这是什么? diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cb155dc..1a822b1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -444,7 +444,7 @@ Headset (type: %1$s) connected Headset (type: %1$s) disconnected Headphone - Microphone + with microphone Either Select type of headphone Rule \"%1$s\" doesn\'t apply. Wrong headphone type. @@ -956,4 +956,6 @@ Location permission is required to continue. Apparently there\'s a bug in Android 14 regarding a time picker dialog. If the following screen crashes when you try to use the up and down buttons next to a field, try inputting numbers with the keyboard instead. I did never find a solution for this and my app is not the only one affected. It looks like this was fixed in Android 15. Because someone at Google seems to have been smoking something the screen brightness setting has been behaving very weird for some Android versions. This behavior has nothing to do with what you\'d think it does according to their own documentation. I\'ve tried to adapt to this as best as I could, but do not expect very precise settings. That means the resulting setting may deviate a bit from what you configure here. + Disable + Enable \ No newline at end of file diff --git a/fastlane/metadata/android/en-US/changelogs/144.txt b/fastlane/metadata/android/en-US/changelogs/144.txt index 86f761f..8528d84 100644 --- a/fastlane/metadata/android/en-US/changelogs/144.txt +++ b/fastlane/metadata/android/en-US/changelogs/144.txt @@ -8,5 +8,7 @@ * Fixed: Bug in NFC trigger that affected only the Google Play version * Fixed: Examples URL fixed * Fixed: Service icon could not be hidden in Android 7 and below +* Fixed: Headphone trigger was not correctly processed * Added: Variable checks can now be inverted. Also regular expressions are now supported. -* Added: Setting to turn on/off console logging (logcat) \ No newline at end of file +* Added: Setting to turn on/off console logging (logcat) +* Added: Rules can now be enabled/disabled from the context menu on the rules screen \ No newline at end of file