From f7d8389668d4b4c21a0590cdc1827cf2581e7e81 Mon Sep 17 00:00:00 2001 From: Jens Date: Sat, 29 Nov 2025 23:41:32 +0100 Subject: [PATCH] Trigger URL fixes --- .../java/com/jens/automation2/Actions.java | 4 +- .../com/jens/automation2/Miscellaneous.java | 13 +++--- .../automation2/receivers/NfcReceiver.java | 46 ++----------------- app/src/main/res/values-de/strings.xml | 1 - app/src/main/res/values-es/strings.xml | 1 - app/src/main/res/values-fr/strings.xml | 1 - app/src/main/res/values-it/strings.xml | 1 - app/src/main/res/values-nl/strings.xml | 1 - app/src/main/res/values-pl/strings.xml | 1 - app/src/main/res/values-ru/strings.xml | 3 +- app/src/main/res/values-zh-rCN/strings.xml | 1 - app/src/main/res/values/strings.xml | 1 - .../metadata/android/en-US/changelogs/145.txt | 2 + 13 files changed, 14 insertions(+), 62 deletions(-) diff --git a/app/src/main/java/com/jens/automation2/Actions.java b/app/src/main/java/com/jens/automation2/Actions.java index 6721fe5..168591f 100644 --- a/app/src/main/java/com/jens/automation2/Actions.java +++ b/app/src/main/java/com/jens/automation2/Actions.java @@ -115,8 +115,7 @@ public class Actions public static void closeNotification(Action action) { NotificationManager nm = (NotificationManager) Miscellaneous.getAnyContext().getSystemService(Context.NOTIFICATION_SERVICE); -// for(StatusBarNotification n : nm.getActiveNotifications()) -// { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { String[] params = action.getParameter2().split(Action.actionParameter2Split, -1); @@ -193,7 +192,6 @@ public class Actions Miscellaneous.logEvent("i", "NotificationCloseCheck", "NotificationListener instance is null. Can\'t close notification.", 3); } } -// } } public static void sendBroadcast(Context context, String action) diff --git a/app/src/main/java/com/jens/automation2/Miscellaneous.java b/app/src/main/java/com/jens/automation2/Miscellaneous.java index dc90200..8748a33 100644 --- a/app/src/main/java/com/jens/automation2/Miscellaneous.java +++ b/app/src/main/java/com/jens/automation2/Miscellaneous.java @@ -96,7 +96,6 @@ import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.time.LocalDate; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -127,6 +126,8 @@ import eu.chainfire.libsuperuser.Shell; public class Miscellaneous extends Service { protected static String writeableFolderStringCache = null; + protected final static String http_error_string = "HTTP_ERROR"; + protected final static String last_trigger_url_result_string = "last_trigger_url_result"; public static Context startupContext; public static final String lineSeparator = System.getProperty("line.separator"); @@ -199,7 +200,7 @@ public class Miscellaneous extends Service // immediate deallocation of all system resources httpclient.getConnectionManager().shutdown(); if(errorFound) - return "httpError"; + return http_error_string; else return responseBody.toString(); } @@ -275,7 +276,7 @@ public class Miscellaneous extends Service catch(Exception e) { Miscellaneous.logEvent("e", "HTTP error", Log.getStackTraceString(e), 3); - return "httpError"; + return http_error_string; } // finally // { @@ -853,15 +854,15 @@ public class Miscellaneous extends Service } } - if(source.contains("[last_trigger_url_result]")) + if(source.contains("[" + last_trigger_url_result_string + "]")) { try { - source = source.replace("[last_trigger_url_result]", AutomationService.getInstance().getVariableMap().get("last_trigger_url_result")); + source = source.replace("[" + last_trigger_url_result_string + "]", AutomationService.getInstance().getVariableMap().get(last_trigger_url_result_string)); } catch (Exception e) { - Miscellaneous.logEvent("w", "Variable replacement", "Error replacing variable last_trigger_url_result.", 3); + Miscellaneous.logEvent("w", "Variable replacement", "Error replacing variable " + last_trigger_url_result_string + ".", 3); } } diff --git a/app/src/main/java/com/jens/automation2/receivers/NfcReceiver.java b/app/src/main/java/com/jens/automation2/receivers/NfcReceiver.java index 6dbcd54..2798f13 100644 --- a/app/src/main/java/com/jens/automation2/receivers/NfcReceiver.java +++ b/app/src/main/java/com/jens/automation2/receivers/NfcReceiver.java @@ -36,18 +36,8 @@ public class NfcReceiver public static NfcAdapter getNfcAdapter(Context context) { if(nfcAdapter == null) - { - if(Build.VERSION.SDK_INT <= 10) - { - // NFC not supported until after Gingerbread. - Miscellaneous.logEvent("w", "NFC", context.getResources().getString(R.string.nfcNotSupportedInThisAndroidVersionYet), 3); - return null; - } - else - { - nfcAdapter = NfcAdapter.getDefaultAdapter(context); - } - } + nfcAdapter = NfcAdapter.getDefaultAdapter(context); + return nfcAdapter; } @@ -91,28 +81,6 @@ public class NfcReceiver new NdefReaderTask().execute(tag); } } -// else if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(action)) -// { -// -// // In case we would still use the Tech Discovered Intent -// Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); -// String[] techList = tag.getTechList(); -// String searchedTech = Ndef.class.getName(); -// -// for (String tech : techList) -// { -// if (searchedTech.equals(tech)) -// { -// new NdefReaderTask().execute(tag); -// break; -// } -// } -// } -// else -// { -// // No NFC NDEF intent -// Miscellaneous.logEvent("w", "NFC", context.getResources().getString(R.string.nfcNoNdefIntentBut) + " " + action + ".", 5); -// } } @SuppressLint("NewApi") @@ -334,15 +302,7 @@ public class NfcReceiver return false; } - else if(Build.VERSION.SDK_INT <= 10) - { - // NFC not supported until after Gingerbread. - if(showErrorMessage) - Toast.makeText(context, context.getResources().getString(R.string.nfcNotSupportedInThisAndroidVersionYet), Toast.LENGTH_LONG).show(); - - return false; - } return true; } -} +} \ No newline at end of file diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 27b105e..51a63ac 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -302,7 +302,6 @@ Tag gefunden mit Bezeichner: Nicht unterstützte Kodierung: Kein NFC NDEF intent, sondern - NFC wird in dieser Android Version noch nicht unterstützt. Regeln können nicht ausgeführt werden. Aktuellen Tag in Regel übernehmen Tag erfolgreich gelesen. diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index c550feb..49e0b63 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -443,7 +443,6 @@ Tag encontrado con etiqueta: No hay soporte para este codigo: No NFC NDEF intent, pero - NFC sin soporto en esta version Android, todavia no. No puedo ejecutar reglas. Aplicar este tag a regla Tag escritoso con éxito. diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 89877fa..1560b74 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -305,7 +305,6 @@ Étiquette trouvée : Codage non pris en charge : Aucun NFC NDEF atteint, mais - NFC non pris en charge dans cette version Android. Impossible d’éxécuter les règles. Affecter l’étiquette à la règle Succès de lecture de l’étiquette. diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 036c891..6f91db2 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -300,7 +300,6 @@ Inserire un nome valido per l\'etichetta (come "Porta d\'ingresso di casa"). Nessun Intent NFC NDEF, ma Nessuna etichetta rilevata. - NFC non ancora supportato in questa versione di Android. Leggi ID dall\'etichetta Etichetta NFC Dati dell\'etichetta non leggibili, si prega di riscriverli. diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index f944dc6..036e6a8 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -300,7 +300,6 @@ Tag gevonden met tekst: Niet ondersteunde codering: Geen NFC NDEF bedoeling, maar - NFC nog niet ondersteund in deze Android versie. Kan regels niet uitvoeren. Pas Tag toe op regel Tag succesvol gelezen. diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index 4cb24bb..372f06b 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -365,7 +365,6 @@ Znaleziono tag z tekstem: Nieobsługiwane kodowanie: Brak intencji NFC NDEF, ale - NFC nie jest jeszcze obsługiwane w tej wersji Androida. Nie można uruchomić reguł. Can\'t download anything. Amount of http requests in settings is lower than 1. Zastosuj tag do reguły diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index e3568df..f26e6ec 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -334,8 +334,7 @@ Найдена метка с текстом: Неподдерживаемая кодировка: Нет NFC NDEF Intent, но - NFC пока не поддерживается в этой версии Android. - Не удается запустить правила. + Не удается запустить правила. Не получается загрузить. Количество http запросов в настройках меньше 1. Применить метку к правилу Метка прочитана успешно. diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 316134f..7042310 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -296,7 +296,6 @@ 找到标签,文本为: 不支持的编码: 没有 NFC NDEF Intent,但是 - 此 Android 版本尚不支持 NFC。 无法运行规则。 将标签应用到规则 标签读取成功。 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2d64b8c..01de932 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -366,7 +366,6 @@ Tag found with text: Unsupported encoding: No NFC NDEF intent, but - NFC not supported in this Android version, yet. Cannot run rules. Can\'t download anything. Amount of http requests in settings is lower than 1. Apply tag to rule diff --git a/fastlane/metadata/android/en-US/changelogs/145.txt b/fastlane/metadata/android/en-US/changelogs/145.txt index 9a18406..4d925b9 100644 --- a/fastlane/metadata/android/en-US/changelogs/145.txt +++ b/fastlane/metadata/android/en-US/changelogs/145.txt @@ -1,6 +1,8 @@ * Fixed: Crash in Play Store version when starting the service * Fixed: trigger url result was not stored correctly in a variable +* Fixed: In case of HTTP errors during trigger url actions, the return value in the variable was not set according to documentation. * Fixed: Crash when clicking +/- when creating/editing TimeFrame trigger * Fixed: Permission BLUETOOTH_CONNECT requested for Bluetooth trigger editor in Google Play version * Fixed: Airplane mode trigger didn't work if no locations where defined. +* Fixed: Vibrate action didn't work on some devices * Added Possibility to select UI theme, hence enabling modern UI designs \ No newline at end of file