From a9673e65b9345a8fe97a92122526549bb4c3975a Mon Sep 17 00:00:00 2001 From: jens Date: Sun, 29 May 2022 15:13:30 +0200 Subject: [PATCH 1/2] crash when editing notification trigger --- .../automation2/ActivityControlCenter.java | 1 + .../jens/automation2/ActivityManageRule.java | 14 +++++++++-- .../ActivityManageTriggerNotification.java | 25 ++++++------------- .../metadata/android/en-US/changelogs/120.txt | 6 +++-- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/com/jens/automation2/ActivityControlCenter.java b/app/src/main/java/com/jens/automation2/ActivityControlCenter.java index 2453142e..06a18339 100644 --- a/app/src/main/java/com/jens/automation2/ActivityControlCenter.java +++ b/app/src/main/java/com/jens/automation2/ActivityControlCenter.java @@ -353,6 +353,7 @@ public class ActivityControlCenter extends Activity systemInfoText.append("Device details" + Miscellaneous.lineSeparator); systemInfoText.append("OS version: " + System.getProperty("os.version") + Miscellaneous.lineSeparator); systemInfoText.append("API Level: " + android.os.Build.VERSION.SDK + Miscellaneous.lineSeparator); + systemInfoText.append("Target SDK: " + Miscellaneous.getAnyContext().getApplicationInfo().targetSdkVersion + Miscellaneous.lineSeparator); systemInfoText.append("Device: " + android.os.Build.DEVICE + Miscellaneous.lineSeparator); systemInfoText.append("Model: " + android.os.Build.MODEL + Miscellaneous.lineSeparator); systemInfoText.append("Product: " + android.os.Build.PRODUCT + Miscellaneous.lineSeparator); diff --git a/app/src/main/java/com/jens/automation2/ActivityManageRule.java b/app/src/main/java/com/jens/automation2/ActivityManageRule.java index a64e6dc2..c212b4bc 100644 --- a/app/src/main/java/com/jens/automation2/ActivityManageRule.java +++ b/app/src/main/java/com/jens/automation2/ActivityManageRule.java @@ -1376,8 +1376,18 @@ public class ActivityManageRule extends Activity { if(resultCode == RESULT_OK) { - newTrigger = ActivityManageTriggerNotification.resultingTrigger; - newTrigger.setParentRule(ruleToEdit); + Trigger editedTrigger = new Trigger(); + editedTrigger.setTriggerType(Trigger_Enum.notification); + editedTrigger.setTriggerParameter(data.getBooleanExtra(ActivityManageTriggerNotification.intentNameNotificationDirection, false)); + editedTrigger.setTriggerParameter2( + data.getStringExtra(ActivityManageTriggerNotification.intentNameNotificationApp) + Trigger.triggerParameter2Split + + data.getStringExtra(ActivityManageTriggerNotification.intentNameNotificationTitleDir) + Trigger.triggerParameter2Split + + data.getStringExtra(ActivityManageTriggerNotification.intentNameNotificationTitle) + Trigger.triggerParameter2Split + + data.getStringExtra(ActivityManageTriggerNotification.intentNameNotificationTextDir) + Trigger.triggerParameter2Split + + data.getStringExtra(ActivityManageTriggerNotification.intentNameNotificationText) + ); + editedTrigger.setParentRule(ruleToEdit); + ruleToEdit.getTriggerSet().set(editIndex, editedTrigger); this.refreshTriggerList(); } } diff --git a/app/src/main/java/com/jens/automation2/ActivityManageTriggerNotification.java b/app/src/main/java/com/jens/automation2/ActivityManageTriggerNotification.java index 63087c79..bc93f10a 100644 --- a/app/src/main/java/com/jens/automation2/ActivityManageTriggerNotification.java +++ b/app/src/main/java/com/jens/automation2/ActivityManageTriggerNotification.java @@ -322,23 +322,14 @@ public class ActivityManageTriggerNotification extends Activity String textDir = Trigger.getMatchCode(spinnerTextDirection.getSelectedItem().toString()); String text = etNotificationText.getText().toString(); - if(edit) - { - editedNotificationTrigger.setTriggerParameter(chkNotificationDirection.isChecked()); - editedNotificationTrigger.setTriggerParameter2(app + triggerParameter2Split + titleDir + triggerParameter2Split + title + triggerParameter2Split + textDir + triggerParameter2Split + text); - ActivityManageTriggerNotification.this.setResult(RESULT_OK); - } - else - { - Intent data = new Intent(); - data.putExtra(intentNameNotificationDirection, chkNotificationDirection.isChecked()); - data.putExtra(intentNameNotificationApp, app); - data.putExtra(intentNameNotificationTitleDir, titleDir); - data.putExtra(intentNameNotificationTitle, title); - data.putExtra(intentNameNotificationTextDir, textDir); - data.putExtra(intentNameNotificationText, text); - ActivityManageTriggerNotification.this.setResult(RESULT_OK, data); - } + Intent data = new Intent(); + data.putExtra(intentNameNotificationDirection, chkNotificationDirection.isChecked()); + data.putExtra(intentNameNotificationApp, app); + data.putExtra(intentNameNotificationTitleDir, titleDir); + data.putExtra(intentNameNotificationTitle, title); + data.putExtra(intentNameNotificationTextDir, textDir); + data.putExtra(intentNameNotificationText, text); + ActivityManageTriggerNotification.this.setResult(RESULT_OK, data); finish(); } diff --git a/fastlane/metadata/android/en-US/changelogs/120.txt b/fastlane/metadata/android/en-US/changelogs/120.txt index 1043b2bc..34117212 100644 --- a/fastlane/metadata/android/en-US/changelogs/120.txt +++ b/fastlane/metadata/android/en-US/changelogs/120.txt @@ -1,5 +1,7 @@ * New trigger: device has just started * New trigger: service has just started -* New parameter for trigger Screen state: New state "locked" * New trigger: Respond to customizable broadcasts -* New action: Send broadcasts \ No newline at end of file +* New parameter for trigger Screen state: New state "locked" +* New action: Send broadcasts +* Fixed: Crash when editing notification trigger +* Fixed: TimeFrame trigger - time may have changed when crossing timezones \ No newline at end of file From efaf0ed27036bada7a73031d5426085a4b078b30 Mon Sep 17 00:00:00 2001 From: Jens Date: Sun, 29 May 2022 22:29:58 +0200 Subject: [PATCH 2/2] wifi toggle dialog reduced --- app/src/main/java/com/jens/automation2/ActivityManageRule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/jens/automation2/ActivityManageRule.java b/app/src/main/java/com/jens/automation2/ActivityManageRule.java index c212b4bc..05c41cae 100644 --- a/app/src/main/java/com/jens/automation2/ActivityManageRule.java +++ b/app/src/main/java/com/jens/automation2/ActivityManageRule.java @@ -1820,7 +1820,7 @@ public class ActivityManageRule extends Activity newAction.setAction(Action_Enum.setWifi); getActionParameter1Dialog(ActivityManageRule.this).show(); - if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) + if(context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.Q) Miscellaneous.messageBox(context.getResources().getString(R.string.app_name), context.getResources().getString(R.string.android10WifiToggleNotice), context).show(); } else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setBluetooth.toString()))