Compare commits

...
333 Commits
Author SHA1 Message Date
jens fd90b14bdc Release candidate 2025-12-26 16:06:09 +01:00
jens 91fdef99c3 startActivity package name fix 2025-12-17 23:22:14 +01:00
jens 63264fcf9b Profile activation logs 2025-12-14 12:49:58 +01:00
jens 2758ef180d NFC tag fix 2025-12-07 23:13:15 +01:00
jens 3d2b48706d Vibrations fix 2025-12-07 14:00:17 +01:00
jens e52ce4cd30 Crash in Google Play version fixed 2025-12-07 12:53:48 +01:00
jens bbb477fc77 Merge branch 'development' of https://git.server47.de/jens/Automation into development
# Conflicts:
#	fastlane/metadata/android/en-US/changelogs/145.txt
2025-12-06 18:00:53 +01:00
jens 4478006109 Permission check for ability to schedule exact timers 2025-12-06 17:59:22 +01:00
jens d117484143 Variable comparison check fixed 2025-12-06 11:30:58 +01:00
jens f7d8389668 Trigger URL fixes 2025-11-29 23:41:32 +01:00
jens 4282c53372 Vibration fix 2025-11-23 18:47:38 +01:00
jens 35e2a1158d Fixed airplane mode trigger not working 2025-11-16 20:30:38 +01:00
jens 66e86e66b3 Minor corrections 2025-11-13 23:12:17 +01:00
jens 4c4a355ff5 BLUETOOTH_CONNECT permission requested for Bluetooth trigger editor in Google Play version 2025-11-10 23:51:13 +01:00
jens 07011b2053 proximity trigger 2025-11-09 23:11:28 +01:00
jens fdcdaf53c9 proximity trigger 2025-11-06 23:27:32 +01:00
jens 55a1c24753 proximity trigger 2025-11-06 22:35:49 +01:00
jens ca88fbfb07 proximity trigger 2025-11-02 23:56:58 +01:00
jens 3497d7b8ea Proximity sensor trigger 2025-11-02 19:10:05 +01:00
jens e8e763210b trigger_url variable name fixed 2025-11-02 01:02:41 +01:00
jens b6ea652e46 UI theme can be changed 2025-10-29 23:24:13 +01:00
jens a30a47f67a UI theme can be changed 2025-10-27 00:13:08 +01:00
jens 914f5c033b UI theme 2025-10-26 19:35:14 +01:00
jens f64b8ea860 Missing translation added 2025-10-26 18:38:18 +01:00
jens 2445431393 Missing translation added 2025-10-25 00:34:47 +02:00
jens a6e10d09c3 Forum added to contact options 2025-10-19 23:32:34 +02:00
jens 7972a335c3 Foreground service type 2025-10-18 18:03:53 +02:00
jens e99203c7e4 Multiple bug fixes 2025-07-19 23:21:44 +02:00
jens ee311b0ba5 New version 1.8.3 RC 2025-07-19 18:03:37 +02:00
jens fb64c46c95 Many fixes 2025-07-18 19:05:42 +02:00
jens c7557519e8 Many fixes 2025-07-16 18:08:58 +02:00
jens 01c1ac3f5e Many fixes 2025-07-15 16:46:03 +02:00
jens b473034703 Many fixes 2025-07-12 18:51:37 +02:00
jens bf78ecc794 Many fixes 2025-07-10 18:39:07 +02:00
jens 6d9a77a990 Screen brightness 2025-07-09 21:20:21 +02:00
jens ec68d375c7 Many fixes 2025-07-08 18:11:56 +02:00
jens e8524f719f Fixed warnings in logs for formatted notifications 2025-05-01 16:07:22 +02:00
jens f04c517c80 Toggle logcat on/off 2025-04-27 13:32:30 +02:00
jens b6d7958389 Invert variable check 2025-03-30 17:50:39 +02:00
jens 04d2e4b432 Bugfix when checking for any battery charging type 2025-03-23 18:33:13 +01:00
jens abd346946a Bugfix when triggering URL 2025-03-22 20:27:59 +01:00
jens 17edf90086 v1.8.2 2025-01-19 16:03:10 +01:00
jens 879e1c6ef3 Additional variables 2024-12-27 15:10:29 +01:00
jens d7d806fb5c Added permission for Termux remote commands 2024-08-25 17:11:24 +02:00
jens 910af92989 Multiple bug fixes 2024-08-11 14:58:13 +02:00
jens 9f36411511 New version 2024-05-23 23:03:43 +02:00
jens eb893a7f21 Fixed crash when exiting settings while service is running 2024-05-23 16:02:58 +02:00
jens 8788a89e48 Removed calendar trigger from Google version and fixed bug in startOtherActivity 2024-05-23 15:02:12 +02:00
jens bb10620883 Removed calendar trigger from Google version 2024-05-07 09:49:32 +02:00
jens 3e29054f82 New version 2024-05-05 23:39:46 +02:00
jens 9d5f0a3cef Merge remote-tracking branch 'origin/development-stable' into development-stable 2024-04-17 23:48:58 +02:00
jens 695b1f2481 New version prepared 2024-04-17 23:48:43 +02:00
jens d7357b0b0f date time repetition 2024-03-29 15:31:32 +01:00
jens e272338cc6 Date time repetition 2024-02-12 23:15:05 +01:00
jens 3dd84220a3 date time repetition 2024-02-11 17:25:42 +01:00
jens 4bc2781ee7 Date time repetition 2024-02-08 23:53:15 +01:00
jens 62bfbbb064 date time repetition 2024-02-08 20:25:54 +01:00
jens 31d167a93f New version prep, fix attempt in notification listener 2024-02-07 23:24:03 +01:00
jens 500610fb98 Merge branch 'development' into development-stable 2024-02-02 23:09:23 +01:00
jens 5ca7295c30 date time repetition 2024-01-27 17:03:27 +01:00
jens e2027a457a Merge remote-tracking branch 'origin/development' into development 2024-01-25 16:54:00 +01:00
jens 6c31b67b14 Battery charging type differentiation and other fixes 2024-01-25 16:53:43 +01:00
jens 04fe674cf6 Battery charging type differentiation 2024-01-25 14:03:39 +01:00
jens 17b3b8fafc New version prep, fix attempt in notification listener 2024-01-24 23:16:24 +01:00
jens 0d38c8bbe0 New version prep, fix attempt in notification listener 2024-01-24 14:00:34 +01:00
jens f7ff8a38e1 New version prep, fix attempt in notification listener 2024-01-21 23:46:08 +01:00
jens b7677bdcce Calendar trigger 2024-01-20 23:47:32 +01:00
jens 1ff4a15818 Calendar trigger 2024-01-18 16:28:42 +01:00
jens bd42507521 Bugfix in triggerUrl action 2024-01-15 16:42:16 +01:00
jens fe924f6fe9 Calendar trigger 2024-01-14 23:18:12 +01:00
jens dfe8594f06 Calendar trigger 2024-01-14 15:56:44 +01:00
jens 553d14b05f Calendar trigger 2024-01-10 20:01:24 +01:00
jens b38ca31df5 Calendar trigger 2024-01-09 22:56:42 +01:00
jens 6e566c664d Calendar trigger 2024-01-08 23:10:27 +01:00
jens 8c4b75232e Calendar trigger 2024-01-07 23:56:55 +01:00
jens 4521bc7d4e Calendar trigger 2024-01-07 15:15:56 +01:00
jens eaecf63724 Calendar trigger 2024-01-06 23:57:52 +01:00
jens ec62b91449 Calendar trigger 2024-01-06 17:25:27 +01:00
jens 223cca442d wifi trigger 2024-01-06 11:49:49 +01:00
jens f3613f8eb0 triggerUrl with POST params 2024-01-03 16:24:21 +01:00
jens 8b193aa89c triggerUrl with POST params 2024-01-02 16:36:10 +01:00
jens 58ec35aae5 calendar trigger 2024-01-01 13:35:21 +01:00
jens c61c5ba14c if brackets 2023-12-31 16:53:59 +01:00
jens d75cf137ba Merge branch 'calendar_trigger' into development 2023-12-31 16:00:13 +01:00
jens 5e3d268815 date time trigger set to wakeup 2023-12-31 15:59:02 +01:00
jens 3bcf90277f calendar trigger 2023-12-31 15:54:24 +01:00
jens 81a205a8db Calendar trigger 2023-12-30 23:26:27 +01:00
jens 97a3344e81 calendar trigger 2023-12-29 19:43:50 +01:00
jens cd47b33449 calendar trigger 2023-12-28 17:17:08 +01:00
jens 2ba25a9e65 Calendar trigger 2023-12-28 00:25:55 +01:00
jens d2606b72cd calendar trigger 2023-12-27 14:48:27 +01:00
jens 584495ef61 Calendar trigger 2023-12-27 13:33:09 +01:00
jens 9b28aeef8b calendar trigger 2023-12-26 11:56:02 +01:00
jens b6bf31589a calendar trigger 2023-12-25 14:28:48 +01:00
jens 67238bd2f0 Calendar trigger 2023-12-25 11:57:55 +01:00
jens 5f278a6ba0 calendar trigger 2023-12-23 13:55:02 +01:00
jens a21f90acb5 Wifi receiver 2023-12-21 23:16:21 +01:00
jens 5f8ed5765a TriggerUrl result stored in variable 2023-12-21 16:40:11 +01:00
jens 605f85d215 Howto for write_secure_settings linked and translations updated 2023-12-21 15:37:55 +01:00
jens 21f4a7fd5c Set location service 2023-12-20 23:54:36 +01:00
jens 2219164869 Set location service 2023-12-19 23:52:28 +01:00
jens a8646ef61d Merge branch 'accessibility_api' into development
# Conflicts:
#	app/src/main/java/com/jens/automation2/Actions.java
2023-12-19 16:54:52 +01:00
jens f641de9893 Take screenshot action added 2023-12-19 16:54:10 +01:00
jens bca8b44ad6 Bugfix for Android 14 for auto dialing mmi codes 2023-12-18 23:13:18 +01:00
jens c34dfa4af4 Bugfix for Android 14 for auto dialing mmi codes 2023-12-18 22:55:18 +01:00
jens 38644cee28 Take screenshot action added 2023-12-16 13:52:18 +01:00
jens 47898e84ea Comment added 2023-12-14 17:46:55 +01:00
jens ac74b52aed Accessibility API 2023-12-14 00:15:59 +01:00
jens 3f76813e80 Http method selectable 2023-12-12 23:40:12 +01:00
jens 1b8dc5de5f Http method selectable 2023-12-11 22:50:07 +01:00
jens 3c8c0f14f2 Fixed bug in broadcast receiver trigger 2023-12-06 23:44:40 +01:00
jens 6e73c74b60 Added changelog for v137 2023-12-03 23:27:23 +01:00
jens 9ead47bdf7 Permissions for startActivity() reduced 2023-12-03 23:24:58 +01:00
jens e4828a9720 Fixes for Google Play version 2023-11-30 00:00:34 +01:00
jens 4f971e8a1b New version 2023-11-25 23:23:58 +01:00
jens 34fbc1d005 New version prepared 2023-11-24 23:57:26 +01:00
jens b72049defc Start other service bugfix attempt 2023-11-22 23:20:26 +01:00
jens 54f3cc84c4 Start other service bugfix attempt 2023-11-19 23:44:10 +01:00
jens 7884358564 Start other service bugfix attempt 2023-11-08 00:15:39 +01:00
jens f24c9f99dc startService() experiments 2023-11-05 16:20:48 +01:00
jens 64b97c650d Small changes 2023-10-28 23:20:07 +02:00
jens 9daf4c4747 Small changes 2023-10-27 23:59:12 +02:00
jens 94f7936c4a ActivityDetection permission fixed 2023-10-26 23:30:45 +02:00
jens 02f7b642cf Wifi trigger hint 2023-10-23 23:44:21 +02:00
jens 8d10bf05af Escaped variables when triggering 2023-10-19 22:30:13 +02:00
jens 8c0cee9589 Wifi trigger fix attempt 2023-10-15 23:54:27 +02:00
jens 6b23bd6733 Icon restored 2023-08-31 15:21:55 +02:00
jens 1a60c88f35 Merge remote-tracking branch 'origin/development' into development
# Conflicts:
#	fastlane/metadata/android/en-US/changelogs/134.txt
2023-08-30 23:25:13 +02:00
jens 3312d99177 Changes icon in Play store version 2023-08-30 23:23:58 +02:00
jens ea01806915 Charging trigger bug fixed 2023-08-24 20:04:05 +02:00
jens 36173f2fcb device admin permission added for start phone call action 2023-08-01 22:59:05 +02:00
jens 4c66fe906e Merge remote-tracking branch 'origin/development-stable' 2023-07-30 22:24:40 +02:00
jens 60cfa150b5 Missing translations added 2023-07-25 23:31:32 +02:00
jens bd2231b075 Changelogs translated 2023-07-24 23:52:25 +02:00
jens 158f5f2e04 Merge remote-tracking branch 'origin/development' into development 2023-07-23 20:10:52 +02:00
jens f1315dc742 Chinese translation added. 2023-07-23 18:57:38 +02:00
jens 28aa0c3e4b Imports optimized 2023-07-11 00:07:07 +02:00
jens 6b9dbca7ab Merge remote-tracking branch 'origin/development' into development
# Conflicts:
#	fastlane/metadata/android/en-US/changelogs/133.txt
2023-07-02 00:33:59 +02:00
jens 291e0c41af Fixed bug 2023-07-02 00:31:09 +02:00
jens c9eedd5d87 Chinese translation added. 2023-06-08 19:43:41 +02:00
jens 2470321e15 Merge remote-tracking branch 'origin/development-stable' 2023-06-05 14:46:05 +02:00
jens d85a199117 New version 2023-05-21 23:24:54 +02:00
jens b047cde4ea Minor corrections 2023-05-21 14:21:09 +02:00
jens 9a1796f2eb Merge remote-tracking branch 'origin/development' into development 2023-05-17 23:24:24 +02:00
jens 7e8a6b121e Minor fix for seconds variable missing leading zero 2023-05-17 23:22:32 +02:00
jens 810c7488c4 Polish translation 2023-05-15 11:53:32 +02:00
jens 8af24695fd Polish translated added 2023-05-11 23:30:10 +02:00
jens 533a9bf54d Comment added 2023-05-10 23:24:47 +02:00
jens 8653e4853b Close notification fix 2023-05-08 23:21:44 +02:00
jens c464a9d71f Battery receiver toasts removed 2023-05-07 22:59:45 +02:00
jens 26e4851c0d Russian translation updated 2023-05-07 22:28:00 +02:00
jens 11f0ee25bf bugfixes 2023-05-06 23:32:43 +02:00
jens a76cafc6e2 Enabled variables as intent parameters 2023-05-05 23:26:32 +02:00
jens bd2920e6d9 Russian translation updated 2023-05-05 22:54:16 +02:00
jens 5caf33b45d revert 6a74d070eb
revert Fixed: Crash when managing phone call action in the F-Droid version
2023-05-05 22:48:39 +02:00
jens 6a74d070eb Fixed: Crash when managing phone call action in the F-Droid version 2023-05-05 22:38:17 +02:00
jens eba02ade08 Fixed: Crash when managing phone call action in the F-Droid version 2023-04-29 01:14:52 +02:00
jens 394effea36 New version 2023-04-24 23:43:08 +02:00
jens 4d51f1890a Merge branch 'development-stable' into development 2023-04-24 23:09:43 +02:00
jens a8b2c3bf7d New version 2023-04-24 23:08:21 +02:00
jens d1c6abaa91 - 2023-04-17 23:26:48 +02:00
jens 587ed5803e - 2023-04-17 23:26:22 +02:00
Jens 49d272be1e PhoneStatusListener 2023-04-16 22:31:01 +02:00
Jens d9e54c7780 PhoneStatusListener 2023-04-14 23:16:47 +02:00
Jens 170dbbc7e8 PhoneStatusListener 2023-04-13 00:10:21 +02:00
jens 3fc1dd1a26 Telephony receiver 2023-04-12 18:05:00 +02:00
Jens 0acb52099c Added overlay permission 2023-03-31 23:58:11 +02:00
Jens b6015a3f2e New versions prepared 2023-03-23 22:59:05 +01:00
Jens ae1e767fa6 copy to clipboard action 2023-03-17 23:22:42 +01:00
Jens 6e12e71133 copy to clipboard action 2023-03-16 23:35:38 +01:00
Jens e4e3faea06 copy to clipboard action 2023-03-15 23:27:27 +01:00
Jens 7c42250e13 copy to clipboard action 2023-03-12 23:57:54 +01:00
Jens ebb0724b28 Android 13 wifi permission text 2023-03-08 23:11:58 +01:00
Jens a7ae0c6588 Android 13 wifi permission 2023-03-01 23:35:19 +01:00
Jens e5433bf2ec Possibility to pick custom language 2023-02-26 18:12:47 +01:00
Jens fd8ffd4f7d translation error fixed 2023-02-19 00:09:20 +01:00
Jens f49455712a Hint for notification access on Android 13 2023-02-18 23:59:29 +01:00
Jens 132f64114e Bug fixed: Editing variable action was not possible 2023-02-12 23:57:37 +01:00
Jens 27e9b3e0d1 New release 2023-02-09 23:24:29 +01:00
jens a6c6dfc6ba Bug fixed in TTS 2023-02-06 14:24:46 +01:00
Jens 6a7875cc61 Bugfix release 2023-02-01 23:29:26 +01:00
Jens 6f80caa1c6 Bugfix release 2023-01-17 22:38:49 +01:00
Jens a9646cbf28 Autostart error fixed 2023-01-16 23:44:28 +01:00
jens 52edfa32df Fixed bug with multiple time frames with reoccurrence configured 2023-01-16 16:54:54 +01:00
Jens ca81e6a7bd Log improvements 2023-01-15 23:18:42 +01:00
Jens 49e4c20ab6 Allow negative integers as intents 2023-01-14 22:50:43 +01:00
Jens ab98b4d1db Build number changed because of Google Play version 2023-01-14 22:20:31 +01:00
Jens 6b32301894 New version prepared 2023-01-14 21:55:52 +01:00
Jens d9cdfab828 French translation updated 2023-01-13 22:52:45 +01:00
jens 62a8723344 Setting ringtones from profiles works again 2023-01-13 18:48:00 +01:00
jens 2b69938ad5 corrected date variables 2023-01-09 20:13:17 +01:00
jens c42f65bd3a corrected date variables 2023-01-05 20:39:29 +01:00
Jens ad0d9962b5 trim()s inserted 2023-01-01 23:51:51 +01:00
jens 58f24953f3 startByService() 2023-01-01 20:13:34 +01:00
jens 3d212456e6 tests 2022-12-24 02:27:35 +01:00
Jens fff0a28310 mms 2022-11-16 22:42:25 +01:00
jens 48da91cb40 send mms with attachment 2022-11-13 17:49:02 +01:00
Jens 98df050f42 mms 2022-11-10 23:06:07 +01:00
Jens 93cb72ac2f cosmetics 2022-11-05 23:10:23 +01:00
jens 713228c06e send mms with attachment 2022-10-30 15:04:09 +01:00
jens c868d45896 variables as triggers and actions 2022-10-09 17:14:02 +02:00
jens 4abce042eb stop phone call action 2022-10-03 20:16:56 +02:00
jens 62034e1b10 stop phone call action 2022-10-03 13:22:25 +02:00
Jens 135f4594be call phone 2022-10-02 23:26:27 +02:00
jens 900aaf3c8c Merge remote-tracking branch 'origin/development' into development 2022-10-02 19:00:40 +02:00
jens 5baa40ed59 make phone call action 2022-10-02 18:59:54 +02:00
Jens 759e8076c3 translation syntax 2022-09-30 22:37:30 +02:00
Jens 17b9f19dc2 Description text about run executable improved 2022-09-22 23:15:53 +02:00
Jens 374a5c4263 confirmation dialog for deletions 2022-09-21 23:29:54 +02:00
Jens 2fd79140cb possible fix 2022-09-05 23:53:22 +02:00
jens a0910e620f cosmetics 2022-09-02 19:31:00 +02:00
Jens 475c1719d7 translation 2022-08-29 23:06:08 +02:00
jens baa39c7a77 new version prepared 2022-08-28 02:23:39 +02:00
jens e11cc09da2 Bluetooth button disabled as not functional, yet 2022-08-27 02:13:46 +02:00
jens eff04037a1 Tethering 2022-08-27 02:07:47 +02:00
Jens b73a45f4cd tethering type 2022-08-27 00:09:20 +02:00
Jens fad6050c7a tethering type 2022-08-23 22:43:44 +02:00
jens 8a00529991 french translation 2022-08-23 16:44:15 +02:00
Jens 1d7cf00b94 tethering type 2022-08-18 23:32:57 +02:00
Jens d74e2eae68 tethering type 2022-08-17 23:36:30 +02:00
Jens 4f7c36c4f7 compile fix 2022-08-17 23:04:35 +02:00
Jens b0df3efa27 Merge branch 'tmp' into development 2022-08-17 22:42:12 +02:00
Jens f99418fda3 started to adapt tethering trigger to check a specific type 2022-08-17 22:32:14 +02:00
jens e05a42f5d6 multidex 2022-08-06 02:13:39 +02:00
Jens 83a27dcfdb started to adapt tethering trigger to check a specific type 2022-07-27 23:00:34 +02:00
Jens bdc89a855b translations and libraries updated 2022-07-27 22:11:35 +02:00
Jens 7ce203a679 translations and libraries updated 2022-07-27 22:10:07 +02:00
Jens 57bc666453 translations 2022-07-25 23:29:02 +02:00
jens c966981eae translations 2022-07-25 20:31:35 +02:00
Jens 7a05b9a95b device is starting-trigger enhanced 2022-07-24 22:50:11 +02:00
jens 7fdbf74906 service is starting can be inverted 2022-07-24 19:53:45 +02:00
jens d17e8b70fe notification dismiss with button 2022-07-24 14:22:17 +02:00
Jens f97bfbb732 close notification with button 2022-07-21 23:05:51 +02:00
jens 937c6ffe1d Merge remote-tracking branch 'origin/development' into development
# Conflicts:
#	app/src/main/res/values/strings.xml
2022-07-19 17:58:41 +02:00
jens 1ecc61452f notification dismiss with button 2022-07-19 17:57:47 +02:00
Jens 19fd2d098b wifi trigger needs location permission 2022-07-17 23:40:17 +02:00
Jens d07c1a05e4 set wifi with root fix 2022-07-15 22:37:55 +02:00
Jens f9f9b30116 su changes 2022-07-14 22:55:54 +02:00
jens d154a3d64f wifi trigger - enabled regex 2022-07-12 17:03:32 +02:00
Jens eeb4f4a39e battery level trigger fixed 2022-07-11 22:56:43 +02:00
jens 53e62068a5 close notification with button 2022-07-09 14:22:33 +02:00
jens 922807d903 meta data changed 2022-07-07 20:40:29 +02:00
Jens a7d294c115 translations 2022-07-04 23:02:46 +02:00
Jens 2d2fd901a1 translations 2022-07-04 22:57:07 +02:00
jens 536a5e22f9 wakelock action 2022-07-02 12:46:34 +02:00
jens 99faa2f7ef wakelock action 2022-07-02 01:38:39 +02:00
jens f3fac2f4e8 wakelock 2022-07-01 20:24:58 +02:00
Jens b3b713e454 email tetx 2022-06-30 23:01:26 +02:00
Jens b0d509aafe Merge remote-tracking branch 'origin/development-stable' into development
# Conflicts:
#	app/src/main/res/values-de/strings.xml
#	app/src/main/res/values/strings.xml
2022-06-27 23:04:33 +02:00
Jens efb4919a1e regex where comparisons are made 2022-06-27 23:02:53 +02:00
Jens 7bc858fee3 number format fix attempt 2022-06-27 22:42:55 +02:00
jens 647d5bd511 fix attempt number format 2022-06-27 20:07:06 +02:00
jens f1f3be56cb new version prep 2022-06-25 02:36:33 +02:00
jens 5856c93fc8 Merge branch 'development' into development-stable
# Conflicts:
#	app/src/main/res/values-it/strings.xml
2022-06-25 02:07:14 +02:00
jens 8201b1d4e4 new version prep 2022-06-25 01:44:24 +02:00
Jens ce9480d188 bug manage startOtherActivity 2022-06-13 23:15:25 +02:00
jens a69bbb1e05 translations 2022-06-13 19:59:14 +02:00
jens 16817e6f53 function cleanup 2022-06-11 14:00:03 +02:00
jens 26ed906521 function cleanup 2022-06-11 13:59:15 +02:00
jens d1ca9ab56b removed function 2022-06-11 13:55:02 +02:00
jens 9c76340f24 bluetooth not present notice 2022-06-11 13:25:13 +02:00
jens aca5572f40 translation updates 2022-06-11 13:09:37 +02:00
jens 944e165dd0 Merge remote-tracking branch 'origin/development' into development 2022-06-11 01:27:48 +02:00
jens 7f2fc4b5de russia translation and bugfix in tethering trigger management 2022-06-11 01:27:34 +02:00
jens cd163afc47 Merge pull request 'Italian translation' (#1) from bagnacauda/Automation:italian into development
Reviewed-on: jens/Automation#1
2022-06-11 01:24:51 +02:00
Simone Dotto 6179f0e9ae translated new strings 2022-06-10 17:27:17 +02:00
Simone Dotto 581cdafb87 improved Italian translation 2022-06-10 17:00:59 +02:00
jens 9162bcb451 Merge remote-tracking branch 'origin/development' into development-stable 2022-06-07 17:21:07 +02:00
jens 5272b56032 send broadcast with intents 2022-06-07 17:18:35 +02:00
jens 2361c758c9 store descriptions 2022-06-06 20:06:11 +02:00
jens f738e02b72 store descriptions 2022-06-06 02:47:51 +02:00
jens f5a3636222 intent pairs for sendBroadcast 2022-06-04 14:32:20 +02:00
jens bb1b3b0149 tethering detection 2022-06-04 02:44:26 +02:00
jens b35208b7aa tethering detection 2022-06-03 19:26:34 +02:00
jens b3ad72cc50 wifi receiver efficiency 2022-06-02 17:55:02 +02:00
jens 92e58149a7 run executable action 2022-06-02 17:43:46 +02:00
jens c1809bd23c run executable action 2022-06-02 17:41:41 +02:00
jens 88a3ab8241 Merge remote-tracking branch 'origin/development' into development
# Conflicts:
#	app/src/main/java/com/jens/automation2/ActivityManageRule.java
2022-06-01 22:39:46 +02:00
jens 00f296d2d1 wifi action 2022-06-01 22:36:30 +02:00
jens e84842361c Merge remote-tracking branch 'origin/development-stable' into development 2022-05-29 22:30:16 +02:00
jens efaf0ed270 wifi toggle dialog reduced 2022-05-29 22:29:58 +02:00
jens 7167f0c03d run executable 2022-05-29 20:14:50 +02:00
jens a9673e65b9 crash when editing notification trigger 2022-05-29 15:13:30 +02:00
jens 592abe5b0d not contains comparator 2022-05-29 14:17:11 +02:00
jens dd7c3cb1d6 not contains comparator 2022-05-29 14:15:47 +02:00
jens 38665ccd92 Merge remote-tracking branch 'origin/development-stable' into development 2022-05-29 14:04:44 +02:00
jens c60347b990 syntax errors in translations fixed 2022-05-29 14:04:32 +02:00
jens 1e7ccf5200 not equals direction 2022-05-29 13:57:47 +02:00
jens 9b84b8dad7 translations 2022-05-29 13:38:57 +02:00
jens a19c84ea51 send broadcasts action 2022-05-29 02:42:12 +02:00
jens 3a14a56fd0 translations 2022-05-28 19:54:29 +02:00
jens 2dfc538343 screenstate no sec lock screen fixed 2022-05-27 20:21:13 +02:00
jens 67a58077cc time class changed 2022-05-26 18:47:30 +02:00
jens df68f7ca5c delayed lock screen 2022-05-26 18:26:49 +02:00
jens ad18313284 delayed lock screen 2022-05-26 15:50:39 +02:00
jens 29a93e0e43 language updates and screen locked trigger 2022-05-24 17:40:11 +02:00
jens a5d54c18d8 language updates and screen locked trigger 2022-05-24 17:31:25 +02:00
jens 62f5ad0005 operator change 2022-05-23 22:59:00 +02:00
jens 4eb7133d9d operator change 2022-05-23 22:45:54 +02:00
jens 343cbba8f8 broadcast trigger 2022-05-23 20:28:56 +02:00
jens 51caae0794 operator change 2022-05-22 23:07:05 +02:00
jens e39a2411ba broadcast trigger 2022-05-22 17:31:55 +02:00
jens 98b49036a7 Merge remote-tracking branch 'origin/development-stable' into development
# Conflicts:
#	app/src/main/res/values-de/strings.xml
#	app/src/main/res/values-es/strings.xml
#	app/src/main/res/values-it/strings.xml
#	app/src/main/res/values-nl/strings.xml
#	app/src/main/res/values/strings.xml
2022-05-21 14:08:19 +02:00
jens a7c4cc0965 app picker removed from play store version 2022-05-21 14:06:09 +02:00
jens 5d67452486 Merge remote-tracking branch 'origin/development-stable' into development
# Conflicts:
#	app/src/main/res/values-de/strings.xml
#	app/src/main/res/values-es/strings.xml
#	app/src/main/res/values-it/strings.xml
#	app/src/main/res/values-nl/strings.xml
#	app/src/main/res/values/strings.xml
2022-05-21 13:37:50 +02:00
jens 7e12a0f3e5 full day time window 2022-05-21 13:34:44 +02:00
jens 5786c1bfd4 full day time window 2022-05-21 02:33:56 +02:00
jens cf500c740e new release prep 2022-05-15 01:54:56 +02:00
jens 41efa7c11b Merge remote-tracking branch 'origin/development-stable' into development
# Conflicts:
#	app/src/main/res/values-de/strings.xml
#	app/src/main/res/values-es/strings.xml
#	app/src/main/res/values-it/strings.xml
#	app/src/main/res/values-nl/strings.xml
#	app/src/main/res/values/strings.xml
#	build.gradle
#	fastlane/metadata/android/en-US/changelogs/119.txt
2022-05-15 01:54:32 +02:00
jens 7046cccabe new release prep 2022-05-15 01:37:18 +02:00
jens bdbed3dbef app info text updated 2022-05-10 12:42:14 +02:00
jens 3f36c4c6b3 bug when picking app to start 2022-05-09 20:09:11 +02:00
jens 52a10fe626 bug when importing config while service is not running 2022-05-08 20:04:45 +02:00
jens 9fce7d987e bug when importing config while service is not running 2022-05-08 14:50:40 +02:00
jens d5ce04f80b wifi trigger, memorize most recent ssid 2022-05-07 02:06:17 +02:00
jens 62c97832a9 fix in DateTimeTrigger management and executions when service already stopped 2022-04-04 20:21:34 +02:00
jens 391edc59bf fix in DateTimeTrigger management and executions when service already stopped 2022-04-03 20:25:10 +02:00
jens 0d3a13e753 fix in DateTimeTrigger management and executions when service already stopped 2022-04-03 16:20:20 +02:00
jens 152b0c3c49 fix in DateTimeTrigger management and executions when service already stopped 2022-04-03 14:46:28 +02:00
jens 7ed04c7ae2 cosmetics 2022-03-29 17:56:04 +02:00
jens c688a4c460 TimeFrame repetition fix 2022-03-26 20:00:50 +01:00
jens 5a09962cc9 TimeFrame repetition fix 2022-03-26 20:00:19 +01:00
jens 965bf55811 Merge remote-tracking branch 'origin/development-stable' into development 2022-03-05 20:59:33 +01:00
jens 13fd4c2aae magnetometer 2022-03-05 02:00:16 +01:00
jens 195a60cfe0 magnetometer 2022-03-03 17:32:06 +01:00
jens 76563eb89b Merge remote-tracking branch 'origin/development-stable' into development 2022-02-28 13:46:42 +01:00
jens 7733d57435 gradle 2022-02-26 13:02:07 +01:00
jens 481e4d1896 screen state string 2022-02-23 18:09:21 +01:00
jens 5af59e1754 Merge remote-tracking branch 'origin/development-stable' into development
# Conflicts:
#	app/src/main/java/com/jens/automation2/Trigger.java
2022-02-22 22:21:39 +01:00
jens 619f348a28 Merge remote-tracking branch 'origin/development-stable' into development 2022-02-20 18:57:38 +01:00
jens 9bf353ea3a logging 2022-02-12 20:04:19 +01:00
jens af90b566c8 new triggers: service or device starts 2022-02-07 20:09:45 +01:00
jens 0e51c577d5 new triggers: service or device starts 2022-02-06 20:12:11 +01:00
376 changed files with 20404 additions and 4276 deletions
+1 -1
View File
@@ -145,7 +145,7 @@ fabric.properties
# End of https://www.toptal.com/developers/gitignore/api/androidstudio
output-metadata.json
/app/app-release.apk
Automation_settings.xml
/app/googlePlayFlavor/
+19 -12
View File
@@ -3,16 +3,16 @@ plugins {
}
android {
compileSdkVersion 29
compileSdkVersion 34
defaultConfig {
applicationId "com.jens.automation2"
minSdkVersion 16
compileSdkVersion 31
buildToolsVersion '29.0.2'
compileSdkVersion 34
buildToolsVersion '34.0.0'
useLibrary 'org.apache.http.legacy'
versionCode 118
versionName "1.7.4"
versionCode 145
versionName "1.8.4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@@ -28,7 +28,6 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
flavorDimensions "version"
productFlavors
@@ -37,9 +36,15 @@ android {
{
dimension "version"
versionNameSuffix "-googlePlay"
targetSdkVersion 30
targetSdkVersion 35
}
/*
targetSdkVersion is kept at 28 for as long as possible.
If raised wifi cannot be switched on or off anymore without root permissions.
In the Google version I'm forced to raise the value regularly.
*/
fdroidFlavor
{
dimension "version"
@@ -57,6 +62,8 @@ android {
abortOnError false
checkReleaseBuilds false
}
namespace 'com.jens.automation2'
buildToolsVersion '34.0.0'
}
dependencies {
@@ -67,14 +74,14 @@ dependencies {
apkFlavorImplementation 'com.google.firebase:firebase-appindexing:20.0.0'
apkFlavorImplementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.linkedin.dexmaker:dexmaker:2.25.0'
implementation 'com.linkedin.dexmaker:dexmaker:2.28.1'
implementation 'org.apache.commons:commons-lang3:3.0'
//implementation "androidx.security:security-crypto:1.0.0"
//implementation "androidx.security:security-identity-credential:1.0.0-alpha02"
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.3.0'
testImplementation 'junit:junit:4.+'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
testImplementation 'junit:junit:4'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
@@ -1,20 +0,0 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.jens.automation2",
"variantName": "googlePlayFlavorRelease",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 118,
"versionName": "1.7.4-googlePlay",
"outputFile": "app-googlePlayFlavor-release.apk"
}
],
"elementType": "File"
}
+51 -5
View File
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jens.automation2">
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<supports-screens
android:anyDensity="true"
@@ -51,7 +52,6 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<!-- <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />-->
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.NFC" />
@@ -67,6 +67,19 @@
<uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.hardware.sensor.proximity"/>
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<!--android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />-->
<uses-permission android:name="com.termux.permission.RUN_COMMAND" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-feature
android:name="android.hardware.telephony"
@@ -84,7 +97,7 @@
<application
android:allowBackup="true"
android:allowClearUserData="true"
android:icon="@drawable/gears"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config">
@@ -112,7 +125,8 @@
<service
android:name=".AutomationService"
android:exported="false"
android:label="@string/app_name" />
android:label="@string/app_name"
android:foregroundServiceType="specialUse" />
<receiver android:name=".receivers.StartupIntentReceiver" android:enabled="true" android:exported="true">
<intent-filter>
@@ -127,6 +141,7 @@
</intent-filter>
</receiver>
<receiver android:name=".receivers.PackageReplacedReceiver"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
@@ -135,9 +150,11 @@
<receiver android:name=".receivers.DateTimeListener" />
<receiver android:name=".receivers.ConnectivityReceiver" />
<receiver android:name=".receivers.TimeZoneListener" />
<receiver android:name=".receivers.CalendarReceiver" />
<receiver
android:name=".DeviceAdmin"
android:exported="true"
android:description="@string/app_name"
android:label="@string/app_name"
android:permission= "android.permission.BIND_DEVICE_ADMIN" >
@@ -159,14 +176,29 @@
<activity android:name=".ActivityManageTriggerTimeFrame" />
<activity android:name=".ActivityControlCenter" />
<activity android:name=".ActivityManageTriggerPhoneCall" />
<activity android:name=".ActivityManageTriggerBroadcast" />
<activity android:name=".ActivityManageActionBrightnessSetting" />
<activity android:name=".ActivityManageActionCreateNotification" />
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
<activity android:name=".ActivityHelp" />
<activity android:name=".ActivityManageActionVibrate" />
<activity android:name=".ActivityManageActionControlMedia" />
<activity android:name=".ActivityManageActionSendBroadcast" />
<activity android:name=".ActivityManageActionRunExecutable" />
<activity android:name=".ActivityManageActionWifi" />
<activity android:name=".ActivityManageTriggerTethering" />
<activity android:name=".ActivityManageActionWakeLock" />
<activity android:name=".ActivityManageTriggerSubSystemState" />
<activity android:name=".ActivityManageActionMakePhoneCall" />
<activity android:name=".ActivityManageActionSetVariable" />
<activity android:name=".ActivityManageTriggerCheckVariable" />
<activity android:name=".ActivityManageActionCopyToClipboard" />
<activity android:name=".ActivityManageActionLocationService" />
<activity android:name=".ActivityManageTriggerCharging" />
<activity
android:name=".ActivityMainTabLayout"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -212,9 +244,12 @@
<activity android:name=".ActivityVolumeTest" />
<activity android:name=".ActivityPermissions"></activity>
<activity android:name=".ActivityManageTriggerNotification" />
<activity android:name=".ActivityManageTriggerCalendar" />
<activity android:name=".ActivityManageTriggerProximity" />
<service
android:name=".receivers.NotificationListener"
android:exported="true"
android:label="@string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" >
<intent-filter>
@@ -246,6 +281,17 @@
android:exported="true"
/>
<service android:name=".MyAccessibilityService"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/config_accessibility_service" />
</service>
</application>
</manifest>
@@ -18,7 +18,7 @@ public class MyGoogleApiClient
public com.google.android.gms.appindexing.Action getIndexApiAction()
{
Thing object = new Thing.Builder()
.setName("ActivityMainScreen Page") // TODO: Define a title for the content shown.
.setName("ActivityMainScreen Page")
// TODO: Make sure this auto-generated URL is correct.
.setUrl(Uri.parse("http://[ENTER-YOUR-URL-HERE]"))
.build();
@@ -10,8 +10,12 @@ import android.os.Looper;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.Nullable;
import com.google.android.gms.location.DetectedActivity;
import com.jens.automation2.receivers.ActivityDetectionReceiver;
import com.jens.automation2.receivers.BroadcastListener;
import com.jens.automation2.receivers.CalendarReceiver;
import java.util.ArrayList;
import java.util.Calendar;
@@ -21,23 +25,23 @@ import java.util.List;
public class Rule implements Comparable<Rule>
{
private static ArrayList<Rule> ruleCollection = new ArrayList<Rule>();
protected static ArrayList<Rule> ruleCollection = new ArrayList<Rule>();
private static List<Rule> ruleRunHistory = new ArrayList<Rule>();
protected static List<Rule> ruleRunHistory = new ArrayList<Rule>();
public static List<Rule> getRuleRunHistory()
{
return ruleRunHistory;
}
private ArrayList<Trigger> triggerSet;
private ArrayList<Action> actionSet;
private String name;
private boolean ruleActive = true; // rules can be deactivated, so they won't fire if you don't want them temporarily
private boolean ruleToggle = false; // rule will run again and do the opposite of its actions if applicable
private Calendar lastExecution;
private static Date lastActivatedRuleActivationTime;
protected ArrayList<Trigger> triggerSet;
protected ArrayList<Action> actionSet;
protected String name;
protected boolean ruleActive = true; // rules can be deactivated, so they won't fire if you don't want them temporarily
protected boolean ruleToggle = false; // rule will run again and do the opposite of its actions if applicable
protected Calendar lastExecution;
protected static Date lastActivatedRuleActivationTime;
public Calendar getLastExecution()
{
@@ -106,7 +110,7 @@ public class Rule implements Comparable<Rule>
}
public void setName(String name)
{
this.name = name;
this.name = name.trim();
}
public static void readFromFile()
@@ -185,6 +189,7 @@ public class Rule implements Comparable<Rule>
if(this.checkBeforeSaving(context, true))
{
Miscellaneous.logEvent("i", "Rule", "Changing rule: " + this.toString(), 3);
boolean returnValue = XmlFileInterface.writeFile();
if(returnValue)
@@ -233,20 +238,24 @@ public class Rule implements Comparable<Rule>
}
if(!changeExistingRule)
for(Rule rule : Rule.ruleCollection)
if(rule.getName().equals(this.getName()))
{
for (Rule rule : Rule.ruleCollection)
{
if (rule.getName().equals(this.getName()))
{
Toast.makeText(context, context.getResources().getString(R.string.anotherRuleByThatName), Toast.LENGTH_LONG).show();
return false;
}
if(this.getTriggerSet().size()==0)
}
}
if(this.getTriggerSet().size() == 0)
{
Toast.makeText(context, context.getResources().getString(R.string.pleaseSpecifiyTrigger), Toast.LENGTH_LONG).show();
return false;
}
if(this.getActionSet().size()==0)
if(this.getActionSet().size() == 0)
{
Toast.makeText(context, context.getResources().getString(R.string.pleaseSpecifiyAction), Toast.LENGTH_LONG).show();
return false;
@@ -334,6 +343,28 @@ public class Rule implements Comparable<Rule>
{
if (oneTrigger.hasStateNotAppliedSinceLastRuleExecution())
return true;
/*
Workaround for repetition in TimeFrame triggers
*/
if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.timeFrame))
{
if(oneTrigger.getTimeFrame().repetition > 0)
{
if(this.getLastExecution() != null)
{
Calendar now = Calendar.getInstance();
if (this.getLastExecution().getTimeInMillis() + oneTrigger.getTimeFrame().getRepetition() * 1000 <= now.getTimeInMillis())
return true;
}
else
return true;
}
}
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.broadcastReceived))
{
return oneTrigger.getTriggerParameter() == BroadcastListener.getInstance().hasBroadcastOccurredSince(oneTrigger.getTriggerParameter2(), getLastExecution());
}
}
return false;
@@ -345,23 +376,28 @@ public class Rule implements Comparable<Rule>
{
if(hasNotAppliedSinceLastExecution())
{
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " applies and has flipped since its last execution.", 4);
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule \"" + getName() + "\" applies and has flipped since its last execution.", 4);
return true;
}
else if(hasTriggerOfType(Trigger.Trigger_Enum.calendarEvent) && CalendarReceiver.mayRuleStillBeActivatedForPendingCalendarEvents(this))
{
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule \"" + getName() + "\" applies, has not flipped since its last execution, but may still be executed for other calendar events.", 4);
return true;
}
else
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " has not flipped since its last execution.", 4);
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule \"" + getName() + "\" has not flipped since its last execution.", 4);
}
else
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " does not apply.", 4);
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule \"" + getName() + "\" does not apply.", 4);
return false;
}
public boolean applies(Context context)
{
if(AutomationService.getInstance() == null)
{
Miscellaneous.logEvent("i", "RuleCheck", "Automation service not running. Rule " + getName() + " cannot apply.", 3);
Miscellaneous.logEvent("i", "RuleCheck", "Automation service not running. Rule \"" + getName() + "\" cannot apply.", 3);
return false;
}
@@ -372,11 +408,12 @@ public class Rule implements Comparable<Rule>
if (!oneTrigger.applies(null, context))
return false;
}
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format("Rule \"%1$s\" generally applies currently. Checking if it's really due, yet will be done separately.", this.getName()), 3);
return true;
}
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3);
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 4);
return false;
}
@@ -447,7 +484,9 @@ public class Rule implements Comparable<Rule>
{
AutomationService service = AutomationService.getInstance();
service.speak(messages[0], false);
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
if(Settings.showToasts)
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
super.onProgressUpdate(messages);
}
@@ -476,7 +515,7 @@ public class Rule implements Comparable<Rule>
{
boolean isActuallyToggleable = isActuallyToggable();
boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
// boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
boolean doToggle = ruleToggle && isActuallyToggleable;
String message;
@@ -490,6 +529,29 @@ public class Rule implements Comparable<Rule>
if(Settings.startNewThreadForRuleActivation)
publishProgress(message);
/*
Make a note of Rule/CalendarEvent executed combinations
*/
if(Rule.this.hasTriggerOfType(Trigger.Trigger_Enum.calendarEvent))
{
for(CalendarReceiver.CalendarEvent event : CalendarReceiver.getApplyingCalendarEvents(Rule.this))
{
if(!CalendarReceiver.hasEventBeenUsedInRule(Rule.this, event))
{
/*
Record only the first calendar event that matched because the rule may
be executed once for every matching event.
*/
Miscellaneous.logEvent("i", "Rule", "Executing this rule run for calender event: " + event, 5);
CalendarReceiver.addUsedPair(new CalendarReceiver.RuleEventPair(Rule.this, event));
break;
}
}
}
/*
Run actions one after another
*/
for(int i = 0; i< Rule.this.getActionSet().size(); i++)
{
try
@@ -749,4 +811,71 @@ public class Rule implements Comparable<Rule>
return null;
}
@Override
public boolean equals(@Nullable Object obj)
{
return this.getName().equals(((Rule)obj).getName());
}
public boolean hasTriggerOfType(Trigger.Trigger_Enum queryType)
{
for(Trigger t : getTriggerSet())
{
if(t.getTriggerType().equals(queryType))
return true;
}
return false;
}
public boolean hasActionOfType(Action.Action_Enum queryType)
{
for(Action a : getActionSet())
{
if(a.getAction().equals(queryType))
return true;
}
return false;
}
public int getAmountOfTriggersForType(Trigger.Trigger_Enum type)
{
int amount = 0;
for(Trigger t : getTriggerSet())
{
if(t.getTriggerType().equals(type))
amount++;
}
return amount;
}
public int getAmountOfActionsForType(Action.Action_Enum type)
{
int amount = 0;
for(Action a : getActionSet())
{
if(a.getAction().equals(type))
amount++;
}
return amount;
}
public static int getAmountOfActivatedRules()
{
int amount = 0;
for(Rule r : Rule.getRuleCollection())
{
if(r.isRuleActive())
amount++;
}
return amount;
}
}
+51 -5
View File
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jens.automation2">
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<supports-screens
android:anyDensity="true"
@@ -51,7 +52,6 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<!-- <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />-->
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.NFC" />
@@ -65,6 +65,19 @@
<uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ANSWER_PHONE_CALLS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.hardware.sensor.proximity"/>
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<!--android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />-->
<uses-permission android:name="com.termux.permission.RUN_COMMAND" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-feature
android:name="android.hardware.telephony"
@@ -82,7 +95,7 @@
<application
android:allowBackup="true"
android:allowClearUserData="true"
android:icon="@drawable/gears"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config">
@@ -110,7 +123,8 @@
<service
android:name=".AutomationService"
android:exported="false"
android:label="@string/app_name" />
android:label="@string/app_name"
android:foregroundServiceType="specialUse" />
<receiver android:name=".receivers.StartupIntentReceiver" android:enabled="true" android:exported="true">
<intent-filter>
@@ -125,6 +139,7 @@
</intent-filter>
</receiver>
<receiver android:name=".receivers.PackageReplacedReceiver"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
@@ -133,9 +148,11 @@
<receiver android:name=".receivers.DateTimeListener" />
<receiver android:name=".receivers.ConnectivityReceiver" />
<receiver android:name=".receivers.TimeZoneListener" />
<receiver android:name=".receivers.CalendarReceiver" />
<receiver
android:name=".DeviceAdmin"
android:exported="true"
android:description="@string/app_name"
android:label="@string/app_name"
android:permission= "android.permission.BIND_DEVICE_ADMIN" >
@@ -157,14 +174,29 @@
<activity android:name=".ActivityManageTriggerTimeFrame" />
<activity android:name=".ActivityControlCenter" />
<activity android:name=".ActivityManageTriggerPhoneCall" />
<activity android:name=".ActivityManageTriggerBroadcast" />
<activity android:name=".ActivityManageActionBrightnessSetting" />
<activity android:name=".ActivityManageActionCreateNotification" />
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
<activity android:name=".ActivityHelp" />
<activity android:name=".ActivityManageActionVibrate" />
<activity android:name=".ActivityManageActionControlMedia" />
<activity android:name=".ActivityManageActionSendBroadcast" />
<activity android:name=".ActivityManageActionRunExecutable" />
<activity android:name=".ActivityManageActionWifi" />
<activity android:name=".ActivityManageTriggerTethering" />
<activity android:name=".ActivityManageActionWakeLock" />
<activity android:name=".ActivityManageTriggerSubSystemState" />
<activity android:name=".ActivityManageActionMakePhoneCall" />
<activity android:name=".ActivityManageActionSetVariable" />
<activity android:name=".ActivityManageTriggerCheckVariable" />
<activity android:name=".ActivityManageActionCopyToClipboard" />
<activity android:name=".ActivityManageActionLocationService" />
<activity android:name=".ActivityManageTriggerCharging" />
<activity
android:name=".ActivityMainTabLayout"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -210,9 +242,12 @@
<activity android:name=".ActivityVolumeTest" />
<activity android:name=".ActivityPermissions"></activity>
<activity android:name=".ActivityManageTriggerNotification" />
<activity android:name=".ActivityManageTriggerCalendar" />
<activity android:name=".ActivityManageTriggerProximity" />
<service
android:name=".receivers.NotificationListener"
android:exported="true"
android:label="@string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" >
<intent-filter>
@@ -232,6 +267,17 @@
android:exported="true"
/>
<service android:name=".MyAccessibilityService"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/config_accessibility_service" />
</service>
</application>
</manifest>
@@ -10,6 +10,10 @@ import android.os.Looper;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.Nullable;
import com.jens.automation2.receivers.BroadcastListener;
import com.jens.automation2.receivers.CalendarReceiver;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@@ -18,23 +22,23 @@ import java.util.List;
public class Rule implements Comparable<Rule>
{
private static ArrayList<Rule> ruleCollection = new ArrayList<Rule>();
protected static ArrayList<Rule> ruleCollection = new ArrayList<Rule>();
private static List<Rule> ruleRunHistory = new ArrayList<Rule>();
protected static List<Rule> ruleRunHistory = new ArrayList<Rule>();
public static List<Rule> getRuleRunHistory()
{
return ruleRunHistory;
}
private ArrayList<Trigger> triggerSet;
private ArrayList<Action> actionSet;
private String name;
private boolean ruleActive = true; // rules can be deactivated, so they won't fire if you don't want them temporarily
private boolean ruleToggle = false; // rule will run again and do the opposite of its actions if applicable
private Calendar lastExecution;
private static Date lastActivatedRuleActivationTime;
protected ArrayList<Trigger> triggerSet;
protected ArrayList<Action> actionSet;
protected String name;
protected boolean ruleActive = true; // rules can be deactivated, so they won't fire if you don't want them temporarily
protected boolean ruleToggle = false; // rule will run again and do the opposite of its actions if applicable
protected Calendar lastExecution;
protected static Date lastActivatedRuleActivationTime;
public Calendar getLastExecution()
{
@@ -103,7 +107,7 @@ public class Rule implements Comparable<Rule>
}
public void setName(String name)
{
this.name = name;
this.name = name.trim();
}
public static void readFromFile()
@@ -182,6 +186,7 @@ public class Rule implements Comparable<Rule>
if(this.checkBeforeSaving(context, true))
{
Miscellaneous.logEvent("i", "Rule", "Changing rule: " + this.toString(), 3);
boolean returnValue = XmlFileInterface.writeFile();
if(returnValue)
@@ -230,20 +235,24 @@ public class Rule implements Comparable<Rule>
}
if(!changeExistingRule)
for(Rule rule : Rule.ruleCollection)
if(rule.getName().equals(this.getName()))
{
for (Rule rule : Rule.ruleCollection)
{
if (rule.getName().equals(this.getName()))
{
Toast.makeText(context, context.getResources().getString(R.string.anotherRuleByThatName), Toast.LENGTH_LONG).show();
return false;
}
if(this.getTriggerSet().size()==0)
}
}
if(this.getTriggerSet().size() == 0)
{
Toast.makeText(context, context.getResources().getString(R.string.pleaseSpecifiyTrigger), Toast.LENGTH_LONG).show();
return false;
}
if(this.getActionSet().size()==0)
if(this.getActionSet().size() == 0)
{
Toast.makeText(context, context.getResources().getString(R.string.pleaseSpecifiyAction), Toast.LENGTH_LONG).show();
return false;
@@ -331,6 +340,28 @@ public class Rule implements Comparable<Rule>
{
if (oneTrigger.hasStateNotAppliedSinceLastRuleExecution())
return true;
/*
Workaround for repetition in TimeFrame triggers
*/
if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.timeFrame))
{
if(oneTrigger.getTimeFrame().repetition > 0)
{
if(this.getLastExecution() != null)
{
Calendar now = Calendar.getInstance();
if (this.getLastExecution().getTimeInMillis() + oneTrigger.getTimeFrame().getRepetition() * 1000 <= now.getTimeInMillis())
return true;
}
else
return true;
}
}
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.broadcastReceived))
{
return oneTrigger.getTriggerParameter() == BroadcastListener.getInstance().hasBroadcastOccurredSince(oneTrigger.getTriggerParameter2(), getLastExecution());
}
}
return false;
@@ -342,23 +373,28 @@ public class Rule implements Comparable<Rule>
{
if(hasNotAppliedSinceLastExecution())
{
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " applies and has flipped since its last execution.", 4);
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule \"" + getName() + "\" applies and has flipped since its last execution.", 4);
return true;
}
else if(hasTriggerOfType(Trigger.Trigger_Enum.calendarEvent) && CalendarReceiver.mayRuleStillBeActivatedForPendingCalendarEvents(this))
{
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule \"" + getName() + "\" applies, has not flipped since its last execution, but may still be executed for other calendar events.", 4);
return true;
}
else
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " has not flipped since its last execution.", 4);
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule \"" + getName() + "\" has not flipped since its last execution.", 4);
}
else
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " does not apply.", 4);
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule \"" + getName() + "\" does not apply.", 4);
return false;
}
public boolean applies(Context context)
{
if(AutomationService.getInstance() == null)
{
Miscellaneous.logEvent("i", "RuleCheck", "Automation service not running. Rule " + getName() + " cannot apply.", 3);
Miscellaneous.logEvent("i", "RuleCheck", "Automation service not running. Rule \"" + getName() + "\" cannot apply.", 3);
return false;
}
@@ -369,11 +405,12 @@ public class Rule implements Comparable<Rule>
if (!oneTrigger.applies(null, context))
return false;
}
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format("Rule \"%1$s\" generally applies currently. Checking if it's really due, yet will be done separately.", this.getName()), 3);
return true;
}
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3);
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 4);
return false;
}
@@ -420,7 +457,9 @@ public class Rule implements Comparable<Rule>
{
AutomationService service = AutomationService.getInstance();
service.speak(messages[0], false);
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
if(Settings.showToasts)
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
super.onProgressUpdate(messages);
}
@@ -449,7 +488,7 @@ public class Rule implements Comparable<Rule>
{
boolean isActuallyToggleable = isActuallyToggable();
boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
// boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
boolean doToggle = ruleToggle && isActuallyToggleable;
String message;
@@ -463,6 +502,29 @@ public class Rule implements Comparable<Rule>
if(Settings.startNewThreadForRuleActivation)
publishProgress(message);
/*
Make a note of Rule/CalendarEvent executed combinations
*/
if(Rule.this.hasTriggerOfType(Trigger.Trigger_Enum.calendarEvent))
{
for(CalendarReceiver.CalendarEvent event : CalendarReceiver.getApplyingCalendarEvents(Rule.this))
{
if(!CalendarReceiver.hasEventBeenUsedInRule(Rule.this, event))
{
/*
Record only the first calendar event that matched because the rule may
be executed once for every matching event.
*/
Miscellaneous.logEvent("i", "Rule", "Executing this rule run for calender event: " + event, 5);
CalendarReceiver.addUsedPair(new CalendarReceiver.RuleEventPair(Rule.this, event));
break;
}
}
}
/*
Run actions one after another
*/
for(int i = 0; i< Rule.this.getActionSet().size(); i++)
{
try
@@ -722,4 +784,71 @@ public class Rule implements Comparable<Rule>
return null;
}
@Override
public boolean equals(@Nullable Object obj)
{
return this.getName().equals(((Rule)obj).getName());
}
public boolean hasTriggerOfType(Trigger.Trigger_Enum queryType)
{
for(Trigger t : getTriggerSet())
{
if(t.getTriggerType().equals(queryType))
return true;
}
return false;
}
public boolean hasActionOfType(Action.Action_Enum queryType)
{
for(Action a : getActionSet())
{
if(a.getAction().equals(queryType))
return true;
}
return false;
}
public int getAmountOfTriggersForType(Trigger.Trigger_Enum type)
{
int amount = 0;
for(Trigger t : getTriggerSet())
{
if(t.getTriggerType().equals(type))
amount++;
}
return amount;
}
public int getAmountOfActionsForType(Action.Action_Enum type)
{
int amount = 0;
for(Action a : getActionSet())
{
if(a.getAction().equals(type))
amount++;
}
return amount;
}
public static int getAmountOfActivatedRules()
{
int amount = 0;
for(Rule r : Rule.getRuleCollection())
{
if(r.isRuleActive())
amount++;
}
return amount;
}
}
+43 -10
View File
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jens.automation2">
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<supports-screens
android:anyDensity="true"
@@ -50,7 +51,6 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<!-- <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />-->
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.NFC" />
@@ -65,12 +65,21 @@
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
<uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.hardware.sensor.proximity"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
<!--android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />-->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="com.termux.permission.RUN_COMMAND" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<application
android:allowBackup="true"
android:allowClearUserData="true"
android:icon="@drawable/gears"
android:icon="@drawable/crane"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config">
@@ -98,9 +107,16 @@
<service
android:name=".AutomationService"
android:exported="false"
android:label="@string/app_name" />
android:label="@string/app_name"
android:foregroundServiceType="specialUse">
<property
android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
android:value="Automating things on the device" />
</service>
<receiver android:name=".receivers.StartupIntentReceiver" android:enabled="true" android:exported="true">
<receiver android:name=".receivers.StartupIntentReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<!--<action android:name="android.intent.action.SCREEN_ON" />-->
<!--<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />-->
@@ -113,6 +129,7 @@
</intent-filter>
</receiver>
<receiver android:name=".receivers.PackageReplacedReceiver"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
@@ -121,9 +138,11 @@
<receiver android:name=".receivers.DateTimeListener" />
<receiver android:name=".receivers.ConnectivityReceiver" />
<receiver android:name=".receivers.TimeZoneListener" />
<receiver android:name=".receivers.CalendarReceiver" />
<receiver
android:name=".DeviceAdmin"
android:exported="true"
android:description="@string/app_name"
android:label="@string/app_name"
android:permission= "android.permission.BIND_DEVICE_ADMIN" >
@@ -145,14 +164,28 @@
<activity android:name=".ActivityManageTriggerTimeFrame" />
<activity android:name=".ActivityControlCenter" />
<activity android:name=".ActivityManageTriggerPhoneCall" />
<activity android:name=".ActivityManageTriggerBroadcast" />
<activity android:name=".ActivityManageActionBrightnessSetting" />
<activity android:name=".ActivityManageActionCreateNotification" />
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
<activity android:name=".ActivityHelp" />
<activity android:name=".ActivityManageActionVibrate" />
<activity android:name=".ActivityManageActionControlMedia" />
<activity android:name=".ActivityManageActionSendBroadcast" />
<activity android:name=".ActivityManageActionRunExecutable" />
<activity android:name=".ActivityManageActionWifi" />
<activity android:name=".ActivityManageTriggerTethering" />
<activity android:name=".ActivityManageActionWakeLock" />
<activity android:name=".ActivityManageTriggerSubSystemState" />
<activity android:name=".ActivityManageActionSetVariable" />
<activity android:name=".ActivityManageTriggerCheckVariable" />
<activity android:name=".ActivityManageActionCopyToClipboard" />
<activity android:name=".ActivityManageActionLocationService" />
<activity android:name=".ActivityManageTriggerCharging" />
<activity
android:name=".ActivityMainTabLayout"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -190,7 +223,6 @@
<activity android:name=".ActivityManageActionStartActivity" />
<activity android:name=".ActivityManageTriggerNfc" />
<activity android:name=".ActivityManageActionSpeakText" />
<activity android:name=".ActivityManageActionPlaySound" />
<activity android:name=".ActivityManageTriggerBluetooth" />
<activity android:name=".ActivityMainProfiles" />
<activity android:name=".ActivityManageProfile" />
@@ -198,9 +230,12 @@
<activity android:name=".ActivityVolumeTest" />
<activity android:name=".ActivityPermissions"></activity>
<activity android:name=".ActivityManageTriggerNotification" />
<activity android:name=".ActivityManageTriggerCalendar" />
<activity android:name=".ActivityManageTriggerProximity" />
<service
android:name=".receivers.NotificationListener"
android:exported="true"
android:label="@string/app_name"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" >
<intent-filter>
@@ -209,8 +244,6 @@
</service>
<activity android:name=".ActivityPermissions" />
<!-- https://developer.android.com/about/versions/pie/android-9.0-changes-28#apache-p-->
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
@@ -10,8 +10,12 @@ import android.os.Looper;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.Nullable;
import com.google.android.gms.location.DetectedActivity;
import com.jens.automation2.receivers.ActivityDetectionReceiver;
import com.jens.automation2.receivers.BroadcastListener;
import com.jens.automation2.receivers.CalendarReceiver;
import java.util.ArrayList;
import java.util.Calendar;
@@ -21,23 +25,23 @@ import java.util.List;
public class Rule implements Comparable<Rule>
{
private static ArrayList<Rule> ruleCollection = new ArrayList<Rule>();
protected static ArrayList<Rule> ruleCollection = new ArrayList<Rule>();
private static List<Rule> ruleRunHistory = new ArrayList<Rule>();
protected static List<Rule> ruleRunHistory = new ArrayList<Rule>();
public static List<Rule> getRuleRunHistory()
{
return ruleRunHistory;
}
private ArrayList<Trigger> triggerSet;
private ArrayList<Action> actionSet;
private String name;
private boolean ruleActive = true; // rules can be deactivated, so they won't fire if you don't want them temporarily
private boolean ruleToggle = false; // rule will run again and do the opposite of its actions if applicable
private Calendar lastExecution;
private static Date lastActivatedRuleActivationTime;
protected ArrayList<Trigger> triggerSet;
protected ArrayList<Action> actionSet;
protected String name;
protected boolean ruleActive = true; // rules can be deactivated, so they won't fire if you don't want them temporarily
protected boolean ruleToggle = false; // rule will run again and do the opposite of its actions if applicable
protected Calendar lastExecution;
protected static Date lastActivatedRuleActivationTime;
public Calendar getLastExecution()
{
@@ -106,7 +110,7 @@ public class Rule implements Comparable<Rule>
}
public void setName(String name)
{
this.name = name;
this.name = name.trim();
}
public static void readFromFile()
@@ -185,6 +189,7 @@ public class Rule implements Comparable<Rule>
if(this.checkBeforeSaving(context, true))
{
Miscellaneous.logEvent("i", "Rule", "Changing rule: " + this.toString(), 3);
boolean returnValue = XmlFileInterface.writeFile();
if(returnValue)
@@ -233,20 +238,24 @@ public class Rule implements Comparable<Rule>
}
if(!changeExistingRule)
for(Rule rule : Rule.ruleCollection)
if(rule.getName().equals(this.getName()))
{
for (Rule rule : Rule.ruleCollection)
{
if (rule.getName().equals(this.getName()))
{
Toast.makeText(context, context.getResources().getString(R.string.anotherRuleByThatName), Toast.LENGTH_LONG).show();
return false;
}
if(this.getTriggerSet().size()==0)
}
}
if(this.getTriggerSet().size() == 0)
{
Toast.makeText(context, context.getResources().getString(R.string.pleaseSpecifiyTrigger), Toast.LENGTH_LONG).show();
return false;
}
if(this.getActionSet().size()==0)
if(this.getActionSet().size() == 0)
{
Toast.makeText(context, context.getResources().getString(R.string.pleaseSpecifiyAction), Toast.LENGTH_LONG).show();
return false;
@@ -334,6 +343,28 @@ public class Rule implements Comparable<Rule>
{
if (oneTrigger.hasStateNotAppliedSinceLastRuleExecution())
return true;
/*
Workaround for repetition in TimeFrame triggers
*/
if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.timeFrame))
{
if(oneTrigger.getTimeFrame().repetition > 0)
{
if(this.getLastExecution() != null)
{
Calendar now = Calendar.getInstance();
if (this.getLastExecution().getTimeInMillis() + oneTrigger.getTimeFrame().getRepetition() * 1000 <= now.getTimeInMillis())
return true;
}
else
return true;
}
}
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.broadcastReceived))
{
return oneTrigger.getTriggerParameter() == BroadcastListener.getInstance().hasBroadcastOccurredSince(oneTrigger.getTriggerParameter2(), getLastExecution());
}
}
return false;
@@ -345,23 +376,28 @@ public class Rule implements Comparable<Rule>
{
if(hasNotAppliedSinceLastExecution())
{
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " applies and has flipped since its last execution.", 4);
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule \"" + getName() + "\" applies and has flipped since its last execution.", 4);
return true;
}
else if(hasTriggerOfType(Trigger.Trigger_Enum.calendarEvent) && CalendarReceiver.mayRuleStillBeActivatedForPendingCalendarEvents(this))
{
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule \"" + getName() + "\" applies, has not flipped since its last execution, but may still be executed for other calendar events.", 4);
return true;
}
else
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " has not flipped since its last execution.", 4);
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule \"" + getName() + "\" has not flipped since its last execution.", 4);
}
else
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " does not apply.", 4);
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule \"" + getName() + "\" does not apply.", 4);
return false;
}
public boolean applies(Context context)
{
if(AutomationService.getInstance() == null)
{
Miscellaneous.logEvent("i", "RuleCheck", "Automation service not running. Rule " + getName() + " cannot apply.", 3);
Miscellaneous.logEvent("i", "RuleCheck", "Automation service not running. Rule \"" + getName() + "\" cannot apply.", 3);
return false;
}
@@ -372,11 +408,12 @@ public class Rule implements Comparable<Rule>
if (!oneTrigger.applies(null, context))
return false;
}
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format("Rule \"%1$s\" generally applies currently. Checking if it's really due, yet will be done separately.", this.getName()), 3);
return true;
}
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3);
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 4);
return false;
}
@@ -447,7 +484,9 @@ public class Rule implements Comparable<Rule>
{
AutomationService service = AutomationService.getInstance();
service.speak(messages[0], false);
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
if(Settings.showToasts)
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
super.onProgressUpdate(messages);
}
@@ -476,7 +515,7 @@ public class Rule implements Comparable<Rule>
{
boolean isActuallyToggleable = isActuallyToggable();
boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
// boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
boolean doToggle = ruleToggle && isActuallyToggleable;
String message;
@@ -490,6 +529,29 @@ public class Rule implements Comparable<Rule>
if(Settings.startNewThreadForRuleActivation)
publishProgress(message);
/*
Make a note of Rule/CalendarEvent executed combinations
*/
if(Rule.this.hasTriggerOfType(Trigger.Trigger_Enum.calendarEvent))
{
for(CalendarReceiver.CalendarEvent event : CalendarReceiver.getApplyingCalendarEvents(Rule.this))
{
if(!CalendarReceiver.hasEventBeenUsedInRule(Rule.this, event))
{
/*
Record only the first calendar event that matched because the rule may
be executed once for every matching event.
*/
Miscellaneous.logEvent("i", "Rule", "Executing this rule run for calender event: " + event, 5);
CalendarReceiver.addUsedPair(new CalendarReceiver.RuleEventPair(Rule.this, event));
break;
}
}
}
/*
Run actions one after another
*/
for(int i = 0; i< Rule.this.getActionSet().size(); i++)
{
try
@@ -749,4 +811,71 @@ public class Rule implements Comparable<Rule>
return null;
}
@Override
public boolean equals(@Nullable Object obj)
{
return this.getName().equals(((Rule)obj).getName());
}
public boolean hasTriggerOfType(Trigger.Trigger_Enum queryType)
{
for(Trigger t : getTriggerSet())
{
if(t.getTriggerType().equals(queryType))
return true;
}
return false;
}
public boolean hasActionOfType(Action.Action_Enum queryType)
{
for(Action a : getActionSet())
{
if(a.getAction().equals(queryType))
return true;
}
return false;
}
public int getAmountOfTriggersForType(Trigger.Trigger_Enum type)
{
int amount = 0;
for(Trigger t : getTriggerSet())
{
if(t.getTriggerType().equals(type))
amount++;
}
return amount;
}
public int getAmountOfActionsForType(Action.Action_Enum type)
{
int amount = 0;
for(Action a : getActionSet())
{
if(a.getAction().equals(type))
amount++;
}
return amount;
}
public static int getAmountOfActivatedRules()
{
int amount = 0;
for(Rule r : Rule.getRuleCollection())
{
if(r.isRuleActive())
amount++;
}
return amount;
}
}
+1 -4
View File
@@ -1,6 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.jens.automation2">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
+297 -156
View File
@@ -7,10 +7,11 @@ import android.util.Log;
import android.widget.Toast;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.methods.HttpGet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
public class Action
@@ -19,110 +20,121 @@ public class Action
public static final String actionParameter2Split = "ap2split";
public static final String intentPairSeparator = "intPairSplit";
public static final String actionParameters2SeparatorInner = "a2splitInner";
public static final String actionParameters2SeparatorOuter = "a2splitOuter";
public static final String vibrateSeparator = ",";
public static final String httpErrorDefaultText = "HTTP_ERROR";
public enum Action_Enum {
setWifi,
setBluetooth,
setUsbTethering,
setWifiTethering,
setBluetoothTethering,
setDisplayRotation,
turnWifiOn,turnWifiOff,
turnBluetoothOn,turnBluetoothOff,
triggerUrl,
changeSoundProfile,
turnUsbTetheringOn,turnUsbTetheringOff,
turnWifiTetheringOn,turnWifiTetheringOff,
enableScreenRotation,disableScreenRotation,
startOtherActivity,
waitBeforeNextAction,
turnScreenOnOrOff,
setAirplaneMode,
setDataConnection,
speakText,
playMusic,
controlMediaPlayback,
setScreenBrightness,
playSound,
vibrate,
createNotification,
closeNotification,
sendTextMessage;
public String getFullName(Context context)
{
switch(this)
{
case setWifi:
return context.getResources().getString(R.string.actionSetWifi);
case setBluetooth:
return context.getResources().getString(R.string.actionSetBluetooth);
case setWifiTethering:
return context.getResources().getString(R.string.actionSetWifiTethering);
case setBluetoothTethering:
return context.getResources().getString(R.string.actionSetBluetoothTethering);
case setUsbTethering:
return context.getResources().getString(R.string.actionSetUsbTethering);
case setDisplayRotation:
return context.getResources().getString(R.string.actionSetDisplayRotation);
case turnWifiOn:
return context.getResources().getString(R.string.actionTurnWifiOn);
case turnWifiOff:
return context.getResources().getString(R.string.actionTurnWifiOff);
case turnBluetoothOn:
return context.getResources().getString(R.string.actionTurnBluetoothOn);
case turnBluetoothOff:
return context.getResources().getString(R.string.actionTurnBluetoothOff);
case triggerUrl:
return context.getResources().getString(R.string.actionTriggerUrl);
case changeSoundProfile:
return context.getResources().getString(R.string.actionChangeSoundProfile);
case turnUsbTetheringOn:
return context.getResources().getString(R.string.actionTurnUsbTetheringOn);
case turnUsbTetheringOff:
return context.getResources().getString(R.string.actionTurnUsbTetheringOff);
case turnWifiTetheringOn:
return context.getResources().getString(R.string.actionTurnWifiTetheringOn);
case turnWifiTetheringOff:
return context.getResources().getString(R.string.actionTurnWifiTetheringOff);
case enableScreenRotation:
return context.getResources().getString(R.string.actionEnableScreenRotation);
case disableScreenRotation:
return context.getResources().getString(R.string.actionDisableScreenRotation);
case startOtherActivity:
return context.getResources().getString(R.string.startOtherActivity);
case waitBeforeNextAction:
return context.getResources().getString(R.string.waitBeforeNextAction);
case turnScreenOnOrOff:
return context.getResources().getString(R.string.turnScreenOnOrOff);
case vibrate:
return context.getResources().getString(R.string.vibrate);
case setAirplaneMode:
return context.getResources().getString(R.string.airplaneMode);
case setDataConnection:
return context.getResources().getString(R.string.actionDataConnection);
case speakText:
return context.getResources().getString(R.string.actionSpeakText);
case playMusic:
return context.getResources().getString(R.string.actionPlayMusic);
case controlMediaPlayback:
return context.getResources().getString(R.string.actionMediaControl);
case playSound:
return context.getResources().getString(R.string.playSound);
case sendTextMessage:
return context.getResources().getString(R.string.sendTextMessage);
case setScreenBrightness:
return context.getResources().getString(R.string.setScreenBrightness);
case createNotification:
return context.getResources().getString(R.string.createNotification);
case closeNotification:
return context.getResources().getString(R.string.closeNotifications);
default:
return "Unknown";
}
}
};
public enum Action_Enum
{
setWifi,
setBluetooth,
setUsbTethering,
setWifiTethering,
setBluetoothTethering,
setDisplayRotation,
triggerUrl,
changeSoundProfile,
turnUsbTetheringOn,turnUsbTetheringOff,
startOtherActivity,
waitBeforeNextAction,
turnScreenOnOrOff,
setAirplaneMode,
setDataConnection,
speakText,
playMusic,
controlMediaPlayback,
setScreenBrightness,
playSound,
vibrate,
createNotification,
closeNotification,
sendBroadcast,
runExecutable,
wakelock,
setVariable,
startPhoneCall,
stopPhoneCall,
copyToClipboard,
setLocationService,
sendTextMessage,
takeScreenshot;
public String getFullName(Context context)
{
switch(this)
{
case setWifi:
return context.getResources().getString(R.string.actionSetWifi);
case setBluetooth:
return context.getResources().getString(R.string.actionSetBluetooth);
case setWifiTethering:
return context.getResources().getString(R.string.actionSetWifiTethering);
case setBluetoothTethering:
return context.getResources().getString(R.string.actionSetBluetoothTethering);
case setUsbTethering:
return context.getResources().getString(R.string.actionSetUsbTethering);
case setDisplayRotation:
return context.getResources().getString(R.string.actionSetDisplayRotation);
case triggerUrl:
return context.getResources().getString(R.string.actionTriggerUrl);
case changeSoundProfile:
return context.getResources().getString(R.string.actionChangeSoundProfile);
case turnUsbTetheringOn:
return context.getResources().getString(R.string.actionTurnUsbTetheringOn);
case turnUsbTetheringOff:
return context.getResources().getString(R.string.actionTurnUsbTetheringOff);
case startOtherActivity:
return context.getResources().getString(R.string.startOtherActivity);
case waitBeforeNextAction:
return context.getResources().getString(R.string.waitBeforeNextAction);
case turnScreenOnOrOff:
return context.getResources().getString(R.string.turnScreenOnOrOff);
case vibrate:
return context.getResources().getString(R.string.vibrate);
case setAirplaneMode:
return context.getResources().getString(R.string.airplaneMode);
case setDataConnection:
return context.getResources().getString(R.string.actionDataConnection);
case speakText:
return context.getResources().getString(R.string.actionSpeakText);
case playMusic:
return context.getResources().getString(R.string.actionPlayMusic);
case controlMediaPlayback:
return context.getResources().getString(R.string.actionMediaControl);
case playSound:
return context.getResources().getString(R.string.playSound);
case sendTextMessage:
return context.getResources().getString(R.string.sendTextMessage);
case setScreenBrightness:
return context.getResources().getString(R.string.setScreenBrightness);
case createNotification:
return context.getResources().getString(R.string.createNotification);
case closeNotification:
return context.getResources().getString(R.string.closeNotifications);
case sendBroadcast:
return context.getResources().getString(R.string.sendBroadcast);
case runExecutable:
return context.getResources().getString(R.string.runExecutable);
case wakelock:
return context.getResources().getString(R.string.keepDeviceAwake);
case setVariable:
return context.getResources().getString(R.string.setVariable);
case startPhoneCall:
return context.getResources().getString(R.string.startPhoneCall);
case stopPhoneCall:
return context.getResources().getString(R.string.endPhoneCall);
case copyToClipboard:
return context.getResources().getString(R.string.copyTextToClipboard);
case takeScreenshot:
return context.getResources().getString(R.string.takeScreenshot);
case setLocationService:
return context.getResources().getString(R.string.setLocationServiceCapital);
default:
return "Unknown";
}
}
};
private Action_Enum action;
private boolean parameter1 = false;
@@ -258,22 +270,88 @@ public class Action
case closeNotification:
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.closeNotifications));
break;
case sendBroadcast:
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.sendBroadcast));
break;
case runExecutable:
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.runExecutable));
break;
case wakelock:
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.keepDeviceAwake) + " (" + String.valueOf(getParameter1()) + ")");
break;
case setVariable:
String[] variableParams = getParameter2().split(actionParameter2Split);
String addition;
if (variableParams.length >= 2)
addition = " (key: " + variableParams[0] + ", value: " + variableParams[1] + ")";
else
addition = " (delete key: " + variableParams[0] + ")";
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.setVariable) + addition);
break;
case startPhoneCall:
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.startPhoneCall));
break;
case stopPhoneCall:
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.endPhoneCall));
break;
case copyToClipboard:
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.copyTextToClipboard));
break;
case takeScreenshot:
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.takeScreenshot));
break;
case setLocationService:
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.setLocationService) + ": " );
switch(Integer.parseInt(getParameter2()))
{
case android.provider.Settings.Secure.LOCATION_MODE_OFF:
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.off));
break;
case android.provider.Settings.Secure.LOCATION_MODE_SENSORS_ONLY:
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.LOCATION_MODE_SENSOR_ONLY));
break;
case android.provider.Settings.Secure.LOCATION_MODE_BATTERY_SAVING:
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.LOCATION_MODE_BATTERY_SAVING));
break;
case android.provider.Settings.Secure.LOCATION_MODE_HIGH_ACCURACY:
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.LOCATION_MODE_HIGH_ACCURACY));
break;
}
break;
default:
returnString.append(action.toString());
}
if (this.getAction().equals(Action_Enum.triggerUrl))
{
String[] components = parameter2.split(";");
String[] components;
if(parameter2.contains(Action.actionParameter2Split))
components = parameter2.split(Action.actionParameter2Split);
else
components = parameter2.split(";");
if (components.length >= 3)
{
returnString.append(" (");
if(components.length >= 4)
returnString.append(components[3]);
else
returnString.append(ActivityManageActionTriggerUrl.methodGet);
returnString.append(")");
returnString.append(": " + components[2]);
if (parameter1)
returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.usingAuthentication) + ".");
}
else
{
returnString.append(" (");
returnString.append(ActivityManageActionTriggerUrl.methodGet);;
returnString.append(")");
returnString.append(": " + components[0]);
}
}
else if (this.getAction().equals(Action_Enum.startOtherActivity))
{
@@ -316,8 +394,24 @@ public class Action
if (parts.length > 4 && !StringUtils.isBlank(parts[4]))
returnString.append(", " + Miscellaneous.getAnyContext().getResources().getString(R.string.ifString) + " " + Miscellaneous.getAnyContext().getResources().getString(R.string.text) + " " + Trigger.getMatchString(parts[3]) + " " + parts[4]);
if (parts.length >= 6)
{
if (!parts[5].equals(ActivityManageActionCloseNotification.dismissRegularString))
{
returnString.append(" " + String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.withButton), parts[5]));
}
}
}
else if(this.getAction().equals(Action_Enum.controlMediaPlayback))
else if (this.getAction().equals(Action_Enum.setWifi))
{
if (!StringUtils.isEmpty(this.parameter2))
{
boolean useRoot = Boolean.parseBoolean(this.parameter2);
if (useRoot)
returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.usingRoot));
}
}
else if (this.getAction().equals(Action_Enum.controlMediaPlayback))
{
returnString.append(": ");
@@ -345,6 +439,12 @@ public class Action
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.unknown));
}
}
else if (this.getAction().equals(Action_Enum.sendBroadcast))
{
returnString.append(": " + parameter2.replace(Action.actionParameter2Split, "; ").replace(Action.intentPairSeparator, "/"));
}
else if(this.getAction().equals(Action_Enum.setVariable) || this.getAction().equals(Action_Enum.copyToClipboard) || this.getAction().equals(Action_Enum.setLocationService))
; // it's completed further above already
else if (parameter2 != null && parameter2.length() > 0)
returnString.append(": " + parameter2.replace(Action.actionParameter2Split, "; "));
}
@@ -373,25 +473,9 @@ public class Action
for(Action_Enum action : Action_Enum.values())
{
if( // exclusion for deprecated types
!action.toString().equals("turnWifiOn")
&&
!action.toString().equals("turnWifiOff")
&&
!action.toString().equals("turnBluetoothOn")
&&
!action.toString().equals("turnBluetoothOff")
&&
!action.toString().equals("turnUsbTetheringOn")
&&
!action.toString().equals("turnUsbTetheringOff")
&&
!action.toString().equals("turnWifiTetheringOn")
&&
!action.toString().equals("turnWifiTetheringOff")
&&
!action.toString().equals("enableScreenRotation")
&&
!action.toString().equals("disableScreenRotation")
) // exclusion for deprecated types
actionTypesList.add(action.toString());
}
@@ -405,32 +489,16 @@ public class Action
for(Action_Enum action : Action_Enum.values())
{
if( // exclusion for deprecated types
!action.toString().equals("turnWifiOn")
&&
!action.toString().equals("turnWifiOff")
&&
!action.toString().equals("turnBluetoothOn")
&&
!action.toString().equals("turnBluetoothOff")
&&
!action.toString().equals("turnUsbTetheringOn")
&&
!action.toString().equals("turnUsbTetheringOff")
&&
!action.toString().equals("turnWifiTetheringOn")
&&
!action.toString().equals("turnWifiTetheringOff")
&&
!action.toString().equals("enableScreenRotation")
&&
!action.toString().equals("disableScreenRotation")
) // exclusion for deprecated types
actionTypesList.add(action.getFullName(context));
}
return (String[])actionTypesList.toArray(new String[actionTypesList.size()]);
}
public void run(Context context, boolean toggleActionIfPossible)
{
try
@@ -458,7 +526,7 @@ public class Action
Actions.setUsbTethering(context, getParameter1(), toggleActionIfPossible);
break;
case setWifi:
Actions.WifiStuff.setWifi(context, getParameter1(), toggleActionIfPossible);
Actions.WifiStuff.setWifi(context, getParameter1(), getParameter2(), toggleActionIfPossible);
break;
case setWifiTethering:
Actions.setWifiTethering(context, getParameter1(), toggleActionIfPossible);
@@ -533,6 +601,40 @@ public class Action
else
Miscellaneous.logEvent("w", "Close notification", "Close notification was requested, but OS version is too low: " + String.valueOf(Build.VERSION.SDK_INT), 2);
break;
case sendBroadcast:
Actions.sendBroadcast(context, this.getParameter2());
break;
case runExecutable:
String[] execParts = this.getParameter2().split(Action.actionParameter2Split);
if(execParts.length == 1)
Actions.runExecutable(context, this.getParameter1(), execParts[0], null);
else if(execParts.length == 2)
Actions.runExecutable(context, this.getParameter1(), execParts[0], execParts[1]);
break;
case wakelock:
if(this.getParameter1())
Actions.wakeLockStart(context, Long.parseLong(this.getParameter2()));
else
Actions.wakeLockStop();
break;
case setVariable:
Actions.setVariable(this.getParameter2());
break;
case startPhoneCall:
Actions.startPhoneCall(context, this.getParameter2());
break;
case stopPhoneCall:
Actions.endPhoneCall(context);
break;
case copyToClipboard:
Actions.copyToClipboard(context, Miscellaneous.replaceVariablesInText(this.getParameter2(), context));
break;
case takeScreenshot:
Actions.takeScreenshot();
break;
case setLocationService:
Actions.setLocationService(Integer.parseInt(this.getParameter2()), AutomationService.getInstance());
break;
default:
Miscellaneous.logEvent("w", "Action", context.getResources().getString(R.string.unknownActionSpecified), 3);
break;
@@ -546,34 +648,55 @@ public class Action
}
private void triggerUrl(Context context)
{
{
//TODO: Check if data needs to be escaped
String username = null;
String password = null;
String method = ActivityManageActionTriggerUrl.methodGet;
String url;
String params = null;
String[] components = getParameter2().split(";");
String[] components;
if(getParameter2().contains(Action.actionParameter2Split))
components = getParameter2().split(Action.actionParameter2Split, -1);
else
components = getParameter2().split(";", -1);
if(components.length >= 3)
{
username = components[0];
password = components[1];
url = components[2];
if(components.length >= 4)
method = components[3];
if(components.length >= 5)
{
params = components[4];
}
}
else
else // compatibility for very old versions which haven't upgraded, yet.
url = components[0];
try
{
url = Miscellaneous.replaceVariablesInText(url, context);
if(!StringUtils.isEmpty(params))
params = Miscellaneous.replaceVariablesInText(params, context);
Actions myAction = new Actions();
Miscellaneous.logEvent("i", "HTTP", "Attempting download of " + url, 4); //getResources().getString("attemptingDownloadOf");
/*
Theoretically credentials could be saved, but authentication has been turned off afterwards.
The following if clause is there to force username and password to be null.
*/
if(this.getParameter1()) // use authentication
new DownloadTask().execute(url, username, password);
new DownloadTask().execute(url, username, password, method, params);
else
new DownloadTask().execute(url, null, null);
new DownloadTask().execute(url, null, null, method, params);
}
catch(Exception e)
{
@@ -588,32 +711,50 @@ public class Action
{
Thread.setDefaultUncaughtExceptionHandler(Miscellaneous.uncaughtExceptionHandler);
int attempts=1;
int attempts = 1;
String urlString=parameters[0];
String urlUsername = null;
String urlPassword = null;
String method = ActivityManageActionTriggerUrl.methodGet;
Map<String,String> httpParams = new HashMap<>();
if(parameters.length >= 3)
{
urlUsername=parameters[1];
urlPassword=parameters[2];
urlUsername = parameters[1];
urlPassword = parameters[2];
if(parameters.length >= 4)
method = parameters[3];
if(parameters.length >= 5 && parameters[4] != null)
{
// has params
String[] paramPairs = parameters[4].split(Action.actionParameters2SeparatorOuter);
for(String pair : paramPairs)
{
String[] pieces = pair.split(Action.actionParameters2SeparatorInner);
if(pieces.length == 2)
httpParams.put(pieces[0], pieces[1]);
}
}
}
String response = "httpError";
HttpGet post;
if(Settings.httpAttempts < 1)
String response = httpErrorDefaultText;
if(Settings.httpAttempts < 1)
Miscellaneous.logEvent("w", "HTTP Request", Miscellaneous.getAnyContext().getResources().getString(R.string.cantDownloadTooFewRequestsInSettings), 3);
while(attempts <= Settings.httpAttempts && response.equals("httpError"))
while(attempts <= Settings.httpAttempts && response.equals(httpErrorDefaultText))
{
Miscellaneous.logEvent("i", "HTTP Request", "Attempt " + String.valueOf(attempts++) + " of " + String.valueOf(Settings.httpAttempts), 3);
// Either thorough checking or no encryption
if(!Settings.httpAcceptAllCertificates || !urlString.toLowerCase(Locale.getDefault()).contains("https"))
response = Miscellaneous.downloadURL(urlString, urlUsername, urlPassword);
response = Miscellaneous.downloadURL(urlString, urlUsername, urlPassword, method, httpParams);
else
response = Miscellaneous.downloadURLwithoutCertificateChecking(urlString, urlUsername, urlPassword);
response = Miscellaneous.downloadUrlWithoutCertificateChecking(urlString, urlUsername, urlPassword, method, httpParams);
try
{
@@ -636,7 +777,7 @@ public class Action
//Do something with result
//Toast.makeText(context, text, duration) result;
Miscellaneous.logEvent("i", "HTTP RESULT", result, 3);
Actions myAction=new Actions();
Actions myAction = new Actions();
myAction.useDownloadedWebpage(result);
}
}
File diff suppressed because it is too large Load Diff
@@ -8,6 +8,7 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
@@ -39,8 +40,11 @@ public class ActivityControlCenter extends Activity
protected void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.activity_control_center);
bVolumeTest = (Button) findViewById(R.id.bVolumeTest);
bVolumeTest.setOnClickListener(new View.OnClickListener()
{
@@ -96,8 +100,17 @@ public class ActivityControlCenter extends Activity
@Override
public void onClick(View v)
{
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intent, requestCodeImport);
AlertDialog dialog = Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.importChooseFolderNotice), ActivityControlCenter.this);
dialog.setOnDismissListener(new DialogInterface.OnDismissListener()
{
@Override
public void onDismiss(DialogInterface dialogInterface)
{
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intent, requestCodeImport);
}
});
dialog.show();
}
});
@@ -222,6 +235,10 @@ public class ActivityControlCenter extends Activity
}
Settings.readFromPersistentStorage(ActivityControlCenter.this);
AutomationService service = AutomationService.getInstance();
if(service != null && service.isRunning)
service.applySettingsAndRules();
}
else
Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.noFilesImported), Toast.LENGTH_LONG).show();
@@ -342,15 +359,22 @@ public class ActivityControlCenter extends Activity
public static String getSystemInfo()
{
StringBuilder systemInfoText = new StringBuilder();
systemInfoText.append("App details" + Miscellaneous.lineSeparator);
systemInfoText.append("Version name: " + BuildConfig.VERSION_NAME + Miscellaneous.lineSeparator);
systemInfoText.append("Version code: " + BuildConfig.VERSION_CODE + Miscellaneous.lineSeparator);
systemInfoText.append("Flavor: " + BuildConfig.FLAVOR + Miscellaneous.lineSeparator);
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);
systemInfoText.append("Flavor: " + BuildConfig.FLAVOR + Miscellaneous.lineSeparator);
systemInfoText.append("Rooted: " + String.valueOf(Miscellaneous.isPhoneRooted()) + Miscellaneous.lineSeparator);
systemInfoText.append("Country: " + Miscellaneous.getUserCountry(Miscellaneous.getAnyContext()) + Miscellaneous.lineSeparator);
systemInfoText.append("OS language: " + Locale.getDefault().getDisplayName());
systemInfoText.append("OS language: " + Locale.getDefault().getDisplayName() + Miscellaneous.lineSeparator);
systemInfoText.append("Logfile written: " + String.valueOf(Settings.writeLogFile) + Miscellaneous.lineSeparator);
systemInfoText.append("Log level: " + String.valueOf(Settings.logLevel));
/*
I've checked the Locale methods on my Android 4.1.2 device, and the results:
@@ -373,6 +397,7 @@ public class ActivityControlCenter extends Activity
protected void onResume()
{
super.onResume();
Miscellaneous.setDisplayLanguage(this);
String folder = Miscellaneous.getWriteableFolder();
if (folder != null && folder.length() > 0)
@@ -21,6 +21,8 @@ public class ActivityDisplayLongMessage extends Activity
protected void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.activity_display_long_message);
tvMessageTitle = (TextView)findViewById(R.id.tvMessageTitle);
@@ -13,7 +13,9 @@ public class ActivityHelp extends Activity
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(layout.help_text);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(layout.activity_help_text);
TextView tvHelpTextEnergySaving = (TextView) findViewById(R.id.tvHelpTextEnergySaving);
tvHelpTextEnergySaving.setMovementMethod(LinkMovementMethod.getInstance());
@@ -44,6 +44,8 @@ public class ActivityMainPoi extends ActivityGeneric
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.main_poi_layout);
instance = this;
@@ -107,6 +109,13 @@ public class ActivityMainPoi extends ActivityGeneric
this.storeServiceReferenceInVariable();
}
@Override
protected void onResume()
{
super.onResume();
Miscellaneous.setDisplayLanguage(this);
}
private void buttonAddPoi()
{
poiToEdit = null;
@@ -190,8 +199,27 @@ public class ActivityMainPoi extends ActivityGeneric
startActivityForResult(manageSpecificPoiIntent, 2000);
break;
case 1:
if(pointOfInterest.delete(Miscellaneous.getAnyContext()))
updateListView();
AlertDialog.Builder deleteDialog = new AlertDialog.Builder(ActivityMainPoi.this);
deleteDialog.setMessage(getResources().getString(R.string.areYouSure));
deleteDialog.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialogInterface, int i)
{
if(pointOfInterest.delete(Miscellaneous.getAnyContext()))
updateListView();
}
});
deleteDialog.setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialogInterface, int i)
{
}
});
deleteDialog.show();
break;
}
}
@@ -40,6 +40,8 @@ public class ActivityMainProfiles extends ActivityGeneric
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.main_profile_layout);
instance = this;
@@ -154,6 +156,13 @@ public class ActivityMainProfiles extends ActivityGeneric
}
}
@Override
protected void onResume()
{
super.onResume();
Miscellaneous.setDisplayLanguage(this);
}
private AlertDialog getProfileDialog(final Profile profile)
{
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
@@ -187,10 +196,29 @@ public class ActivityMainProfiles extends ActivityGeneric
Rule user = profile.isInUseByRules();
if(user == null)
{
if (profile.delete(ActivityMainProfiles.this))
updateListView();
else
Toast.makeText(ActivityMainProfiles.this, getResources().getString(R.string.profileCouldNotBeDeleted), Toast.LENGTH_LONG).show();
AlertDialog.Builder deleteDialog = new AlertDialog.Builder(ActivityMainProfiles.this);
deleteDialog.setMessage(getResources().getString(R.string.areYouSure));
deleteDialog.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialogInterface, int i)
{
if (profile.delete(ActivityMainProfiles.this))
updateListView();
else
Toast.makeText(ActivityMainProfiles.this, getResources().getString(R.string.profileCouldNotBeDeleted), Toast.LENGTH_LONG).show();
}
});
deleteDialog.setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialogInterface, int i)
{
}
});
deleteDialog.show();
}
else
Toast.makeText(ActivityMainProfiles.this, String.format(getResources().getString(R.string.ruleXIsUsingProfileY), user.getName(), profile.getName()), Toast.LENGTH_LONG).show();
@@ -18,6 +18,7 @@ import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.jens.automation2.AutomationService.serviceCommands;
import com.jens.automation2.receivers.DateTimeListener;
@@ -25,6 +26,7 @@ import java.util.ArrayList;
public class ActivityMainRules extends ActivityGeneric
{
public static final String intentNameRuleName = "ruleName";
private ListView ruleListView;
ArrayList<Rule> ruleList = new ArrayList<>();
private ArrayAdapter<Rule> ruleListViewAdapter;
@@ -45,7 +47,9 @@ public class ActivityMainRules extends ActivityGeneric
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.main_rule_layout);
instance = this;
@@ -151,6 +155,13 @@ public class ActivityMainRules extends ActivityGeneric
return v;
}
}
@Override
protected void onResume()
{
super.onResume();
Miscellaneous.setDisplayLanguage(this);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
@@ -186,7 +197,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)
@@ -207,18 +225,50 @@ public class ActivityMainRules extends ActivityGeneric
Toast.makeText(ActivityMainRules.this, getResources().getString(R.string.serviceHasToRunForThat), Toast.LENGTH_LONG).show();
break;
case 1:
ruleToEdit = ruleThisIsAbout;
Intent manageSpecificRuleIntent = new Intent (ActivityMainRules.this, ActivityManageRule.class);
manageSpecificRuleIntent.putExtra(intentNameRuleName, ruleThisIsAbout.getName());
startActivityForResult(manageSpecificRuleIntent, requestCodeChangeRule);
break;
case 2:
if(ruleThisIsAbout.delete())
AlertDialog.Builder deleteDialog = new AlertDialog.Builder(ActivityMainRules.this);
deleteDialog.setMessage(getResources().getString(R.string.areYouSure));
deleteDialog.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialogInterface, int i)
{
if(ruleThisIsAbout.delete())
{
ruleToEdit = null; //clear cache
updateListView();
}
}
});
deleteDialog.setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialogInterface, int i)
{
}
});
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 3:
case 4:
ruleToEdit = ruleThisIsAbout;
if(ruleToEdit.cloneRule(ActivityMainRules.this))
{
@@ -251,15 +301,5 @@ public class ActivityMainRules extends ActivityGeneric
}
catch(NullPointerException e)
{}
try
{
if(AutomationService.isMyServiceRunning(this))
DateTimeListener.reloadAlarms();
}
catch(NullPointerException e)
{
// AlarmManager instance not prepared, yet.
}
}
}
@@ -6,9 +6,13 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
@@ -31,6 +35,7 @@ import com.jens.automation2.location.LocationProvider;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
@SuppressLint("NewApi")
public class ActivityMainScreen extends ActivityGeneric
@@ -42,7 +47,7 @@ public class ActivityMainScreen extends ActivityGeneric
ToggleButton toggleService, tbLockSound;
Button bShowHelp, bPrivacy, bAddSoundLockTIme, bDonate, bControlCenter;
TextView tvActivePoi, tvClosestPoi, tvLastRule, tvLastProfile, tvMainScreenNotePermissions, tvMainScreenNoteFeaturesFromOtherFlavor, tvMainScreenNoteLocationImpossibleBlameGoogle, tvMainScreenNoteNews, tvLockSoundDuration;
TextView tvActivePoi, tvClosestPoi, tvLastRule, tvLastProfile, tvMainScreenNotePermissions, tvMainScreenNoteFeaturesFromOtherFlavor, tvMainScreenNoteLocationImpossibleBlameGoogle, tvMainScreenNoteNews, tvLockSoundDuration, tvContactNotice;
ListView lvRuleHistory;
ArrayAdapter<Rule> ruleHistoryListViewAdapter;
@@ -51,6 +56,8 @@ public class ActivityMainScreen extends ActivityGeneric
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.main_overview_layout);
activityMainScreenInstance = this;
@@ -77,12 +84,15 @@ public class ActivityMainScreen extends ActivityGeneric
tvLockSoundDuration = (TextView)findViewById(R.id.tvlockSoundDuration);
tbLockSound = (ToggleButton) findViewById(R.id.tbLockSound);
toggleService = (ToggleButton) findViewById(R.id.tbArmMastListener);
bDonate = (Button)findViewById(R.id.bDonate);
tvContactNotice = (TextView) findViewById(R.id.tvContactNotice);
if(!BuildConfig.FLAVOR.equalsIgnoreCase("googlePlayFlavor"))
if(!BuildConfig.FLAVOR.equalsIgnoreCase(AutomationService.flavor_name_googleplay))
bDonate.setVisibility(View.VISIBLE);
// Make links clickable
tvContactNotice.setMovementMethod(LinkMovementMethod.getInstance());
toggleService.setChecked(AutomationService.isMyServiceRunning(this));
toggleService.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
@@ -118,9 +128,9 @@ public class ActivityMainScreen extends ActivityGeneric
@Override
public void onClick(View v)
{
String privacyPolicyUrl = "https://server47.de/donate";
String donationUrl = "https://server47.de/donate";
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(privacyPolicyUrl));
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(donationUrl));
startActivity(browserIntent);
}
});
@@ -271,9 +281,14 @@ public class ActivityMainScreen extends ActivityGeneric
activityMainScreenInstance.tvMainScreenNotePermissions.setVisibility(View.GONE);
}
if(Miscellaneous.restrictedFeaturesConfigured())
if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_fdroid) && Miscellaneous.restrictedFeaturesConfiguredFdroid())
{
activityMainScreenInstance.tvMainScreenNoteFeaturesFromOtherFlavor.setText(R.string.settingsReferringToRestrictedFeatures);
activityMainScreenInstance.tvMainScreenNoteFeaturesFromOtherFlavor.setText(R.string.settingsReferringToRestrictedFeaturesInFdroid);
activityMainScreenInstance.tvMainScreenNoteFeaturesFromOtherFlavor.setVisibility(View.VISIBLE);
}
else if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_googleplay) && Miscellaneous.restrictedFeaturesConfiguredGoogle())
{
activityMainScreenInstance.tvMainScreenNoteFeaturesFromOtherFlavor.setText(R.string.settingsReferringToRestrictedFeaturesInGoogle);
activityMainScreenInstance.tvMainScreenNoteFeaturesFromOtherFlavor.setVisibility(View.VISIBLE);
}
else
@@ -284,14 +299,6 @@ public class ActivityMainScreen extends ActivityGeneric
if(Miscellaneous.googleToBlameForLocation(true))
{
// Intent intent = new Intent(AutomationService.this, ActivityDisplayLongMessage.class);
// intent.putExtra("longMessage", getResources().getString(R.string.locationEngineDisabledLong));
// PendingIntent pi = PendingIntent.getActivity(AutomationService.this, 0, intent, 0);
// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1)
// Miscellaneous.createDismissableNotificationWithDelay(2200, getResources().getString(R.string.featuresDisabled), notificationIdLocationRestriction, pi);
// else
// Miscellaneous.createDismissableNotification(getResources().getString(R.string.featuresDisabled), notificationIdLocationRestriction, pi);
activityMainScreenInstance.tvMainScreenNoteLocationImpossibleBlameGoogle.setText(R.string.locationEngineDisabledShort);
activityMainScreenInstance.tvMainScreenNoteLocationImpossibleBlameGoogle.setVisibility(View.VISIBLE);
activityMainScreenInstance.tvMainScreenNoteLocationImpossibleBlameGoogle.setOnClickListener(new OnClickListener()
@@ -316,8 +323,7 @@ public class ActivityMainScreen extends ActivityGeneric
uiUpdateRunning = true;
activityMainScreenInstance.toggleService.setChecked(true);
uiUpdateRunning = false;
// if(activityMainScreenInstance.hasWindowFocus())
// {
try
{
PointOfInterest activePoi = PointOfInterest.getActivePoi();
@@ -434,7 +440,7 @@ public class ActivityMainScreen extends ActivityGeneric
else
activityMainScreenInstance.checkForNews();
if(BuildConfig.FLAVOR.equals("apkFlavor") && Settings.automaticUpdateCheck)
if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_apk) && Settings.automaticUpdateCheck)
{
Calendar now = Calendar.getInstance();
if (Settings.lastUpdateCheck == Settings.default_lastUpdateCheck || now.getTimeInMillis() >= Settings.lastUpdateCheck + (long)(Settings.updateCheckFrequencyDays * 24 * 60 * 60 * 1000))
@@ -526,15 +532,30 @@ public class ActivityMainScreen extends ActivityGeneric
{
if (Rule.getRuleCollection().size() > 0)
{
if(Rule.getAmountOfActivatedRules() == 0)
{
Toast.makeText(context, context.getResources().getString(R.string.serviceWontStartNoActivatedRules), Toast.LENGTH_LONG).show();
activityMainScreenInstance.toggleService.setChecked(false);
return;
}
if(Miscellaneous.getTargetSDK(Miscellaneous.getAnyContext()) >= 34 && !ActivityPermissions.havePermission(Manifest.permission.FOREGROUND_SERVICE_SPECIAL_USE, context))
{
Toast.makeText(context, context.getResources().getString(R.string.permissionForegroundServiceTypeSpecialUseRequired), Toast.LENGTH_LONG).show();
activityMainScreenInstance.toggleService.setChecked(false);
return;
}
if (!AutomationService.isMyServiceRunning(context))
{
// if(myServiceIntent == null) //do we need that line?????
myServiceIntent = new Intent(context, AutomationService.class);
myServiceIntent.putExtra("startAtBoot", startAtBoot);
context.startService(myServiceIntent);
} else
}
else
Miscellaneous.logEvent("w", "Service", context.getResources().getString(R.string.logServiceAlreadyRunning), 3);
} else
}
else
{
Toast.makeText(context, context.getResources().getString(R.string.serviceWontStart), Toast.LENGTH_LONG).show();
activityMainScreenInstance.toggleService.setChecked(false);
@@ -571,6 +592,7 @@ public class ActivityMainScreen extends ActivityGeneric
protected void onResume()
{
super.onResume();
Miscellaneous.setDisplayLanguage(this);
toggleService.setChecked(AutomationService.isMyServiceRunning(this));
ActivityMainScreen.updateMainScreen();
@@ -581,7 +603,7 @@ public class ActivityMainScreen extends ActivityGeneric
Miscellaneous.messageBox(getResources().getString(R.string.app_name), getResources().getString(R.string.android9RecordAudioNotice) + " " + getResources().getString(R.string.messageNotShownAgain), ActivityMainScreen.this).show();
}
if(Build.VERSION.SDK_INT >= 29 && !Settings.noticeAndroid10WifiShown && Rule.isAnyRuleUsing(Action.Action_Enum.setWifi))
if(Miscellaneous.getTargetSDK(ActivityMainScreen.this) >= 29 && !Settings.noticeAndroid10WifiShown && Rule.isAnyRuleUsing(Action.Action_Enum.setWifi))
{
Settings.noticeAndroid10WifiShown = true;
Settings.writeSettings(ActivityMainScreen.this);
@@ -3,12 +3,17 @@ package com.jens.automation2;
import android.annotation.SuppressLint;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import com.jens.automation2.receivers.NfcReceiver;
import java.util.Locale;
@SuppressLint("NewApi")
public class ActivityMainTabLayout extends TabActivity
@@ -17,8 +22,9 @@ public class ActivityMainTabLayout extends TabActivity
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Settings.readFromPersistentStorage(ActivityMainTabLayout.this);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
if(Settings.tabsPlacement == 1)
setContentView(R.layout.main_tab_layout_tabs_at_bottom);
@@ -60,6 +66,7 @@ public class ActivityMainTabLayout extends TabActivity
protected void onResume()
{
super.onResume();
Miscellaneous.setDisplayLanguage(this);
// Miscellaneous.logEvent("i", "NFC", "ActivityMainTabLayout.onResume().", 5);
NfcReceiver.checkIntentForNFC(this, getIntent());
// NfcReceiver.checkIntentForNFC(this, new Intent(this.getApplicationContext(), this.getClass()));
@@ -26,6 +26,8 @@ public class ActivityManageActionBrightnessSetting extends Activity
protected void onCreate(@Nullable Bundle savedInstanceState)
{
setContentView(R.layout.activity_manage_action_brightness_settings);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
super.onCreate(savedInstanceState);
chkAutoBrightness = (CheckBox)findViewById(R.id.chkAutoBrightness);
@@ -1,7 +1,5 @@
package com.jens.automation2;
import static com.jens.automation2.Trigger.triggerParameter2Split;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
@@ -18,11 +16,12 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import org.apache.commons.lang3.StringUtils;
@@ -43,13 +42,15 @@ public class ActivityManageActionCloseNotification extends Activity
boolean edit = false;
ProgressDialog progressDialog = null;
EditText etNotificationTitle, etNotificationText;
EditText etNotificationTitle, etNotificationText, etNotificationDismissalButtonText;
Button bSelectApp, bSaveActionCloseNotification;
Spinner spinnerTitleDirection, spinnerTextDirection;
TextView tvSelectedApplication;
RadioButton rbNotificationDismissSimple, rbNotificationDismissButton;
private static List<PackageInfo> pInfos = null;
public static Trigger resultingTrigger;
final static String dismissRegularString = "p0815DismissString";
private static String[] directions;
@@ -258,6 +259,8 @@ public class ActivityManageActionCloseNotification extends Activity
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.activity_manage_action_close_notification);
etNotificationTitle = (EditText)findViewById(R.id.etNotificationTitle);
@@ -267,10 +270,14 @@ public class ActivityManageActionCloseNotification extends Activity
spinnerTitleDirection = (Spinner)findViewById(R.id.spinnerTitleDirection);
spinnerTextDirection = (Spinner)findViewById(R.id.spinnerTextDirection);
tvSelectedApplication = (TextView)findViewById(R.id.etActivityOrActionPath);
etNotificationDismissalButtonText = (EditText)findViewById(R.id.etNotificationDismissalButtonText);
rbNotificationDismissSimple = (RadioButton)findViewById(R.id.rbNotificationDismissSimple);
rbNotificationDismissButton = (RadioButton)findViewById(R.id.rbNotificationDismissButton);
directions = new String[] {
getResources().getString(R.string.directionStringEquals),
getResources().getString(R.string.directionStringContains),
getResources().getString(R.string.directionStringDoesNotContain),
getResources().getString(R.string.directionStringStartsWith),
getResources().getString(R.string.directionStringEndsWith),
getResources().getString(R.string.directionStringNotEquals)
@@ -298,7 +305,7 @@ public class ActivityManageActionCloseNotification extends Activity
public void onClick(View v)
{
String app;
if(tvSelectedApplication.getText().toString().equalsIgnoreCase(getResources().getString(R.string.anyApp)))
if (tvSelectedApplication.getText().toString().equalsIgnoreCase(getResources().getString(R.string.anyApp)))
app = Trigger.anyAppString;
else
app = tvSelectedApplication.getText().toString();
@@ -309,34 +316,44 @@ public class ActivityManageActionCloseNotification extends Activity
String text = etNotificationText.getText().toString();
Intent responseData = new Intent();
if(edit)
{
// editedNotificationAction.setTriggerParameter(chkNotificationDirection.isChecked());
responseData.putExtra(ActivityManageRule.intentNameActionParameter2, app + Action.actionParameter2Split + titleDir + Action.actionParameter2Split + title + Action.actionParameter2Split + textDir + Action.actionParameter2Split + text);
ActivityManageActionCloseNotification.this.setResult(RESULT_OK, responseData);
}
String dismissMethod;
if (rbNotificationDismissSimple.isChecked())
dismissMethod = dismissRegularString;
else
{
// data.putExtra(intentNameNotificationDirection, chkNotificationDirection.isChecked());
responseData.putExtra(ActivityManageRule.intentNameActionParameter2,
app + Action.actionParameter2Split +
titleDir + Action.actionParameter2Split +
title + Action.actionParameter2Split +
textDir + Action.actionParameter2Split +
text
);
// data.putExtra(intentNameNotificationApp, app);
// data.putExtra(intentNameNotificationTitleDir, titleDir);
// data.putExtra(intentNameNotificationTitle, title);
// data.putExtra(intentNameNotificationTextDir, textDir);
// data.putExtra(intentNameNotificationText, text);
ActivityManageActionCloseNotification.this.setResult(RESULT_OK, responseData);
if(StringUtils.isEmpty(etNotificationDismissalButtonText.getText().toString()))
{
Toast.makeText(ActivityManageActionCloseNotification.this, getResources().getString(R.string.enterText), Toast.LENGTH_LONG).show();
return;
}
else
dismissMethod = etNotificationDismissalButtonText.getText().toString();
}
responseData.putExtra(ActivityManageRule.intentNameActionParameter2,
app + Action.actionParameter2Split +
titleDir + Action.actionParameter2Split +
title + Action.actionParameter2Split +
textDir + Action.actionParameter2Split +
text + Action.actionParameter2Split +
dismissMethod
);
ActivityManageActionCloseNotification.this.setResult(RESULT_OK, responseData);
finish();
}
});
rbNotificationDismissSimple.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b)
{
etNotificationDismissalButtonText.setEnabled(!b);
}
});
Intent i = getIntent();
if(!StringUtils.isBlank(i.getStringExtra(ActivityManageRule.intentNameActionParameter2)))
{
@@ -359,6 +376,24 @@ public class ActivityManageActionCloseNotification extends Activity
else
text = "";
/*
That's not reliable, yet. Last parameter may be empty, hence the method might
be incorrectly interpreted as a text notification text.
*/
if (params.length >= 6 && !params[5].equals(dismissRegularString))
{
rbNotificationDismissButton.setChecked(true);
etNotificationDismissalButtonText.setText(params[5]);
etNotificationDismissalButtonText.setEnabled(true);
}
else
{
rbNotificationDismissSimple.setChecked(true);
etNotificationDismissalButtonText.setText("");
etNotificationDismissalButtonText.setEnabled(false);
}
if(!app.equals(Trigger.anyAppString))
tvSelectedApplication.setText(app);
@@ -19,6 +19,8 @@ public class ActivityManageActionControlMedia extends Activity
protected void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.activity_manage_action_control_media);
rbMediaPlayPause = (RadioButton)findViewById(R.id.rbMediaPlayPause);
@@ -0,0 +1,54 @@
package com.jens.automation2;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import org.apache.commons.lang3.StringUtils;
public class ActivityManageActionCopyToClipboard extends Activity
{
private Button bSaveCopyToClipboard;
private EditText etCopyToClipboard;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
this.setContentView(R.layout.activity_manage_action_copy_to_clipboard);
bSaveCopyToClipboard = (Button) findViewById(R.id.bSaveCopyToClipboard);
etCopyToClipboard = (EditText)findViewById(R.id.etCopyToClipboard);
bSaveCopyToClipboard.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
if(StringUtils.isEmpty(etCopyToClipboard.getText().toString()))
{
Toast.makeText(ActivityManageActionCopyToClipboard.this, getResources().getString(R.string.enterText), Toast.LENGTH_SHORT).show();
}
else
{
Intent response = new Intent();
response.putExtra(ActivityManageRule.intentNameActionParameter2, etCopyToClipboard.getText().toString());
setResult(RESULT_OK, response);
finish();
}
}
});
if(getIntent().hasExtra(ActivityManageRule.intentNameActionParameter2))
{
String text = getIntent().getStringExtra(ActivityManageRule.intentNameActionParameter2);
etCopyToClipboard.setText(text);
}
}
}
@@ -24,6 +24,8 @@ public class ActivityManageActionCreateNotification extends Activity
protected void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.activity_manage_action_create_notification);
etNotificationTitle = (EditText) findViewById(R.id.etNotificationTitle);
@@ -0,0 +1,76 @@
package com.jens.automation2;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import androidx.annotation.Nullable;
public class ActivityManageActionLocationService extends Activity
{
RadioButton rbActionLocationServiceOff, rbActionLocationServiceSensorsOnly, rbActionLocationServiceBatterySaving, rbActionLocationServiceHighAccuracy;
Button bActionSetLocationServiceSave;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.activity_manage_action_location_service);
rbActionLocationServiceOff = (RadioButton) findViewById(R.id.rbActionLocationServiceOff);
rbActionLocationServiceSensorsOnly = (RadioButton)findViewById(R.id.rbActionLocationServiceSensorsOnly);
rbActionLocationServiceBatterySaving = (RadioButton)findViewById(R.id.rbActionLocationServiceBatterySaving);
rbActionLocationServiceHighAccuracy = (RadioButton)findViewById(R.id.rbActionLocationServiceHighAccuracy);
bActionSetLocationServiceSave = (Button) findViewById(R.id.bActionSetLocationServiceSave);
Intent input = getIntent();
if(input.hasExtra(ActivityManageRule.intentNameActionParameter2))
{
String[] params = input.getStringExtra(ActivityManageRule.intentNameActionParameter2).split(Action.actionParameter2Split);
int desiredState = Integer.parseInt(params[0]);
switch(desiredState)
{
case Settings.Secure.LOCATION_MODE_OFF:
rbActionLocationServiceOff.setChecked(true);
break;
case Settings.Secure.LOCATION_MODE_SENSORS_ONLY:
rbActionLocationServiceSensorsOnly.setChecked(true);
break;
case Settings.Secure.LOCATION_MODE_BATTERY_SAVING:
rbActionLocationServiceBatterySaving.setChecked(true);
break;
case Settings.Secure.LOCATION_MODE_HIGH_ACCURACY:
rbActionLocationServiceHighAccuracy.setChecked(true);
break;
}
}
bActionSetLocationServiceSave.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
Intent response = new Intent();
if(rbActionLocationServiceOff.isChecked())
response.putExtra(ActivityManageRule.intentNameActionParameter2, String.valueOf(Settings.Secure.LOCATION_MODE_OFF));
else if(rbActionLocationServiceSensorsOnly.isChecked())
response.putExtra(ActivityManageRule.intentNameActionParameter2, String.valueOf(Settings.Secure.LOCATION_MODE_SENSORS_ONLY));
else if(rbActionLocationServiceBatterySaving.isChecked())
response.putExtra(ActivityManageRule.intentNameActionParameter2, String.valueOf(Settings.Secure.LOCATION_MODE_BATTERY_SAVING));
else
response.putExtra(ActivityManageRule.intentNameActionParameter2, String.valueOf(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY));
setResult(RESULT_OK, response);
finish();
}
});
}
}
@@ -0,0 +1,56 @@
package com.jens.automation2;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;
public class ActivityManageActionMakePhoneCall extends Activity
{
EditText etTargetPhoneNumber;
Button bActionMakePhoneCallSave;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.activity_manage_action_make_phone_call);
etTargetPhoneNumber = (EditText)findViewById(R.id.etTargetPhoneNumber);
bActionMakePhoneCallSave = (Button) findViewById(R.id.bActionMakePhoneCallSave);
Intent input = getIntent();
/*if(input.hasExtra(ActivityManageRule.intentNameActionParameter1))
rbActionWifiOn.setChecked(input.getBooleanExtra(ActivityManageRule.intentNameActionParameter1, true));
*/
if(input.hasExtra(ActivityManageRule.intentNameActionParameter2))
etTargetPhoneNumber.setText(input.getStringExtra(ActivityManageRule.intentNameActionParameter2));
bActionMakePhoneCallSave.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
if(!StringUtils.isEmpty(etTargetPhoneNumber.getText()))
{
Intent response = new Intent();
response.putExtra(ActivityManageRule.intentNameActionParameter1, false);
response.putExtra(ActivityManageRule.intentNameActionParameter2, etTargetPhoneNumber.getText().toString());
setResult(RESULT_OK, response);
finish();
}
else
Toast.makeText(ActivityManageActionMakePhoneCall.this, getResources().getText(R.string.enterPhoneNumber), Toast.LENGTH_SHORT).show();
}
});
}
}
@@ -26,6 +26,8 @@ public class ActivityManageActionPlaySound extends Activity
protected void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.activity_manage_action_play_sound);
chkPlaySoundAlwaysPlay = (CheckBox)findViewById(R.id.chkPlaySoundAlwaysPlay);
@@ -0,0 +1,125 @@
package com.jens.automation2;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;
import androidx.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
public class ActivityManageActionRunExecutable extends Activity
{
final static int PICKFILE_RESULT_CODE = 4711;
CheckBox chkRunExecAsRoot;
EditText etRunExecutablePath, etRunExecutableParameters;
Button bChooseExecutable, bSaveActionRunExec;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.activity_manage_action_run_executable);
chkRunExecAsRoot = (CheckBox)findViewById(R.id.chkRunExecAsRoot);
etRunExecutablePath = (EditText) findViewById(R.id.etRunExecutablePath);
etRunExecutableParameters = (EditText) findViewById(R.id.etRunExecutableParameters);
bChooseExecutable = (Button) findViewById(R.id.bChooseExecutable);
bSaveActionRunExec = (Button) findViewById(R.id.bSaveActionRunExec);
bChooseExecutable.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
//Need to check for storage permissions
Intent chooseFile = new Intent(Intent.ACTION_GET_CONTENT);
chooseFile.setType("*/*");
chooseFile = Intent.createChooser(chooseFile, getResources().getString(R.string.selectSoundFile));
startActivityForResult(chooseFile, PICKFILE_RESULT_CODE);
}
});
bSaveActionRunExec.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
saveExecSettings();
}
});
if(getIntent().hasExtra(ActivityManageRule.intentNameActionParameter2))
{
String[] parts = getIntent().getStringExtra(ActivityManageRule.intentNameActionParameter2).split(Action.actionParameter2Split);
etRunExecutablePath.setText(parts[0]);
if(parts.length > 1)
etRunExecutableParameters.setText(parts[1]);
}
}
void saveExecSettings()
{
if(etRunExecutablePath.getText().toString() == null || etRunExecutablePath.getText().toString().length() == 0)
{
Toast.makeText(ActivityManageActionRunExecutable.this, getResources().getString(R.string.selectValidExecutable), Toast.LENGTH_LONG).show();
return;
}
else
{
File executableFile = new File(etRunExecutablePath.getText().toString());
if(!executableFile.exists())
{
Toast.makeText(ActivityManageActionRunExecutable.this, getResources().getString(R.string.fileDoesNotExist), Toast.LENGTH_LONG).show();
return;
}
else
{
if(!chkRunExecAsRoot.isChecked() && !executableFile.canExecute())
{
Toast.makeText(ActivityManageActionRunExecutable.this, getResources().getString(R.string.fileNotExecutable), Toast.LENGTH_LONG).show();
return;
}
}
}
Intent returnData = new Intent();
returnData.putExtra(ActivityManageRule.intentNameActionParameter1, chkRunExecAsRoot.isChecked());
if(etRunExecutableParameters.getText() != null && !StringUtils.isEmpty(etRunExecutableParameters.getText().toString()))
returnData.putExtra(ActivityManageRule.intentNameActionParameter2, etRunExecutablePath.getText().toString() + Action.actionParameter2Split + etRunExecutableParameters.getText().toString());
else
returnData.putExtra(ActivityManageRule.intentNameActionParameter2, etRunExecutablePath.getText().toString());
setResult(RESULT_OK, returnData);
finish();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == RESULT_OK)
{
if(requestCode == PICKFILE_RESULT_CODE)
{
Uri fileUri = data.getData();
String filePath = CompensateCrappyAndroidPaths.getPath(ActivityManageActionRunExecutable.this, fileUri);
etRunExecutablePath.setText(filePath);
}
}
}
}
@@ -0,0 +1,281 @@
package com.jens.automation2;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.InputType;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.Toast;
import androidx.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
public class ActivityManageActionSendBroadcast extends Activity
{
EditText etBroadcastToSend;
Button bBroadcastSendShowSuggestions, bSaveSendBroadcast, bAddIntentPair;
ListView lvIntentPairs;
EditText etParameterName, etParameterValue;
Spinner spinnerParameterType;
ArrayAdapter<String> intentTypeSpinnerAdapter, intentPairAdapter;
private static final String[] supportedIntentTypes = { "boolean", "byte", "char", "double", "float", "int", "long", "short", "String", "Uri" };
private ArrayList<String> intentPairList = new ArrayList<>();
@Override
protected void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.activity_manage_action_send_broadcast);
etBroadcastToSend = (EditText)findViewById(R.id.etBroadcastToSend);
bBroadcastSendShowSuggestions = (Button)findViewById(R.id.bBroadcastSendShowSuggestions);
bSaveSendBroadcast = (Button)findViewById(R.id.bSaveSendBroadcast);
bAddIntentPair = (Button)findViewById(R.id.bAddIntentPair);
lvIntentPairs = (ListView) findViewById(R.id.lvIntentPairs);
etParameterName = (EditText) findViewById(R.id.etParameterName);
etParameterValue = (EditText) findViewById(R.id.etParameterValue);
spinnerParameterType = (Spinner) findViewById(R.id.spinnerParameterType);
intentTypeSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, ActivityManageActionSendBroadcast.supportedIntentTypes);
spinnerParameterType.setAdapter(intentTypeSpinnerAdapter);
intentTypeSpinnerAdapter.notifyDataSetChanged();
intentPairAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, intentPairList);
bSaveSendBroadcast.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
if(checkInput())
{
Intent answer = new Intent();
String param2 = etBroadcastToSend.getText().toString();
if(intentPairList.size() > 0)
{
param2 += Action.actionParameter2Split;
for (String s : intentPairList)
param2 += s + ";";
param2 = param2.substring(0, param2.length() - 1);
}
answer.putExtra(ActivityManageRule.intentNameActionParameter2, param2);
setResult(RESULT_OK, answer);
finish();
}
}
});
bBroadcastSendShowSuggestions.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
AlertDialog.Builder builder = new AlertDialog.Builder(ActivityManageActionSendBroadcast.this);
builder.setTitle(getResources().getString(R.string.selectBroadcast));
builder.setItems(ActivityManageTriggerBroadcast.broadcastSuggestions, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialogInterface, int which)
{
etBroadcastToSend.setText(ActivityManageTriggerBroadcast.broadcastSuggestions[which]);
}
});
builder.create().show();
}
});
Intent input = getIntent();
if(input.hasExtra(ActivityManageRule.intentNameActionParameter2))
{
String param2 = input.getStringExtra(ActivityManageRule.intentNameActionParameter2);
if(!param2.contains(Action.actionParameter2Split))
etBroadcastToSend.setText(input.getStringExtra(ActivityManageRule.intentNameActionParameter2));
else
{
String[] param2Parts = param2.split(Action.actionParameter2Split);
etBroadcastToSend.setText(param2Parts[0]);
String[] params = param2Parts[1].split(";");
intentPairList.clear();
for(int i = 0; i < params.length; i++)
{
if(lvIntentPairs.getVisibility() != View.VISIBLE)
lvIntentPairs.setVisibility(View.VISIBLE);
intentPairList.add(params[i]);
}
updateIntentPairList();
}
}
bAddIntentPair.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
// type;name;value
if(spinnerParameterType.getSelectedItem().toString().length() == 0)
{
Toast.makeText(ActivityManageActionSendBroadcast.this, getResources().getString(R.string.selectTypeOfIntentPair), Toast.LENGTH_LONG).show();
return;
}
if(etParameterName.getText().toString().length() == 0)
{
Toast.makeText(ActivityManageActionSendBroadcast.this, getResources().getString(R.string.enterNameForIntentPair), Toast.LENGTH_LONG).show();
return;
}
else if(etParameterName.getText().toString().contains(Action.intentPairSeparator))
{
Toast.makeText(ActivityManageActionSendBroadcast.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
return;
}
else if(etParameterName.getText().toString().contains(";"))
{
Toast.makeText(ActivityManageActionSendBroadcast.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
return;
}
if(etParameterValue.getText().toString().length() == 0)
{
Toast.makeText(ActivityManageActionSendBroadcast.this, getResources().getString(R.string.enterValueForIntentPair), Toast.LENGTH_LONG).show();
return;
}
else if(etParameterValue.getText().toString().contains(Action.intentPairSeparator))
{
Toast.makeText(ActivityManageActionSendBroadcast.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
return;
}
else if(etParameterValue.getText().toString().contains(";"))
{
Toast.makeText(ActivityManageActionSendBroadcast.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
return;
}
switch(supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()])
{
case "int":
case "long":
case "short":
if(!Miscellaneous.isNumeric(etParameterValue.getText().toString()))
{
Toast.makeText(ActivityManageActionSendBroadcast.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show();
return;
}
break;
case "double":
case "float":
if(!Miscellaneous.isNumericDecimal(etParameterValue.getText().toString()))
{
Toast.makeText(ActivityManageActionSendBroadcast.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show();
return;
}
break;
default:
ActivityManageActionSendBroadcast.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
}
String param = supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()] + Action.intentPairSeparator + etParameterName.getText().toString() + Action.intentPairSeparator + etParameterValue.getText().toString();
intentPairList.add(param);
spinnerParameterType.setSelection(0);
etParameterName.setText("");
etParameterValue.setText("");
updateIntentPairList();
if(lvIntentPairs.getVisibility() != View.VISIBLE)
lvIntentPairs.setVisibility(View.VISIBLE);
}
});
lvIntentPairs.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener()
{
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
{
getIntentPairDialog(arg2).show();
return false;
}
});
spinnerParameterType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3)
{
if(supportedIntentTypes[arg2].equals("int") || supportedIntentTypes[arg2].equals("long") || supportedIntentTypes[arg2].equals("short"))
ActivityManageActionSendBroadcast.this.etParameterValue.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
else if(supportedIntentTypes[arg2].equals("double") || supportedIntentTypes[arg2].equals("float"))
ActivityManageActionSendBroadcast.this.etParameterValue.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
else
ActivityManageActionSendBroadcast.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
}
@Override
public void onNothingSelected(AdapterView<?> arg0)
{
}
});
}
boolean checkInput()
{
String broadcastToSend = etBroadcastToSend.getText().toString();
if(StringUtils.isEmpty(broadcastToSend))
{
Toast.makeText(ActivityManageActionSendBroadcast.this, getResources().getString(R.string.enterBroadcast), Toast.LENGTH_SHORT).show();
return false;
}
return true;
}
private void updateIntentPairList()
{
if(lvIntentPairs.getAdapter() == null)
lvIntentPairs.setAdapter(intentPairAdapter);
intentPairAdapter.notifyDataSetChanged();
}
private AlertDialog getIntentPairDialog(final int itemPosition)
{
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityManageActionSendBroadcast.this);
alertDialogBuilder.setTitle(getResources().getString(R.string.whatToDoWithIntentPair));
alertDialogBuilder.setItems(new String[]{getResources().getString(R.string.delete)}, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
// Only 1 choice at the moment, no need to check
ActivityManageActionSendBroadcast.this.intentPairList.remove(itemPosition);
updateIntentPairList();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
return alertDialog;
}
}
@@ -9,26 +9,37 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.MediaStore;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import com.jens.automation2.Action.Action_Enum;
import org.apache.commons.lang3.StringUtils;
public class ActivityManageActionSendTextMessage extends Activity
{
Button bSaveSendTextMessage, bImportNumberFromContacts;
Button bSaveSendTextMessage, bImportNumberFromContacts, bMmsAttachment;
EditText etPhoneNumber, etSendTextMessage;
RadioButton rbMessageTypeSms, rbMessageTypeMms;
TextView tvSendMmsFileAttachment;
protected final static int requestCodeForContactsPermissions = 9876;
protected final static int requestCodeGetContact = 3235;
// private String existingUrl = "";
protected final static int requestCodeGetMMSattachment = 3236;
public static final String messageTypeSms = "sms";
public static final String messageTypeMms = "mms";
public static boolean edit = false;
public static Action resultingAction = null;
@@ -37,12 +48,18 @@ public class ActivityManageActionSendTextMessage extends Activity
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
this.setContentView(R.layout.activity_manage_action_send_textmessage);
etSendTextMessage = (EditText)findViewById(R.id.etSendTextMessage);
etPhoneNumber = (EditText)findViewById(R.id.etPhoneNumber);
bSaveSendTextMessage = (Button)findViewById(R.id.bSaveSendTextMessage);
bImportNumberFromContacts = (Button)findViewById(R.id.bImportNumberFromContacts);
rbMessageTypeSms = (RadioButton)findViewById(R.id.rbMessageTypeSms);
rbMessageTypeMms = (RadioButton) findViewById(R.id.rbMessageTypeMms);
bMmsAttachment = (Button)findViewById(R.id.bMmsAttachment);
tvSendMmsFileAttachment = (TextView)findViewById(R.id.tvSendMmsFileAttachment);
bSaveSendTextMessage.setOnClickListener(new OnClickListener()
{
@@ -51,13 +68,29 @@ public class ActivityManageActionSendTextMessage extends Activity
{
if(etSendTextMessage.getText().toString().length() > 0 && etPhoneNumber.getText().toString().length() > 0)
{
if(resultingAction == null)
if(rbMessageTypeMms.isChecked() && StringUtils.isEmpty(tvSendMmsFileAttachment.getText().toString()))
Toast.makeText(getBaseContext(), getResources().getString(R.string.chooseFile), Toast.LENGTH_LONG).show();
else
{
resultingAction = new Action();
resultingAction.setAction(Action_Enum.sendTextMessage);
resultingAction.setParameter2(etPhoneNumber.getText().toString() + Actions.smsSeparator + etSendTextMessage.getText().toString());
if (resultingAction == null)
{
resultingAction = new Action();
resultingAction.setAction(Action_Enum.sendTextMessage);
String messageType = null;
String path = "";
if(rbMessageTypeSms.isChecked())
messageType = messageTypeSms;
else
{
messageType = messageTypeMms;
path = Actions.smsSeparator + tvSendMmsFileAttachment.getText().toString();
}
resultingAction.setParameter2(etPhoneNumber.getText().toString() + Actions.smsSeparator + etSendTextMessage.getText().toString() + Actions.smsSeparator + messageType + path);
}
backToRuleManager();
}
backToRuleManager();
}
else
Toast.makeText(getBaseContext(), getResources().getString(R.string.enterPhoneNumberAndText), Toast.LENGTH_LONG).show();
@@ -78,6 +111,28 @@ public class ActivityManageActionSendTextMessage extends Activity
}
});
RadioButton.OnCheckedChangeListener checkedChangedListener = new RadioButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b)
{
bMmsAttachment.setEnabled(rbMessageTypeMms.isChecked());
}
};
rbMessageTypeSms.setOnCheckedChangeListener(checkedChangedListener);
rbMessageTypeMms.setOnCheckedChangeListener(checkedChangedListener);
bMmsAttachment.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View view)
{
Intent chooseFileIntent = new Intent(Intent.ACTION_GET_CONTENT);
chooseFileIntent.setType("*/*");
chooseFileIntent = Intent.createChooser(chooseFileIntent, getResources().getString(R.string.chooseFile));
startActivityForResult(chooseFileIntent, requestCodeGetMMSattachment);
}
});
ActivityManageActionSendTextMessage.edit = getIntent().getBooleanExtra("edit", false);
if(edit)
{
@@ -144,10 +199,10 @@ public class ActivityManageActionSendTextMessage extends Activity
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if(requestCode == requestCodeGetContact)
{
if(resultCode == Activity.RESULT_OK)
{
if(resultCode == Activity.RESULT_OK)
{
if(requestCode == requestCodeGetContact)
{
String phoneNo = null;
String name = null;
@@ -165,6 +220,12 @@ public class ActivityManageActionSendTextMessage extends Activity
etPhoneNumber.setText(phoneNo);
}
}
else if (requestCode == requestCodeGetMMSattachment)
{
Uri fileUri = data.getData();
String filePath = fileUri.getPath();
tvSendMmsFileAttachment.setText(filePath);
}
}
//super.onActivityResult(requestCode, resultCode, data);
}
@@ -0,0 +1,66 @@
package com.jens.automation2;
//import static com.jens.automation2.ActivityManageActionTriggerUrl.edit;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.jens.automation2.Action.Action_Enum;
import org.apache.commons.lang3.StringUtils;
public class ActivityManageActionSetVariable extends Activity
{
private Button bSaveVariable;
private EditText etVariableSetKey, etVariableSetValue;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
this.setContentView(R.layout.activity_manage_action_set_variable);
etVariableSetKey = (EditText)findViewById(R.id.etVariableSetKey);
etVariableSetValue = (EditText)findViewById(R.id.etVariableSetValue);
bSaveVariable = (Button)findViewById(R.id.bSaveVariable);
bSaveVariable.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
if(StringUtils.isEmpty(etVariableSetKey.getText().toString()))
{
Toast.makeText(ActivityManageActionSetVariable.this, getResources().getString(R.string.enterVariableKey), Toast.LENGTH_SHORT).show();
}
else
{
Intent response = new Intent();
if(StringUtils.isEmpty(etVariableSetValue.getText().toString()))
response.putExtra(ActivityManageRule.intentNameActionParameter2, etVariableSetKey.getText().toString());
else
response.putExtra(ActivityManageRule.intentNameActionParameter2, etVariableSetKey.getText().toString() + Action.actionParameter2Split + etVariableSetValue.getText().toString());
setResult(RESULT_OK, response);
finish();
}
}
});
if(getIntent().hasExtra(ActivityManageRule.intentNameActionParameter2))
{
String[] input = getIntent().getStringExtra(ActivityManageRule.intentNameActionParameter2).split(Action.actionParameter2Split);
etVariableSetKey.setText(input[0]);
if(input.length > 1)
etVariableSetValue.setText(input[1]);
}
}
}
@@ -15,8 +15,6 @@ public class ActivityManageActionSpeakText extends Activity
private Button bSaveSpeakText;
private EditText etSpeakText;
// private String existingUrl = "";
public static boolean edit = false;
public static Action resultingAction = null;
@@ -24,16 +22,18 @@ public class ActivityManageActionSpeakText extends Activity
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
this.setContentView(R.layout.activity_manage_action_speak_text);
etSpeakText = (EditText)findViewById(R.id.etTextToSpeak);
bSaveSpeakText = (Button)findViewById(R.id.bSaveTriggerUrl);
bSaveSpeakText = (Button)findViewById(R.id.bSaveSpeakText);
bSaveSpeakText.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
if(etSpeakText.getText().toString().length()>0)
if(!etSpeakText.getText().toString().isEmpty())
{
if(resultingAction == null)
{
@@ -29,6 +29,7 @@ import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.Toast;
@@ -48,18 +49,281 @@ public class ActivityManageActionStartActivity extends Activity
*/
ListView lvIntentPairs;
EditText etParameterName, etParameterValue, etPackageName, etActivityOrActionPath;
EditText etParameterName, etParameterValue, etPackageName, etActivityOrActionPath, etClassName;
Button bSelectApp, bAddIntentPair, bSaveActionStartOtherActivity, showStartProgramExamples;
Spinner spinnerParameterType;
boolean edit = false;
RadioGroup rgAppStartupType;
// boolean edit = false;
ProgressDialog progressDialog = null;
RadioButton rbStartAppSelectByActivity, rbStartAppSelectByAction, rbStartAppByActivity, rbStartAppByBroadcast;
RadioButton rbStartAppSelectByActivity, rbStartAppSelectByAction, rbStartAppByActivity, rbStartAppByBroadcast, rbStartAppByService, rbStartAppByForegroundService;
final String urlShowExamples = "https://server47.de/automation/examples_startProgram.html";
final static String startByActivityString = "0";
final static String startByBroadcastString = "1";
final String urlShowExamples = "https://server47.de/automation/examples.html";
public final static String startByActivityString = "0";
public final static String startByBroadcastString = "1";
public final static String startByServiceString = "2";
public final static String startByForegroundServiceString = "3";
final static int requestCodeForRequestQueryAllPackagesPermission = 4711;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.activity_manage_action_start_activity);
lvIntentPairs = (ListView)findViewById(R.id.lvIntentPairs);
etParameterName = (EditText)findViewById(R.id.etParameterName);
etParameterValue = (EditText)findViewById(R.id.etParameterValue);
etClassName = (EditText)findViewById(R.id.etClassName);
bSelectApp = (Button)findViewById(R.id.bSelectApp);
bAddIntentPair = (Button)findViewById(R.id.bAddIntentPair);
bSaveActionStartOtherActivity = (Button)findViewById(R.id.bSaveActionStartOtherActivity);
spinnerParameterType = (Spinner)findViewById(R.id.spinnerParameterType);
etPackageName = (EditText) findViewById(R.id.etPackageName);
etActivityOrActionPath = (EditText) findViewById(R.id.etActivityOrActionPath);
rbStartAppSelectByActivity = (RadioButton)findViewById(R.id.rbStartAppSelectByActivity);
rbStartAppSelectByAction = (RadioButton)findViewById(R.id.rbStartAppSelectByAction);
showStartProgramExamples = (Button)findViewById(R.id.showStartProgramExamples);
rbStartAppByActivity = (RadioButton)findViewById(R.id.rbStartAppByActivity);
rbStartAppByBroadcast = (RadioButton)findViewById(R.id.rbStartAppByBroadcast);
rbStartAppByService = (RadioButton)findViewById(R.id.rbStartAppByService);
rbStartAppByForegroundService = (RadioButton)findViewById(R.id.rbStartAppByForegroundService);
rgAppStartupType = (RadioGroup)findViewById(R.id.rgAppStartupType);
intentTypeSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, ActivityManageActionStartActivity.supportedIntentTypes);
spinnerParameterType.setAdapter(intentTypeSpinnerAdapter);
intentTypeSpinnerAdapter.notifyDataSetChanged();
// etClassName.setEnabled(false);
intentPairAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, intentPairList);
bSelectApp.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
int targetSdkVersion = getApplicationContext().getApplicationInfo().targetSdkVersion;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && targetSdkVersion >= 30 && !ActivityPermissions.havePermission(Manifest.permission.QUERY_ALL_PACKAGES, ActivityManageActionStartActivity.this))// && shouldShowRequestPermissionRationale(Manifest.permission.QUERY_ALL_PACKAGES))
{
if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_googleplay))
{
// This ain't possible anymore.
Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.featureNotInGooglePlayVersion) + Miscellaneous.lineSeparator + Miscellaneous.lineSeparator + getResources().getString(R.string.startActivityInsertManually), ActivityManageActionStartActivity.this).show();
}
else
requestPermissions(new String[] {Manifest.permission.QUERY_ALL_PACKAGES}, requestCodeForRequestQueryAllPackagesPermission);
}
else
getAppList();
}
});
bAddIntentPair.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
// type;name;value
if(spinnerParameterType.getSelectedItem().toString().length() == 0)
{
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.selectTypeOfIntentPair), Toast.LENGTH_LONG).show();
return;
}
if(etParameterName.getText().toString().length() == 0)
{
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterNameForIntentPair), Toast.LENGTH_LONG).show();
return;
}
else if(etParameterName.getText().toString().contains(Action.intentPairSeparator))
{
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
return;
}
else if(etParameterName.getText().toString().contains(";"))
{
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
return;
}
if(etParameterValue.getText().toString().length() == 0)
{
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterValueForIntentPair), Toast.LENGTH_LONG).show();
return;
}
else if(etParameterValue.getText().toString().contains(Action.intentPairSeparator))
{
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
return;
}
else if(etParameterValue.getText().toString().contains(";"))
{
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
return;
}
switch(supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()])
{
case "int":
case "long":
case "short":
if(!Miscellaneous.isNumeric(etParameterValue.getText().toString()))
{
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show();
return;
}
break;
case "double":
case "float":
if(!Miscellaneous.isNumericDecimal(etParameterValue.getText().toString()))
{
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show();
return;
}
break;
default:
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
}
String param = supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()] + Action.intentPairSeparator + etParameterName.getText().toString() + Action.intentPairSeparator + etParameterValue.getText().toString();
intentPairList.add(param);
spinnerParameterType.setSelection(0);
etParameterName.setText("");
etParameterValue.setText("");
updateIntentPairList();
if(lvIntentPairs.getVisibility() != View.VISIBLE)
lvIntentPairs.setVisibility(View.VISIBLE);
}
});
showStartProgramExamples.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlShowExamples));
startActivity(browserIntent);
}
});
lvIntentPairs.setOnItemLongClickListener(new OnItemLongClickListener()
{
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
{
getIntentPairDialog(arg2).show();
return false;
}
});
bSaveActionStartOtherActivity.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
if(checkInput())
{
Intent returnData = new Intent();
returnData.putExtra(ActivityManageRule.intentNameActionParameter1, rbStartAppSelectByAction.isChecked());
String parameter2 = "";
/*
0 = packageName
1 = className
2 = activityName/actionName
3 = startType
4 = parameters
*/
parameter2 += etPackageName.getText().toString()
+ Action.actionParameter2Split
+ etClassName.getText().toString()
+ Action.actionParameter2Split
+ etActivityOrActionPath.getText().toString()
+ Action.actionParameter2Split;
if (rbStartAppByActivity.isChecked())
parameter2 += startByActivityString;
else if(rbStartAppByService.isChecked())
parameter2 += startByServiceString;
else if(rbStartAppByForegroundService.isChecked())
parameter2 += startByForegroundServiceString;
else
parameter2 += startByBroadcastString;
for (String s : intentPairList)
parameter2 += Action.actionParameter2Split + s;
returnData.putExtra(ActivityManageRule.intentNameActionParameter2, parameter2);
setResult(RESULT_OK, returnData);
finish();
}
}
});
lvIntentPairs.setOnTouchListener(new OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
spinnerParameterType.setOnItemSelectedListener(new OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3)
{
if(supportedIntentTypes[arg2].equals("int") || supportedIntentTypes[arg2].equals("long") || supportedIntentTypes[arg2].equals("short"))
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
else if(supportedIntentTypes[arg2].equals("double") || supportedIntentTypes[arg2].equals("float"))
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
else
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
}
@Override
public void onNothingSelected(AdapterView<?> arg0)
{
}
});
rbStartAppSelectByActivity.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
if(isChecked)
{
bSelectApp.setEnabled(isChecked);
}
}
});
rbStartAppSelectByAction.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
if(isChecked)
bSelectApp.setEnabled(!isChecked);
}
});
Intent i = getIntent();
if(i.hasExtra(ActivityManageRule.intentNameActionParameter1))
loadValuesIntoGui(i);
}
private class CustomPackageInfo extends PackageInfo implements Comparable<CustomPackageInfo>
{
@@ -82,11 +346,9 @@ public class ActivityManageActionStartActivity extends Activity
return name1.compareTo(name2);
}
}
private static List<PackageInfo> pInfos = null;
public static Action resultingAction;
private static final String[] supportedIntentTypes = { "boolean", "byte", "char", "double", "float", "int", "long", "short", "String", "Uri" };
private ArrayList<String> intentPairList = new ArrayList<String>();
@@ -343,232 +605,43 @@ public class ActivityManageActionStartActivity extends Activity
getActivityListTask.execute();
progressDialog = ProgressDialog.show(ActivityManageActionStartActivity.this, "", ActivityManageActionStartActivity.this.getResources().getString(R.string.gettingListOfInstalledApplications));
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_manage_action_start_activity);
lvIntentPairs = (ListView)findViewById(R.id.lvIntentPairs);
etParameterName = (EditText)findViewById(R.id.etParameterName);
etParameterValue = (EditText)findViewById(R.id.etParameterValue);
bSelectApp = (Button)findViewById(R.id.bSelectApp);
bAddIntentPair = (Button)findViewById(R.id.bAddIntentPair);
bSaveActionStartOtherActivity = (Button)findViewById(R.id.bSaveActionStartOtherActivity);
spinnerParameterType = (Spinner)findViewById(R.id.spinnerParameterType);
etPackageName = (EditText) findViewById(R.id.etPackageName);
etActivityOrActionPath = (EditText) findViewById(R.id.etActivityOrActionPath);
rbStartAppSelectByActivity = (RadioButton)findViewById(R.id.rbStartAppSelectByActivity);
rbStartAppSelectByAction = (RadioButton)findViewById(R.id.rbStartAppSelectByAction);
showStartProgramExamples = (Button)findViewById(R.id.showStartProgramExamples);
rbStartAppByActivity = (RadioButton)findViewById(R.id.rbStartAppByActivity);
rbStartAppByBroadcast = (RadioButton)findViewById(R.id.rbStartAppByBroadcast);
intentTypeSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, ActivityManageActionStartActivity.supportedIntentTypes);
spinnerParameterType.setAdapter(intentTypeSpinnerAdapter);
intentTypeSpinnerAdapter.notifyDataSetChanged();
intentPairAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, intentPairList);
bSelectApp.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
int targetSdkVersion = getApplicationContext().getApplicationInfo().targetSdkVersion;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && targetSdkVersion >= 30)
{
requestPermissions(new String[] {Manifest.permission.QUERY_ALL_PACKAGES}, requestCodeForRequestQueryAllPackagesPermission);
}
else
getAppList();
}
});
bAddIntentPair.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
// type;name;value
if(spinnerParameterType.getSelectedItem().toString().length() == 0)
{
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.selectTypeOfIntentPair), Toast.LENGTH_LONG).show();
return;
}
if(etParameterName.getText().toString().length() == 0)
{
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterNameForIntentPair), Toast.LENGTH_LONG).show();
return;
}
else if(etParameterName.getText().toString().contains(Action.intentPairSeparator))
{
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
return;
}
else if(etParameterName.getText().toString().contains(";"))
{
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
return;
}
if(etParameterValue.getText().toString().length() == 0)
{
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterValueForIntentPair), Toast.LENGTH_LONG).show();
return;
}
else if(etParameterValue.getText().toString().contains(Action.intentPairSeparator))
{
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
return;
}
else if(etParameterValue.getText().toString().contains(";"))
{
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
return;
}
String param = supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()] + Action.intentPairSeparator + etParameterName.getText().toString() + Action.intentPairSeparator + etParameterValue.getText().toString();
intentPairList.add(param);
spinnerParameterType.setSelection(0);
etParameterName.setText("");
etParameterValue.setText("");
updateIntentPairList();
if(lvIntentPairs.getVisibility() != View.VISIBLE)
lvIntentPairs.setVisibility(View.VISIBLE);
}
});
showStartProgramExamples.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlShowExamples));
startActivity(browserIntent);
}
});
lvIntentPairs.setOnItemLongClickListener(new OnItemLongClickListener()
{
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
{
getIntentPairDialog(arg2).show();
return false;
}
});
bSaveActionStartOtherActivity.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
if(saveAction())
{
ActivityManageActionStartActivity.this.setResult(RESULT_OK);
finish();
}
}
});
lvIntentPairs.setOnTouchListener(new OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent event)
{
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
spinnerParameterType.setOnItemSelectedListener(new OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3)
{
if(supportedIntentTypes[arg2].equals("double") | supportedIntentTypes[arg2].equals("float") | supportedIntentTypes[arg2].equals("int") | supportedIntentTypes[arg2].equals("long") | supportedIntentTypes[arg2].equals("short"))
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_NUMBER);
else
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
}
@Override
public void onNothingSelected(AdapterView<?> arg0)
{
// TODO Auto-generated method stub
}
});
rbStartAppSelectByActivity.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
if(isChecked)
bSelectApp.setEnabled(isChecked);
}
});
rbStartAppSelectByAction.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
if(isChecked)
bSelectApp.setEnabled(!isChecked);
}
});
Intent i = getIntent();
if(i.getBooleanExtra("edit", false) == true)
{
edit = true;
loadValuesIntoGui();
}
}
private void loadValuesIntoGui()
private void loadValuesIntoGui(Intent input)
{
boolean selectionByAction = resultingAction.getParameter1();
boolean selectionByAction = input.getBooleanExtra(ActivityManageRule.intentNameActionParameter1, true);
rbStartAppSelectByActivity.setChecked(!selectionByAction);
rbStartAppSelectByAction.setChecked(selectionByAction);
String[] params = resultingAction.getParameter2().split(";");
/*
0 = packageName
1 = className
2 = activityName/actionName
3 = startType
4 = parameters
*/
rbStartAppByActivity.setChecked(params[2].equals(startByActivityString));
rbStartAppByBroadcast.setChecked(params[2].equals(startByBroadcastString));
int startIndex = -1;
if(!selectionByAction)
try
{
String[] params;
String partsString = input.getStringExtra(ActivityManageRule.intentNameActionParameter2);
if(partsString.contains(Action.actionParameter2Split))
params = partsString.split(Action.actionParameter2Split, -1);
else
params = partsString.split(";", -1);
etPackageName.setText(params[0]);
etActivityOrActionPath.setText(params[1]);
}
else
{
if(!params[0].contains(Actions.dummyPackageString))
etPackageName.setText(params[0]);
etClassName.setText(params[1]);
etActivityOrActionPath.setText(params[2]);
etActivityOrActionPath.setText(params[1]);
}
rbStartAppByActivity.setChecked(params[3].equals(startByActivityString));
rbStartAppByBroadcast.setChecked(params[3].equals(startByBroadcastString));
rbStartAppByService.setChecked(params[3].equals(startByServiceString));
rbStartAppByForegroundService.setChecked(params[3].equals(startByForegroundServiceString));
if (params.length >= 3)
startIndex = 3;
if(startIndex > -1 && params.length > startIndex)
{
intentPairList.clear();
for(int i=startIndex; i<params.length; i++)
for(int i=4; i<params.length; i++)
{
if(lvIntentPairs.getVisibility() != View.VISIBLE)
lvIntentPairs.setVisibility(View.VISIBLE);
@@ -578,6 +651,10 @@ public class ActivityManageActionStartActivity extends Activity
updateIntentPairList();
}
catch(Exception e)
{
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.errorLoadingValues), Toast.LENGTH_LONG).show();
}
}
private void updateIntentPairList()
@@ -587,8 +664,8 @@ public class ActivityManageActionStartActivity extends Activity
intentPairAdapter.notifyDataSetChanged();
}
private boolean saveAction()
boolean checkInput()
{
if(rbStartAppSelectByActivity.isChecked())
{
@@ -611,36 +688,7 @@ public class ActivityManageActionStartActivity extends Activity
return false;
}
}
if(resultingAction == null)
resultingAction = new Action();
resultingAction.setParameter1(rbStartAppSelectByAction.isChecked());
resultingAction.setAction(Action_Enum.startOtherActivity);
String parameter2 = "";
if(rbStartAppSelectByActivity.isChecked())
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString();
else
{
if(etPackageName.getText().toString() != null && etPackageName.getText().toString().length() > 0)
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString();
else
parameter2 += Actions.dummyPackageString + ";" + etActivityOrActionPath.getText().toString();
}
if(rbStartAppByActivity.isChecked())
parameter2 += ";" + startByActivityString;
else
parameter2 += ";" + startByBroadcastString;
for(String s : intentPairList)
parameter2 += ";" + s;
resultingAction.setParameter2(parameter2);
return true;
}
@@ -1,6 +1,10 @@
package com.jens.automation2;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
@@ -13,32 +17,44 @@ import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.TableLayout;
import android.widget.Toast;
import androidx.annotation.NonNull;
import com.jens.automation2.Action.Action_Enum;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Map;
public class ActivityManageActionTriggerUrl extends Activity
{
Button bSaveTriggerUrl;
EditText etTriggerUrl, etTriggerUrlUsername, etTriggerUrlPassword;
Button bSaveTriggerUrl, bAddHttpParam;
EditText etTriggerUrl, etTriggerUrlUsername, etTriggerUrlPassword, etParameterName, etParameterValue;
ListView lvTriggerUrlPostParameters;
CheckBox chkTriggerUrlUseAuthentication;
RadioButton rbTriggerUrlMethodGet, rbTriggerUrlMethodPost;
TableLayout tlTriggerUrlAuthentication;
ArrayAdapter<String> httpParametersAdapter;
private ArrayList<String> httpParamsList = new ArrayList<>();
ArrayAdapter<Map<String,String>> lvTriggerUrlPostParametersAdapter;
public static final String methodGet = "GET";
public static final String methodPost = "POST";
// private String existingUrl = "";
public static boolean edit = false;
public static Action resultingAction = null;
// public static boolean edit = false;
// public static Action resultingAction = null;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
this.setContentView(R.layout.activity_manage_action_trigger_url);
etTriggerUrl = (EditText)findViewById(R.id.etTriggerUrl);
@@ -47,7 +63,33 @@ public class ActivityManageActionTriggerUrl extends Activity
chkTriggerUrlUseAuthentication = (CheckBox)findViewById(R.id.chkTriggerUrlUseAuthentication);
lvTriggerUrlPostParameters = (ListView)findViewById(R.id.lvTriggerUrlPostParameters);
tlTriggerUrlAuthentication = (TableLayout)findViewById(R.id.tlTriggerUrlAuthentication);
bSaveTriggerUrl = (Button)findViewById(R.id.bSaveTriggerUrl);
bSaveTriggerUrl = (Button)findViewById(R.id.bSaveSpeakText);
rbTriggerUrlMethodGet = (RadioButton) findViewById(R.id.rbTriggerUrlMethodGet);
rbTriggerUrlMethodPost = (RadioButton) findViewById(R.id.rbTriggerUrlMethodPost);
etTriggerUrl = (EditText) findViewById(R.id.etTriggerUrl);
etParameterName = (EditText) findViewById(R.id.etParameterName);
etParameterValue = (EditText)findViewById(R.id.etParameterValue);
bAddHttpParam = (Button)findViewById(R.id.bAddHttpParam);
etParameterName.setEnabled(false);
etParameterValue.setEnabled(false);
bAddHttpParam.setEnabled(false);
rbTriggerUrlMethodPost.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked)
{
etParameterName.setEnabled(checked);
etParameterValue.setEnabled(checked);
bAddHttpParam.setEnabled(checked);
if(checked)
lvTriggerUrlPostParameters.setVisibility(View.VISIBLE);
}
});
httpParametersAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, httpParamsList);
bSaveTriggerUrl.setOnClickListener(new OnClickListener()
{
@Override
@@ -55,44 +97,64 @@ public class ActivityManageActionTriggerUrl extends Activity
{
if(etTriggerUrl.getText().toString().length() > 0)
{
if(resultingAction == null)
{
resultingAction = new Action();
resultingAction.setAction(Action_Enum.triggerUrl);
resultingAction.setParameter1(chkTriggerUrlUseAuthentication.isChecked());
String username = etTriggerUrlUsername.getText().toString();
String password = etTriggerUrlPassword.getText().toString();
if(username == null)
username = "";
if(password == null)
password = "";
ActivityManageActionTriggerUrl.resultingAction.setParameter2(
username + ";" +
password + ";" +
etTriggerUrl.getText().toString().trim()
);
}
backToRuleManager();
Intent returnIntent = new Intent();
returnIntent.putExtra(ActivityManageRule.intentNameActionParameter1, chkTriggerUrlUseAuthentication.isChecked());
String username = etTriggerUrlUsername.getText().toString();
String password = etTriggerUrlPassword.getText().toString();
if(username == null)
username = "";
if(password == null)
password = "";
String method = methodGet;
if(rbTriggerUrlMethodPost.isChecked())
method = methodPost;
String httpParams = "";
for (String s : httpParamsList)
httpParams += Action.actionParameters2SeparatorOuter + s;
if(httpParams.length() > 0)
httpParams = httpParams.substring(Action.actionParameters2SeparatorOuter.length());
returnIntent.putExtra(ActivityManageRule.intentNameActionParameter2,
username + Action.actionParameter2Split +
password + Action.actionParameter2Split +
etTriggerUrl.getText().toString().trim() + Action.actionParameter2Split +
method + Action.actionParameter2Split +
httpParams
);
setResult(RESULT_OK, returnIntent);
finish();
}
else
Toast.makeText(getBaseContext(), getResources().getString(R.string.urlTooShort), Toast.LENGTH_LONG).show();
}
});
chkTriggerUrlUseAuthentication.setOnCheckedChangeListener(new OnCheckedChangeListener()
{
{
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
if(isChecked)
{
tlTriggerUrlAuthentication.setVisibility(View.VISIBLE);
rbTriggerUrlMethodGet.setChecked(false);
rbTriggerUrlMethodPost.setChecked(true);
rbTriggerUrlMethodGet.setEnabled(false);
rbTriggerUrlMethodPost.setEnabled(false);
}
else
{
tlTriggerUrlAuthentication.setVisibility(View.GONE);
rbTriggerUrlMethodGet.setEnabled(true);
rbTriggerUrlMethodPost.setEnabled(true);
}
etTriggerUrlUsername.setEnabled(isChecked);
etTriggerUrlPassword.setEnabled(isChecked);
@@ -109,52 +171,86 @@ public class ActivityManageActionTriggerUrl extends Activity
});
updateListView();
ActivityManageActionTriggerUrl.edit = getIntent().getBooleanExtra("edit", false);
if(edit)
if(getIntent().hasExtra(ActivityManageRule.intentNameActionParameter2))
{
// username,password,URL
String[] components = ActivityManageActionTriggerUrl.resultingAction.getParameter2().split(";");
// username,password,URL,etc.
String[] components;
if(getIntent().getStringExtra(ActivityManageRule.intentNameActionParameter2).contains(Action.actionParameter2Split))
components = getIntent().getStringExtra(ActivityManageRule.intentNameActionParameter2).split(Action.actionParameter2Split, -1);
else
components = getIntent().getStringExtra(ActivityManageRule.intentNameActionParameter2).split(";", -1);
if(components.length >= 3)
{
etTriggerUrl.setText(components[2]);
chkTriggerUrlUseAuthentication.setChecked(ActivityManageActionTriggerUrl.resultingAction.getParameter1());
etTriggerUrl.setText(components[2]);
chkTriggerUrlUseAuthentication.setChecked(getIntent().getBooleanExtra(ActivityManageRule.intentNameActionParameter1, false));
etTriggerUrlUsername.setText(components[0]);
etTriggerUrlPassword.setText(components[1]);
if(components.length >= 4)
{
switch(components[3])
{
case methodPost:
rbTriggerUrlMethodPost.setChecked(true);
break;
case methodGet:
default:
rbTriggerUrlMethodGet.setChecked(true);
break;
}
}
if(components.length >= 5)
{
if(!StringUtils.isEmpty(components[4]) && components[4].contains(Action.actionParameters2SeparatorInner))
{
String httpParams[] = components[4].split(Action.actionParameters2SeparatorOuter);
for (String paramPair : httpParams)
httpParamsList.add(paramPair);
updateHttpParamsList();
}
}
}
else
etTriggerUrl.setText(components[0]);
}
}
private void backToRuleManager()
{
if(edit && resultingAction != null)
bAddHttpParam.setOnClickListener(new OnClickListener()
{
String username = etTriggerUrlUsername.getText().toString();
String password = etTriggerUrlPassword.getText().toString();
if(username == null)
username = "";
if(password == null)
password = "";
ActivityManageActionTriggerUrl.resultingAction.setParameter1(chkTriggerUrlUseAuthentication.isChecked());
ActivityManageActionTriggerUrl.resultingAction.setParameter2(
username + ";" +
password + ";" +
etTriggerUrl.getText().toString()
);
}
setResult(RESULT_OK);
this.finish();
@Override
public void onClick(View view)
{
if(StringUtils.isEmpty(etParameterName.getText()) || StringUtils.isEmpty(etParameterValue.getText()))
{
Toast.makeText(ActivityManageActionTriggerUrl.this, getResources().getString(R.string.enterValidDataIntoParametersFields), Toast.LENGTH_SHORT).show();
return;
}
httpParamsList.add(etParameterName.getText() + Action.actionParameters2SeparatorInner + etParameterValue.getText());
updateHttpParamsList();
etParameterName.setText("");
etParameterValue.setText("");
if(lvTriggerUrlPostParameters.getVisibility() != View.VISIBLE)
lvTriggerUrlPostParameters.setVisibility(View.VISIBLE);
}
});
lvTriggerUrlPostParameters.setOnItemLongClickListener(new OnItemLongClickListener()
{
@Override
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
{
getHttpParamsDialog(arg2).show();
return false;
}
});
}
private void updateListView()
{
Miscellaneous.logEvent("i", "ListView", "Attempting to update lvTriggerUrlPostParameters", 4);
@@ -162,10 +258,36 @@ public class ActivityManageActionTriggerUrl extends Activity
{
if(lvTriggerUrlPostParameters.getAdapter() == null)
lvTriggerUrlPostParameters.setAdapter(lvTriggerUrlPostParametersAdapter);
lvTriggerUrlPostParametersAdapter.notifyDataSetChanged();
}
catch(NullPointerException e)
{}
}
private void updateHttpParamsList()
{
if(lvTriggerUrlPostParameters.getAdapter() == null)
lvTriggerUrlPostParameters.setAdapter(httpParametersAdapter);
httpParametersAdapter.notifyDataSetChanged();
}
private AlertDialog getHttpParamsDialog(final int itemPosition)
{
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityManageActionTriggerUrl.this);
alertDialogBuilder.setTitle(getResources().getString(R.string.whatToDoWithIntentPair));
alertDialogBuilder.setItems(new String[]{getResources().getString(R.string.delete)}, new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
// Only 1 choice at the moment, no need to check
ActivityManageActionTriggerUrl.this.httpParamsList.remove(itemPosition);
updateHttpParamsList();
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
return alertDialog;
}
}
@@ -2,10 +2,13 @@ package com.jens.automation2;
import android.Manifest;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Looper;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.view.View;
@@ -22,11 +25,14 @@ public class ActivityManageActionVibrate extends Activity
{
TextView etVibratePattern;
Button bTestVibratePattern, bSaveVibratePattern;
ProgressDialog pdPleaseWait = null;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.activity_manage_action_vibrate);
etVibratePattern = (EditText)findViewById(R.id.etVibratePattern);
@@ -58,7 +64,20 @@ public class ActivityManageActionVibrate extends Activity
if (ActivityPermissions.havePermission(Manifest.permission.VIBRATE, ActivityManageActionVibrate.this))
{
String pattern = etVibratePattern.getText().toString();
Actions.vibrate(false, pattern);
String[] patternArray = pattern.split(",");
long sum = 0;
for(String element : patternArray)
sum += Long.parseLong(element);
if(sum <= 2000)
Actions.vibrate(false, pattern);
else
{
pdPleaseWait = ProgressDialog.show(ActivityManageActionVibrate.this, null, getResources().getString(R.string.pleaseWait));
VibrateTask vt = new VibrateTask();
vt.execute(pattern);
}
}
}
}
@@ -82,4 +101,22 @@ public class ActivityManageActionVibrate extends Activity
return true;
}
class VibrateTask extends AsyncTask<String, Void, Void>
{
@Override
protected Void doInBackground(String... strings)
{
String pattern = (String)strings[0];
Actions.vibrate(false, pattern);
return null;
}
@Override
protected void onPostExecute(Void unused)
{
pdPleaseWait.dismiss();
super.onPostExecute(unused);
}
}
}
@@ -0,0 +1,101 @@
package com.jens.automation2;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;
import androidx.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;
public class ActivityManageActionWakeLock extends Activity
{
RadioButton rbWakeLockActivate, rbWakeLockDeactivate;
CheckBox chkWakeLockTimeout;
EditText etWakeLockDuration;
Button bSaveWakelock;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(this);
Miscellaneous.setUiTheme(this);
setContentView(R.layout.activity_manage_action_wakelock);
rbWakeLockActivate = (RadioButton)findViewById(R.id.rbWakeLockActivate);
rbWakeLockDeactivate = (RadioButton)findViewById(R.id.rbWakeLockDeactivate);
chkWakeLockTimeout = (CheckBox)findViewById(R.id.chkWakeLockTimeout);
etWakeLockDuration = (EditText)findViewById(R.id.etWakeLockDuration);
bSaveWakelock = (Button)findViewById(R.id.bSaveWakelock);
etWakeLockDuration.setEnabled(chkWakeLockTimeout.isChecked());
chkWakeLockTimeout.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean wakeLockTimeoutSet)
{
etWakeLockDuration.setEnabled(wakeLockTimeoutSet);
if(wakeLockTimeoutSet)
etWakeLockDuration.setText(String.valueOf(Actions.wakeLockTimeoutDisabled));
}
});
if(getIntent().hasExtra(ActivityManageRule.intentNameActionParameter1))
{
rbWakeLockActivate.setChecked(getIntent().getBooleanExtra(ActivityManageRule.intentNameActionParameter1, true));
rbWakeLockDeactivate.setChecked(!getIntent().getBooleanExtra(ActivityManageRule.intentNameActionParameter1, false));
if(getIntent().hasExtra(ActivityManageRule.intentNameActionParameter2))
{
if(Miscellaneous.isNumeric(getIntent().getStringExtra(ActivityManageRule.intentNameActionParameter2)))
{
long timeout = Long.parseLong((getIntent().getStringExtra(ActivityManageRule.intentNameActionParameter2)));
chkWakeLockTimeout.setChecked(timeout != Actions.wakeLockTimeoutDisabled);
etWakeLockDuration.setText(String.valueOf(timeout));
}
else
{
chkWakeLockTimeout.setChecked(false);
etWakeLockDuration.setText(String.valueOf(Actions.wakeLockTimeoutDisabled));
}
}
}
bSaveWakelock.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
if(chkWakeLockTimeout.isChecked())
{
if((StringUtils.isEmpty(etWakeLockDuration.getText().toString()) || Integer.parseInt(etWakeLockDuration.getText().toString()) <= 0))
{
Toast.makeText(ActivityManageActionWakeLock.this, getResources().getString(R.string.enterAPositiveValidNonDecimalNumber), Toast.LENGTH_LONG).show();
return;
}
}
Intent response = new Intent();
response.putExtra(ActivityManageRule.intentNameActionParameter1, rbWakeLockActivate.isChecked());
if(chkWakeLockTimeout.isChecked())
response.putExtra(ActivityManageRule.intentNameActionParameter2, etWakeLockDuration.getText().toString());
else
response.putExtra(ActivityManageRule.intentNameActionParameter2, String.valueOf(Actions.wakeLockTimeoutDisabled));
setResult(RESULT_OK, response);
finish();
}
});
}
}
@@ -0,0 +1,65 @@
package com.jens.automation2;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;