Compare commits
138 Commits
Author | SHA1 | Date | |
---|---|---|---|
4f971e8a1b | |||
34fbc1d005 | |||
b72049defc | |||
54f3cc84c4 | |||
7884358564 | |||
f24c9f99dc | |||
64b97c650d | |||
9daf4c4747 | |||
94f7936c4a | |||
02f7b642cf | |||
8d10bf05af | |||
8c0cee9589 | |||
6b23bd6733 | |||
1a60c88f35 | |||
3312d99177 | |||
ea01806915 | |||
36173f2fcb | |||
4c66fe906e | |||
60cfa150b5 | |||
bd2231b075 | |||
158f5f2e04 | |||
f1315dc742 | |||
28aa0c3e4b | |||
6b9dbca7ab | |||
291e0c41af | |||
c9eedd5d87 | |||
2470321e15 | |||
d85a199117 | |||
b047cde4ea | |||
9a1796f2eb | |||
7e8a6b121e | |||
810c7488c4 | |||
8af24695fd | |||
533a9bf54d | |||
8653e4853b | |||
c464a9d71f | |||
26e4851c0d | |||
11f0ee25bf | |||
a76cafc6e2 | |||
bd2920e6d9 | |||
5caf33b45d | |||
6a74d070eb | |||
eba02ade08 | |||
394effea36 | |||
4d51f1890a | |||
a8b2c3bf7d | |||
d1c6abaa91 | |||
587ed5803e | |||
49d272be1e | |||
d9e54c7780 | |||
170dbbc7e8 | |||
3fc1dd1a26 | |||
0acb52099c | |||
b6015a3f2e | |||
ae1e767fa6 | |||
6e12e71133 | |||
e4e3faea06 | |||
7c42250e13 | |||
ebb0724b28 | |||
a7ae0c6588 | |||
e5433bf2ec | |||
fd8ffd4f7d | |||
f49455712a | |||
132f64114e | |||
27e9b3e0d1 | |||
a6c6dfc6ba | |||
6a7875cc61 | |||
6f80caa1c6 | |||
a9646cbf28 | |||
52edfa32df | |||
ca81e6a7bd | |||
49e4c20ab6 | |||
ab98b4d1db | |||
6b32301894 | |||
d9cdfab828 | |||
62a8723344 | |||
2b69938ad5 | |||
c42f65bd3a | |||
ad0d9962b5 | |||
58f24953f3 | |||
3d212456e6 | |||
fff0a28310 | |||
48da91cb40 | |||
98df050f42 | |||
93cb72ac2f | |||
713228c06e | |||
c868d45896 | |||
4abce042eb | |||
62034e1b10 | |||
135f4594be | |||
900aaf3c8c | |||
5baa40ed59 | |||
759e8076c3 | |||
17b9f19dc2 | |||
374a5c4263 | |||
2fd79140cb | |||
a0910e620f | |||
475c1719d7 | |||
baa39c7a77 | |||
e11cc09da2 | |||
eff04037a1 | |||
b73a45f4cd | |||
fad6050c7a | |||
8a00529991 | |||
1d7cf00b94 | |||
d74e2eae68 | |||
4f7c36c4f7 | |||
b0df3efa27 | |||
f99418fda3 | |||
e05a42f5d6 | |||
83a27dcfdb | |||
bdc89a855b | |||
7ce203a679 | |||
57bc666453 | |||
c966981eae | |||
7a05b9a95b | |||
7fdbf74906 | |||
d17e8b70fe | |||
f97bfbb732 | |||
937c6ffe1d | |||
1ecc61452f | |||
19fd2d098b | |||
d07c1a05e4 | |||
f9f9b30116 | |||
d154a3d64f | |||
eeb4f4a39e | |||
53e62068a5 | |||
922807d903 | |||
a7d294c115 | |||
2d2fd901a1 | |||
536a5e22f9 | |||
99faa2f7ef | |||
f3fac2f4e8 | |||
b3b713e454 | |||
b0d509aafe | |||
efb4919a1e | |||
7bc858fee3 | |||
647d5bd511 |
2
.gitignore
vendored
@ -145,7 +145,7 @@ fabric.properties
|
|||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/androidstudio
|
# End of https://www.toptal.com/developers/gitignore/api/androidstudio
|
||||||
|
|
||||||
|
output-metadata.json
|
||||||
/app/app-release.apk
|
/app/app-release.apk
|
||||||
Automation_settings.xml
|
Automation_settings.xml
|
||||||
/app/googlePlayFlavor/
|
/app/googlePlayFlavor/
|
||||||
|
@ -11,8 +11,8 @@ android {
|
|||||||
compileSdkVersion 31
|
compileSdkVersion 31
|
||||||
buildToolsVersion '29.0.2'
|
buildToolsVersion '29.0.2'
|
||||||
useLibrary 'org.apache.http.legacy'
|
useLibrary 'org.apache.http.legacy'
|
||||||
versionCode 121
|
versionCode 136
|
||||||
versionName "1.7.6"
|
versionName "1.7.19"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
@ -36,9 +36,15 @@ android {
|
|||||||
{
|
{
|
||||||
dimension "version"
|
dimension "version"
|
||||||
versionNameSuffix "-googlePlay"
|
versionNameSuffix "-googlePlay"
|
||||||
targetSdkVersion 30
|
targetSdkVersion 33
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
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
|
fdroidFlavor
|
||||||
{
|
{
|
||||||
dimension "version"
|
dimension "version"
|
||||||
@ -72,9 +78,9 @@ dependencies {
|
|||||||
|
|
||||||
//implementation "androidx.security:security-crypto:1.0.0"
|
//implementation "androidx.security:security-crypto:1.0.0"
|
||||||
//implementation "androidx.security:security-identity-credential:1.0.0-alpha02"
|
//implementation "androidx.security:security-identity-credential:1.0.0-alpha02"
|
||||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
implementation 'androidx.appcompat:appcompat:1.4.2'
|
||||||
implementation 'com.google.android.material:material:1.3.0'
|
implementation 'com.google.android.material:material:1.6.1'
|
||||||
testImplementation 'junit:junit:4.+'
|
testImplementation 'junit:junit:4'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
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": 121,
|
|
||||||
"versionName": "1.7.6-googlePlay",
|
|
||||||
"outputFile": "app-googlePlayFlavor-release.apk"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"elementType": "File"
|
|
||||||
}
|
|
@ -66,6 +66,10 @@
|
|||||||
<uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/>
|
<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.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
||||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
|
<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.permission.READ_CALL_LOG" />
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.telephony"
|
android:name="android.hardware.telephony"
|
||||||
@ -83,7 +87,7 @@
|
|||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:allowClearUserData="true"
|
android:allowClearUserData="true"
|
||||||
android:icon="@drawable/gears"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:networkSecurityConfig="@xml/network_security_config">
|
android:networkSecurityConfig="@xml/network_security_config">
|
||||||
@ -169,6 +173,13 @@
|
|||||||
<activity android:name=".ActivityManageActionRunExecutable" />
|
<activity android:name=".ActivityManageActionRunExecutable" />
|
||||||
<activity android:name=".ActivityManageActionWifi" />
|
<activity android:name=".ActivityManageActionWifi" />
|
||||||
<activity android:name=".ActivityManageTriggerTethering" />
|
<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
|
<activity
|
||||||
android:name=".ActivityMainTabLayout"
|
android:name=".ActivityMainTabLayout"
|
||||||
android:launchMode="singleTask">
|
android:launchMode="singleTask">
|
||||||
|
@ -107,7 +107,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
}
|
}
|
||||||
public void setName(String name)
|
public void setName(String name)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void readFromFile()
|
public static void readFromFile()
|
||||||
@ -347,8 +347,17 @@ public class Rule implements Comparable<Rule>
|
|||||||
if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.timeFrame))
|
if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.timeFrame))
|
||||||
{
|
{
|
||||||
if(oneTrigger.getTimeFrame().repetition > 0)
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.broadcastReceived))
|
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.broadcastReceived))
|
||||||
{
|
{
|
||||||
return oneTrigger.getTriggerParameter() == BroadcastListener.getInstance().hasBroadcastOccurredSince(oneTrigger.getTriggerParameter2(), getLastExecution());
|
return oneTrigger.getTriggerParameter() == BroadcastListener.getInstance().hasBroadcastOccurredSince(oneTrigger.getTriggerParameter2(), getLastExecution());
|
||||||
@ -396,7 +405,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,6 +476,8 @@ public class Rule implements Comparable<Rule>
|
|||||||
{
|
{
|
||||||
AutomationService service = AutomationService.getInstance();
|
AutomationService service = AutomationService.getInstance();
|
||||||
service.speak(messages[0], false);
|
service.speak(messages[0], false);
|
||||||
|
|
||||||
|
if(Settings.showToasts)
|
||||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
super.onProgressUpdate(messages);
|
super.onProgressUpdate(messages);
|
||||||
|
@ -64,6 +64,10 @@
|
|||||||
<uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/>
|
<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.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
||||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
|
<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.permission.READ_CALL_LOG" />
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.telephony"
|
android:name="android.hardware.telephony"
|
||||||
@ -81,7 +85,7 @@
|
|||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:allowClearUserData="true"
|
android:allowClearUserData="true"
|
||||||
android:icon="@drawable/gears"
|
android:icon="@drawable/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:networkSecurityConfig="@xml/network_security_config">
|
android:networkSecurityConfig="@xml/network_security_config">
|
||||||
@ -167,6 +171,12 @@
|
|||||||
<activity android:name=".ActivityManageActionRunExecutable" />
|
<activity android:name=".ActivityManageActionRunExecutable" />
|
||||||
<activity android:name=".ActivityManageActionWifi" />
|
<activity android:name=".ActivityManageActionWifi" />
|
||||||
<activity android:name=".ActivityManageTriggerTethering" />
|
<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
|
<activity
|
||||||
android:name=".ActivityMainTabLayout"
|
android:name=".ActivityMainTabLayout"
|
||||||
android:launchMode="singleTask">
|
android:launchMode="singleTask">
|
||||||
|
@ -104,7 +104,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
}
|
}
|
||||||
public void setName(String name)
|
public void setName(String name)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void readFromFile()
|
public static void readFromFile()
|
||||||
@ -393,7 +393,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,6 +440,8 @@ public class Rule implements Comparable<Rule>
|
|||||||
{
|
{
|
||||||
AutomationService service = AutomationService.getInstance();
|
AutomationService service = AutomationService.getInstance();
|
||||||
service.speak(messages[0], false);
|
service.speak(messages[0], false);
|
||||||
|
|
||||||
|
if(Settings.showToasts)
|
||||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
super.onProgressUpdate(messages);
|
super.onProgressUpdate(messages);
|
||||||
|
@ -64,11 +64,12 @@
|
|||||||
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
|
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
|
||||||
<uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/>
|
<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.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
||||||
|
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:allowClearUserData="true"
|
android:allowClearUserData="true"
|
||||||
android:icon="@drawable/gears"
|
android:icon="@drawable/crane"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/AppTheme"
|
android:theme="@style/AppTheme"
|
||||||
android:networkSecurityConfig="@xml/network_security_config">
|
android:networkSecurityConfig="@xml/network_security_config">
|
||||||
@ -111,6 +112,7 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
<receiver android:name=".receivers.PackageReplacedReceiver"
|
<receiver android:name=".receivers.PackageReplacedReceiver"
|
||||||
|
android:exported="true"
|
||||||
android:enabled="true">
|
android:enabled="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||||
@ -122,6 +124,7 @@
|
|||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".DeviceAdmin"
|
android:name=".DeviceAdmin"
|
||||||
|
android:exported="true"
|
||||||
android:description="@string/app_name"
|
android:description="@string/app_name"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:permission= "android.permission.BIND_DEVICE_ADMIN" >
|
android:permission= "android.permission.BIND_DEVICE_ADMIN" >
|
||||||
@ -154,8 +157,14 @@
|
|||||||
<activity android:name=".ActivityManageActionRunExecutable" />
|
<activity android:name=".ActivityManageActionRunExecutable" />
|
||||||
<activity android:name=".ActivityManageActionWifi" />
|
<activity android:name=".ActivityManageActionWifi" />
|
||||||
<activity android:name=".ActivityManageTriggerTethering" />
|
<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
|
<activity
|
||||||
android:name=".ActivityMainTabLayout"
|
android:name=".ActivityMainTabLayout"
|
||||||
|
android:exported="true"
|
||||||
android:launchMode="singleTask">
|
android:launchMode="singleTask">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
@ -204,6 +213,7 @@
|
|||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".receivers.NotificationListener"
|
android:name=".receivers.NotificationListener"
|
||||||
|
android:exported="true"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" >
|
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" >
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -107,7 +107,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
}
|
}
|
||||||
public void setName(String name)
|
public void setName(String name)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void readFromFile()
|
public static void readFromFile()
|
||||||
@ -396,7 +396,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,6 +467,8 @@ public class Rule implements Comparable<Rule>
|
|||||||
{
|
{
|
||||||
AutomationService service = AutomationService.getInstance();
|
AutomationService service = AutomationService.getInstance();
|
||||||
service.speak(messages[0], false);
|
service.speak(messages[0], false);
|
||||||
|
|
||||||
|
if(Settings.showToasts)
|
||||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
super.onProgressUpdate(messages);
|
super.onProgressUpdate(messages);
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
@ -6,8 +6,6 @@ import android.os.Build;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.RequiresApi;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
|
||||||
@ -53,6 +51,11 @@ public class Action
|
|||||||
closeNotification,
|
closeNotification,
|
||||||
sendBroadcast,
|
sendBroadcast,
|
||||||
runExecutable,
|
runExecutable,
|
||||||
|
wakelock,
|
||||||
|
setVariable,
|
||||||
|
startPhoneCall,
|
||||||
|
stopPhoneCall,
|
||||||
|
copyToClipboard,
|
||||||
sendTextMessage;
|
sendTextMessage;
|
||||||
|
|
||||||
public String getFullName(Context context)
|
public String getFullName(Context context)
|
||||||
@ -127,6 +130,16 @@ public class Action
|
|||||||
return context.getResources().getString(R.string.sendBroadcast);
|
return context.getResources().getString(R.string.sendBroadcast);
|
||||||
case runExecutable:
|
case runExecutable:
|
||||||
return context.getResources().getString(R.string.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);
|
||||||
default:
|
default:
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
@ -273,6 +286,27 @@ public class Action
|
|||||||
case runExecutable:
|
case runExecutable:
|
||||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.runExecutable));
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.runExecutable));
|
||||||
break;
|
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));
|
||||||
default:
|
default:
|
||||||
returnString.append(action.toString());
|
returnString.append(action.toString());
|
||||||
}
|
}
|
||||||
@ -330,6 +364,14 @@ public class Action
|
|||||||
|
|
||||||
if (parts.length > 4 && !StringUtils.isBlank(parts[4]))
|
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]);
|
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.setWifi))
|
else if (this.getAction().equals(Action_Enum.setWifi))
|
||||||
{
|
{
|
||||||
@ -372,6 +414,8 @@ public class Action
|
|||||||
{
|
{
|
||||||
returnString.append(": " + parameter2.replace(Action.actionParameter2Split, "; ").replace(Action.intentPairSeparator, "/"));
|
returnString.append(": " + parameter2.replace(Action.actionParameter2Split, "; ").replace(Action.intentPairSeparator, "/"));
|
||||||
}
|
}
|
||||||
|
else if(this.getAction().equals(Action_Enum.setVariable) || this.getAction().equals(Action_Enum.copyToClipboard))
|
||||||
|
; // it's completed further above already
|
||||||
else if (parameter2 != null && parameter2.length() > 0)
|
else if (parameter2 != null && parameter2.length() > 0)
|
||||||
returnString.append(": " + parameter2.replace(Action.actionParameter2Split, "; "));
|
returnString.append(": " + parameter2.replace(Action.actionParameter2Split, "; "));
|
||||||
}
|
}
|
||||||
@ -485,7 +529,7 @@ public class Action
|
|||||||
Actions.setUsbTethering(context, getParameter1(), toggleActionIfPossible);
|
Actions.setUsbTethering(context, getParameter1(), toggleActionIfPossible);
|
||||||
break;
|
break;
|
||||||
case setWifi:
|
case setWifi:
|
||||||
Actions.WifiStuff.setWifi(context, getParameter1(), toggleActionIfPossible);
|
Actions.WifiStuff.setWifi(context, getParameter1(), getParameter2(), toggleActionIfPossible);
|
||||||
break;
|
break;
|
||||||
case setWifiTethering:
|
case setWifiTethering:
|
||||||
Actions.setWifiTethering(context, getParameter1(), toggleActionIfPossible);
|
Actions.setWifiTethering(context, getParameter1(), toggleActionIfPossible);
|
||||||
@ -570,6 +614,24 @@ public class Action
|
|||||||
else if(execParts.length == 2)
|
else if(execParts.length == 2)
|
||||||
Actions.runExecutable(context, this.getParameter1(), execParts[0], execParts[1]);
|
Actions.runExecutable(context, this.getParameter1(), execParts[0], execParts[1]);
|
||||||
break;
|
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;
|
||||||
default:
|
default:
|
||||||
Miscellaneous.logEvent("w", "Action", context.getResources().getString(R.string.unknownActionSpecified), 3);
|
Miscellaneous.logEvent("w", "Action", context.getResources().getString(R.string.unknownActionSpecified), 3);
|
||||||
break;
|
break;
|
||||||
@ -596,7 +658,7 @@ public class Action
|
|||||||
password = components[1];
|
password = components[1];
|
||||||
url = components[2];
|
url = components[2];
|
||||||
}
|
}
|
||||||
else
|
else // compatibility for very old versions which haven't upgraded, yet.
|
||||||
url = components[0];
|
url = components[0];
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -15,8 +15,6 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.media.MediaPlayer;
|
import android.media.MediaPlayer;
|
||||||
import android.media.session.MediaController;
|
|
||||||
import android.media.session.MediaSessionManager;
|
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
@ -26,8 +24,8 @@ import android.os.PowerManager.WakeLock;
|
|||||||
import android.os.VibrationEffect;
|
import android.os.VibrationEffect;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.service.notification.NotificationListenerService;
|
|
||||||
import android.service.notification.StatusBarNotification;
|
import android.service.notification.StatusBarNotification;
|
||||||
|
import android.telecom.TelecomManager;
|
||||||
import android.telephony.SmsManager;
|
import android.telephony.SmsManager;
|
||||||
import android.telephony.SubscriptionManager;
|
import android.telephony.SubscriptionManager;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
@ -70,6 +68,7 @@ import java.util.Collections;
|
|||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -82,10 +81,6 @@ public class Actions
|
|||||||
public static AutomationService automationServerRef;
|
public static AutomationService automationServerRef;
|
||||||
public static Context context;
|
public static Context context;
|
||||||
private static Intent playMusicIntent;
|
private static Intent playMusicIntent;
|
||||||
private static boolean suAvailable = false;
|
|
||||||
private static String suVersion = null;
|
|
||||||
private static String suVersionInternal = null;
|
|
||||||
private static List<String> suResult = null;
|
|
||||||
public final static String smsSeparator = "&sms&";
|
public final static String smsSeparator = "&sms&";
|
||||||
public final static String dummyPackageString = "dummyPkg239asd";
|
public final static String dummyPackageString = "dummyPkg239asd";
|
||||||
|
|
||||||
@ -99,6 +94,7 @@ public class Actions
|
|||||||
|
|
||||||
Miscellaneous.logEvent("w", "createNotification", "Creating notification with title " + elements[0] + " and text " + elements[1], 3);
|
Miscellaneous.logEvent("w", "createNotification", "Creating notification with title " + elements[0] + " and text " + elements[1], 3);
|
||||||
|
|
||||||
|
// Create a new notification ID each time
|
||||||
int notificationId = Math.round(Calendar.getInstance().getTimeInMillis()/1000);
|
int notificationId = Math.round(Calendar.getInstance().getTimeInMillis()/1000);
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -117,8 +113,8 @@ public class Actions
|
|||||||
public static void closeNotification(Action action)
|
public static void closeNotification(Action action)
|
||||||
{
|
{
|
||||||
NotificationManager nm = (NotificationManager) Miscellaneous.getAnyContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
NotificationManager nm = (NotificationManager) Miscellaneous.getAnyContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
for(StatusBarNotification n : nm.getActiveNotifications())
|
// for(StatusBarNotification n : nm.getActiveNotifications())
|
||||||
{
|
// {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
|
||||||
{
|
{
|
||||||
String[] params = action.getParameter2().split(Action.actionParameter2Split);
|
String[] params = action.getParameter2().split(Action.actionParameter2Split);
|
||||||
@ -127,11 +123,14 @@ public class Actions
|
|||||||
String myTitleDir = params[1];
|
String myTitleDir = params[1];
|
||||||
String requiredTitle = params[2];
|
String requiredTitle = params[2];
|
||||||
String myTextDir = params[3];
|
String myTextDir = params[3];
|
||||||
String requiredText;
|
String requiredText = "";
|
||||||
|
String method = ActivityManageActionCloseNotification.dismissRegularString;
|
||||||
|
|
||||||
if(params.length >= 5)
|
if(params.length >= 5)
|
||||||
requiredText = params[4];
|
requiredText = params[4];
|
||||||
else
|
|
||||||
requiredText = "";
|
if(params.length >= 6 && !params[5].equals(ActivityManageActionCloseNotification.dismissRegularString))
|
||||||
|
method = params[5];
|
||||||
|
|
||||||
for (StatusBarNotification sbn : NotificationListener.getInstance().getActiveNotifications())
|
for (StatusBarNotification sbn : NotificationListener.getInstance().getActiveNotifications())
|
||||||
{
|
{
|
||||||
@ -185,12 +184,17 @@ public class Actions
|
|||||||
|
|
||||||
Miscellaneous.logEvent("i", "NotificationCloseCheck", "All criteria matches. Closing notification: " + sbn.getNotification().toString(), 3);
|
Miscellaneous.logEvent("i", "NotificationCloseCheck", "All criteria matches. Closing notification: " + sbn.getNotification().toString(), 3);
|
||||||
if(NotificationListener.getInstance() != null)
|
if(NotificationListener.getInstance() != null)
|
||||||
|
{
|
||||||
|
if(method == ActivityManageActionCloseNotification.dismissRegularString)
|
||||||
NotificationListener.getInstance().dismissNotification(sbn);
|
NotificationListener.getInstance().dismissNotification(sbn);
|
||||||
|
else
|
||||||
|
NotificationListener.getInstance().clickNotificationButton(sbn, method);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Miscellaneous.logEvent("i", "NotificationCloseCheck", "NotificationListener instance is null. Can\'t close notification.", 3);
|
Miscellaneous.logEvent("i", "NotificationCloseCheck", "NotificationListener instance is null. Can\'t close notification.", 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendBroadcast(Context context, String action)
|
public static void sendBroadcast(Context context, String action)
|
||||||
@ -212,11 +216,50 @@ public class Actions
|
|||||||
context.sendBroadcast(broadcastIntent);
|
context.sendBroadcast(broadcastIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setVariable(String parameter2)
|
||||||
|
{
|
||||||
|
String[] parts = parameter2.split(Action.actionParameter2Split);
|
||||||
|
|
||||||
|
if(AutomationService.isMyServiceRunning(Miscellaneous.getAnyContext()))
|
||||||
|
{
|
||||||
|
Map<String,String> map = AutomationService.getInstance().getVariableMap();
|
||||||
|
|
||||||
|
if(parts.length > 1)
|
||||||
|
map.put(parts[0], parts[1]);
|
||||||
|
else
|
||||||
|
map.remove(parts[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Miscellaneous.logEvent("i", "Variable", "Checking for applicable rules after variable has been set or deleted.", 2);
|
||||||
|
List<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.checkVariable);
|
||||||
|
for(int i=0; i<ruleCandidates.size(); i++)
|
||||||
|
{
|
||||||
|
if(ruleCandidates.get(i).haveEnoughPermissions() && ruleCandidates.get(i).getsGreenLight(AutomationService.getInstance()))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "Variable", "Rule " + ruleCandidates.get(i).getName() + " applies after variable has been set or deleted.", 2);
|
||||||
|
ruleCandidates.get(i).activate(AutomationService.getInstance(), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Miscellaneous.logEvent("i", "Variable", "Done checking for applicable rules after variable has been set or deleted.", 2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static class WifiStuff
|
public static class WifiStuff
|
||||||
{
|
{
|
||||||
public static Boolean setWifi(Context context, Boolean desiredState, boolean toggleActionIfPossible)
|
public static Boolean setWifi(Context context, Boolean desiredState, String parameter2, boolean toggleActionIfPossible)
|
||||||
{
|
{
|
||||||
if(context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.Q)
|
boolean forceUseRoot = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
forceUseRoot = Boolean.parseBoolean(parameter2);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.Q || forceUseRoot)
|
||||||
return setWifiWithRoot(context, desiredState, toggleActionIfPossible);
|
return setWifiWithRoot(context, desiredState, toggleActionIfPossible);
|
||||||
else
|
else
|
||||||
return setWifiOldFashioned(context, desiredState, toggleActionIfPossible);
|
return setWifiOldFashioned(context, desiredState, toggleActionIfPossible);
|
||||||
@ -252,8 +295,15 @@ public class Actions
|
|||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "Wifi", "Changing wifi to " + String.valueOf(desiredState), 4);
|
Miscellaneous.logEvent("i", "Wifi", "Changing wifi to " + String.valueOf(desiredState), 4);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (desiredState && Settings.useWifiForPositioning)
|
if (desiredState && Settings.useWifiForPositioning)
|
||||||
WifiBroadcastReceiver.startWifiReceiver(automationServerRef.getLocationProvider());
|
WifiBroadcastReceiver.startWifiReceiver(automationServerRef.getLocationProvider());
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("w", "setWifiOldFashioned()", Log.getStackTraceString(e), 4);
|
||||||
|
}
|
||||||
|
|
||||||
WifiManager myWifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
WifiManager myWifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
|
||||||
|
|
||||||
@ -997,7 +1047,7 @@ public class Actions
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Intent externalActivityIntent;
|
Intent externalApplicationIntent;
|
||||||
|
|
||||||
if (!startByAction)
|
if (!startByAction)
|
||||||
{
|
{
|
||||||
@ -1010,15 +1060,15 @@ public class Actions
|
|||||||
|
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Starting app by activity: " + packageName + " " + className, 3);
|
Miscellaneous.logEvent("i", "StartOtherApp", "Starting app by activity: " + packageName + " " + className, 3);
|
||||||
|
|
||||||
externalActivityIntent = new Intent(Intent.ACTION_MAIN);
|
externalApplicationIntent = new Intent(Intent.ACTION_MAIN);
|
||||||
externalActivityIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
externalApplicationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||||
|
|
||||||
// if(packageName.equals("dummyPkg"))
|
if(packageName.equals("dummyPkg"))
|
||||||
// externalActivityIntent.setAction(className);
|
externalApplicationIntent.setAction(className);
|
||||||
// else
|
|
||||||
externalActivityIntent.setClassName(packageName, className);
|
|
||||||
|
|
||||||
if (!Miscellaneous.doesActivityExist(externalActivityIntent, Miscellaneous.getAnyContext()))
|
externalApplicationIntent.setClassName(packageName, className);
|
||||||
|
|
||||||
|
if (!Miscellaneous.doesActivityExist(externalApplicationIntent, Miscellaneous.getAnyContext()))
|
||||||
Miscellaneous.logEvent("w", "StartOtherApp", "Activity not found: " + className, 2);
|
Miscellaneous.logEvent("w", "StartOtherApp", "Activity not found: " + className, 2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1026,23 +1076,32 @@ public class Actions
|
|||||||
// selected by action
|
// selected by action
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Starting app by action: " + param, 3);
|
Miscellaneous.logEvent("i", "StartOtherApp", "Starting app by action: " + param, 3);
|
||||||
|
|
||||||
externalActivityIntent = new Intent();
|
externalApplicationIntent = new Intent();
|
||||||
|
|
||||||
if (!params[0].equals(dummyPackageString))
|
if (!params[0].equals(dummyPackageString))
|
||||||
externalActivityIntent.setPackage(params[0]);
|
externalApplicationIntent.setPackage(params[0]);
|
||||||
|
|
||||||
externalActivityIntent.setAction(params[1]);
|
externalApplicationIntent.setAction(params[1]);
|
||||||
|
|
||||||
|
if (params[2].equals(ActivityManageActionStartActivity.startByServiceString) || params[2].equals(ActivityManageActionStartActivity.startByForegroundServiceString))
|
||||||
|
{
|
||||||
|
externalApplicationIntent.setComponent(new ComponentName(params[0], params[2]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
externalActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
externalApplicationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
|
||||||
// Pack intents
|
// Pack intents
|
||||||
externalActivityIntent = packParametersIntoIntent(externalActivityIntent, params, 3);
|
externalApplicationIntent = packParametersIntoIntent(externalApplicationIntent, params, 3);
|
||||||
|
|
||||||
if (params[2].equals(ActivityManageActionStartActivity.startByActivityString))
|
if (params[2].equals(ActivityManageActionStartActivity.startByActivityString))
|
||||||
automationServerRef.startActivity(externalActivityIntent);
|
automationServerRef.startActivity(externalApplicationIntent);
|
||||||
|
else if (params[2].equals(ActivityManageActionStartActivity.startByServiceString))
|
||||||
|
automationServerRef.startService(externalApplicationIntent);
|
||||||
|
else if (params[2].equals(ActivityManageActionStartActivity.startByForegroundServiceString) && Build.VERSION.SDK_INT >= 26)
|
||||||
|
automationServerRef.startForegroundService(externalApplicationIntent);
|
||||||
else
|
else
|
||||||
automationServerRef.sendBroadcast(externalActivityIntent);
|
automationServerRef.sendBroadcast(externalApplicationIntent);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -1113,23 +1172,38 @@ public class Actions
|
|||||||
intent.putExtra(singleParam[1], Short.parseShort(singleParam[2]));
|
intent.putExtra(singleParam[1], Short.parseShort(singleParam[2]));
|
||||||
}
|
}
|
||||||
else if (singleParam[0].equals("Uri"))
|
else if (singleParam[0].equals("Uri"))
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (singleParam[1].equalsIgnoreCase("IntentData"))
|
if (singleParam[1].equalsIgnoreCase("IntentData"))
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with value " + singleParam[2] + " as standard data parameter.", 3);
|
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with value " + singleParam[2] + " as standard data parameter.", 3);
|
||||||
intent.setData(Uri.parse(singleParam[2]));
|
intent.setData(Uri.parse(Miscellaneous.replaceVariablesInText(singleParam[2], context)));
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||||
intent.putExtra(singleParam[1], Uri.parse(singleParam[2]));
|
intent.putExtra(singleParam[1], Uri.parse(Miscellaneous.replaceVariablesInText(singleParam[2], context)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (singleParam[0].equals("String"))
|
else if (singleParam[0].equals("String"))
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
intent.putExtra(singleParam[1], Miscellaneous.replaceVariablesInText(singleParam[2], context));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
intent.putExtra(singleParam[1], singleParam[2]);
|
intent.putExtra(singleParam[1], singleParam[2]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Miscellaneous.logEvent("w", "StartOtherApp", "Unknown type of parameter " + singleParam[0] + " found. Name " + singleParam[1] + " and value " + singleParam[2], 3);
|
Miscellaneous.logEvent("w", "StartOtherApp", "Unknown type of parameter " + singleParam[0] + " found. Name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||||
}
|
}
|
||||||
@ -1173,21 +1247,37 @@ public class Actions
|
|||||||
|
|
||||||
public static void sendTextMessage(Context context, String[] parametersArray)
|
public static void sendTextMessage(Context context, String[] parametersArray)
|
||||||
{
|
{
|
||||||
String phoneNumber, message;
|
String phoneNumber, message, messageType = ActivityManageActionSendTextMessage.messageTypeSms, filePath = null;
|
||||||
|
|
||||||
phoneNumber = parametersArray[0];
|
phoneNumber = parametersArray[0];
|
||||||
message = parametersArray[1];
|
message = parametersArray[1];
|
||||||
|
|
||||||
|
if(parametersArray.length > 2)
|
||||||
|
{
|
||||||
|
messageType = parametersArray[2];
|
||||||
|
|
||||||
|
if(parametersArray.length > 3)
|
||||||
|
filePath = parametersArray[3];
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String textToSend = Miscellaneous.replaceVariablesInText(message, context);
|
String textToSend = Miscellaneous.replaceVariablesInText(message, context);
|
||||||
|
if(messageType.equals("sms"))
|
||||||
|
sendSmsMessage(phoneNumber, textToSend);
|
||||||
|
else
|
||||||
|
sendMmsMessage(phoneNumber, textToSend, filePath);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("e", Miscellaneous.getAnyContext().getString(R.string.sendTextMessage), "Error in sendTextMessage: " + Log.getStackTraceString(e), 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
private static void sendSmsMessage(String phoneNumber, String textToSend)
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("sms:" + phoneNumber));
|
{
|
||||||
intent.putExtra("sms_body", message);
|
try
|
||||||
AutomationService.getInstance().startActivity(intent);
|
{
|
||||||
*/
|
|
||||||
|
|
||||||
PendingIntent pi = PendingIntent.getActivity(context, 0, new Intent(context, Actions.class), 0);
|
PendingIntent pi = PendingIntent.getActivity(context, 0, new Intent(context, Actions.class), 0);
|
||||||
SmsManager sms = SmsManager.getDefault();
|
SmsManager sms = SmsManager.getDefault();
|
||||||
sms.sendTextMessage(phoneNumber, null, textToSend, pi, null);
|
sms.sendTextMessage(phoneNumber, null, textToSend, pi, null);
|
||||||
@ -1198,6 +1288,26 @@ public class Actions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
private static void sendMmsMessage(String phoneNumber, String textToSend, String fileToBeAttached)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "sendMmsMessage()", "Sending MMS message...", 2);
|
||||||
|
// Uri contentUri = Uri.fromFile(new File(fileToBeAttached));
|
||||||
|
String str2 = "send." + String.valueOf(Math.abs(new Random().nextLong())) + ".dat";
|
||||||
|
Uri contentUri = new Uri.Builder().authority(context.getPackageName() + ".MmsFileProvider").path(str2).scheme("content").build();
|
||||||
|
|
||||||
|
// Bundle a3 = C3326a.m16196a(new C8792q("enableGroupMms", true), new C8792q("maxMessageSize", Integer.valueOf(C3664a.m17428d())));
|
||||||
|
|
||||||
|
SmsManager.getDefault().sendMultimediaMessage(context, contentUri, phoneNumber, null, null);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("e", "sendMmsMessage()", "Error in sendMmsMessage(): " + Log.getStackTraceString(e), 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class WakeUpDeviceClass implements Runnable
|
private static class WakeUpDeviceClass implements Runnable
|
||||||
{
|
{
|
||||||
private long awakeTime;
|
private long awakeTime;
|
||||||
@ -1864,6 +1974,12 @@ public class Actions
|
|||||||
|
|
||||||
protected static boolean executeCommandViaSu(String[] commands)
|
protected static boolean executeCommandViaSu(String[] commands)
|
||||||
{
|
{
|
||||||
|
boolean suAvailable = false;
|
||||||
|
String suVersion = null;
|
||||||
|
String suVersionInternal = null;
|
||||||
|
// List<String> suResult = null;
|
||||||
|
int suResult;
|
||||||
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -1873,17 +1989,30 @@ public class Actions
|
|||||||
{
|
{
|
||||||
suVersion = Shell.SU.version(false);
|
suVersion = Shell.SU.version(false);
|
||||||
suVersionInternal = Shell.SU.version(true);
|
suVersionInternal = Shell.SU.version(true);
|
||||||
suResult = Shell.SU.run(commands);
|
|
||||||
|
|
||||||
if (suResult != null)
|
Miscellaneous.logEvent("i", "executeCommandViaSu()", "suVersion: " + suVersion + ", suVersionInternal: " + suVersionInternal, 5);
|
||||||
|
|
||||||
|
// suResult = Shell.SU.run(commands);
|
||||||
|
suResult = Shell.Pool.SU.run(commands);
|
||||||
|
|
||||||
|
// if (suResult != null)
|
||||||
|
// success = true;
|
||||||
|
|
||||||
|
Miscellaneous.logEvent("i", "executeCommandViaSu()", "RC=" + String.valueOf(suResult), 3);
|
||||||
|
|
||||||
|
if(suResult == 0)
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
Miscellaneous.logEvent("w", "executeCommandViaSu()", "su not available.", 4);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Miscellaneous.logEvent("i", "executeCommandViaSu()", "Returning " + String.valueOf(success), 4);
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2092,4 +2221,117 @@ public class Actions
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final static int wakeLockTimeoutDisabled = -1;
|
||||||
|
static boolean wakeLockStopRequested = false;
|
||||||
|
public static void wakeLockStart(Context context, long duration)
|
||||||
|
{
|
||||||
|
Thread lockThread = new Thread(new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
wakeLockStopRequested = false;
|
||||||
|
|
||||||
|
long waited = 0;
|
||||||
|
int step = 2000;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
|
PowerManager.WakeLock fullWakeLock = powerManager.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "Loneworker - FULL WAKE LOCK");
|
||||||
|
fullWakeLock.acquire(); // turn on
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Thread.sleep(step); // turn on duration
|
||||||
|
}
|
||||||
|
catch (InterruptedException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(duration > 0)
|
||||||
|
waited += step;
|
||||||
|
|
||||||
|
if(wakeLockStopRequested) //stop requested
|
||||||
|
Miscellaneous.logEvent("i", "WakeLockStart", "Stop requested.", 4);
|
||||||
|
}
|
||||||
|
while(!wakeLockStopRequested && (duration < 0 || waited <= duration));
|
||||||
|
|
||||||
|
fullWakeLock.release();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
lockThread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void wakeLockStop()
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "WakeLockStart", "Requesting stop.", 4);
|
||||||
|
wakeLockStopRequested = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void startPhoneCall(Context context, String phoneNumber)
|
||||||
|
{
|
||||||
|
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + Uri.encode(phoneNumber)));
|
||||||
|
// intent.setClassName("com.android.phone","com.android.phone.OutgoingCallBroadcaster");
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
intent.addFlags(Intent.FLAG_FROM_BACKGROUND);
|
||||||
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void endPhoneCall(Context context)
|
||||||
|
{
|
||||||
|
if(Build.VERSION.SDK_INT < 21)
|
||||||
|
{
|
||||||
|
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Class c = Class.forName(tm.getClass().getName());
|
||||||
|
Method m = c.getDeclaredMethod("getITelephony");
|
||||||
|
m.setAccessible(true);
|
||||||
|
Object telephonyService = m.invoke(tm);
|
||||||
|
|
||||||
|
c = Class.forName(telephonyService.getClass().getName());
|
||||||
|
m = c.getDeclaredMethod("endCall");
|
||||||
|
m.setAccessible(true);
|
||||||
|
m.invoke(telephonyService);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TelecomManager mgr = (TelecomManager) context.getSystemService(context.TELECOM_SERVICE);
|
||||||
|
mgr.endCall();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void copyToClipboard(Context context, String text)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "Clipboard", "Copying data to clipboard: " + text, 4);
|
||||||
|
|
||||||
|
if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB)
|
||||||
|
{
|
||||||
|
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
clipboard.setText(text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
android.content.ClipData clip = android.content.ClipData.newPlainText("Data-from-Automation", text);
|
||||||
|
clipboard.setPrimaryClip(clip);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -39,8 +39,10 @@ public class ActivityControlCenter extends Activity
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_control_center);
|
setContentView(R.layout.activity_control_center);
|
||||||
|
|
||||||
|
|
||||||
bVolumeTest = (Button) findViewById(R.id.bVolumeTest);
|
bVolumeTest = (Button) findViewById(R.id.bVolumeTest);
|
||||||
bVolumeTest.setOnClickListener(new View.OnClickListener()
|
bVolumeTest.setOnClickListener(new View.OnClickListener()
|
||||||
{
|
{
|
||||||
@ -384,6 +386,7 @@ public class ActivityControlCenter extends Activity
|
|||||||
protected void onResume()
|
protected void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
|
|
||||||
String folder = Miscellaneous.getWriteableFolder();
|
String folder = Miscellaneous.getWriteableFolder();
|
||||||
if (folder != null && folder.length() > 0)
|
if (folder != null && folder.length() > 0)
|
||||||
|
@ -21,6 +21,7 @@ public class ActivityDisplayLongMessage extends Activity
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_display_long_message);
|
setContentView(R.layout.activity_display_long_message);
|
||||||
|
|
||||||
tvMessageTitle = (TextView)findViewById(R.id.tvMessageTitle);
|
tvMessageTitle = (TextView)findViewById(R.id.tvMessageTitle);
|
||||||
|
@ -13,7 +13,8 @@ public class ActivityHelp extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(layout.help_text);
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
|
setContentView(layout.activity_help_text);
|
||||||
|
|
||||||
TextView tvHelpTextEnergySaving = (TextView) findViewById(R.id.tvHelpTextEnergySaving);
|
TextView tvHelpTextEnergySaving = (TextView) findViewById(R.id.tvHelpTextEnergySaving);
|
||||||
tvHelpTextEnergySaving.setMovementMethod(LinkMovementMethod.getInstance());
|
tvHelpTextEnergySaving.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
|
@ -44,6 +44,7 @@ public class ActivityMainPoi extends ActivityGeneric
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.main_poi_layout);
|
setContentView(R.layout.main_poi_layout);
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
@ -107,6 +108,13 @@ public class ActivityMainPoi extends ActivityGeneric
|
|||||||
this.storeServiceReferenceInVariable();
|
this.storeServiceReferenceInVariable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume()
|
||||||
|
{
|
||||||
|
super.onResume();
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
|
}
|
||||||
|
|
||||||
private void buttonAddPoi()
|
private void buttonAddPoi()
|
||||||
{
|
{
|
||||||
poiToEdit = null;
|
poiToEdit = null;
|
||||||
@ -190,8 +198,27 @@ public class ActivityMainPoi extends ActivityGeneric
|
|||||||
startActivityForResult(manageSpecificPoiIntent, 2000);
|
startActivityForResult(manageSpecificPoiIntent, 2000);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
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()))
|
if(pointOfInterest.delete(Miscellaneous.getAnyContext()))
|
||||||
updateListView();
|
updateListView();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
deleteDialog.setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
deleteDialog.show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ public class ActivityMainProfiles extends ActivityGeneric
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.main_profile_layout);
|
setContentView(R.layout.main_profile_layout);
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
@ -154,6 +155,13 @@ public class ActivityMainProfiles extends ActivityGeneric
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume()
|
||||||
|
{
|
||||||
|
super.onResume();
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
|
}
|
||||||
|
|
||||||
private AlertDialog getProfileDialog(final Profile profile)
|
private AlertDialog getProfileDialog(final Profile profile)
|
||||||
{
|
{
|
||||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
|
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
|
||||||
@ -186,12 +194,31 @@ public class ActivityMainProfiles extends ActivityGeneric
|
|||||||
case 2:
|
case 2:
|
||||||
Rule user = profile.isInUseByRules();
|
Rule user = profile.isInUseByRules();
|
||||||
if(user == null)
|
if(user == null)
|
||||||
|
{
|
||||||
|
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))
|
if (profile.delete(ActivityMainProfiles.this))
|
||||||
updateListView();
|
updateListView();
|
||||||
else
|
else
|
||||||
Toast.makeText(ActivityMainProfiles.this, getResources().getString(R.string.profileCouldNotBeDeleted), Toast.LENGTH_LONG).show();
|
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
|
else
|
||||||
Toast.makeText(ActivityMainProfiles.this, String.format(getResources().getString(R.string.ruleXIsUsingProfileY), user.getName(), profile.getName()), Toast.LENGTH_LONG).show();
|
Toast.makeText(ActivityMainProfiles.this, String.format(getResources().getString(R.string.ruleXIsUsingProfileY), user.getName(), profile.getName()), Toast.LENGTH_LONG).show();
|
||||||
break;
|
break;
|
||||||
|
@ -18,6 +18,7 @@ import android.widget.ListView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
import com.jens.automation2.AutomationService.serviceCommands;
|
import com.jens.automation2.AutomationService.serviceCommands;
|
||||||
import com.jens.automation2.receivers.DateTimeListener;
|
import com.jens.automation2.receivers.DateTimeListener;
|
||||||
|
|
||||||
@ -47,6 +48,7 @@ public class ActivityMainRules extends ActivityGeneric
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.main_rule_layout);
|
setContentView(R.layout.main_rule_layout);
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
@ -153,6 +155,13 @@ public class ActivityMainRules extends ActivityGeneric
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume()
|
||||||
|
{
|
||||||
|
super.onResume();
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
||||||
{
|
{
|
||||||
@ -213,11 +222,30 @@ public class ActivityMainRules extends ActivityGeneric
|
|||||||
startActivityForResult(manageSpecificRuleIntent, requestCodeChangeRule);
|
startActivityForResult(manageSpecificRuleIntent, requestCodeChangeRule);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
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())
|
if(ruleThisIsAbout.delete())
|
||||||
{
|
{
|
||||||
ruleToEdit = null; //clear cache
|
ruleToEdit = null; //clear cache
|
||||||
updateListView();
|
updateListView();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
deleteDialog.setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialogInterface, int i)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
deleteDialog.show();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
ruleToEdit = ruleThisIsAbout;
|
ruleToEdit = ruleThisIsAbout;
|
||||||
|
@ -6,9 +6,12 @@ import android.app.AlertDialog;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -31,6 +34,7 @@ import com.jens.automation2.location.LocationProvider;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
public class ActivityMainScreen extends ActivityGeneric
|
public class ActivityMainScreen extends ActivityGeneric
|
||||||
@ -51,6 +55,7 @@ public class ActivityMainScreen extends ActivityGeneric
|
|||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.main_overview_layout);
|
setContentView(R.layout.main_overview_layout);
|
||||||
|
|
||||||
activityMainScreenInstance = this;
|
activityMainScreenInstance = this;
|
||||||
@ -270,9 +275,14 @@ public class ActivityMainScreen extends ActivityGeneric
|
|||||||
activityMainScreenInstance.tvMainScreenNotePermissions.setVisibility(View.GONE);
|
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);
|
activityMainScreenInstance.tvMainScreenNoteFeaturesFromOtherFlavor.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -283,14 +293,6 @@ public class ActivityMainScreen extends ActivityGeneric
|
|||||||
|
|
||||||
if(Miscellaneous.googleToBlameForLocation(true))
|
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.setText(R.string.locationEngineDisabledShort);
|
||||||
activityMainScreenInstance.tvMainScreenNoteLocationImpossibleBlameGoogle.setVisibility(View.VISIBLE);
|
activityMainScreenInstance.tvMainScreenNoteLocationImpossibleBlameGoogle.setVisibility(View.VISIBLE);
|
||||||
activityMainScreenInstance.tvMainScreenNoteLocationImpossibleBlameGoogle.setOnClickListener(new OnClickListener()
|
activityMainScreenInstance.tvMainScreenNoteLocationImpossibleBlameGoogle.setOnClickListener(new OnClickListener()
|
||||||
@ -315,8 +317,7 @@ public class ActivityMainScreen extends ActivityGeneric
|
|||||||
uiUpdateRunning = true;
|
uiUpdateRunning = true;
|
||||||
activityMainScreenInstance.toggleService.setChecked(true);
|
activityMainScreenInstance.toggleService.setChecked(true);
|
||||||
uiUpdateRunning = false;
|
uiUpdateRunning = false;
|
||||||
// if(activityMainScreenInstance.hasWindowFocus())
|
|
||||||
// {
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PointOfInterest activePoi = PointOfInterest.getActivePoi();
|
PointOfInterest activePoi = PointOfInterest.getActivePoi();
|
||||||
@ -433,7 +434,7 @@ public class ActivityMainScreen extends ActivityGeneric
|
|||||||
else
|
else
|
||||||
activityMainScreenInstance.checkForNews();
|
activityMainScreenInstance.checkForNews();
|
||||||
|
|
||||||
if(BuildConfig.FLAVOR.equals("apkFlavor") && Settings.automaticUpdateCheck)
|
if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_apk) && Settings.automaticUpdateCheck)
|
||||||
{
|
{
|
||||||
Calendar now = Calendar.getInstance();
|
Calendar now = Calendar.getInstance();
|
||||||
if (Settings.lastUpdateCheck == Settings.default_lastUpdateCheck || now.getTimeInMillis() >= Settings.lastUpdateCheck + (long)(Settings.updateCheckFrequencyDays * 24 * 60 * 60 * 1000))
|
if (Settings.lastUpdateCheck == Settings.default_lastUpdateCheck || now.getTimeInMillis() >= Settings.lastUpdateCheck + (long)(Settings.updateCheckFrequencyDays * 24 * 60 * 60 * 1000))
|
||||||
@ -570,6 +571,7 @@ public class ActivityMainScreen extends ActivityGeneric
|
|||||||
protected void onResume()
|
protected void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
toggleService.setChecked(AutomationService.isMyServiceRunning(this));
|
toggleService.setChecked(AutomationService.isMyServiceRunning(this));
|
||||||
ActivityMainScreen.updateMainScreen();
|
ActivityMainScreen.updateMainScreen();
|
||||||
|
|
||||||
|
@ -3,12 +3,17 @@ package com.jens.automation2;
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.TabActivity;
|
import android.app.TabActivity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
import android.widget.TabHost.TabSpec;
|
import android.widget.TabHost.TabSpec;
|
||||||
|
|
||||||
import com.jens.automation2.receivers.NfcReceiver;
|
import com.jens.automation2.receivers.NfcReceiver;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
public class ActivityMainTabLayout extends TabActivity
|
public class ActivityMainTabLayout extends TabActivity
|
||||||
@ -17,8 +22,8 @@ public class ActivityMainTabLayout extends TabActivity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
Settings.readFromPersistentStorage(ActivityMainTabLayout.this);
|
Settings.readFromPersistentStorage(ActivityMainTabLayout.this);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
|
|
||||||
if(Settings.tabsPlacement == 1)
|
if(Settings.tabsPlacement == 1)
|
||||||
setContentView(R.layout.main_tab_layout_tabs_at_bottom);
|
setContentView(R.layout.main_tab_layout_tabs_at_bottom);
|
||||||
@ -60,6 +65,7 @@ public class ActivityMainTabLayout extends TabActivity
|
|||||||
protected void onResume()
|
protected void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
// Miscellaneous.logEvent("i", "NFC", "ActivityMainTabLayout.onResume().", 5);
|
// Miscellaneous.logEvent("i", "NFC", "ActivityMainTabLayout.onResume().", 5);
|
||||||
NfcReceiver.checkIntentForNFC(this, getIntent());
|
NfcReceiver.checkIntentForNFC(this, getIntent());
|
||||||
// NfcReceiver.checkIntentForNFC(this, new Intent(this.getApplicationContext(), this.getClass()));
|
// NfcReceiver.checkIntentForNFC(this, new Intent(this.getApplicationContext(), this.getClass()));
|
||||||
|
@ -26,6 +26,7 @@ public class ActivityManageActionBrightnessSetting extends Activity
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
setContentView(R.layout.activity_manage_action_brightness_settings);
|
setContentView(R.layout.activity_manage_action_brightness_settings);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
chkAutoBrightness = (CheckBox)findViewById(R.id.chkAutoBrightness);
|
chkAutoBrightness = (CheckBox)findViewById(R.id.chkAutoBrightness);
|
||||||
|
@ -16,9 +16,12 @@ import android.view.View;
|
|||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.RadioButton;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@ -39,13 +42,16 @@ public class ActivityManageActionCloseNotification extends Activity
|
|||||||
boolean edit = false;
|
boolean edit = false;
|
||||||
ProgressDialog progressDialog = null;
|
ProgressDialog progressDialog = null;
|
||||||
|
|
||||||
EditText etNotificationTitle, etNotificationText;
|
EditText etNotificationTitle, etNotificationText, etNotificationDismissalButtonText;
|
||||||
Button bSelectApp, bSaveActionCloseNotification;
|
Button bSelectApp, bSaveActionCloseNotification;
|
||||||
Spinner spinnerTitleDirection, spinnerTextDirection;
|
Spinner spinnerTitleDirection, spinnerTextDirection;
|
||||||
TextView tvSelectedApplication;
|
TextView tvSelectedApplication;
|
||||||
|
RadioButton rbNotificationDismissSimple, rbNotificationDismissButton;
|
||||||
|
|
||||||
private static List<PackageInfo> pInfos = null;
|
private static List<PackageInfo> pInfos = null;
|
||||||
|
|
||||||
|
final static String dismissRegularString = "p0815DismissString";
|
||||||
|
|
||||||
private static String[] directions;
|
private static String[] directions;
|
||||||
|
|
||||||
ArrayAdapter<String> directionSpinnerAdapter;
|
ArrayAdapter<String> directionSpinnerAdapter;
|
||||||
@ -253,6 +259,7 @@ public class ActivityManageActionCloseNotification extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_action_close_notification);
|
setContentView(R.layout.activity_manage_action_close_notification);
|
||||||
|
|
||||||
etNotificationTitle = (EditText)findViewById(R.id.etNotificationTitle);
|
etNotificationTitle = (EditText)findViewById(R.id.etNotificationTitle);
|
||||||
@ -262,6 +269,9 @@ public class ActivityManageActionCloseNotification extends Activity
|
|||||||
spinnerTitleDirection = (Spinner)findViewById(R.id.spinnerTitleDirection);
|
spinnerTitleDirection = (Spinner)findViewById(R.id.spinnerTitleDirection);
|
||||||
spinnerTextDirection = (Spinner)findViewById(R.id.spinnerTextDirection);
|
spinnerTextDirection = (Spinner)findViewById(R.id.spinnerTextDirection);
|
||||||
tvSelectedApplication = (TextView)findViewById(R.id.etActivityOrActionPath);
|
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[] {
|
directions = new String[] {
|
||||||
getResources().getString(R.string.directionStringEquals),
|
getResources().getString(R.string.directionStringEquals),
|
||||||
@ -305,34 +315,44 @@ public class ActivityManageActionCloseNotification extends Activity
|
|||||||
String text = etNotificationText.getText().toString();
|
String text = etNotificationText.getText().toString();
|
||||||
|
|
||||||
Intent responseData = new Intent();
|
Intent responseData = new Intent();
|
||||||
if(edit)
|
|
||||||
{
|
String dismissMethod;
|
||||||
// editedNotificationAction.setTriggerParameter(chkNotificationDirection.isChecked());
|
if (rbNotificationDismissSimple.isChecked())
|
||||||
responseData.putExtra(ActivityManageRule.intentNameActionParameter2, app + Action.actionParameter2Split + titleDir + Action.actionParameter2Split + title + Action.actionParameter2Split + textDir + Action.actionParameter2Split + text);
|
dismissMethod = dismissRegularString;
|
||||||
ActivityManageActionCloseNotification.this.setResult(RESULT_OK, responseData);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// data.putExtra(intentNameNotificationDirection, chkNotificationDirection.isChecked());
|
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,
|
responseData.putExtra(ActivityManageRule.intentNameActionParameter2,
|
||||||
app + Action.actionParameter2Split +
|
app + Action.actionParameter2Split +
|
||||||
titleDir + Action.actionParameter2Split +
|
titleDir + Action.actionParameter2Split +
|
||||||
title + Action.actionParameter2Split +
|
title + Action.actionParameter2Split +
|
||||||
textDir + Action.actionParameter2Split +
|
textDir + Action.actionParameter2Split +
|
||||||
text
|
text + Action.actionParameter2Split +
|
||||||
|
dismissMethod
|
||||||
);
|
);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ActivityManageActionCloseNotification.this.setResult(RESULT_OK, responseData);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
rbNotificationDismissSimple.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean b)
|
||||||
|
{
|
||||||
|
etNotificationDismissalButtonText.setEnabled(!b);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
if(!StringUtils.isBlank(i.getStringExtra(ActivityManageRule.intentNameActionParameter2)))
|
if(!StringUtils.isBlank(i.getStringExtra(ActivityManageRule.intentNameActionParameter2)))
|
||||||
{
|
{
|
||||||
@ -355,6 +375,24 @@ public class ActivityManageActionCloseNotification extends Activity
|
|||||||
else
|
else
|
||||||
text = "";
|
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))
|
if(!app.equals(Trigger.anyAppString))
|
||||||
tvSelectedApplication.setText(app);
|
tvSelectedApplication.setText(app);
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ public class ActivityManageActionControlMedia extends Activity
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_action_control_media);
|
setContentView(R.layout.activity_manage_action_control_media);
|
||||||
|
|
||||||
rbMediaPlayPause = (RadioButton)findViewById(R.id.rbMediaPlayPause);
|
rbMediaPlayPause = (RadioButton)findViewById(R.id.rbMediaPlayPause);
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
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);
|
||||||
|
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,7 @@ public class ActivityManageActionCreateNotification extends Activity
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_action_create_notification);
|
setContentView(R.layout.activity_manage_action_create_notification);
|
||||||
|
|
||||||
etNotificationTitle = (EditText) findViewById(R.id.etNotificationTitle);
|
etNotificationTitle = (EditText) findViewById(R.id.etNotificationTitle);
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
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);
|
||||||
|
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,7 @@ public class ActivityManageActionPlaySound extends Activity
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_action_play_sound);
|
setContentView(R.layout.activity_manage_action_play_sound);
|
||||||
|
|
||||||
chkPlaySoundAlwaysPlay = (CheckBox)findViewById(R.id.chkPlaySoundAlwaysPlay);
|
chkPlaySoundAlwaysPlay = (CheckBox)findViewById(R.id.chkPlaySoundAlwaysPlay);
|
||||||
|
@ -28,6 +28,7 @@ public class ActivityManageActionRunExecutable extends Activity
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_action_run_executable);
|
setContentView(R.layout.activity_manage_action_run_executable);
|
||||||
|
|
||||||
chkRunExecAsRoot = (CheckBox)findViewById(R.id.chkRunExecAsRoot);
|
chkRunExecAsRoot = (CheckBox)findViewById(R.id.chkRunExecAsRoot);
|
||||||
@ -57,6 +58,15 @@ public class ActivityManageActionRunExecutable extends Activity
|
|||||||
saveExecSettings();
|
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()
|
void saveExecSettings()
|
||||||
|
@ -37,6 +37,7 @@ public class ActivityManageActionSendBroadcast extends Activity
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_action_send_broadcast);
|
setContentView(R.layout.activity_manage_action_send_broadcast);
|
||||||
|
|
||||||
etBroadcastToSend = (EditText)findViewById(R.id.etBroadcastToSend);
|
etBroadcastToSend = (EditText)findViewById(R.id.etBroadcastToSend);
|
||||||
@ -172,6 +173,29 @@ public class ActivityManageActionSendBroadcast extends Activity
|
|||||||
return;
|
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();
|
String param = supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()] + Action.intentPairSeparator + etParameterName.getText().toString() + Action.intentPairSeparator + etParameterValue.getText().toString();
|
||||||
intentPairList.add(param);
|
intentPairList.add(param);
|
||||||
|
|
||||||
@ -201,8 +225,10 @@ public class ActivityManageActionSendBroadcast extends Activity
|
|||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3)
|
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"))
|
if(supportedIntentTypes[arg2].equals("int") || supportedIntentTypes[arg2].equals("long") || supportedIntentTypes[arg2].equals("short"))
|
||||||
ActivityManageActionSendBroadcast.this.etParameterValue.setInputType(InputType.TYPE_CLASS_NUMBER);
|
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
|
else
|
||||||
ActivityManageActionSendBroadcast.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
|
ActivityManageActionSendBroadcast.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||||
}
|
}
|
||||||
|
@ -9,26 +9,37 @@ import android.net.Uri;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.ContactsContract;
|
import android.provider.ContactsContract;
|
||||||
|
import android.provider.MediaStore;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import com.jens.automation2.Action.Action_Enum;
|
import com.jens.automation2.Action.Action_Enum;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
|
||||||
public class ActivityManageActionSendTextMessage extends Activity
|
public class ActivityManageActionSendTextMessage extends Activity
|
||||||
{
|
{
|
||||||
Button bSaveSendTextMessage, bImportNumberFromContacts;
|
Button bSaveSendTextMessage, bImportNumberFromContacts, bMmsAttachment;
|
||||||
EditText etPhoneNumber, etSendTextMessage;
|
EditText etPhoneNumber, etSendTextMessage;
|
||||||
|
RadioButton rbMessageTypeSms, rbMessageTypeMms;
|
||||||
|
TextView tvSendMmsFileAttachment;
|
||||||
|
|
||||||
protected final static int requestCodeForContactsPermissions = 9876;
|
protected final static int requestCodeForContactsPermissions = 9876;
|
||||||
protected final static int requestCodeGetContact = 3235;
|
protected final static int requestCodeGetContact = 3235;
|
||||||
|
protected final static int requestCodeGetMMSattachment = 3236;
|
||||||
|
|
||||||
// private String existingUrl = "";
|
public static final String messageTypeSms = "sms";
|
||||||
|
public static final String messageTypeMms = "mms";
|
||||||
|
|
||||||
public static boolean edit = false;
|
public static boolean edit = false;
|
||||||
public static Action resultingAction = null;
|
public static Action resultingAction = null;
|
||||||
@ -37,12 +48,17 @@ public class ActivityManageActionSendTextMessage extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
this.setContentView(R.layout.activity_manage_action_send_textmessage);
|
this.setContentView(R.layout.activity_manage_action_send_textmessage);
|
||||||
|
|
||||||
etSendTextMessage = (EditText)findViewById(R.id.etSendTextMessage);
|
etSendTextMessage = (EditText)findViewById(R.id.etSendTextMessage);
|
||||||
etPhoneNumber = (EditText)findViewById(R.id.etPhoneNumber);
|
etPhoneNumber = (EditText)findViewById(R.id.etPhoneNumber);
|
||||||
bSaveSendTextMessage = (Button)findViewById(R.id.bSaveSendTextMessage);
|
bSaveSendTextMessage = (Button)findViewById(R.id.bSaveSendTextMessage);
|
||||||
bImportNumberFromContacts = (Button)findViewById(R.id.bImportNumberFromContacts);
|
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()
|
bSaveSendTextMessage.setOnClickListener(new OnClickListener()
|
||||||
{
|
{
|
||||||
@ -50,15 +66,31 @@ public class ActivityManageActionSendTextMessage extends Activity
|
|||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
if(etSendTextMessage.getText().toString().length() > 0 && etPhoneNumber.getText().toString().length() > 0)
|
if(etSendTextMessage.getText().toString().length() > 0 && etPhoneNumber.getText().toString().length() > 0)
|
||||||
|
{
|
||||||
|
if(rbMessageTypeMms.isChecked() && StringUtils.isEmpty(tvSendMmsFileAttachment.getText().toString()))
|
||||||
|
Toast.makeText(getBaseContext(), getResources().getString(R.string.chooseFile), Toast.LENGTH_LONG).show();
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (resultingAction == null)
|
if (resultingAction == null)
|
||||||
{
|
{
|
||||||
resultingAction = new Action();
|
resultingAction = new Action();
|
||||||
resultingAction.setAction(Action_Enum.sendTextMessage);
|
resultingAction.setAction(Action_Enum.sendTextMessage);
|
||||||
resultingAction.setParameter2(etPhoneNumber.getText().toString() + Actions.smsSeparator + etSendTextMessage.getText().toString());
|
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
|
else
|
||||||
Toast.makeText(getBaseContext(), getResources().getString(R.string.enterPhoneNumberAndText), Toast.LENGTH_LONG).show();
|
Toast.makeText(getBaseContext(), getResources().getString(R.string.enterPhoneNumberAndText), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
@ -78,6 +110,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);
|
ActivityManageActionSendTextMessage.edit = getIntent().getBooleanExtra("edit", false);
|
||||||
if(edit)
|
if(edit)
|
||||||
{
|
{
|
||||||
@ -143,10 +197,10 @@ public class ActivityManageActionSendTextMessage extends Activity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
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 phoneNo = null;
|
||||||
String name = null;
|
String name = null;
|
||||||
@ -165,6 +219,12 @@ public class ActivityManageActionSendTextMessage extends Activity
|
|||||||
etPhoneNumber.setText(phoneNo);
|
etPhoneNumber.setText(phoneNo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (requestCode == requestCodeGetMMSattachment)
|
||||||
|
{
|
||||||
|
Uri fileUri = data.getData();
|
||||||
|
String filePath = fileUri.getPath();
|
||||||
|
tvSendMmsFileAttachment.setText(filePath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//super.onActivityResult(requestCode, resultCode, data);
|
//super.onActivityResult(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
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);
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,7 @@ public class ActivityManageActionSpeakText extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
this.setContentView(R.layout.activity_manage_action_speak_text);
|
this.setContentView(R.layout.activity_manage_action_speak_text);
|
||||||
|
|
||||||
etSpeakText = (EditText)findViewById(R.id.etTextToSpeak);
|
etSpeakText = (EditText)findViewById(R.id.etTextToSpeak);
|
||||||
|
@ -29,6 +29,7 @@ import android.widget.CompoundButton;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -48,16 +49,19 @@ public class ActivityManageActionStartActivity extends Activity
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
ListView lvIntentPairs;
|
ListView lvIntentPairs;
|
||||||
EditText etParameterName, etParameterValue, etPackageName, etActivityOrActionPath;
|
EditText etParameterName, etParameterValue, etPackageName, etActivityOrActionPath, etClassName;
|
||||||
Button bSelectApp, bAddIntentPair, bSaveActionStartOtherActivity, showStartProgramExamples;
|
Button bSelectApp, bAddIntentPair, bSaveActionStartOtherActivity, showStartProgramExamples;
|
||||||
Spinner spinnerParameterType;
|
Spinner spinnerParameterType;
|
||||||
|
RadioGroup rgAppStartupType;
|
||||||
boolean edit = false;
|
boolean edit = false;
|
||||||
ProgressDialog progressDialog = null;
|
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 String urlShowExamples = "https://server47.de/automation/examples_startProgram.html";
|
||||||
final static String startByActivityString = "0";
|
final static String startByActivityString = "0";
|
||||||
final static String startByBroadcastString = "1";
|
final static String startByBroadcastString = "1";
|
||||||
|
final static String startByServiceString = "2";
|
||||||
|
final static String startByForegroundServiceString = "3";
|
||||||
|
|
||||||
final static int requestCodeForRequestQueryAllPackagesPermission = 4711;
|
final static int requestCodeForRequestQueryAllPackagesPermission = 4711;
|
||||||
|
|
||||||
@ -65,11 +69,13 @@ public class ActivityManageActionStartActivity extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_action_start_activity);
|
setContentView(R.layout.activity_manage_action_start_activity);
|
||||||
|
|
||||||
lvIntentPairs = (ListView)findViewById(R.id.lvIntentPairs);
|
lvIntentPairs = (ListView)findViewById(R.id.lvIntentPairs);
|
||||||
etParameterName = (EditText)findViewById(R.id.etParameterName);
|
etParameterName = (EditText)findViewById(R.id.etParameterName);
|
||||||
etParameterValue = (EditText)findViewById(R.id.etParameterValue);
|
etParameterValue = (EditText)findViewById(R.id.etParameterValue);
|
||||||
|
etClassName = (EditText)findViewById(R.id.etClassName);
|
||||||
bSelectApp = (Button)findViewById(R.id.bSelectApp);
|
bSelectApp = (Button)findViewById(R.id.bSelectApp);
|
||||||
bAddIntentPair = (Button)findViewById(R.id.bAddIntentPair);
|
bAddIntentPair = (Button)findViewById(R.id.bAddIntentPair);
|
||||||
bSaveActionStartOtherActivity = (Button)findViewById(R.id.bSaveActionStartOtherActivity);
|
bSaveActionStartOtherActivity = (Button)findViewById(R.id.bSaveActionStartOtherActivity);
|
||||||
@ -81,13 +87,17 @@ public class ActivityManageActionStartActivity extends Activity
|
|||||||
showStartProgramExamples = (Button)findViewById(R.id.showStartProgramExamples);
|
showStartProgramExamples = (Button)findViewById(R.id.showStartProgramExamples);
|
||||||
rbStartAppByActivity = (RadioButton)findViewById(R.id.rbStartAppByActivity);
|
rbStartAppByActivity = (RadioButton)findViewById(R.id.rbStartAppByActivity);
|
||||||
rbStartAppByBroadcast = (RadioButton)findViewById(R.id.rbStartAppByBroadcast);
|
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);
|
intentTypeSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, ActivityManageActionStartActivity.supportedIntentTypes);
|
||||||
spinnerParameterType.setAdapter(intentTypeSpinnerAdapter);
|
spinnerParameterType.setAdapter(intentTypeSpinnerAdapter);
|
||||||
intentTypeSpinnerAdapter.notifyDataSetChanged();
|
intentTypeSpinnerAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
intentPairAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, intentPairList);
|
etClassName.setEnabled(false);
|
||||||
|
|
||||||
|
intentPairAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, intentPairList);
|
||||||
bSelectApp.setOnClickListener(new OnClickListener()
|
bSelectApp.setOnClickListener(new OnClickListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -153,6 +163,29 @@ public class ActivityManageActionStartActivity extends Activity
|
|||||||
return;
|
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();
|
String param = supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()] + Action.intentPairSeparator + etParameterName.getText().toString() + Action.intentPairSeparator + etParameterValue.getText().toString();
|
||||||
intentPairList.add(param);
|
intentPairList.add(param);
|
||||||
|
|
||||||
@ -202,15 +235,23 @@ public class ActivityManageActionStartActivity extends Activity
|
|||||||
|
|
||||||
if (rbStartAppSelectByActivity.isChecked())
|
if (rbStartAppSelectByActivity.isChecked())
|
||||||
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString();
|
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString();
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
if (etPackageName.getText().toString() != null && etPackageName.getText().toString().length() > 0)
|
if (etPackageName.getText().toString() != null && etPackageName.getText().toString().length() > 0)
|
||||||
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString();
|
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString();
|
||||||
else
|
else
|
||||||
parameter2 += Actions.dummyPackageString + ";" + etActivityOrActionPath.getText().toString();
|
parameter2 += Actions.dummyPackageString + ";" + etActivityOrActionPath.getText().toString();
|
||||||
|
|
||||||
|
// if(etClassName.getText().toString().length() > 0)
|
||||||
|
parameter2 += ";" + etClassName.getText().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rbStartAppByActivity.isChecked())
|
if (rbStartAppByActivity.isChecked())
|
||||||
parameter2 += ";" + startByActivityString;
|
parameter2 += ";" + startByActivityString;
|
||||||
|
else if(rbStartAppByService.isChecked())
|
||||||
|
parameter2 += ";" + startByServiceString;
|
||||||
|
else if(rbStartAppByForegroundService.isChecked())
|
||||||
|
parameter2 += ";" + startByForegroundServiceString;
|
||||||
else
|
else
|
||||||
parameter2 += ";" + startByBroadcastString;
|
parameter2 += ";" + startByBroadcastString;
|
||||||
|
|
||||||
@ -240,8 +281,10 @@ public class ActivityManageActionStartActivity extends Activity
|
|||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3)
|
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"))
|
if(supportedIntentTypes[arg2].equals("int") || supportedIntentTypes[arg2].equals("long") || supportedIntentTypes[arg2].equals("short"))
|
||||||
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_NUMBER);
|
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
|
else
|
||||||
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
|
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||||
}
|
}
|
||||||
@ -260,8 +303,10 @@ public class ActivityManageActionStartActivity extends Activity
|
|||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
||||||
{
|
{
|
||||||
if(isChecked)
|
if(isChecked)
|
||||||
|
{
|
||||||
bSelectApp.setEnabled(isChecked);
|
bSelectApp.setEnabled(isChecked);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
rbStartAppSelectByAction.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
rbStartAppSelectByAction.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
||||||
@ -274,6 +319,23 @@ public class ActivityManageActionStartActivity extends Activity
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
rgAppStartupType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(RadioGroup radioGroup, int i)
|
||||||
|
{
|
||||||
|
if(rbStartAppByActivity.isChecked())
|
||||||
|
etClassName.setEnabled(false);
|
||||||
|
else if (rbStartAppByBroadcast.isChecked())
|
||||||
|
etClassName.setEnabled(false);
|
||||||
|
else if(rbStartAppByService.isChecked())
|
||||||
|
etClassName.setEnabled(true);
|
||||||
|
else if(rbStartAppByForegroundService.isChecked())
|
||||||
|
etClassName.setEnabled(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
if(i.hasExtra(ActivityManageRule.intentNameActionParameter1))
|
if(i.hasExtra(ActivityManageRule.intentNameActionParameter1))
|
||||||
loadValuesIntoGui(i);
|
loadValuesIntoGui(i);
|
||||||
@ -568,8 +630,19 @@ public class ActivityManageActionStartActivity extends Activity
|
|||||||
|
|
||||||
String[] params = input.getStringExtra(ActivityManageRule.intentNameActionParameter2).split(";");
|
String[] params = input.getStringExtra(ActivityManageRule.intentNameActionParameter2).split(";");
|
||||||
|
|
||||||
|
if(Miscellaneous.isNumeric(params[2])) // old configuration file
|
||||||
|
{
|
||||||
rbStartAppByActivity.setChecked(params[2].equals(startByActivityString));
|
rbStartAppByActivity.setChecked(params[2].equals(startByActivityString));
|
||||||
rbStartAppByBroadcast.setChecked(params[2].equals(startByBroadcastString));
|
rbStartAppByBroadcast.setChecked(params[2].equals(startByBroadcastString));
|
||||||
|
rbStartAppByService.setChecked(params[2].equals(startByServiceString));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rbStartAppByActivity.setChecked(params[3].equals(startByActivityString));
|
||||||
|
rbStartAppByBroadcast.setChecked(params[3].equals(startByBroadcastString));
|
||||||
|
rbStartAppByService.setChecked(params[3].equals(startByServiceString));
|
||||||
|
rbStartAppByForegroundService.setChecked(params[3].equals(startByForegroundServiceString));
|
||||||
|
}
|
||||||
|
|
||||||
int startIndex = -1;
|
int startIndex = -1;
|
||||||
|
|
||||||
@ -584,10 +657,11 @@ public class ActivityManageActionStartActivity extends Activity
|
|||||||
etPackageName.setText(params[0]);
|
etPackageName.setText(params[0]);
|
||||||
|
|
||||||
etActivityOrActionPath.setText(params[1]);
|
etActivityOrActionPath.setText(params[1]);
|
||||||
|
etClassName.setText(params[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.length >= 3)
|
if (params.length >= 4)
|
||||||
startIndex = 3;
|
startIndex = 4;
|
||||||
|
|
||||||
if(startIndex > -1 && params.length > startIndex)
|
if(startIndex > -1 && params.length > startIndex)
|
||||||
{
|
{
|
||||||
|
@ -39,6 +39,7 @@ public class ActivityManageActionTriggerUrl extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
this.setContentView(R.layout.activity_manage_action_trigger_url);
|
this.setContentView(R.layout.activity_manage_action_trigger_url);
|
||||||
|
|
||||||
etTriggerUrl = (EditText)findViewById(R.id.etTriggerUrl);
|
etTriggerUrl = (EditText)findViewById(R.id.etTriggerUrl);
|
||||||
|
@ -27,6 +27,7 @@ public class ActivityManageActionVibrate extends Activity
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_action_vibrate);
|
setContentView(R.layout.activity_manage_action_vibrate);
|
||||||
|
|
||||||
etVibratePattern = (EditText)findViewById(R.id.etVibratePattern);
|
etVibratePattern = (EditText)findViewById(R.id.etVibratePattern);
|
||||||
|
@ -0,0 +1,100 @@
|
|||||||
|
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);
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -23,6 +23,7 @@ public class ActivityManageActionWifi extends Activity
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_action_wifi);
|
setContentView(R.layout.activity_manage_action_wifi);
|
||||||
|
|
||||||
chkWifiRunAsRoot = (CheckBox)findViewById(R.id.chkWifiRunAsRoot);
|
chkWifiRunAsRoot = (CheckBox)findViewById(R.id.chkWifiRunAsRoot);
|
||||||
|
@ -59,6 +59,7 @@ public class ActivityManagePoi extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
this.setContentView(R.layout.activity_manage_specific_poi);
|
this.setContentView(R.layout.activity_manage_specific_poi);
|
||||||
|
|
||||||
myLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
myLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
|
||||||
|
@ -47,37 +47,37 @@ public class ActivityManageProfile extends Activity
|
|||||||
|
|
||||||
boolean guiUpdate = false;
|
boolean guiUpdate = false;
|
||||||
|
|
||||||
File incomingCallsRingtone = null, notificationsRingtone = null;
|
String incomingCallsRingtone = null, notificationsRingtone = null;
|
||||||
|
|
||||||
ArrayAdapter<String> soundModeAdapter;
|
ArrayAdapter<String> soundModeAdapter;
|
||||||
ArrayAdapter<String> dndModeAdapter;
|
ArrayAdapter<String> dndModeAdapter;
|
||||||
|
|
||||||
public void setIncomingCallsRingtone(File incomingCallsRingtone)
|
public void setIncomingCallsRingtone(String incomingCallsRingtone)
|
||||||
{
|
{
|
||||||
this.incomingCallsRingtone = incomingCallsRingtone;
|
this.incomingCallsRingtone = incomingCallsRingtone;
|
||||||
|
|
||||||
if(incomingCallsRingtone != null)
|
if(incomingCallsRingtone != null)
|
||||||
tvIncomingCallsRingtone.setText(this.incomingCallsRingtone.getAbsolutePath());
|
tvIncomingCallsRingtone.setText(this.incomingCallsRingtone);
|
||||||
else
|
else
|
||||||
tvIncomingCallsRingtone.setText(getResources().getString(R.string.none));
|
tvIncomingCallsRingtone.setText(getResources().getString(R.string.none));
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getIncomingCallsRingtone()
|
public String getIncomingCallsRingtone()
|
||||||
{
|
{
|
||||||
return incomingCallsRingtone;
|
return incomingCallsRingtone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNotificationsRingtone(File notificationsRingtone)
|
public void setNotificationsRingtone(String notificationsRingtone)
|
||||||
{
|
{
|
||||||
this.notificationsRingtone = notificationsRingtone;
|
this.notificationsRingtone = notificationsRingtone;
|
||||||
|
|
||||||
if(this.notificationsRingtone != null)
|
if(this.notificationsRingtone != null)
|
||||||
tvNotificationsRingtone.setText(this.notificationsRingtone.getAbsolutePath());
|
tvNotificationsRingtone.setText(this.notificationsRingtone);
|
||||||
else
|
else
|
||||||
tvNotificationsRingtone.setText(getResources().getString(R.string.none));
|
tvNotificationsRingtone.setText(getResources().getString(R.string.none));
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getNotificationsRingtone()
|
public String getNotificationsRingtone()
|
||||||
{
|
{
|
||||||
return notificationsRingtone;
|
return notificationsRingtone;
|
||||||
}
|
}
|
||||||
@ -86,6 +86,7 @@ public class ActivityManageProfile extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
this.setContentView(R.layout.activity_manage_specific_profile);
|
this.setContentView(R.layout.activity_manage_specific_profile);
|
||||||
|
|
||||||
checkBoxChangeSoundMode = (CheckBox)findViewById(R.id.checkBoxChangeSoundMode);
|
checkBoxChangeSoundMode = (CheckBox)findViewById(R.id.checkBoxChangeSoundMode);
|
||||||
@ -284,26 +285,26 @@ public class ActivityManageProfile extends Activity
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
Intent fileIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
// Intent fileIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||||
fileIntent.setType("audio/*");
|
// fileIntent.setType("audio/*");
|
||||||
startActivityForResult(Intent.createChooser(fileIntent, "Select a ringtone"), intentCodeRingtonePickerCallsFile);
|
// startActivityForResult(Intent.createChooser(fileIntent, "Select a ringtone"), intentCodeRingtonePickerCallsFile);
|
||||||
}
|
// }
|
||||||
catch(ActivityNotFoundException e)
|
// catch(ActivityNotFoundException e)
|
||||||
{
|
// {
|
||||||
// Use media browser instead
|
// Use media browser instead
|
||||||
Intent fileSelectionIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
|
Intent fileSelectionIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
|
||||||
|
|
||||||
if(ActivityMainProfiles.profileToEdit != null)
|
if(ActivityMainProfiles.profileToEdit != null)
|
||||||
{
|
{
|
||||||
Uri currenturi = Uri.parse(ActivityMainProfiles.profileToEdit.incomingCallsRingtone.getAbsolutePath());
|
Uri currenturi = Uri.parse(ActivityMainProfiles.profileToEdit.incomingCallsRingtone);
|
||||||
if(ActivityMainProfiles.profileToEdit.changeIncomingCallsRingtone)
|
if(ActivityMainProfiles.profileToEdit.changeIncomingCallsRingtone)
|
||||||
fileSelectionIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currenturi);
|
fileSelectionIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currenturi);
|
||||||
}
|
}
|
||||||
|
|
||||||
startActivityForResult(fileSelectionIntent, intentCodeRingtonePickerCallsRingtone);
|
startActivityForResult(fileSelectionIntent, intentCodeRingtonePickerCallsRingtone);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
bChangeSoundNotifications.setOnClickListener(new OnClickListener()
|
bChangeSoundNotifications.setOnClickListener(new OnClickListener()
|
||||||
@ -324,7 +325,7 @@ public class ActivityManageProfile extends Activity
|
|||||||
|
|
||||||
if(ActivityMainProfiles.profileToEdit != null)
|
if(ActivityMainProfiles.profileToEdit != null)
|
||||||
{
|
{
|
||||||
Uri currenturi = Uri.parse(ActivityMainProfiles.profileToEdit.notificationRingtone.getAbsolutePath());
|
Uri currenturi = Uri.parse(ActivityMainProfiles.profileToEdit.notificationRingtone);
|
||||||
if(ActivityMainProfiles.profileToEdit.changeNotificationRingtone)
|
if(ActivityMainProfiles.profileToEdit.changeNotificationRingtone)
|
||||||
fileSelectionIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currenturi);
|
fileSelectionIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currenturi);
|
||||||
}
|
}
|
||||||
@ -495,15 +496,20 @@ public class ActivityManageProfile extends Activity
|
|||||||
Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
||||||
if (uri != null)
|
if (uri != null)
|
||||||
{
|
{
|
||||||
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, uri);
|
// if(Build.VERSION.SDK_INT < 26)
|
||||||
setIncomingCallsRingtone(new File(ringTonePath));
|
// {
|
||||||
|
// String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, uri);
|
||||||
|
// setIncomingCallsRingtone(ringTonePath);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
setIncomingCallsRingtone(uri.toString());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case intentCodeRingtonePickerCallsFile:
|
case intentCodeRingtonePickerCallsFile:
|
||||||
{
|
{
|
||||||
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, data.getData());
|
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, data.getData());
|
||||||
setIncomingCallsRingtone(new File(ringTonePath));
|
setIncomingCallsRingtone(ringTonePath);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case intentCodeRingtonePickerNotificationsRingtone: // notifications
|
case intentCodeRingtonePickerNotificationsRingtone: // notifications
|
||||||
@ -511,15 +517,20 @@ public class ActivityManageProfile extends Activity
|
|||||||
Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
||||||
if (uri != null)
|
if (uri != null)
|
||||||
{
|
{
|
||||||
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, data.getData());
|
// if(Build.VERSION.SDK_INT < 26)
|
||||||
setNotificationsRingtone(new File(ringTonePath));
|
// {
|
||||||
|
// String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, uri);
|
||||||
|
// setNotificationsRingtone(ringTonePath);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
setNotificationsRingtone(uri.toString());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case intentCodeRingtonePickerNotificationsFile:
|
case intentCodeRingtonePickerNotificationsFile:
|
||||||
{
|
{
|
||||||
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, data.getData());
|
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, data.getData());
|
||||||
setNotificationsRingtone(new File(ringTonePath));
|
setNotificationsRingtone(ringTonePath);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -129,6 +129,18 @@ public class ActivityManageRule extends Activity
|
|||||||
final static int requestCodeActionSetWifiEdit = 816;
|
final static int requestCodeActionSetWifiEdit = 816;
|
||||||
final static int requestCodeTriggerTetheringAdd = 817;
|
final static int requestCodeTriggerTetheringAdd = 817;
|
||||||
final static int requestCodeTriggerTetheringEdit = 818;
|
final static int requestCodeTriggerTetheringEdit = 818;
|
||||||
|
final static int requestCodeActionWakeLockAdd = 819;
|
||||||
|
final static int requestCodeActionWakeLockEdit = 820;
|
||||||
|
final static int requestCodeTriggerSubSystemStateAdd = 821;
|
||||||
|
final static int requestCodeTriggerSubSystemStateEdit = 822;
|
||||||
|
final static int requestCodeActionMakePhoneCallAdd = 823;
|
||||||
|
final static int requestCodeActionMakePhoneCallEdit = 824;
|
||||||
|
final static int requestCodeActionSetVariableAdd = 825;
|
||||||
|
final static int requestCodeActionSetVariableEdit = 826;
|
||||||
|
final static int requestCodeTriggerCheckVariableAdd = 827;
|
||||||
|
final static int requestCodeTriggerCheckVariableEdit = 828;
|
||||||
|
final static int requestCodeActionCopyTextToClipboardAdd = 829;
|
||||||
|
final static int requestCodeActionCopyTextToClipboardEdit = 830;
|
||||||
|
|
||||||
public static ActivityManageRule getInstance()
|
public static ActivityManageRule getInstance()
|
||||||
{
|
{
|
||||||
@ -142,6 +154,7 @@ public class ActivityManageRule extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_specific_rule);
|
setContentView(R.layout.activity_manage_specific_rule);
|
||||||
|
|
||||||
context = this;
|
context = this;
|
||||||
@ -317,8 +330,21 @@ public class ActivityManageRule extends Activity
|
|||||||
case tethering:
|
case tethering:
|
||||||
Intent tetheringEditor = new Intent(ActivityManageRule.this, ActivityManageTriggerTethering.class);
|
Intent tetheringEditor = new Intent(ActivityManageRule.this, ActivityManageTriggerTethering.class);
|
||||||
tetheringEditor.putExtra(intentNameTriggerParameter1, selectedTrigger.getTriggerParameter());
|
tetheringEditor.putExtra(intentNameTriggerParameter1, selectedTrigger.getTriggerParameter());
|
||||||
|
tetheringEditor.putExtra(intentNameTriggerParameter2, selectedTrigger.getTriggerParameter2());
|
||||||
startActivityForResult(tetheringEditor, requestCodeTriggerTetheringEdit);
|
startActivityForResult(tetheringEditor, requestCodeTriggerTetheringEdit);
|
||||||
break;
|
break;
|
||||||
|
case subSystemState:
|
||||||
|
Intent subSystemStateEditor = new Intent(ActivityManageRule.this, ActivityManageTriggerSubSystemState.class);
|
||||||
|
subSystemStateEditor.putExtra(intentNameTriggerParameter1, selectedTrigger.getTriggerParameter());
|
||||||
|
subSystemStateEditor.putExtra(intentNameTriggerParameter2, selectedTrigger.getTriggerParameter2());
|
||||||
|
startActivityForResult(subSystemStateEditor, requestCodeTriggerSubSystemStateEdit);
|
||||||
|
break;
|
||||||
|
case checkVariable:
|
||||||
|
Intent variableStateEditor = new Intent(ActivityManageRule.this, ActivityManageTriggerCheckVariable.class);
|
||||||
|
variableStateEditor.putExtra(intentNameTriggerParameter1, selectedTrigger.getTriggerParameter());
|
||||||
|
variableStateEditor.putExtra(intentNameTriggerParameter2, selectedTrigger.getTriggerParameter2());
|
||||||
|
startActivityForResult(variableStateEditor, requestCodeTriggerCheckVariableEdit);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -393,12 +419,29 @@ public class ActivityManageRule extends Activity
|
|||||||
activityEditSendBroadcastIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
activityEditSendBroadcastIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
||||||
startActivityForResult(activityEditSendBroadcastIntent, requestCodeActionSendBroadcastEdit);
|
startActivityForResult(activityEditSendBroadcastIntent, requestCodeActionSendBroadcastEdit);
|
||||||
break;
|
break;
|
||||||
|
case wakelock:
|
||||||
|
Intent activityEditWakeLockIntent = new Intent(ActivityManageRule.this, ActivityManageActionWakeLock.class);
|
||||||
|
activityEditWakeLockIntent.putExtra(intentNameActionParameter1, a.getParameter1());
|
||||||
|
activityEditWakeLockIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
||||||
|
startActivityForResult(activityEditWakeLockIntent, requestCodeActionWakeLockEdit);
|
||||||
|
break;
|
||||||
case runExecutable:
|
case runExecutable:
|
||||||
Intent activityEditRunExecutableIntent = new Intent(ActivityManageRule.this, ActivityManageActionRunExecutable.class);
|
Intent activityEditRunExecutableIntent = new Intent(ActivityManageRule.this, ActivityManageActionRunExecutable.class);
|
||||||
activityEditRunExecutableIntent.putExtra(intentNameActionParameter1, a.getParameter1());
|
activityEditRunExecutableIntent.putExtra(intentNameActionParameter1, a.getParameter1());
|
||||||
activityEditRunExecutableIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
activityEditRunExecutableIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
||||||
startActivityForResult(activityEditRunExecutableIntent, requestCodeActionRunExecutableEdit);
|
startActivityForResult(activityEditRunExecutableIntent, requestCodeActionRunExecutableEdit);
|
||||||
break;
|
break;
|
||||||
|
case startPhoneCall:
|
||||||
|
Intent activityEditMakePhoneCallIntent = new Intent(ActivityManageRule.this, ActivityManageActionMakePhoneCall.class);
|
||||||
|
activityEditMakePhoneCallIntent.putExtra(intentNameActionParameter1, a.getParameter1());
|
||||||
|
activityEditMakePhoneCallIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
||||||
|
startActivityForResult(activityEditMakePhoneCallIntent, requestCodeActionMakePhoneCallEdit);
|
||||||
|
break;
|
||||||
|
case setVariable:
|
||||||
|
Intent activityEditSetVariableIntent = new Intent(ActivityManageRule.this, ActivityManageActionSetVariable.class);
|
||||||
|
activityEditSetVariableIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
||||||
|
startActivityForResult(activityEditSetVariableIntent, requestCodeActionSetVariableEdit);
|
||||||
|
break;
|
||||||
case setWifi:
|
case setWifi:
|
||||||
Intent activityEditSetWifiIntent = new Intent(ActivityManageRule.this, ActivityManageActionWifi.class);
|
Intent activityEditSetWifiIntent = new Intent(ActivityManageRule.this, ActivityManageActionWifi.class);
|
||||||
activityEditSetWifiIntent.putExtra(intentNameActionParameter1, a.getParameter1());
|
activityEditSetWifiIntent.putExtra(intentNameActionParameter1, a.getParameter1());
|
||||||
@ -429,6 +472,12 @@ public class ActivityManageRule extends Activity
|
|||||||
actionPlaySoundIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
actionPlaySoundIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
||||||
startActivityForResult(actionPlaySoundIntent, requestCodeActionPlaySoundEdit);
|
startActivityForResult(actionPlaySoundIntent, requestCodeActionPlaySoundEdit);
|
||||||
break;
|
break;
|
||||||
|
case copyToClipboard:
|
||||||
|
Intent actionCopyToClipboardIntent = new Intent(context, ActivityManageActionCopyToClipboard.class);
|
||||||
|
actionCopyToClipboardIntent.putExtra(intentNameActionParameter1, a.getParameter1());
|
||||||
|
actionCopyToClipboardIntent.putExtra(intentNameActionParameter2, a.getParameter2());
|
||||||
|
startActivityForResult(actionCopyToClipboardIntent, requestCodeActionCopyTextToClipboardEdit);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Miscellaneous.logEvent("w", "Edit action", "Editing of action type " + a.getAction().toString() + " not implemented, yet.", 4);
|
Miscellaneous.logEvent("w", "Edit action", "Editing of action type " + a.getAction().toString() + " not implemented, yet.", 4);
|
||||||
break;
|
break;
|
||||||
@ -577,6 +626,8 @@ public class ActivityManageRule extends Activity
|
|||||||
items.add(new Item(typesLong[i].toString(), R.drawable.alarm));
|
items.add(new Item(typesLong[i].toString(), R.drawable.alarm));
|
||||||
else if(types[i].toString().equals(Trigger_Enum.tethering.toString()))
|
else if(types[i].toString().equals(Trigger_Enum.tethering.toString()))
|
||||||
items.add(new Item(typesLong[i].toString(), R.drawable.router));
|
items.add(new Item(typesLong[i].toString(), R.drawable.router));
|
||||||
|
else if(types[i].toString().equals(Trigger_Enum.subSystemState.toString()))
|
||||||
|
items.add(new Item(typesLong[i].toString(), R.drawable.subsystemstate));
|
||||||
else
|
else
|
||||||
items.add(new Item(typesLong[i].toString(), R.drawable.placeholder));
|
items.add(new Item(typesLong[i].toString(), R.drawable.placeholder));
|
||||||
}
|
}
|
||||||
@ -749,19 +800,22 @@ public class ActivityManageRule extends Activity
|
|||||||
Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.lockedCommentScreenMustBeOff), ActivityManageRule.this).show();
|
Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.lockedCommentScreenMustBeOff), ActivityManageRule.this).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(triggerType == Trigger_Enum.deviceStarts)
|
/*else if(triggerType == Trigger_Enum.deviceStarts)
|
||||||
{
|
{
|
||||||
newTrigger.setTriggerType(Trigger_Enum.deviceStarts);
|
newTrigger.setTriggerType(Trigger_Enum.deviceStarts);
|
||||||
ruleToEdit.getTriggerSet().add(newTrigger);
|
ruleToEdit.getTriggerSet().add(newTrigger);
|
||||||
refreshTriggerList();
|
refreshTriggerList();
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
else if(triggerType == Trigger_Enum.serviceStarts)
|
else if(triggerType == Trigger_Enum.deviceStarts || triggerType == Trigger_Enum.serviceStarts)
|
||||||
{
|
{
|
||||||
newTrigger.setTriggerType(Trigger_Enum.serviceStarts);
|
// newTrigger.setTriggerType(Trigger_Enum.serviceStarts);
|
||||||
ruleToEdit.getTriggerSet().add(newTrigger);
|
// ruleToEdit.getTriggerSet().add(newTrigger);
|
||||||
refreshTriggerList();
|
|
||||||
return;
|
booleanChoices = new String[]{getResources().getString(R.string.yes), getResources().getString(R.string.no)};
|
||||||
|
|
||||||
|
// refreshTriggerList();
|
||||||
|
// return;
|
||||||
}
|
}
|
||||||
else if(triggerType == Trigger_Enum.headsetPlugged)
|
else if(triggerType == Trigger_Enum.headsetPlugged)
|
||||||
booleanChoices = new String[]{getResources().getString(R.string.connected), getResources().getString(R.string.disconnected)};
|
booleanChoices = new String[]{getResources().getString(R.string.connected), getResources().getString(R.string.disconnected)};
|
||||||
@ -785,6 +839,20 @@ public class ActivityManageRule extends Activity
|
|||||||
startActivityForResult(tetheringTriggerEditor, requestCodeTriggerTetheringAdd);
|
startActivityForResult(tetheringTriggerEditor, requestCodeTriggerTetheringAdd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if(triggerType == Trigger_Enum.subSystemState)
|
||||||
|
{
|
||||||
|
newTrigger.setTriggerType(Trigger_Enum.subSystemState);
|
||||||
|
Intent subSystemStateTriggerEditor = new Intent(myContext, ActivityManageTriggerSubSystemState.class);
|
||||||
|
startActivityForResult(subSystemStateTriggerEditor, requestCodeTriggerSubSystemStateAdd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(triggerType == Trigger_Enum.checkVariable)
|
||||||
|
{
|
||||||
|
newTrigger.setTriggerType(Trigger_Enum.checkVariable);
|
||||||
|
Intent variableTriggerEditor = new Intent(myContext, ActivityManageTriggerCheckVariable.class);
|
||||||
|
startActivityForResult(variableTriggerEditor, requestCodeTriggerCheckVariableAdd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
getTriggerParameterDialog(context, booleanChoices).show();
|
getTriggerParameterDialog(context, booleanChoices).show();
|
||||||
|
|
||||||
@ -876,6 +944,7 @@ public class ActivityManageRule extends Activity
|
|||||||
|
|
||||||
return alertDialog;
|
return alertDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
private AlertDialog getTriggerBatteryDialog(final Context myContext, final String[] choices)
|
private AlertDialog getTriggerBatteryDialog(final Context myContext, final String[] choices)
|
||||||
{
|
{
|
||||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
|
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
|
||||||
@ -890,6 +959,7 @@ public class ActivityManageRule extends Activity
|
|||||||
triggerBattery = (which+1);
|
triggerBattery = (which+1);
|
||||||
newTrigger.setTriggerType(Trigger_Enum.batteryLevel);
|
newTrigger.setTriggerType(Trigger_Enum.batteryLevel);
|
||||||
newTrigger.setBatteryLevel(triggerBattery);
|
newTrigger.setBatteryLevel(triggerBattery);
|
||||||
|
newTrigger.setTriggerParameter2(String.valueOf(triggerBattery));
|
||||||
// Log.i("test", newTrigger.toString());
|
// Log.i("test", newTrigger.toString());
|
||||||
// Log.i("test", String.valueOf(newTrigger.getBatteryLevel()));
|
// Log.i("test", String.valueOf(newTrigger.getBatteryLevel()));
|
||||||
ruleToEdit.getTriggerSet().add(newTrigger);
|
ruleToEdit.getTriggerSet().add(newTrigger);
|
||||||
@ -1024,7 +1094,7 @@ public class ActivityManageRule extends Activity
|
|||||||
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
|
AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
|
||||||
|
|
||||||
alertDialog.setTitle(myContext.getResources().getString(R.string.phoneNumber));
|
alertDialog.setTitle(myContext.getResources().getString(R.string.phoneNumber));
|
||||||
alertDialog.setMessage(myContext.getResources().getString(R.string.enterPhoneNumber));
|
alertDialog.setMessage(myContext.getResources().getString(R.string.enterPhoneNumberBlankForAny));
|
||||||
|
|
||||||
// Set an EditText view to get user input
|
// Set an EditText view to get user input
|
||||||
final EditText input = new EditText(this);
|
final EditText input = new EditText(this);
|
||||||
@ -1551,6 +1621,38 @@ public class ActivityManageRule extends Activity
|
|||||||
this.refreshActionList();
|
this.refreshActionList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(requestCode == requestCodeActionMakePhoneCallAdd)
|
||||||
|
{
|
||||||
|
if(resultCode == RESULT_OK)
|
||||||
|
{
|
||||||
|
newAction.setParentRule(ruleToEdit);
|
||||||
|
newAction.setParameter1(data.getBooleanExtra(intentNameActionParameter1, false));
|
||||||
|
newAction.setParameter2(data.getStringExtra(intentNameActionParameter2));
|
||||||
|
ruleToEdit.getActionSet().add(newAction);
|
||||||
|
this.refreshActionList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(requestCode == requestCodeActionSetVariableAdd)
|
||||||
|
{
|
||||||
|
if(resultCode == RESULT_OK)
|
||||||
|
{
|
||||||
|
newAction.setParentRule(ruleToEdit);
|
||||||
|
newAction.setParameter2(data.getStringExtra(intentNameActionParameter2));
|
||||||
|
ruleToEdit.getActionSet().add(newAction);
|
||||||
|
this.refreshActionList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(requestCode == requestCodeActionWakeLockAdd)
|
||||||
|
{
|
||||||
|
if(resultCode == RESULT_OK)
|
||||||
|
{
|
||||||
|
newAction.setParentRule(ruleToEdit);
|
||||||
|
newAction.setParameter1(data.getBooleanExtra(intentNameActionParameter1, false));
|
||||||
|
newAction.setParameter2(data.getStringExtra(intentNameActionParameter2));
|
||||||
|
ruleToEdit.getActionSet().add(newAction);
|
||||||
|
this.refreshActionList();
|
||||||
|
}
|
||||||
|
}
|
||||||
else if(requestCode == requestCodeActionControlMediaAdd)
|
else if(requestCode == requestCodeActionControlMediaAdd)
|
||||||
{
|
{
|
||||||
if(resultCode == RESULT_OK)
|
if(resultCode == RESULT_OK)
|
||||||
@ -1620,6 +1722,21 @@ public class ActivityManageRule extends Activity
|
|||||||
this.refreshActionList();
|
this.refreshActionList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(requestCode == requestCodeActionWakeLockEdit)
|
||||||
|
{
|
||||||
|
if(resultCode == RESULT_OK)
|
||||||
|
{
|
||||||
|
ruleToEdit.getActionSet().get(editIndex).setParentRule(ruleToEdit);
|
||||||
|
|
||||||
|
if(data.hasExtra(intentNameActionParameter1))
|
||||||
|
ruleToEdit.getActionSet().get(editIndex).setParameter1(data.getBooleanExtra(intentNameActionParameter1, true));
|
||||||
|
|
||||||
|
if(data.hasExtra(intentNameActionParameter2))
|
||||||
|
ruleToEdit.getActionSet().get(editIndex).setParameter2(data.getStringExtra(intentNameActionParameter2));
|
||||||
|
|
||||||
|
this.refreshActionList();
|
||||||
|
}
|
||||||
|
}
|
||||||
else if(requestCode == requestCodeActionRunExecutableEdit)
|
else if(requestCode == requestCodeActionRunExecutableEdit)
|
||||||
{
|
{
|
||||||
if(resultCode == RESULT_OK)
|
if(resultCode == RESULT_OK)
|
||||||
@ -1635,6 +1752,35 @@ public class ActivityManageRule extends Activity
|
|||||||
this.refreshActionList();
|
this.refreshActionList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(requestCode == requestCodeActionMakePhoneCallEdit)
|
||||||
|
{
|
||||||
|
if(resultCode == RESULT_OK)
|
||||||
|
{
|
||||||
|
ruleToEdit.getActionSet().get(editIndex).setParentRule(ruleToEdit);
|
||||||
|
|
||||||
|
if(data.hasExtra(intentNameActionParameter1) && data.hasExtra(intentNameActionParameter2))
|
||||||
|
{
|
||||||
|
ruleToEdit.getActionSet().get(editIndex).setParameter1(data.getBooleanExtra(intentNameActionParameter1, false));
|
||||||
|
ruleToEdit.getActionSet().get(editIndex).setParameter2(data.getStringExtra(intentNameActionParameter2));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.refreshActionList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(requestCode == requestCodeActionSetVariableEdit)
|
||||||
|
{
|
||||||
|
if(resultCode == RESULT_OK)
|
||||||
|
{
|
||||||
|
ruleToEdit.getActionSet().get(editIndex).setParentRule(ruleToEdit);
|
||||||
|
|
||||||
|
if(data.hasExtra(intentNameActionParameter2))
|
||||||
|
{
|
||||||
|
ruleToEdit.getActionSet().get(editIndex).setParameter2(data.getStringExtra(intentNameActionParameter2));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.refreshActionList();
|
||||||
|
}
|
||||||
|
}
|
||||||
else if(requestCode == requestCodeActionSetWifiEdit)
|
else if(requestCode == requestCodeActionSetWifiEdit)
|
||||||
{
|
{
|
||||||
if(resultCode == RESULT_OK)
|
if(resultCode == RESULT_OK)
|
||||||
@ -1812,6 +1958,29 @@ public class ActivityManageRule extends Activity
|
|||||||
if(resultCode == RESULT_OK)
|
if(resultCode == RESULT_OK)
|
||||||
{
|
{
|
||||||
newTrigger.setTriggerParameter(data.getBooleanExtra(intentNameTriggerParameter1, true));
|
newTrigger.setTriggerParameter(data.getBooleanExtra(intentNameTriggerParameter1, true));
|
||||||
|
newTrigger.setTriggerParameter2(data.getStringExtra(intentNameTriggerParameter2));
|
||||||
|
newTrigger.setParentRule(ruleToEdit);
|
||||||
|
ruleToEdit.getTriggerSet().add(newTrigger);
|
||||||
|
this.refreshTriggerList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(requestCode == requestCodeTriggerSubSystemStateAdd)
|
||||||
|
{
|
||||||
|
if(resultCode == RESULT_OK)
|
||||||
|
{
|
||||||
|
newTrigger.setTriggerParameter(data.getBooleanExtra(intentNameTriggerParameter1, true));
|
||||||
|
newTrigger.setTriggerParameter2(data.getStringExtra(intentNameTriggerParameter2));
|
||||||
|
newTrigger.setParentRule(ruleToEdit);
|
||||||
|
ruleToEdit.getTriggerSet().add(newTrigger);
|
||||||
|
this.refreshTriggerList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(requestCode == requestCodeTriggerCheckVariableAdd)
|
||||||
|
{
|
||||||
|
if(resultCode == RESULT_OK)
|
||||||
|
{
|
||||||
|
newTrigger.setTriggerParameter(data.getBooleanExtra(intentNameTriggerParameter1, true));
|
||||||
|
newTrigger.setTriggerParameter2(data.getStringExtra(intentNameTriggerParameter2));
|
||||||
newTrigger.setParentRule(ruleToEdit);
|
newTrigger.setParentRule(ruleToEdit);
|
||||||
ruleToEdit.getTriggerSet().add(newTrigger);
|
ruleToEdit.getTriggerSet().add(newTrigger);
|
||||||
this.refreshTriggerList();
|
this.refreshTriggerList();
|
||||||
@ -1824,11 +1993,63 @@ public class ActivityManageRule extends Activity
|
|||||||
Trigger editedTrigger = new Trigger();
|
Trigger editedTrigger = new Trigger();
|
||||||
editedTrigger.setTriggerType(Trigger_Enum.tethering);
|
editedTrigger.setTriggerType(Trigger_Enum.tethering);
|
||||||
editedTrigger.setTriggerParameter(data.getBooleanExtra(intentNameTriggerParameter1, true));
|
editedTrigger.setTriggerParameter(data.getBooleanExtra(intentNameTriggerParameter1, true));
|
||||||
|
editedTrigger.setTriggerParameter2(data.getStringExtra(intentNameTriggerParameter2));
|
||||||
editedTrigger.setParentRule(ruleToEdit);
|
editedTrigger.setParentRule(ruleToEdit);
|
||||||
ruleToEdit.getTriggerSet().set(editIndex, editedTrigger);
|
ruleToEdit.getTriggerSet().set(editIndex, editedTrigger);
|
||||||
this.refreshTriggerList();
|
this.refreshTriggerList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(requestCode == requestCodeTriggerSubSystemStateEdit)
|
||||||
|
{
|
||||||
|
if(resultCode == RESULT_OK)
|
||||||
|
{
|
||||||
|
Trigger editedTrigger = new Trigger();
|
||||||
|
editedTrigger.setTriggerType(Trigger_Enum.subSystemState);
|
||||||
|
editedTrigger.setTriggerParameter(data.getBooleanExtra(intentNameTriggerParameter1, true));
|
||||||
|
editedTrigger.setTriggerParameter2(data.getStringExtra(intentNameTriggerParameter2));
|
||||||
|
editedTrigger.setParentRule(ruleToEdit);
|
||||||
|
ruleToEdit.getTriggerSet().set(editIndex, editedTrigger);
|
||||||
|
this.refreshTriggerList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(requestCode == requestCodeTriggerCheckVariableEdit)
|
||||||
|
{
|
||||||
|
if(resultCode == RESULT_OK)
|
||||||
|
{
|
||||||
|
Trigger editedTrigger = new Trigger();
|
||||||
|
editedTrigger.setTriggerType(Trigger_Enum.checkVariable);
|
||||||
|
editedTrigger.setTriggerParameter(data.getBooleanExtra(intentNameTriggerParameter1, true));
|
||||||
|
editedTrigger.setTriggerParameter2(data.getStringExtra(intentNameTriggerParameter2));
|
||||||
|
editedTrigger.setParentRule(ruleToEdit);
|
||||||
|
ruleToEdit.getTriggerSet().set(editIndex, editedTrigger);
|
||||||
|
this.refreshTriggerList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(requestCode == requestCodeActionCopyTextToClipboardAdd)
|
||||||
|
{
|
||||||
|
if(resultCode == RESULT_OK)
|
||||||
|
{
|
||||||
|
newAction.setParentRule(ruleToEdit);
|
||||||
|
newAction.setParameter1(data.getBooleanExtra(intentNameActionParameter1, false));
|
||||||
|
newAction.setParameter2(data.getStringExtra(intentNameActionParameter2));
|
||||||
|
ruleToEdit.getActionSet().add(newAction);
|
||||||
|
this.refreshActionList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(requestCode == requestCodeActionCopyTextToClipboardEdit)
|
||||||
|
{
|
||||||
|
if(resultCode == RESULT_OK)
|
||||||
|
{
|
||||||
|
ruleToEdit.getActionSet().get(editIndex).setParentRule(ruleToEdit);
|
||||||
|
|
||||||
|
if(data.hasExtra(intentNameActionParameter2))
|
||||||
|
{
|
||||||
|
ruleToEdit.getActionSet().get(editIndex).setParameter2(data.getStringExtra(intentNameActionParameter2));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.refreshActionList();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AlertDialog getActionTypeDialog()
|
protected AlertDialog getActionTypeDialog()
|
||||||
@ -1884,14 +2105,27 @@ public class ActivityManageRule extends Activity
|
|||||||
items.add(new Item(typesLong[i].toString(), R.drawable.notification));
|
items.add(new Item(typesLong[i].toString(), R.drawable.notification));
|
||||||
else if(types[i].toString().equals(Action_Enum.sendBroadcast.toString()))
|
else if(types[i].toString().equals(Action_Enum.sendBroadcast.toString()))
|
||||||
items.add(new Item(typesLong[i].toString(), R.drawable.megaphone));
|
items.add(new Item(typesLong[i].toString(), R.drawable.megaphone));
|
||||||
|
else if(types[i].toString().equals(Action_Enum.wakelock.toString()))
|
||||||
|
items.add(new Item(typesLong[i].toString(), R.drawable.coffee));
|
||||||
else if(types[i].toString().equals(Action_Enum.runExecutable.toString()))
|
else if(types[i].toString().equals(Action_Enum.runExecutable.toString()))
|
||||||
items.add(new Item(typesLong[i].toString(), R.drawable.script));
|
items.add(new Item(typesLong[i].toString(), R.drawable.script));
|
||||||
|
else if(types[i].toString().equals(Action_Enum.startPhoneCall.toString()))
|
||||||
|
{
|
||||||
|
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageRule.this, Manifest.permission.CALL_PHONE))
|
||||||
|
items.add(new Item(typesLong[i].toString(), R.drawable.phone));
|
||||||
|
}
|
||||||
|
else if(types[i].toString().equals(Action_Enum.stopPhoneCall.toString()))
|
||||||
|
{
|
||||||
|
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageRule.this, Manifest.permission.ANSWER_PHONE_CALLS))
|
||||||
|
items.add(new Item(typesLong[i].toString(), R.drawable.phone));
|
||||||
|
}
|
||||||
else if(types[i].toString().equals(Action_Enum.sendTextMessage.toString()))
|
else if(types[i].toString().equals(Action_Enum.sendTextMessage.toString()))
|
||||||
{
|
{
|
||||||
// if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageSpecificRule.this, "android.permission.SEND_SMS") && !Miscellaneous.isGooglePlayInstalled(ActivityManageSpecificRule.this))
|
|
||||||
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageRule.this, Manifest.permission.SEND_SMS))
|
if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageRule.this, Manifest.permission.SEND_SMS))
|
||||||
items.add(new Item(typesLong[i].toString(), R.drawable.message));
|
items.add(new Item(typesLong[i].toString(), R.drawable.message));
|
||||||
}
|
}
|
||||||
|
else if(types[i].toString().equals(Action_Enum.copyToClipboard.toString()))
|
||||||
|
items.add(new Item(typesLong[i].toString(), R.drawable.clipboard));
|
||||||
else
|
else
|
||||||
items.add(new Item(typesLong[i].toString(), R.drawable.placeholder));
|
items.add(new Item(typesLong[i].toString(), R.drawable.placeholder));
|
||||||
}
|
}
|
||||||
@ -2058,6 +2292,30 @@ public class ActivityManageRule extends Activity
|
|||||||
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionRunExecutable.class);
|
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionRunExecutable.class);
|
||||||
startActivityForResult(intent, requestCodeActionRunExecutableAdd);
|
startActivityForResult(intent, requestCodeActionRunExecutableAdd);
|
||||||
}
|
}
|
||||||
|
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.startPhoneCall.toString()))
|
||||||
|
{
|
||||||
|
newAction.setAction(Action_Enum.startPhoneCall);
|
||||||
|
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionMakePhoneCall.class);
|
||||||
|
startActivityForResult(intent, requestCodeActionMakePhoneCallAdd);
|
||||||
|
}
|
||||||
|
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.setVariable.toString()))
|
||||||
|
{
|
||||||
|
newAction.setAction(Action_Enum.setVariable);
|
||||||
|
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionSetVariable.class);
|
||||||
|
startActivityForResult(intent, requestCodeActionSetVariableAdd);
|
||||||
|
}
|
||||||
|
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.stopPhoneCall.toString()))
|
||||||
|
{
|
||||||
|
newAction.setAction(Action_Enum.stopPhoneCall);
|
||||||
|
ruleToEdit.getActionSet().add(newAction);
|
||||||
|
refreshActionList();
|
||||||
|
}
|
||||||
|
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.wakelock.toString()))
|
||||||
|
{
|
||||||
|
newAction.setAction(Action_Enum.wakelock);
|
||||||
|
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionWakeLock.class);
|
||||||
|
startActivityForResult(intent, requestCodeActionWakeLockAdd);
|
||||||
|
}
|
||||||
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.controlMediaPlayback.toString()))
|
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.controlMediaPlayback.toString()))
|
||||||
{
|
{
|
||||||
newAction.setAction(Action_Enum.controlMediaPlayback);
|
newAction.setAction(Action_Enum.controlMediaPlayback);
|
||||||
@ -2088,6 +2346,12 @@ public class ActivityManageRule extends Activity
|
|||||||
Intent actionPlaySoundIntent = new Intent(context, ActivityManageActionPlaySound.class);
|
Intent actionPlaySoundIntent = new Intent(context, ActivityManageActionPlaySound.class);
|
||||||
startActivityForResult(actionPlaySoundIntent, requestCodeActionPlaySoundAdd);
|
startActivityForResult(actionPlaySoundIntent, requestCodeActionPlaySoundAdd);
|
||||||
}
|
}
|
||||||
|
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.copyToClipboard.toString()))
|
||||||
|
{
|
||||||
|
newAction.setAction(Action_Enum.copyToClipboard);
|
||||||
|
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionCopyToClipboard.class);
|
||||||
|
startActivityForResult(intent, requestCodeActionCopyTextToClipboardAdd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ public class ActivityManageTriggerBluetooth extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_trigger_bluetooth);
|
setContentView(R.layout.activity_manage_trigger_bluetooth);
|
||||||
|
|
||||||
radioAnyBluetoothDevice = (RadioButton)findViewById(R.id.radioAnyBluetoothDevice);
|
radioAnyBluetoothDevice = (RadioButton)findViewById(R.id.radioAnyBluetoothDevice);
|
||||||
|
@ -28,6 +28,7 @@ public class ActivityManageTriggerBroadcast extends Activity
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_trigger_broadcasts);
|
setContentView(R.layout.activity_manage_trigger_broadcasts);
|
||||||
|
|
||||||
bBroadcastShowSuggestions = findViewById(R.id.bBroadcastShowSuggestions);
|
bBroadcastShowSuggestions = findViewById(R.id.bBroadcastShowSuggestions);
|
||||||
|
@ -0,0 +1,57 @@
|
|||||||
|
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 androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
public class ActivityManageTriggerCheckVariable extends Activity
|
||||||
|
{
|
||||||
|
EditText etVariableKeyTrigger, etVariableValueTrigger;
|
||||||
|
Button bTriggerVariableSave;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
|
{
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
|
setContentView(R.layout.activity_manage_trigger_check_variable);
|
||||||
|
|
||||||
|
etVariableKeyTrigger = (EditText) findViewById(R.id.etVariableKeyTrigger);
|
||||||
|
etVariableValueTrigger = (EditText) findViewById(R.id.etVariableValueTrigger);
|
||||||
|
bTriggerVariableSave = (Button) findViewById(R.id.bTriggerVariableSave);
|
||||||
|
|
||||||
|
Intent input = getIntent();
|
||||||
|
if(input.hasExtra(ActivityManageRule.intentNameTriggerParameter2))
|
||||||
|
{
|
||||||
|
String[] conditions = input.getStringExtra(ActivityManageRule.intentNameTriggerParameter2).split(Trigger.triggerParameter2Split);
|
||||||
|
etVariableKeyTrigger.setText(conditions[0]);
|
||||||
|
if(conditions.length > 1)
|
||||||
|
etVariableValueTrigger.setText(conditions[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
bTriggerVariableSave.setOnClickListener(new View.OnClickListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick(View view)
|
||||||
|
{
|
||||||
|
Intent response = new Intent();
|
||||||
|
// response.putExtra(ActivityManageRule.intentNameTriggerParameter1, rbTetheringOn.isChecked());
|
||||||
|
|
||||||
|
if(StringUtils.isEmpty(etVariableValueTrigger.getText().toString()))
|
||||||
|
response.putExtra(ActivityManageRule.intentNameTriggerParameter2, etVariableKeyTrigger.getText().toString());
|
||||||
|
else
|
||||||
|
response.putExtra(ActivityManageRule.intentNameTriggerParameter2, etVariableKeyTrigger.getText().toString() + Trigger.triggerParameter2Split + etVariableValueTrigger.getText().toString());
|
||||||
|
|
||||||
|
setResult(RESULT_OK, response);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -104,6 +104,7 @@ public class ActivityManageTriggerDeviceOrientation extends Activity
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_trigger_device_orientation);
|
setContentView(R.layout.activity_manage_trigger_device_orientation);
|
||||||
|
|
||||||
currentAzimuth = (TextView) findViewById(R.id.tvCurrentAzimuth);
|
currentAzimuth = (TextView) findViewById(R.id.tvCurrentAzimuth);
|
||||||
|
@ -39,6 +39,7 @@ public class ActivityManageTriggerNfc extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_trigger_nfc);
|
setContentView(R.layout.activity_manage_trigger_nfc);
|
||||||
|
|
||||||
etNewNfcIdValue = (EditText)findViewById(R.id.etNewNfcIdValue);
|
etNewNfcIdValue = (EditText)findViewById(R.id.etNewNfcIdValue);
|
||||||
|
@ -258,6 +258,7 @@ public class ActivityManageTriggerNotification extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_trigger_notification);
|
setContentView(R.layout.activity_manage_trigger_notification);
|
||||||
|
|
||||||
etNotificationTitle = (EditText)findViewById(R.id.etNotificationTitle);
|
etNotificationTitle = (EditText)findViewById(R.id.etNotificationTitle);
|
||||||
|
@ -35,6 +35,7 @@ public class ActivityManageTriggerPhoneCall extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_trigger_phone_call);
|
setContentView(R.layout.activity_manage_trigger_phone_call);
|
||||||
|
|
||||||
etTriggerPhoneCallPhoneNumber = (EditText)findViewById(R.id.etTriggerPhoneCallPhoneNumber);
|
etTriggerPhoneCallPhoneNumber = (EditText)findViewById(R.id.etTriggerPhoneCallPhoneNumber);
|
||||||
|
@ -31,6 +31,7 @@ public class ActivityManageTriggerProfile extends Activity
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_trigger_profile);
|
setContentView(R.layout.activity_manage_trigger_profile);
|
||||||
|
|
||||||
bSaveTriggerProfile = (Button)findViewById(R.id.bSaveTriggerProfile);
|
bSaveTriggerProfile = (Button)findViewById(R.id.bSaveTriggerProfile);
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
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.RadioButton;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.jens.automation2.Trigger.subSystemStates;
|
||||||
|
|
||||||
|
public class ActivityManageTriggerSubSystemState extends Activity
|
||||||
|
{
|
||||||
|
RadioButton rbSubSystemStateWifi, rbSubSystemStateBluetooth;
|
||||||
|
RadioButton rbSubSystemStateEnabled, rbSubSystemStateDisabled;
|
||||||
|
Button bSubSystemStateSave;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
|
{
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
|
setContentView(R.layout.activity_manage_trigger_subsystemstate);
|
||||||
|
|
||||||
|
rbSubSystemStateWifi = (RadioButton)findViewById(R.id.rbSubSystemStateWifi);
|
||||||
|
rbSubSystemStateBluetooth = (RadioButton)findViewById(R.id.rbSubSystemStateBluetooth);
|
||||||
|
rbSubSystemStateEnabled = (RadioButton)findViewById(R.id.rbSubSystemStateEnabled);
|
||||||
|
rbSubSystemStateDisabled = (RadioButton)findViewById(R.id.rbSubSystemStateDisabled);
|
||||||
|
bSubSystemStateSave = (Button)findViewById(R.id.bSubSystemStateSave);
|
||||||
|
|
||||||
|
if(getIntent().hasExtra(ActivityManageRule.intentNameTriggerParameter1) && getIntent().hasExtra(ActivityManageRule.intentNameTriggerParameter2))
|
||||||
|
{
|
||||||
|
subSystemStates desiredState = subSystemStates.valueOf(getIntent().getStringExtra(ActivityManageRule.intentNameTriggerParameter2));
|
||||||
|
|
||||||
|
switch(desiredState)
|
||||||
|
{
|
||||||
|
case wifi:
|
||||||
|
rbSubSystemStateWifi.setChecked(true);
|
||||||
|
break;
|
||||||
|
case bluetooth:
|
||||||
|
rbSubSystemStateBluetooth.setChecked(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
if(getIntent().getBooleanExtra(ActivityManageRule.intentNameTriggerParameter1, true))
|
||||||
|
rbSubSystemStateEnabled.setChecked(true);
|
||||||
|
else
|
||||||
|
rbSubSystemStateDisabled.setChecked(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bSubSystemStateSave.setOnClickListener(new View.OnClickListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onClick(View view)
|
||||||
|
{
|
||||||
|
Intent data = new Intent();
|
||||||
|
|
||||||
|
data.putExtra(ActivityManageRule.intentNameTriggerParameter1, rbSubSystemStateEnabled.isChecked());
|
||||||
|
|
||||||
|
if(rbSubSystemStateWifi.isChecked())
|
||||||
|
data.putExtra(ActivityManageRule.intentNameTriggerParameter2, subSystemStates.wifi.name());
|
||||||
|
else if(rbSubSystemStateBluetooth.isChecked())
|
||||||
|
data.putExtra(ActivityManageRule.intentNameTriggerParameter2, subSystemStates.bluetooth.name());
|
||||||
|
|
||||||
|
ActivityManageTriggerSubSystemState.this.setResult(RESULT_OK, data);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -9,19 +9,33 @@ import android.widget.RadioButton;
|
|||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
public class ActivityManageTriggerTethering extends Activity
|
public class ActivityManageTriggerTethering extends Activity
|
||||||
{
|
{
|
||||||
RadioButton rbTetheringOn, rbTetheringOff;
|
RadioButton rbTetheringOn, rbTetheringOff, rbTetheringTypeAny, rbTetheringTypeWifi, rbTetheringTypeBluetooth, rbTetheringTypeUsb, rbTetheringTypeCable;
|
||||||
Button bTriggerTetheringSave;
|
Button bTriggerTetheringSave;
|
||||||
|
|
||||||
|
public final static String tetheringTypeAny = "tetheringTypeAny";
|
||||||
|
public final static String tetheringTypeWifi = "tetheringTypeWifi";
|
||||||
|
public final static String tetheringTypeBluetooth = "tetheringTypeBluetooth";
|
||||||
|
public final static String tetheringTypeUsb = "tetheringTypeUsb";
|
||||||
|
public final static String tetheringTypeCable = "tetheringTypeCable";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_trigger_tethering);
|
setContentView(R.layout.activity_manage_trigger_tethering);
|
||||||
|
|
||||||
rbTetheringOn = (RadioButton) findViewById(R.id.rbTetheringOn);
|
rbTetheringOn = (RadioButton) findViewById(R.id.rbTetheringOn);
|
||||||
rbTetheringOff = (RadioButton)findViewById(R.id.rbTetheringOff);
|
rbTetheringOff = (RadioButton)findViewById(R.id.rbTetheringOff);
|
||||||
|
rbTetheringTypeAny = (RadioButton) findViewById(R.id.rbTetheringTypeAny);
|
||||||
|
rbTetheringTypeWifi = (RadioButton) findViewById(R.id.rbTetheringTypeWifi);
|
||||||
|
rbTetheringTypeBluetooth = (RadioButton) findViewById(R.id.rbTetheringTypeBluetooth);
|
||||||
|
rbTetheringTypeUsb = (RadioButton) findViewById(R.id.rbTetheringTypeUsb);
|
||||||
|
rbTetheringTypeCable = (RadioButton) findViewById(R.id.rbTetheringTypeCable);
|
||||||
bTriggerTetheringSave = (Button) findViewById(R.id.bTriggerTetheringSave);
|
bTriggerTetheringSave = (Button) findViewById(R.id.bTriggerTetheringSave);
|
||||||
|
|
||||||
Intent input = getIntent();
|
Intent input = getIntent();
|
||||||
@ -31,6 +45,36 @@ public class ActivityManageTriggerTethering extends Activity
|
|||||||
rbTetheringOff.setChecked(!input.getBooleanExtra(ActivityManageRule.intentNameTriggerParameter1, false));
|
rbTetheringOff.setChecked(!input.getBooleanExtra(ActivityManageRule.intentNameTriggerParameter1, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(input.hasExtra(ActivityManageRule.intentNameTriggerParameter2))
|
||||||
|
{
|
||||||
|
String type = input.getStringExtra(ActivityManageRule.intentNameTriggerParameter2);
|
||||||
|
|
||||||
|
if(!StringUtils.isEmpty(type))
|
||||||
|
{
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case tetheringTypeAny:
|
||||||
|
rbTetheringTypeAny.setChecked(true);
|
||||||
|
break;
|
||||||
|
case tetheringTypeWifi:
|
||||||
|
rbTetheringTypeWifi.setChecked(true);
|
||||||
|
break;
|
||||||
|
case tetheringTypeBluetooth:
|
||||||
|
rbTetheringTypeBluetooth.setChecked(true);
|
||||||
|
break;
|
||||||
|
case tetheringTypeUsb:
|
||||||
|
rbTetheringTypeUsb.setChecked(true);
|
||||||
|
break;
|
||||||
|
case tetheringTypeCable:
|
||||||
|
rbTetheringTypeCable.setChecked(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
rbTetheringTypeAny.setChecked(true);
|
||||||
|
|
||||||
bTriggerTetheringSave.setOnClickListener(new View.OnClickListener()
|
bTriggerTetheringSave.setOnClickListener(new View.OnClickListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -38,6 +82,18 @@ public class ActivityManageTriggerTethering extends Activity
|
|||||||
{
|
{
|
||||||
Intent response = new Intent();
|
Intent response = new Intent();
|
||||||
response.putExtra(ActivityManageRule.intentNameTriggerParameter1, rbTetheringOn.isChecked());
|
response.putExtra(ActivityManageRule.intentNameTriggerParameter1, rbTetheringOn.isChecked());
|
||||||
|
|
||||||
|
if(rbTetheringTypeAny.isChecked())
|
||||||
|
response.putExtra(ActivityManageRule.intentNameTriggerParameter2, tetheringTypeAny);
|
||||||
|
else if(rbTetheringTypeWifi.isChecked())
|
||||||
|
response.putExtra(ActivityManageRule.intentNameTriggerParameter2, tetheringTypeWifi);
|
||||||
|
else if(rbTetheringTypeBluetooth.isChecked())
|
||||||
|
response.putExtra(ActivityManageRule.intentNameTriggerParameter2, tetheringTypeBluetooth);
|
||||||
|
else if(rbTetheringTypeUsb.isChecked())
|
||||||
|
response.putExtra(ActivityManageRule.intentNameTriggerParameter2, tetheringTypeUsb);
|
||||||
|
else if(rbTetheringTypeCable.isChecked())
|
||||||
|
response.putExtra(ActivityManageRule.intentNameTriggerParameter2, tetheringTypeCable);
|
||||||
|
|
||||||
setResult(RESULT_OK, response);
|
setResult(RESULT_OK, response);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ public class ActivityManageTriggerTimeFrame extends Activity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_trigger_timeframe);
|
setContentView(R.layout.activity_manage_trigger_timeframe);
|
||||||
|
|
||||||
startPicker = (TimePicker)findViewById(R.id.tpTimeFrameStart);
|
startPicker = (TimePicker)findViewById(R.id.tpTimeFrameStart);
|
||||||
|
@ -12,23 +12,25 @@ import android.net.wifi.WifiConfiguration;
|
|||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
|
|
||||||
import com.jens.automation2.receivers.BluetoothReceiver;
|
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -41,28 +43,41 @@ public class ActivityManageTriggerWifi extends Activity
|
|||||||
RadioButton rbTriggerWifiConnected, rbTriggerWifiDisconnected;
|
RadioButton rbTriggerWifiConnected, rbTriggerWifiDisconnected;
|
||||||
EditText etTriggerWifiName;
|
EditText etTriggerWifiName;
|
||||||
Spinner spinnerWifiList;
|
Spinner spinnerWifiList;
|
||||||
Button btriggerWifiSave, bLoadWifiList;
|
Button bTriggerWifiSave, bLoadWifiList;
|
||||||
List<String> wifiList = new ArrayList<>();
|
List<String> wifiList = new ArrayList<>();
|
||||||
ArrayAdapter<String> wifiSpinnerAdapter;
|
ArrayAdapter<String> wifiSpinnerAdapter;
|
||||||
private final static int requestCodeLocationPermission = 124;
|
private final static int requestCodeLocationPermission = 124;
|
||||||
|
TextView tvWifiTriggerNameLocationNotice, tvWifiTriggerDisconnectionHint;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_manage_trigger_wifi);
|
setContentView(R.layout.activity_manage_trigger_wifi);
|
||||||
|
|
||||||
rbTriggerWifiConnected = (RadioButton) findViewById(R.id.rbTriggerWifiConnected);
|
rbTriggerWifiConnected = (RadioButton) findViewById(R.id.rbTriggerWifiConnected);
|
||||||
rbTriggerWifiDisconnected = (RadioButton) findViewById(R.id.rbTriggerWifiDisconnected);
|
rbTriggerWifiDisconnected = (RadioButton) findViewById(R.id.rbTriggerWifiDisconnected);
|
||||||
etTriggerWifiName = (EditText) findViewById(R.id.etTriggerWifiName);
|
etTriggerWifiName = (EditText) findViewById(R.id.etTriggerWifiName);
|
||||||
spinnerWifiList = (Spinner) findViewById(R.id.spinnerWifiList);
|
spinnerWifiList = (Spinner) findViewById(R.id.spinnerWifiList);
|
||||||
btriggerWifiSave = (Button) findViewById(R.id.btriggerWifiSave);
|
bTriggerWifiSave = (Button) findViewById(R.id.bTriggerWifiSave);
|
||||||
bLoadWifiList = (Button) findViewById(R.id.bLoadWifiList);
|
bLoadWifiList = (Button) findViewById(R.id.bLoadWifiList);
|
||||||
|
tvWifiTriggerNameLocationNotice = (TextView)findViewById(R.id.tvWifiTriggerNameLocationNotice);
|
||||||
|
tvWifiTriggerDisconnectionHint = (TextView)findViewById(R.id.tvWifiTriggerDisconnectionHint);
|
||||||
|
|
||||||
|
tvWifiTriggerDisconnectionHint.setVisibility(View.GONE);
|
||||||
|
|
||||||
wifiSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, wifiList);
|
wifiSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, wifiList);
|
||||||
spinnerWifiList.setAdapter(wifiSpinnerAdapter);
|
spinnerWifiList.setAdapter(wifiSpinnerAdapter);
|
||||||
spinnerWifiList.setEnabled(false); // bug in Android; this only works when done in code, not in xml
|
spinnerWifiList.setEnabled(false); // bug in Android; this only works when done in code, not in xml
|
||||||
|
|
||||||
|
if(
|
||||||
|
Miscellaneous.getTargetSDK(Miscellaneous.getAnyContext()) >= 29
|
||||||
|
&&
|
||||||
|
!ActivityPermissions.isPermissionDeclaratedInManifest(Miscellaneous.getAnyContext(), Manifest.permission.ACCESS_BACKGROUND_LOCATION)
|
||||||
|
)
|
||||||
|
tvWifiTriggerNameLocationNotice.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if (getIntent().hasExtra("edit"))
|
if (getIntent().hasExtra("edit"))
|
||||||
{
|
{
|
||||||
boolean connected = getIntent().getBooleanExtra("wifiState", false);
|
boolean connected = getIntent().getBooleanExtra("wifiState", false);
|
||||||
@ -74,7 +89,7 @@ public class ActivityManageTriggerWifi extends Activity
|
|||||||
etTriggerWifiName.setText(wifiName);
|
etTriggerWifiName.setText(wifiName);
|
||||||
}
|
}
|
||||||
|
|
||||||
btriggerWifiSave.setOnClickListener(new View.OnClickListener()
|
bTriggerWifiSave.setOnClickListener(new View.OnClickListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
@ -93,6 +108,11 @@ public class ActivityManageTriggerWifi extends Activity
|
|||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
|
||||||
{
|
{
|
||||||
etTriggerWifiName.setText(wifiList.get(position));
|
etTriggerWifiName.setText(wifiList.get(position));
|
||||||
|
|
||||||
|
if(etTriggerWifiName.getText().toString().length() > 0 && rbTriggerWifiDisconnected.isChecked())
|
||||||
|
tvWifiTriggerDisconnectionHint.setVisibility(View.VISIBLE);
|
||||||
|
else
|
||||||
|
tvWifiTriggerDisconnectionHint.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -110,6 +130,41 @@ public class ActivityManageTriggerWifi extends Activity
|
|||||||
loadWifis();
|
loadWifis();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
rbTriggerWifiDisconnected.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean b)
|
||||||
|
{
|
||||||
|
if(etTriggerWifiName.getText().toString().length() > 0 && b)
|
||||||
|
tvWifiTriggerDisconnectionHint.setVisibility(View.VISIBLE);
|
||||||
|
else
|
||||||
|
tvWifiTriggerDisconnectionHint.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
etTriggerWifiName.addTextChangedListener(new TextWatcher()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2)
|
||||||
|
{
|
||||||
|
if(etTriggerWifiName.getText().toString().length() > 0 && rbTriggerWifiDisconnected.isChecked())
|
||||||
|
tvWifiTriggerDisconnectionHint.setVisibility(View.VISIBLE);
|
||||||
|
else
|
||||||
|
tvWifiTriggerDisconnectionHint.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable editable)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadWifis()
|
public void loadWifis()
|
||||||
|
@ -25,6 +25,8 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.jens.automation2.receivers.NotificationListener;
|
import com.jens.automation2.receivers.NotificationListener;
|
||||||
|
|
||||||
|
import org.w3c.dom.DOMImplementationSource;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -47,6 +49,8 @@ public class ActivityPermissions extends Activity
|
|||||||
private static final int requestCodeForPermissionsNotifications = 12046;
|
private static final int requestCodeForPermissionsNotifications = 12046;
|
||||||
private static final int requestCodeForPermissionsDeviceAdmin = 12047;
|
private static final int requestCodeForPermissionsDeviceAdmin = 12047;
|
||||||
private static final int requestCodeForPermissionsBatteryOptimization = 12048;
|
private static final int requestCodeForPermissionsBatteryOptimization = 12048;
|
||||||
|
private static final int requestCodeForPermissionNotificationAccessAndroid13 = 12049;
|
||||||
|
private static final int requestCodeForPermissionsManageOverlay = 12050;
|
||||||
protected String[] specificPermissionsToRequest = null;
|
protected String[] specificPermissionsToRequest = null;
|
||||||
|
|
||||||
public static String intentExtraName = "permissionsToBeRequested";
|
public static String intentExtraName = "permissionsToBeRequested";
|
||||||
@ -75,6 +79,7 @@ public class ActivityPermissions extends Activity
|
|||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.permissions_activity);
|
setContentView(R.layout.permissions_activity);
|
||||||
|
|
||||||
bCancelPermissions = (Button)findViewById(R.id.bCancelPermissions);
|
bCancelPermissions = (Button)findViewById(R.id.bCancelPermissions);
|
||||||
@ -248,14 +253,17 @@ public class ActivityPermissions extends Activity
|
|||||||
if (!havePermission(s, context))
|
if (!havePermission(s, context))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if((s.equalsIgnoreCase(Manifest.permission.CALL_PHONE) || s.equalsIgnoreCase(Manifest.permission.ANSWER_PHONE_CALLS)) && BuildConfig.FLAVOR.equalsIgnoreCase(AutomationService.flavor_name_googleplay))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
else if(s.equalsIgnoreCase(Manifest.permission.ACTIVITY_RECOGNITION) || s.equalsIgnoreCase(permissionNameGoogleActivityDetection))
|
else if(s.equalsIgnoreCase(Manifest.permission.ACTIVITY_RECOGNITION) || s.equalsIgnoreCase(permissionNameGoogleActivityDetection))
|
||||||
{
|
{
|
||||||
if(!BuildConfig.FLAVOR.equalsIgnoreCase(AutomationService.flavor_name_fdroid))
|
if(!BuildConfig.FLAVOR.equalsIgnoreCase(AutomationService.flavor_name_fdroid))
|
||||||
if (!havePermission(s, context))
|
if (!havePermission(s, context))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else if (!havePermission(s, context))
|
||||||
if (!havePermission(s, context))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -293,6 +301,10 @@ public class ActivityPermissions extends Activity
|
|||||||
String packageName = context.getApplicationContext().getPackageName();
|
String packageName = context.getApplicationContext().getPackageName();
|
||||||
return pm.isIgnoringBatteryOptimizations(packageName);
|
return pm.isIgnoringBatteryOptimizations(packageName);
|
||||||
}
|
}
|
||||||
|
else if (s.equals(Manifest.permission.SYSTEM_ALERT_WINDOW))
|
||||||
|
{
|
||||||
|
return android.provider.Settings.canDrawOverlays(Miscellaneous.getAnyContext());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int res = context.checkCallingOrSelfPermission(s);
|
int res = context.checkCallingOrSelfPermission(s);
|
||||||
@ -311,6 +323,11 @@ public class ActivityPermissions extends Activity
|
|||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void requestOverlay()
|
||||||
|
{
|
||||||
|
Intent intent = new Intent(android.provider.Settings.ACTION_MANAGE_OVERLAY_PERMISSION);
|
||||||
|
ActivityPermissions.getInstance().startActivityForResult(intent, requestCodeForPermissionsManageOverlay);
|
||||||
|
}
|
||||||
public static void requestDeviceAdmin()
|
public static void requestDeviceAdmin()
|
||||||
{
|
{
|
||||||
if(!haveDeviceAdmin())
|
if(!haveDeviceAdmin())
|
||||||
@ -439,6 +456,7 @@ public class ActivityPermissions extends Activity
|
|||||||
{
|
{
|
||||||
case activityDetection:
|
case activityDetection:
|
||||||
addToArrayListUnique(permissionNameGoogleActivityDetection, requiredPermissions);
|
addToArrayListUnique(permissionNameGoogleActivityDetection, requiredPermissions);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
|
||||||
addToArrayListUnique(Manifest.permission.ACTIVITY_RECOGNITION, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.ACTIVITY_RECOGNITION, requiredPermissions);
|
||||||
break;
|
break;
|
||||||
case airplaneMode:
|
case airplaneMode:
|
||||||
@ -469,6 +487,7 @@ public class ActivityPermissions extends Activity
|
|||||||
case phoneCall:
|
case phoneCall:
|
||||||
addToArrayListUnique(Manifest.permission.READ_PHONE_STATE, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.READ_PHONE_STATE, requiredPermissions);
|
||||||
addToArrayListUnique(Manifest.permission.PROCESS_OUTGOING_CALLS, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.PROCESS_OUTGOING_CALLS, requiredPermissions);
|
||||||
|
addToArrayListUnique(Manifest.permission.READ_CALL_LOG, requiredPermissions);
|
||||||
break;
|
break;
|
||||||
case pointOfInterest:
|
case pointOfInterest:
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
|
||||||
@ -509,6 +528,16 @@ public class ActivityPermissions extends Activity
|
|||||||
case wifiConnection:
|
case wifiConnection:
|
||||||
addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions);
|
||||||
addToArrayListUnique(Manifest.permission.ACCESS_WIFI_STATE, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.ACCESS_WIFI_STATE, requiredPermissions);
|
||||||
|
if(
|
||||||
|
(
|
||||||
|
Miscellaneous.getTargetSDK(Miscellaneous.getAnyContext()) >= 29
|
||||||
|
&&
|
||||||
|
isPermissionDeclaratedInManifest(Miscellaneous.getAnyContext(), Manifest.permission.ACCESS_BACKGROUND_LOCATION)
|
||||||
|
)
|
||||||
|
||
|
||||||
|
Build.VERSION.SDK_INT >= 33
|
||||||
|
)
|
||||||
|
addToArrayListUnique(Manifest.permission.ACCESS_BACKGROUND_LOCATION, requiredPermissions);
|
||||||
break;
|
break;
|
||||||
case notification:
|
case notification:
|
||||||
addToArrayListUnique(Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE, requiredPermissions);
|
||||||
@ -620,6 +649,8 @@ public class ActivityPermissions extends Activity
|
|||||||
// action.getParameter2().contains("eu.faircode.netguard.STOP_PORT_FORWARD")
|
// action.getParameter2().contains("eu.faircode.netguard.STOP_PORT_FORWARD")
|
||||||
// )
|
// )
|
||||||
// addToArrayListUnique("net.kollnig.missioncontrol.permission.ADMIN", requiredPermissions);
|
// addToArrayListUnique("net.kollnig.missioncontrol.permission.ADMIN", requiredPermissions);
|
||||||
|
if(Build.VERSION.SDK_INT >= 29)
|
||||||
|
addToArrayListUnique(Manifest.permission.SYSTEM_ALERT_WINDOW, requiredPermissions);
|
||||||
break;
|
break;
|
||||||
case triggerUrl:
|
case triggerUrl:
|
||||||
addToArrayListUnique(Manifest.permission.INTERNET, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.INTERNET, requiredPermissions);
|
||||||
@ -673,6 +704,13 @@ public class ActivityPermissions extends Activity
|
|||||||
else
|
else
|
||||||
addToArrayListUnique(Manifest.permission.BIND_DEVICE_ADMIN, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.BIND_DEVICE_ADMIN, requiredPermissions);
|
||||||
break;
|
break;
|
||||||
|
case startPhoneCall:
|
||||||
|
addToArrayListUnique(Manifest.permission.CALL_PHONE, requiredPermissions);
|
||||||
|
addToArrayListUnique(Manifest.permission.SYSTEM_ALERT_WINDOW, requiredPermissions);
|
||||||
|
break;
|
||||||
|
case stopPhoneCall:
|
||||||
|
addToArrayListUnique(Manifest.permission.ANSWER_PHONE_CALLS, requiredPermissions);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -738,11 +776,10 @@ public class ActivityPermissions extends Activity
|
|||||||
case Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE:
|
case Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE:
|
||||||
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.notification))
|
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.notification))
|
||||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
break;
|
for(String ruleName : getRulesUsing(Action.Action_Enum.closeNotification))
|
||||||
case permissionNameGoogleActivityDetection:
|
|
||||||
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.activityDetection))
|
|
||||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
break;
|
break;
|
||||||
|
case permissionNameGoogleActivityDetection:
|
||||||
case Manifest.permission.ACTIVITY_RECOGNITION:
|
case Manifest.permission.ACTIVITY_RECOGNITION:
|
||||||
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.activityDetection))
|
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.activityDetection))
|
||||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
@ -757,6 +794,7 @@ public class ActivityPermissions extends Activity
|
|||||||
break;
|
break;
|
||||||
case Manifest.permission.ACCESS_BACKGROUND_LOCATION:
|
case Manifest.permission.ACCESS_BACKGROUND_LOCATION:
|
||||||
usingElements.add(getResources().getString(R.string.googleLocationChicanery));
|
usingElements.add(getResources().getString(R.string.googleLocationChicanery));
|
||||||
|
usingElements.add(getResources().getString(R.string.wifiMonitoringAlsoRequiresThis));
|
||||||
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.pointOfInterest))
|
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.pointOfInterest))
|
||||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.speed))
|
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.speed))
|
||||||
@ -841,6 +879,7 @@ public class ActivityPermissions extends Activity
|
|||||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
break;
|
break;
|
||||||
case Manifest.permission.PROCESS_OUTGOING_CALLS:
|
case Manifest.permission.PROCESS_OUTGOING_CALLS:
|
||||||
|
case Manifest.permission.READ_CALL_LOG:
|
||||||
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.phoneCall))
|
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.phoneCall))
|
||||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
break;
|
break;
|
||||||
@ -864,6 +903,20 @@ public class ActivityPermissions extends Activity
|
|||||||
for(String ruleName : getRulesUsing(Action.Action_Enum.sendTextMessage))
|
for(String ruleName : getRulesUsing(Action.Action_Enum.sendTextMessage))
|
||||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
break;
|
break;
|
||||||
|
case Manifest.permission.CALL_PHONE:
|
||||||
|
for(String ruleName : getRulesUsing(Action.Action_Enum.startPhoneCall))
|
||||||
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
|
break;
|
||||||
|
case Manifest.permission.SYSTEM_ALERT_WINDOW:
|
||||||
|
for(String ruleName : getRulesUsing(Action.Action_Enum.startOtherActivity))
|
||||||
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
|
for(String ruleName : getRulesUsing(Action.Action_Enum.startPhoneCall))
|
||||||
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
|
break;
|
||||||
|
case Manifest.permission.ANSWER_PHONE_CALLS:
|
||||||
|
for(String ruleName : getRulesUsing(Action.Action_Enum.stopPhoneCall))
|
||||||
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
|
break;
|
||||||
case Manifest.permission.FOREGROUND_SERVICE:
|
case Manifest.permission.FOREGROUND_SERVICE:
|
||||||
usingElements.add(getResources().getString(R.string.startAutomationAsService));
|
usingElements.add(getResources().getString(R.string.startAutomationAsService));
|
||||||
break;
|
break;
|
||||||
@ -958,6 +1011,10 @@ public class ActivityPermissions extends Activity
|
|||||||
if (requestCode == requestCodeForPermissionsBatteryOptimization)
|
if (requestCode == requestCodeForPermissionsBatteryOptimization)
|
||||||
if(havePermission(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, ActivityPermissions.this))
|
if(havePermission(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, ActivityPermissions.this))
|
||||||
requestPermissions(cachedPermissionsToRequest, true);
|
requestPermissions(cachedPermissionsToRequest, true);
|
||||||
|
|
||||||
|
if (requestCode == requestCodeForPermissionsManageOverlay)
|
||||||
|
if(havePermission(Manifest.permission.SYSTEM_ALERT_WINDOW, ActivityPermissions.this))
|
||||||
|
requestPermissions(cachedPermissionsToRequest, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1008,7 +1065,7 @@ public class ActivityPermissions extends Activity
|
|||||||
startActivityForResult(intent, requestCodeForPermissionsWriteSettings);
|
startActivityForResult(intent, requestCodeForPermissionsWriteSettings);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (s.equalsIgnoreCase(Manifest.permission.BIND_DEVICE_ADMIN))
|
else if (s.equalsIgnoreCase(Manifest.permission.BIND_DEVICE_ADMIN))
|
||||||
{
|
{
|
||||||
requiredPermissions.remove(s);
|
requiredPermissions.remove(s);
|
||||||
cachedPermissionsToRequest = requiredPermissions;
|
cachedPermissionsToRequest = requiredPermissions;
|
||||||
@ -1023,12 +1080,46 @@ public class ActivityPermissions extends Activity
|
|||||||
startActivityForResult(intent, requestCodeForPermissionsNotificationPolicy);
|
startActivityForResult(intent, requestCodeForPermissionsNotificationPolicy);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (s.equalsIgnoreCase(Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE))
|
else if (s.equalsIgnoreCase(Manifest.permission.SYSTEM_ALERT_WINDOW))
|
||||||
|
{
|
||||||
|
AlertDialog diag = Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.overlayPermissionHint), ActivityPermissions.this);
|
||||||
|
diag.setOnDismissListener(new DialogInterface.OnDismissListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialogInterface)
|
||||||
{
|
{
|
||||||
requiredPermissions.remove(s);
|
requiredPermissions.remove(s);
|
||||||
cachedPermissionsToRequest = requiredPermissions;
|
cachedPermissionsToRequest = requiredPermissions;
|
||||||
Intent intent = new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS);
|
requestOverlay();
|
||||||
startActivityForResult(intent, requestCodeForPermissionsNotifications);
|
}
|
||||||
|
});
|
||||||
|
diag.show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (s.equalsIgnoreCase(Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE))
|
||||||
|
{
|
||||||
|
if(Build.VERSION.SDK_INT >= 33)
|
||||||
|
{
|
||||||
|
AlertDialog dialog = Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.notificationAccessAndroid13), ActivityPermissions.this);
|
||||||
|
dialog.setOnDismissListener(new DialogInterface.OnDismissListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onDismiss(DialogInterface dialogInterface)
|
||||||
|
{
|
||||||
|
requiredPermissions.remove(s);
|
||||||
|
cachedPermissionsToRequest = requiredPermissions;
|
||||||
|
requestNotificationAccess();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
requiredPermissions.remove(s);
|
||||||
|
cachedPermissionsToRequest = requiredPermissions;
|
||||||
|
requestNotificationAccess();
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(s.equals(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS))
|
else if(s.equals(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS))
|
||||||
@ -1103,6 +1194,12 @@ public class ActivityPermissions extends Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void requestNotificationAccess()
|
||||||
|
{
|
||||||
|
Intent intent = new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS);
|
||||||
|
startActivityForResult(intent, requestCodeForPermissionsNotifications);
|
||||||
|
}
|
||||||
|
|
||||||
protected void applyChanges()
|
protected void applyChanges()
|
||||||
{
|
{
|
||||||
AutomationService service = AutomationService.getInstance();
|
AutomationService service = AutomationService.getInstance();
|
||||||
|
@ -16,6 +16,7 @@ public class ActivitySettings extends PreferenceActivity
|
|||||||
protected void onCreate(Bundle savedInstanceState)
|
protected void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
addPreferencesFromResource(layout.activity_settings);
|
addPreferencesFromResource(layout.activity_settings);
|
||||||
|
|
||||||
if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_apk))
|
if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_apk))
|
||||||
@ -24,4 +25,11 @@ public class ActivitySettings extends PreferenceActivity
|
|||||||
chkPrefUpdateCheck.setEnabled(true);
|
chkPrefUpdateCheck.setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume()
|
||||||
|
{
|
||||||
|
super.onResume();
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
|
}
|
||||||
}
|
}
|
@ -30,6 +30,7 @@ public class ActivityVolumeTest extends Activity
|
|||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
Miscellaneous.setDisplayLanguage(this);
|
||||||
setContentView(R.layout.activity_volume_calibration);
|
setContentView(R.layout.activity_volume_calibration);
|
||||||
|
|
||||||
tvCurrentVolume = (TextView)findViewById(R.id.tvCurrentVolume);
|
tvCurrentVolume = (TextView)findViewById(R.id.tvCurrentVolume);
|
||||||
|
@ -4,7 +4,6 @@ import android.content.Context;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
public class AsyncTasks
|
public class AsyncTasks
|
||||||
|
@ -33,12 +33,15 @@ import com.jens.automation2.receivers.PackageReplacedReceiver;
|
|||||||
import com.jens.automation2.receivers.PhoneStatusListener;
|
import com.jens.automation2.receivers.PhoneStatusListener;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Set;
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
public class AutomationService extends Service implements OnInitListener
|
public class AutomationService extends Service implements OnInitListener
|
||||||
{
|
{
|
||||||
protected TextToSpeech ttsEngine = null;
|
protected TextToSpeech ttsEngine = null;
|
||||||
|
protected int ttsStatus = -1;
|
||||||
protected final static int notificationId = 1000;
|
protected final static int notificationId = 1000;
|
||||||
protected final static int notificationIdRestrictions = 1005;
|
protected final static int notificationIdRestrictions = 1005;
|
||||||
protected final static int notificationIdLocationRestriction = 1006;
|
protected final static int notificationIdLocationRestriction = 1006;
|
||||||
@ -63,6 +66,8 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
protected Calendar lockSoundChangesEnd = null;
|
protected Calendar lockSoundChangesEnd = null;
|
||||||
protected boolean isRunning;
|
protected boolean isRunning;
|
||||||
|
|
||||||
|
Map<String,String> variableMap = new HashMap();
|
||||||
|
|
||||||
protected static AutomationService centralInstance = null;
|
protected static AutomationService centralInstance = null;
|
||||||
|
|
||||||
public void nullLockSoundChangesEnd()
|
public void nullLockSoundChangesEnd()
|
||||||
@ -93,6 +98,11 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
this.lockSoundChangesEnd = lockSoundChangesEnd;
|
this.lockSoundChangesEnd = lockSoundChangesEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTtsStatus()
|
||||||
|
{
|
||||||
|
return ttsStatus;
|
||||||
|
}
|
||||||
|
|
||||||
protected final IBinder myBinder = new LocalBinder();
|
protected final IBinder myBinder = new LocalBinder();
|
||||||
|
|
||||||
protected LocationProvider myLocationProvider;
|
protected LocationProvider myLocationProvider;
|
||||||
@ -116,6 +126,8 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
|
|
||||||
// Store a reference to myself. Other classes often need a context or something, this can provide that.
|
// Store a reference to myself. Other classes often need a context or something, this can provide that.
|
||||||
centralInstance = this;
|
centralInstance = this;
|
||||||
|
|
||||||
|
Miscellaneous.setDisplayLanguage(AutomationService.this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkStartupRequirements(Context context, boolean startAtBoot)
|
public boolean checkStartupRequirements(Context context, boolean startAtBoot)
|
||||||
@ -222,6 +234,7 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
this.isRunning = true;
|
this.isRunning = true;
|
||||||
|
|
||||||
Miscellaneous.logEvent("i", "Service", this.getResources().getString(R.string.serviceStarted) + " VERSION_CODE: " + BuildConfig.VERSION_CODE + ", VERSION_NAME: " + BuildConfig.VERSION_NAME + ", flavor: " + BuildConfig.FLAVOR, 1);
|
Miscellaneous.logEvent("i", "Service", this.getResources().getString(R.string.serviceStarted) + " VERSION_CODE: " + BuildConfig.VERSION_CODE + ", VERSION_NAME: " + BuildConfig.VERSION_NAME + ", flavor: " + BuildConfig.FLAVOR, 1);
|
||||||
|
if(Settings.showToasts)
|
||||||
Toast.makeText(this, this.getResources().getString(R.string.serviceStarted), Toast.LENGTH_LONG).show();
|
Toast.makeText(this, this.getResources().getString(R.string.serviceStarted), Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -302,6 +315,7 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
|
|
||||||
stopRoutine();
|
stopRoutine();
|
||||||
this.isRunning = false;
|
this.isRunning = false;
|
||||||
|
if(Settings.showToasts)
|
||||||
Toast.makeText(this, getResources().getString(R.string.serviceStopped), Toast.LENGTH_LONG).show();
|
Toast.makeText(this, getResources().getString(R.string.serviceStopped), Toast.LENGTH_LONG).show();
|
||||||
Miscellaneous.logEvent("i", "Service", getResources().getString(R.string.serviceStopped), 1);
|
Miscellaneous.logEvent("i", "Service", getResources().getString(R.string.serviceStopped), 1);
|
||||||
}
|
}
|
||||||
@ -311,8 +325,26 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
if (Settings.useTextToSpeechOnNormal || Settings.useTextToSpeechOnSilent || Settings.useTextToSpeechOnVibrate || Rule.isAnyRuleUsing(Action.Action_Enum.speakText))
|
if (Settings.useTextToSpeechOnNormal || Settings.useTextToSpeechOnSilent || Settings.useTextToSpeechOnVibrate || Rule.isAnyRuleUsing(Action.Action_Enum.speakText))
|
||||||
{
|
{
|
||||||
if (ttsEngine == null)
|
if (ttsEngine == null)
|
||||||
ttsEngine = new TextToSpeech(this, this);
|
{
|
||||||
} else
|
ttsEngine = new TextToSpeech(this, new TextToSpeech.OnInitListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onInit(int status)
|
||||||
|
{
|
||||||
|
ttsStatus = status;
|
||||||
|
|
||||||
|
if (status == TextToSpeech.SUCCESS)
|
||||||
|
{
|
||||||
|
ttsEngine.setLanguage(Locale.getDefault());
|
||||||
|
Miscellaneous.logEvent("i", "TTS engine", "TTS engine available.", 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Miscellaneous.logEvent("i", "TTS engine", "TTS engine not available. Status: " + String.valueOf(status), 3);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (ttsEngine != null)
|
if (ttsEngine != null)
|
||||||
ttsEngine.shutdown();
|
ttsEngine.shutdown();
|
||||||
@ -457,6 +489,10 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
private void stopRoutine()
|
private void stopRoutine()
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "Service", "Stopping service...", 3);
|
Miscellaneous.logEvent("i", "Service", "Stopping service...", 3);
|
||||||
|
|
||||||
|
// Clear variables for trigger/action with same name
|
||||||
|
variableMap.clear();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
myLocationProvider.stopLocationService();
|
myLocationProvider.stopLocationService();
|
||||||
@ -473,6 +509,7 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
PackageReplacedReceiver.setHasServiceBeenRunning(false, this);
|
PackageReplacedReceiver.setHasServiceBeenRunning(false, this);
|
||||||
|
|
||||||
centralInstance = null;
|
centralInstance = null;
|
||||||
|
Settings.serviceStartDone = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Builder createDefaultNotificationBuilderOld()
|
protected static Builder createDefaultNotificationBuilderOld()
|
||||||
@ -481,7 +518,12 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
builder.setContentTitle("Automation");
|
builder.setContentTitle("Automation");
|
||||||
|
|
||||||
if(Settings.showIconWhenServiceIsRunning)
|
if(Settings.showIconWhenServiceIsRunning)
|
||||||
|
{
|
||||||
|
if(BuildConfig.FLAVOR.equalsIgnoreCase(AutomationService.flavor_name_googleplay))
|
||||||
|
builder.setSmallIcon(R.drawable.crane);
|
||||||
|
else
|
||||||
builder.setSmallIcon(R.drawable.ic_launcher);
|
builder.setSmallIcon(R.drawable.ic_launcher);
|
||||||
|
}
|
||||||
|
|
||||||
builder.setCategory(Notification.CATEGORY_SERVICE);
|
builder.setCategory(Notification.CATEGORY_SERVICE);
|
||||||
builder.setWhen(System.currentTimeMillis());
|
builder.setWhen(System.currentTimeMillis());
|
||||||
@ -489,7 +531,7 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
|
|
||||||
Notification defaultNotification = builder.build();
|
Notification defaultNotification = builder.build();
|
||||||
|
|
||||||
defaultNotification.icon = R.drawable.ic_launcher;
|
defaultNotification.icon = R.drawable.crane;
|
||||||
defaultNotification.when = System.currentTimeMillis();
|
defaultNotification.when = System.currentTimeMillis();
|
||||||
|
|
||||||
// defaultNotification.defaults |= Notification.DEFAULT_VIBRATE;
|
// defaultNotification.defaults |= Notification.DEFAULT_VIBRATE;
|
||||||
@ -536,7 +578,12 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
builder.setOnlyAlertOnce(true);
|
builder.setOnlyAlertOnce(true);
|
||||||
|
|
||||||
if(Settings.showIconWhenServiceIsRunning)
|
if(Settings.showIconWhenServiceIsRunning)
|
||||||
|
{
|
||||||
|
if (BuildConfig.FLAVOR.equals(AutomationService.flavor_name_googleplay))
|
||||||
|
builder.setSmallIcon(R.drawable.crane);
|
||||||
|
else
|
||||||
builder.setSmallIcon(R.drawable.ic_launcher);
|
builder.setSmallIcon(R.drawable.ic_launcher);
|
||||||
|
}
|
||||||
|
|
||||||
// builder.setContentText(textToDisplay);
|
// builder.setContentText(textToDisplay);
|
||||||
// builder.setSmallIcon(icon);
|
// builder.setSmallIcon(icon);
|
||||||
@ -662,25 +709,26 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for(int i = 0; i < 5; i++)
|
for(int i = 0; i < 60; i++)
|
||||||
{
|
{
|
||||||
if(ttsEngine != null)
|
if(ttsEngine == null || ttsStatus != TextToSpeech.SUCCESS)
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "TTS", "Waiting for a moment to give the TTS service time to load...", 4);
|
Miscellaneous.logEvent("i", "TTS", "Waiting for a moment to give the TTS service time to load...", 4);
|
||||||
Thread.sleep(1000); // give the tts engine time to load
|
Thread.sleep(500); // give the tts engine time to load
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{}
|
{}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
Miscellaneous.logEvent("i", "TextToSpeech", "Speaking " + text + " in language " + ttsEngine.getLanguage().toLanguageTag(), 3);
|
{
|
||||||
|
Miscellaneous.logEvent("i", "TextToSpeech", "Speaking \"" + text + "\" in language " + ttsEngine.getLanguage().toLanguageTag(), 3);
|
||||||
this.ttsEngine.speak(text, TextToSpeech.QUEUE_ADD, null);
|
this.ttsEngine.speak(text, TextToSpeech.QUEUE_ADD, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Miscellaneous.logEvent("i", "TextToSpeech", "TTS engine not available after waiting 30 seconds, yet. Aborting.", 3);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
@ -691,6 +739,11 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getVariableMap()
|
||||||
|
{
|
||||||
|
return variableMap;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isMainActivityRunning(Context context)
|
public static boolean isMainActivityRunning(Context context)
|
||||||
{
|
{
|
||||||
if(ActivityMainScreen.getActivityMainScreenInstance() == null)
|
if(ActivityMainScreen.getActivityMainScreenInstance() == null)
|
||||||
|
@ -15,6 +15,7 @@ import android.content.Intent;
|
|||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.media.AudioAttributes;
|
import android.media.AudioAttributes;
|
||||||
import android.media.RingtoneManager;
|
import android.media.RingtoneManager;
|
||||||
@ -31,6 +32,7 @@ import android.provider.Settings.Secure;
|
|||||||
import android.telephony.PhoneNumberUtils;
|
import android.telephony.PhoneNumberUtils;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@ -68,6 +70,7 @@ import java.io.InputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.Thread.UncaughtExceptionHandler;
|
import java.lang.Thread.UncaughtExceptionHandler;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -75,6 +78,8 @@ import java.math.BigDecimal;
|
|||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.DigestInputStream;
|
import java.security.DigestInputStream;
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.KeyStore;
|
import java.security.KeyStore;
|
||||||
@ -82,7 +87,6 @@ import java.security.MessageDigest;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.sql.Time;
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -91,7 +95,6 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
@ -113,6 +116,8 @@ import androidx.documentfile.provider.DocumentFile;
|
|||||||
public class Miscellaneous extends Service
|
public class Miscellaneous extends Service
|
||||||
{
|
{
|
||||||
protected static String writeableFolderStringCache = null;
|
protected static String writeableFolderStringCache = null;
|
||||||
|
public static Context startupContext;
|
||||||
|
|
||||||
public static final String lineSeparator = System.getProperty("line.separator");
|
public static final String lineSeparator = System.getProperty("line.separator");
|
||||||
|
|
||||||
public static String downloadURL(String url, String username, String password)
|
public static String downloadURL(String url, String username, String password)
|
||||||
@ -476,6 +481,9 @@ public class Miscellaneous extends Service
|
|||||||
switch(direction)
|
switch(direction)
|
||||||
{
|
{
|
||||||
case Trigger.directionEquals:
|
case Trigger.directionEquals:
|
||||||
|
if(Miscellaneous.isRegularExpression(needle))
|
||||||
|
return haystack.matches(needle);
|
||||||
|
else
|
||||||
return haystack.equalsIgnoreCase(needle);
|
return haystack.equalsIgnoreCase(needle);
|
||||||
case Trigger.directionNotEquals:
|
case Trigger.directionNotEquals:
|
||||||
return !haystack.equalsIgnoreCase(needle);
|
return !haystack.equalsIgnoreCase(needle);
|
||||||
@ -557,6 +565,9 @@ public class Miscellaneous extends Service
|
|||||||
if(returnContext != null)
|
if(returnContext != null)
|
||||||
return returnContext;
|
return returnContext;
|
||||||
|
|
||||||
|
if(startupContext != null)
|
||||||
|
return startupContext;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,33 +619,90 @@ public class Miscellaneous extends Service
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(source.contains("[serialnr]"))
|
if(source.contains("[serialnr]"))
|
||||||
|
{
|
||||||
if (Build.VERSION.SDK_INT > 8)
|
if (Build.VERSION.SDK_INT > 8)
|
||||||
source = source.replace("[serialnr]", Secure.getString(context.getContentResolver(), Build.SERIAL));
|
source = source.replace("[serialnr]", Secure.getString(context.getContentResolver(), Build.SERIAL));
|
||||||
else
|
else
|
||||||
source = source.replace("[serialnr]", "serialUnknown");
|
source = source.replace("[serialnr]", "serialUnknown");
|
||||||
|
}
|
||||||
|
|
||||||
if(
|
if(
|
||||||
source.contains("[d]") |
|
source.contains("[d]") ||
|
||||||
source.contains("[m]") |
|
source.contains("[m]") ||
|
||||||
source.contains("[Y]") |
|
source.contains("[Y]") ||
|
||||||
source.contains("[h]") |
|
source.contains("[h]") ||
|
||||||
source.contains("[H]") |
|
source.contains("[H]") ||
|
||||||
source.contains("[i]") |
|
source.contains("[i]") ||
|
||||||
source.contains("[s]") |
|
source.contains("[s]") ||
|
||||||
source.contains("[ms]")
|
source.contains("[ms]")
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
|
|
||||||
source = source.replace("[d]", String.valueOf(cal.get(Calendar.DAY_OF_MONTH)));
|
if(source.contains("[d]"))
|
||||||
source = source.replace("[m]", String.valueOf(cal.get(Calendar.MONTH)));
|
{
|
||||||
|
String result = String.valueOf(cal.get(Calendar.DAY_OF_MONTH));
|
||||||
|
if(result.length() < 2)
|
||||||
|
result = "0" + result;
|
||||||
|
|
||||||
|
source = source.replace("[d]", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(source.contains("[m]"))
|
||||||
|
{
|
||||||
|
String result = String.valueOf(cal.get(Calendar.MONTH) +1);
|
||||||
|
if(result.length() < 2)
|
||||||
|
result = "0" + result;
|
||||||
|
|
||||||
|
source = source.replace("[m]", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(source.contains("[Y]"))
|
||||||
|
{
|
||||||
source = source.replace("[Y]", String.valueOf(cal.get(Calendar.YEAR)));
|
source = source.replace("[Y]", String.valueOf(cal.get(Calendar.YEAR)));
|
||||||
source = source.replace("[h]", String.valueOf(cal.get(Calendar.HOUR)));
|
}
|
||||||
source = source.replace("[H]", String.valueOf(cal.get(Calendar.HOUR_OF_DAY)));
|
|
||||||
source = source.replace("[i]", String.valueOf(cal.get(Calendar.MINUTE)));
|
if(source.contains("[h]"))
|
||||||
source = source.replace("[s]", String.valueOf(cal.get(Calendar.SECOND)));
|
{
|
||||||
|
String result = String.valueOf(cal.get(Calendar.HOUR));
|
||||||
|
if(result.length() < 2)
|
||||||
|
result = "0" + result;
|
||||||
|
|
||||||
|
source = source.replace("[h]", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(source.contains("[H]"))
|
||||||
|
{
|
||||||
|
String result = String.valueOf(cal.get(Calendar.HOUR_OF_DAY));
|
||||||
|
if(result.length() < 2)
|
||||||
|
result = "0" + result;
|
||||||
|
|
||||||
|
source = source.replace("[H]", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(source.contains("[i]"))
|
||||||
|
{
|
||||||
|
String result = String.valueOf(cal.get(Calendar.MINUTE));
|
||||||
|
if(result.length() < 2)
|
||||||
|
result = "0" + result;
|
||||||
|
|
||||||
|
source = source.replace("[i]", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(source.contains("[s]"))
|
||||||
|
{
|
||||||
|
String result = String.valueOf(cal.get(Calendar.SECOND));
|
||||||
|
if(result.length() < 2)
|
||||||
|
result = "0" + result;
|
||||||
|
|
||||||
|
source = source.replace("[s]", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(source.contains("[ms]"))
|
||||||
|
{
|
||||||
source = source.replace("[ms]", String.valueOf(cal.get(Calendar.MILLISECOND)));
|
source = source.replace("[ms]", String.valueOf(cal.get(Calendar.MILLISECOND)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(source.contains("[notificationTitle]"))
|
if(source.contains("[notificationTitle]"))
|
||||||
{
|
{
|
||||||
@ -643,7 +711,7 @@ public class Miscellaneous extends Service
|
|||||||
String notificationTitle = NotificationListener.getLastNotification().getTitle();
|
String notificationTitle = NotificationListener.getLastNotification().getTitle();
|
||||||
|
|
||||||
if (notificationTitle != null && notificationTitle.length() > 0)
|
if (notificationTitle != null && notificationTitle.length() > 0)
|
||||||
source = source.replace("[notificationTitle]", notificationTitle);
|
source = source.replace("[notificationTitle]", escapeStringForUrl(notificationTitle));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
source = source.replace("[notificationTitle]", "notificationTitle unknown");
|
source = source.replace("[notificationTitle]", "notificationTitle unknown");
|
||||||
@ -664,7 +732,7 @@ public class Miscellaneous extends Service
|
|||||||
String notificationText = NotificationListener.getLastNotification().getText();
|
String notificationText = NotificationListener.getLastNotification().getText();
|
||||||
|
|
||||||
if (notificationText != null && notificationText.length() > 0)
|
if (notificationText != null && notificationText.length() > 0)
|
||||||
source = source.replace("[notificationText]", notificationText);
|
source = source.replace("[notificationText]", escapeStringForUrl(notificationText));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
source = source.replace("[notificationText]", "notificationText unknown");
|
source = source.replace("[notificationText]", "notificationText unknown");
|
||||||
@ -678,6 +746,26 @@ public class Miscellaneous extends Service
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while(source.contains("[variable-"))
|
||||||
|
{
|
||||||
|
int pos1 = source.indexOf("[variable-");
|
||||||
|
int pos2 = source.indexOf("]", pos1);
|
||||||
|
|
||||||
|
int posA = pos1 + "[variable-".length();
|
||||||
|
int posB = source.indexOf("]", posA);
|
||||||
|
|
||||||
|
String variableName = source.substring(posA, posB);
|
||||||
|
|
||||||
|
String replacement;
|
||||||
|
|
||||||
|
if(AutomationService.getInstance().variableMap.containsKey(variableName))
|
||||||
|
replacement = AutomationService.getInstance().variableMap.get(variableName);
|
||||||
|
else
|
||||||
|
replacement = "unknownVariable";
|
||||||
|
|
||||||
|
source = source.substring(0, pos1) + escapeStringForUrl(replacement) + source.substring(pos2 +1);
|
||||||
|
}
|
||||||
|
|
||||||
// Miscellaneous.logEvent("i", "URL after replace", source);
|
// Miscellaneous.logEvent("i", "URL after replace", source);
|
||||||
|
|
||||||
return source;
|
return source;
|
||||||
@ -788,6 +876,22 @@ public class Miscellaneous extends Service
|
|||||||
|
|
||||||
return executedSuccesfully;
|
return executedSuccesfully;
|
||||||
}
|
}
|
||||||
|
public static boolean isNumericDecimal(String strNum)
|
||||||
|
{
|
||||||
|
if (strNum == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
double d = Double.parseDouble(strNum);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException nfe)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isNumeric(String str)
|
public static boolean isNumeric(String str)
|
||||||
{
|
{
|
||||||
@ -1063,7 +1167,12 @@ public class Miscellaneous extends Service
|
|||||||
builder.setOnlyAlertOnce(true);
|
builder.setOnlyAlertOnce(true);
|
||||||
|
|
||||||
if(Settings.showIconWhenServiceIsRunning && notificationChannelId.equals(AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE))
|
if(Settings.showIconWhenServiceIsRunning && notificationChannelId.equals(AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE))
|
||||||
|
{
|
||||||
|
if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_googleplay))
|
||||||
|
builder.setSmallIcon(R.drawable.crane);
|
||||||
|
else
|
||||||
builder.setSmallIcon(R.drawable.ic_launcher);
|
builder.setSmallIcon(R.drawable.ic_launcher);
|
||||||
|
}
|
||||||
else if(!notificationChannelId.equals(AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE))
|
else if(!notificationChannelId.equals(AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE))
|
||||||
builder.setSmallIcon(R.drawable.info);
|
builder.setSmallIcon(R.drawable.info);
|
||||||
|
|
||||||
@ -1373,7 +1482,7 @@ public class Miscellaneous extends Service
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean restrictedFeaturesConfigured()
|
public static boolean restrictedFeaturesConfiguredFdroid()
|
||||||
{
|
{
|
||||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.activityDetection))
|
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.activityDetection))
|
||||||
{
|
{
|
||||||
@ -1390,6 +1499,17 @@ public class Miscellaneous extends Service
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean restrictedFeaturesConfiguredGoogle()
|
||||||
|
{
|
||||||
|
if(Rule.isAnyRuleUsing(Action.Action_Enum.startPhoneCall) || Rule.isAnyRuleUsing(Action.Action_Enum.stopPhoneCall))
|
||||||
|
{
|
||||||
|
if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_googleplay))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static Element getXmlTree(String inputString) throws SAXException, IOException, ParserConfigurationException
|
public static Element getXmlTree(String inputString) throws SAXException, IOException, ParserConfigurationException
|
||||||
{
|
{
|
||||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
@ -1753,13 +1873,12 @@ public class Miscellaneous extends Service
|
|||||||
|
|
||||||
public static boolean comparePhoneNumbers(String number1, String number2)
|
public static boolean comparePhoneNumbers(String number1, String number2)
|
||||||
{
|
{
|
||||||
/* To be activated when Android S SDK comes out
|
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.S)
|
||||||
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.Q)
|
|
||||||
{
|
{
|
||||||
TelephonyManager tm = (TelephonyManager)Miscellaneous.getAnyContext().getSystemService(Context.TELEPHONY_SERVICE);
|
TelephonyManager tm = (TelephonyManager)Miscellaneous.getAnyContext().getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
return PhoneNumberUtils.areSamePhoneNumber(number1, number2, tm.getNetworkCountryIso());
|
return PhoneNumberUtils.areSamePhoneNumber(number1, number2, tm.getNetworkCountryIso());
|
||||||
}
|
}
|
||||||
else*/
|
else
|
||||||
return PhoneNumberUtils.compare(number1, number2);
|
return PhoneNumberUtils.compare(number1, number2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1893,4 +2012,58 @@ public class Miscellaneous extends Service
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getTargetSDK(Context context)
|
||||||
|
{
|
||||||
|
return context.getApplicationContext().getApplicationInfo().targetSdkVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDisplayLanguage(Context context)
|
||||||
|
{
|
||||||
|
if(!Settings.displayLanguage.equals(Settings.default_displayLanguage))
|
||||||
|
{
|
||||||
|
Locale myLocale;
|
||||||
|
|
||||||
|
if(Settings.displayLanguage.contains("_"))
|
||||||
|
{
|
||||||
|
String[] parts = Settings.displayLanguage.split("_");
|
||||||
|
myLocale = new Locale(parts[0], parts[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
myLocale = new Locale(Settings.displayLanguage);
|
||||||
|
|
||||||
|
Resources res = context.getResources();
|
||||||
|
DisplayMetrics dm = res.getDisplayMetrics();
|
||||||
|
Configuration conf = res.getConfiguration();
|
||||||
|
conf.locale = myLocale;
|
||||||
|
res.updateConfiguration(conf, dm);
|
||||||
|
//Intent refresh = new Intent(this, AndroidLocalize.class);
|
||||||
|
//finish();
|
||||||
|
//startActivity(refresh);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String escapeStringForUrl(String input)
|
||||||
|
{
|
||||||
|
String output;
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
output = URLEncoder.encode(input, String.valueOf(StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
catch (UnsupportedEncodingException e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("e", "URLEncoder", "Error encoding string for URL. Leaving as it is. Error details: " + Log.getStackTraceString(e), 3);
|
||||||
|
output = input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
output = Uri.encode(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
}
|
}
|
@ -64,7 +64,7 @@ public class PointOfInterest implements Comparable<PointOfInterest>
|
|||||||
public void setName(String desiredName)
|
public void setName(String desiredName)
|
||||||
{
|
{
|
||||||
this.oldName = this.name;
|
this.oldName = this.name;
|
||||||
this.name = desiredName;
|
this.name = desiredName.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getLocation()
|
public Location getLocation()
|
||||||
@ -421,14 +421,18 @@ public class PointOfInterest implements Comparable<PointOfInterest>
|
|||||||
public boolean create(Context context)
|
public boolean create(Context context)
|
||||||
{
|
{
|
||||||
for(PointOfInterest poi : PointOfInterest.pointOfInterestCollection)
|
for(PointOfInterest poi : PointOfInterest.pointOfInterestCollection)
|
||||||
|
{
|
||||||
if (poi.getName().equals(this.getName()))
|
if (poi.getName().equals(this.getName()))
|
||||||
{
|
{
|
||||||
Toast.makeText(context, context.getResources().getString(R.string.anotherPoiByThatName), Toast.LENGTH_LONG).show();
|
Toast.makeText(context, context.getResources().getString(R.string.anotherPoiByThatName), Toast.LENGTH_LONG).show();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(plausibilityCheck())
|
if(plausibilityCheck())
|
||||||
{
|
{
|
||||||
|
Miscellaneous.logEvent("i", "Creating POI", this.toStringLong(), 3);
|
||||||
|
|
||||||
PointOfInterest.pointOfInterestCollection.add(this);
|
PointOfInterest.pointOfInterestCollection.add(this);
|
||||||
PointOfInterest.writePoisToFile();
|
PointOfInterest.writePoisToFile();
|
||||||
|
|
||||||
@ -492,6 +496,8 @@ public class PointOfInterest implements Comparable<PointOfInterest>
|
|||||||
|
|
||||||
if(plausibilityCheck())
|
if(plausibilityCheck())
|
||||||
{
|
{
|
||||||
|
Miscellaneous.logEvent("i", "Changing POI", "Old name: " + this.oldName + ", new data: " + this.toStringLong(), 3);
|
||||||
|
|
||||||
if(PointOfInterest.writePoisToFile())
|
if(PointOfInterest.writePoisToFile())
|
||||||
{
|
{
|
||||||
AutomationService service = AutomationService.getInstance();
|
AutomationService service = AutomationService.getInstance();
|
||||||
|
@ -3,6 +3,7 @@ package com.jens.automation2;
|
|||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.database.Cursor;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.media.RingtoneManager;
|
import android.media.RingtoneManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@ -41,13 +42,13 @@ public class Profile implements Comparable<Profile>
|
|||||||
protected int volumeAlarms;
|
protected int volumeAlarms;
|
||||||
|
|
||||||
protected boolean changeIncomingCallsRingtone;
|
protected boolean changeIncomingCallsRingtone;
|
||||||
protected File incomingCallsRingtone;
|
protected String incomingCallsRingtone;
|
||||||
|
|
||||||
protected boolean changeVibrateWhenRinging;
|
protected boolean changeVibrateWhenRinging;
|
||||||
protected boolean vibrateWhenRinging;
|
protected boolean vibrateWhenRinging;
|
||||||
|
|
||||||
protected boolean changeNotificationRingtone;
|
protected boolean changeNotificationRingtone;
|
||||||
protected File notificationRingtone;
|
protected String notificationRingtone;
|
||||||
|
|
||||||
protected boolean changeAudibleSelection;
|
protected boolean changeAudibleSelection;
|
||||||
protected boolean audibleSelection;
|
protected boolean audibleSelection;
|
||||||
@ -62,7 +63,7 @@ public class Profile implements Comparable<Profile>
|
|||||||
public void setName(String name)
|
public void setName(String name)
|
||||||
{
|
{
|
||||||
this.oldName = this.name;
|
this.oldName = this.name;
|
||||||
this.name = name;
|
this.name = name.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
@ -171,11 +172,11 @@ public class Profile implements Comparable<Profile>
|
|||||||
return changeIncomingCallsRingtone;
|
return changeIncomingCallsRingtone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIncomingCallsRingtone(File incomingCallsRingtone)
|
public void setIncomingCallsRingtone(String incomingCallsRingtone)
|
||||||
{
|
{
|
||||||
this.incomingCallsRingtone = incomingCallsRingtone;
|
this.incomingCallsRingtone = incomingCallsRingtone;
|
||||||
}
|
}
|
||||||
public File getIncomingCallsRingtone()
|
public String getIncomingCallsRingtone()
|
||||||
{
|
{
|
||||||
return incomingCallsRingtone;
|
return incomingCallsRingtone;
|
||||||
}
|
}
|
||||||
@ -207,11 +208,11 @@ public class Profile implements Comparable<Profile>
|
|||||||
return changeNotificationRingtone;
|
return changeNotificationRingtone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNotificationRingtone(File notificationsRingtone)
|
public void setNotificationRingtone(String notificationsRingtone)
|
||||||
{
|
{
|
||||||
this.notificationRingtone = notificationsRingtone;
|
this.notificationRingtone = notificationsRingtone;
|
||||||
}
|
}
|
||||||
public File getNotificationRingtone()
|
public String getNotificationRingtone()
|
||||||
{
|
{
|
||||||
return notificationRingtone;
|
return notificationRingtone;
|
||||||
}
|
}
|
||||||
@ -292,21 +293,32 @@ public class Profile implements Comparable<Profile>
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean applyRingTone(File ringtoneFile, int ringtoneType, Context context)
|
private boolean applyRingTone(String ringtoneFile, int ringtoneType, Context context)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "Profile", "Request to set ringtone to " + ringtoneFile.getAbsolutePath(), 3);
|
Miscellaneous.logEvent("i", "Profile", "Request to set ringtone to " + ringtoneFile, 3);
|
||||||
|
|
||||||
if(!ringtoneFile.exists() || !ringtoneFile.canRead())
|
// if(!ringtoneFile.exists() || !ringtoneFile.canRead())
|
||||||
|
// {
|
||||||
|
// String message = "Ringtone file does not exist or cannot read it: " + ringtoneFile.getAbsolutePath();
|
||||||
|
// Miscellaneous.logEvent("i", "Profile", message, 3);
|
||||||
|
// Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Set by URI
|
||||||
|
if(ringtoneFile.contains("//"))
|
||||||
|
{
|
||||||
|
Uri target = Uri.parse(ringtoneFile);
|
||||||
|
RingtoneManager.setActualDefaultRingtoneUri(context, ringtoneType, target);
|
||||||
|
Miscellaneous.logEvent("i", "Profile", "Ringtone set to: " + ringtoneFile, 1);
|
||||||
|
return true;
|
||||||
|
} // Set by filepath
|
||||||
|
else
|
||||||
{
|
{
|
||||||
String message = "Ringtone file does not exist or cannot read it: " + ringtoneFile.getAbsolutePath();
|
|
||||||
Miscellaneous.logEvent("i", "Profile", message, 3);
|
|
||||||
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(MediaStore.MediaColumns.DATA, ringtoneFile.getAbsolutePath());
|
values.put(MediaStore.MediaColumns.DATA, ringtoneFile);
|
||||||
values.put(MediaStore.MediaColumns.TITLE, ringtoneFile.getName());
|
values.put(MediaStore.MediaColumns.TITLE, ringtoneFile);
|
||||||
|
//values.put(MediaStore.MediaColumns.TITLE, ringtoneFile.getName());
|
||||||
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");
|
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");
|
||||||
values.put(MediaStore.MediaColumns.SIZE, ringtoneFile.length());
|
values.put(MediaStore.MediaColumns.SIZE, ringtoneFile.length());
|
||||||
values.put(MediaStore.Audio.Media.IS_RINGTONE, ringtoneType == RingtoneManager.TYPE_RINGTONE);
|
values.put(MediaStore.Audio.Media.IS_RINGTONE, ringtoneType == RingtoneManager.TYPE_RINGTONE);
|
||||||
@ -318,18 +330,22 @@ public class Profile implements Comparable<Profile>
|
|||||||
{
|
{
|
||||||
Uri newRingTone = null;
|
Uri newRingTone = null;
|
||||||
|
|
||||||
//TODO: This part needs to be made compatible with Android 11 and above.
|
Uri existingRingTone = MediaStore.Audio.Media.getContentUriForPath(ringtoneFile);
|
||||||
if(Build.VERSION.SDK_INT > 30)
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Uri existingRingTone = MediaStore.Audio.Media.getContentUriForPath(ringtoneFile.getAbsolutePath());
|
|
||||||
|
|
||||||
if (existingRingTone != null)
|
if (existingRingTone != null)
|
||||||
context.getContentResolver().delete(existingRingTone, MediaStore.MediaColumns.DATA + "=\"" + ringtoneFile.getAbsolutePath() + "\"", null);
|
context.getContentResolver().delete(existingRingTone, MediaStore.MediaColumns.DATA + "=\"" + ringtoneFile + "\"", null);
|
||||||
|
}
|
||||||
newRingTone = context.getContentResolver().insert(existingRingTone, values);
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("w","Delete file from ringtones", "Deleting ringtone from library failed: " + Log.getStackTraceString(e), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newRingTone = context.getContentResolver().insert(existingRingTone, values);
|
||||||
|
|
||||||
RingtoneManager.setActualDefaultRingtoneUri(context, ringtoneType, newRingTone);
|
RingtoneManager.setActualDefaultRingtoneUri(context, ringtoneType, newRingTone);
|
||||||
|
|
||||||
Miscellaneous.logEvent("i", "Profile", "Ringtone set to: " + newRingTone.toString(), 1);
|
Miscellaneous.logEvent("i", "Profile", "Ringtone set to: " + newRingTone.toString(), 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -338,6 +354,7 @@ public class Profile implements Comparable<Profile>
|
|||||||
String message = "Error setting ringtone: " + Log.getStackTraceString(t);
|
String message = "Error setting ringtone: " + Log.getStackTraceString(t);
|
||||||
Miscellaneous.logEvent("e", "Profile", message, 1);
|
Miscellaneous.logEvent("e", "Profile", message, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -568,17 +585,17 @@ public class Profile implements Comparable<Profile>
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "POI", "Checking for applicable rule after profile " + this.getName() + " has been activated.", 2);
|
Miscellaneous.logEvent("i", "Profile", "Checking for applicable rules after profile " + this.getName() + " has been activated.", 2);
|
||||||
List<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.profileActive);
|
List<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.profileActive);
|
||||||
for(int i=0; i<ruleCandidates.size(); i++)
|
for(int i=0; i<ruleCandidates.size(); i++)
|
||||||
{
|
{
|
||||||
if(ruleCandidates.get(i).haveEnoughPermissions() && ruleCandidates.get(i).getsGreenLight(AutomationService.getInstance()))
|
if(ruleCandidates.get(i).haveEnoughPermissions() && ruleCandidates.get(i).getsGreenLight(AutomationService.getInstance()))
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "POI", "Rule " + ruleCandidates.get(i).getName() + " applies after " + this.getName() + " has been activated.", 2);
|
Miscellaneous.logEvent("i", "Profile", "Rule " + ruleCandidates.get(i).getName() + " applies after " + this.getName() + " has been activated.", 2);
|
||||||
ruleCandidates.get(i).activate(AutomationService.getInstance(), false);
|
ruleCandidates.get(i).activate(AutomationService.getInstance(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Miscellaneous.logEvent("i", "POI", "Done checking for applicable rule after profile " + this.getName() + " has been activated.", 2);
|
Miscellaneous.logEvent("i", "Profile", "Done checking for applicable rules after profile " + this.getName() + " has been activated.", 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -18,6 +18,7 @@ import com.jens.automation2.receivers.NoiseListener;
|
|||||||
import com.jens.automation2.receivers.PhoneStatusListener;
|
import com.jens.automation2.receivers.PhoneStatusListener;
|
||||||
import com.jens.automation2.receivers.ProcessListener;
|
import com.jens.automation2.receivers.ProcessListener;
|
||||||
import com.jens.automation2.receivers.ScreenStateReceiver;
|
import com.jens.automation2.receivers.ScreenStateReceiver;
|
||||||
|
import com.jens.automation2.receivers.SubSystemStateReceiver;
|
||||||
import com.jens.automation2.receivers.TetheringReceiver;
|
import com.jens.automation2.receivers.TetheringReceiver;
|
||||||
import com.jens.automation2.receivers.TimeZoneListener;
|
import com.jens.automation2.receivers.TimeZoneListener;
|
||||||
|
|
||||||
@ -182,6 +183,9 @@ public class ReceiverCoordinator
|
|||||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.tethering))
|
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.tethering))
|
||||||
TetheringReceiver.getInstance().startListener(AutomationService.getInstance());
|
TetheringReceiver.getInstance().startListener(AutomationService.getInstance());
|
||||||
|
|
||||||
|
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.subSystemState))
|
||||||
|
SubSystemStateReceiver.getInstance().startListener(AutomationService.getInstance());
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Class testClass = Class.forName(ActivityManageRule.activityDetectionClassPath);
|
Class testClass = Class.forName(ActivityManageRule.activityDetectionClassPath);
|
||||||
@ -223,6 +227,7 @@ public class ReceiverCoordinator
|
|||||||
MediaPlayerListener.getInstance().stopListener(AutomationService.getInstance());
|
MediaPlayerListener.getInstance().stopListener(AutomationService.getInstance());
|
||||||
DeviceOrientationListener.getInstance().stopListener(AutomationService.getInstance());
|
DeviceOrientationListener.getInstance().stopListener(AutomationService.getInstance());
|
||||||
TetheringReceiver.getInstance().stopListener(AutomationService.getInstance());
|
TetheringReceiver.getInstance().stopListener(AutomationService.getInstance());
|
||||||
|
SubSystemStateReceiver.getInstance().stopListener(AutomationService.getInstance());
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -390,7 +395,7 @@ public class ReceiverCoordinator
|
|||||||
{
|
{
|
||||||
if(!HeadphoneJackListener.isHeadphoneJackListenerActive())
|
if(!HeadphoneJackListener.isHeadphoneJackListenerActive())
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "LocationProvider", "Starting HeadphoneJackListener because used in a new/changed rule.", 4);
|
Miscellaneous.logEvent("i", "HeadphoneJackListener", "Starting HeadphoneJackListener because used in a new/changed rule.", 4);
|
||||||
if(HeadphoneJackListener.getInstance().haveAllPermission())
|
if(HeadphoneJackListener.getInstance().haveAllPermission())
|
||||||
HeadphoneJackListener.getInstance().startListener(AutomationService.getInstance());
|
HeadphoneJackListener.getInstance().startListener(AutomationService.getInstance());
|
||||||
}
|
}
|
||||||
@ -399,7 +404,7 @@ public class ReceiverCoordinator
|
|||||||
{
|
{
|
||||||
if(HeadphoneJackListener.isHeadphoneJackListenerActive())
|
if(HeadphoneJackListener.isHeadphoneJackListenerActive())
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "LocationProvider", "Shutting down HeadphoneJackListener because not used in any rule.", 4);
|
Miscellaneous.logEvent("i", "HeadphoneJackListener", "Shutting down HeadphoneJackListener because not used in any rule.", 4);
|
||||||
HeadphoneJackListener.getInstance().stopListener(AutomationService.getInstance());
|
HeadphoneJackListener.getInstance().stopListener(AutomationService.getInstance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -440,6 +445,24 @@ public class ReceiverCoordinator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.subSystemState))
|
||||||
|
{
|
||||||
|
if(!SubSystemStateReceiver.getInstance().isListenerRunning())
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "SubSystemStateReceiver", "Starting SubSystemStateReceiver because used in a new/changed rule.", 4);
|
||||||
|
// if(DevicePositionListener.getInstance().haveAllPermission())
|
||||||
|
TetheringReceiver.getInstance().startListener(AutomationService.getInstance());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(SubSystemStateReceiver.getInstance().isListenerRunning())
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "SubSystemStateReceiver", "Shutting down SubSystemStateReceiver because not used in any rule.", 4);
|
||||||
|
SubSystemStateReceiver.getInstance().stopListener(AutomationService.getInstance());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AutomationService.updateNotification();
|
AutomationService.updateNotification();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,10 @@ public class Settings implements SharedPreferences
|
|||||||
public static int tabsPlacement;
|
public static int tabsPlacement;
|
||||||
public static boolean executeRulesAndProfilesWithSingleClick;
|
public static boolean executeRulesAndProfilesWithSingleClick;
|
||||||
public static boolean displayNewsOnMainScreen;
|
public static boolean displayNewsOnMainScreen;
|
||||||
|
public static boolean showToasts;
|
||||||
public static boolean automaticUpdateCheck;
|
public static boolean automaticUpdateCheck;
|
||||||
public static long musicCheckFrequency;
|
public static long musicCheckFrequency;
|
||||||
|
public static String displayLanguage;
|
||||||
|
|
||||||
public static boolean lockSoundChanges;
|
public static boolean lockSoundChanges;
|
||||||
public static boolean noticeAndroid9MicrophoneShown;
|
public static boolean noticeAndroid9MicrophoneShown;
|
||||||
@ -130,11 +132,14 @@ public class Settings implements SharedPreferences
|
|||||||
public static final int default_tabsPlacement = 0;
|
public static final int default_tabsPlacement = 0;
|
||||||
public static final boolean default_executeRulesAndProfilesWithSingleClick = false;
|
public static final boolean default_executeRulesAndProfilesWithSingleClick = false;
|
||||||
public static final boolean default_displayNewsOnMainScreen = false;
|
public static final boolean default_displayNewsOnMainScreen = false;
|
||||||
|
|
||||||
|
public static final boolean default_showToasts = true;
|
||||||
public static final boolean default_automaticUpdateCheck = false;
|
public static final boolean default_automaticUpdateCheck = false;
|
||||||
public static final boolean default_lockSoundChanges = false;
|
public static final boolean default_lockSoundChanges = false;
|
||||||
public static final long default_lastNewsPolltime = -1;
|
public static final long default_lastNewsPolltime = -1;
|
||||||
public static final long default_lastUpdateCheck = -1;
|
public static final long default_lastUpdateCheck = -1;
|
||||||
public static final long default_musicCheckFrequency = 2500;
|
public static final long default_musicCheckFrequency = 2500;
|
||||||
|
public static final String default_displayLanguage = "systemDefaultLanguage";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(String arg0)
|
public boolean contains(String arg0)
|
||||||
@ -270,6 +275,7 @@ public class Settings implements SharedPreferences
|
|||||||
tabsPlacement = Integer.parseInt(prefs.getString("tabsPlacement", String.valueOf(default_tabsPlacement)));
|
tabsPlacement = Integer.parseInt(prefs.getString("tabsPlacement", String.valueOf(default_tabsPlacement)));
|
||||||
|
|
||||||
musicCheckFrequency = Long.parseLong(prefs.getString("musicCheckFrequency", String.valueOf(default_musicCheckFrequency)));
|
musicCheckFrequency = Long.parseLong(prefs.getString("musicCheckFrequency", String.valueOf(default_musicCheckFrequency)));
|
||||||
|
displayLanguage = prefs.getString("displayLanguage", default_displayLanguage);
|
||||||
|
|
||||||
if(Settings.musicCheckFrequency == 0)
|
if(Settings.musicCheckFrequency == 0)
|
||||||
Settings.musicCheckFrequency = Settings.default_musicCheckFrequency;
|
Settings.musicCheckFrequency = Settings.default_musicCheckFrequency;
|
||||||
@ -277,6 +283,7 @@ public class Settings implements SharedPreferences
|
|||||||
executeRulesAndProfilesWithSingleClick = prefs.getBoolean("executeRulesAndProfilesWithSingleClick", default_executeRulesAndProfilesWithSingleClick);
|
executeRulesAndProfilesWithSingleClick = prefs.getBoolean("executeRulesAndProfilesWithSingleClick", default_executeRulesAndProfilesWithSingleClick);
|
||||||
automaticUpdateCheck = prefs.getBoolean("automaticUpdateCheck", default_automaticUpdateCheck);
|
automaticUpdateCheck = prefs.getBoolean("automaticUpdateCheck", default_automaticUpdateCheck);
|
||||||
displayNewsOnMainScreen = prefs.getBoolean("displayNewsOnMainScreen", default_displayNewsOnMainScreen);
|
displayNewsOnMainScreen = prefs.getBoolean("displayNewsOnMainScreen", default_displayNewsOnMainScreen);
|
||||||
|
showToasts = prefs.getBoolean("showToasts", default_showToasts);
|
||||||
|
|
||||||
lockSoundChanges = prefs.getBoolean("lockSoundChanges", default_lockSoundChanges);
|
lockSoundChanges = prefs.getBoolean("lockSoundChanges", default_lockSoundChanges);
|
||||||
noticeAndroid9MicrophoneShown = prefs.getBoolean("noticeAndroid9MicrophoneShown", false);
|
noticeAndroid9MicrophoneShown = prefs.getBoolean("noticeAndroid9MicrophoneShown", false);
|
||||||
@ -472,9 +479,15 @@ public class Settings implements SharedPreferences
|
|||||||
if(!prefs.contains("displayNewsOnMainScreen") || force)
|
if(!prefs.contains("displayNewsOnMainScreen") || force)
|
||||||
editor.putBoolean("displayNewsOnMainScreen", default_displayNewsOnMainScreen);
|
editor.putBoolean("displayNewsOnMainScreen", default_displayNewsOnMainScreen);
|
||||||
|
|
||||||
|
if(!prefs.contains("showToasts") || force)
|
||||||
|
editor.putBoolean("showToasts", default_showToasts);
|
||||||
|
|
||||||
if(!prefs.contains("musicCheckFrequency") || force)
|
if(!prefs.contains("musicCheckFrequency") || force)
|
||||||
editor.putLong("musicCheckFrequency", default_musicCheckFrequency);
|
editor.putLong("musicCheckFrequency", default_musicCheckFrequency);
|
||||||
|
|
||||||
|
if(!prefs.contains("displayLanguage") || force)
|
||||||
|
editor.putString("displayLanguage", default_displayLanguage);
|
||||||
|
|
||||||
if(!prefs.contains("lockSoundChanges") || force)
|
if(!prefs.contains("lockSoundChanges") || force)
|
||||||
editor.putBoolean("lockSoundChanges", default_lockSoundChanges);
|
editor.putBoolean("lockSoundChanges", default_lockSoundChanges);
|
||||||
|
|
||||||
@ -555,11 +568,14 @@ public class Settings implements SharedPreferences
|
|||||||
editor.putBoolean("executeRulesAndProfilesWithSingleClick", executeRulesAndProfilesWithSingleClick);
|
editor.putBoolean("executeRulesAndProfilesWithSingleClick", executeRulesAndProfilesWithSingleClick);
|
||||||
editor.putBoolean("automaticUpdateCheck", automaticUpdateCheck);
|
editor.putBoolean("automaticUpdateCheck", automaticUpdateCheck);
|
||||||
editor.putBoolean("displayNewsOnMainScreen", displayNewsOnMainScreen);
|
editor.putBoolean("displayNewsOnMainScreen", displayNewsOnMainScreen);
|
||||||
|
editor.putBoolean("showToasts", showToasts);
|
||||||
|
|
||||||
if(Settings.musicCheckFrequency == 0)
|
if(Settings.musicCheckFrequency == 0)
|
||||||
Settings.musicCheckFrequency = Settings.default_musicCheckFrequency;
|
Settings.musicCheckFrequency = Settings.default_musicCheckFrequency;
|
||||||
editor.putString("musicCheckFrequency", String.valueOf(musicCheckFrequency));
|
editor.putString("musicCheckFrequency", String.valueOf(musicCheckFrequency));
|
||||||
|
|
||||||
|
editor.putString("displayLanguage", displayLanguage);
|
||||||
|
|
||||||
editor.putBoolean("lockSoundChanges", lockSoundChanges);
|
editor.putBoolean("lockSoundChanges", lockSoundChanges);
|
||||||
editor.putBoolean("noticeAndroid9MicrophoneShown", noticeAndroid9MicrophoneShown);
|
editor.putBoolean("noticeAndroid9MicrophoneShown", noticeAndroid9MicrophoneShown);
|
||||||
editor.putBoolean("noticeAndroid10WifiShown", noticeAndroid10WifiShown);
|
editor.putBoolean("noticeAndroid10WifiShown", noticeAndroid10WifiShown);
|
||||||
|
@ -31,6 +31,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class Trigger
|
public class Trigger
|
||||||
{
|
{
|
||||||
@ -60,6 +61,8 @@ public class Trigger
|
|||||||
serviceStarts,
|
serviceStarts,
|
||||||
broadcastReceived,
|
broadcastReceived,
|
||||||
tethering,
|
tethering,
|
||||||
|
subSystemState,
|
||||||
|
checkVariable,
|
||||||
phoneCall; //phoneCall always needs to be at the very end because of Google's shitty so called privacy
|
phoneCall; //phoneCall always needs to be at the very end because of Google's shitty so called privacy
|
||||||
|
|
||||||
public String getFullName(Context context)
|
public String getFullName(Context context)
|
||||||
@ -116,12 +119,18 @@ public class Trigger
|
|||||||
return context.getResources().getString(R.string.broadcastReceivedTitle);
|
return context.getResources().getString(R.string.broadcastReceivedTitle);
|
||||||
case tethering:
|
case tethering:
|
||||||
return context.getResources().getString(R.string.tetheringState);
|
return context.getResources().getString(R.string.tetheringState);
|
||||||
|
case subSystemState:
|
||||||
|
return context.getResources().getString(R.string.subSystemState);
|
||||||
|
case checkVariable:
|
||||||
|
return context.getResources().getString(R.string.checkVariable);
|
||||||
default:
|
default:
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static enum subSystemStates { wifi, bluetooth };
|
||||||
|
|
||||||
Rule parentRule = null;
|
Rule parentRule = null;
|
||||||
Calendar lastTimeNotApplied = null;
|
Calendar lastTimeNotApplied = null;
|
||||||
|
|
||||||
@ -235,6 +244,14 @@ public class Trigger
|
|||||||
if(!checkTetheringActive())
|
if(!checkTetheringActive())
|
||||||
result = false;
|
result = false;
|
||||||
break;
|
break;
|
||||||
|
case subSystemState:
|
||||||
|
if(!checkSubSystemState())
|
||||||
|
result = false;
|
||||||
|
break;
|
||||||
|
case checkVariable:
|
||||||
|
if(!checkVariable())
|
||||||
|
result = false;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -402,12 +419,17 @@ public class Trigger
|
|||||||
|
|
||||||
boolean checkDeviceStarts()
|
boolean checkDeviceStarts()
|
||||||
{
|
{
|
||||||
return checkServiceStarts() && !Settings.deviceStartDone;
|
if(triggerParameter && checkServiceStarts() && !Settings.deviceStartDone)
|
||||||
|
return true;
|
||||||
|
else if(!triggerParameter && !checkServiceStarts() && Settings.deviceStartDone)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean checkServiceStarts()
|
boolean checkServiceStarts()
|
||||||
{
|
{
|
||||||
return !Settings.serviceStartDone;
|
return !Settings.serviceStartDone == getTriggerParameter();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean checkProfileActive()
|
boolean checkProfileActive()
|
||||||
@ -535,6 +557,58 @@ public class Trigger
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean checkSubSystemState()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
subSystemStates state = subSystemStates.valueOf(triggerParameter2);
|
||||||
|
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case wifi:
|
||||||
|
return WifiBroadcastReceiver.isWifiEnabled(Miscellaneous.getAnyContext()) == triggerParameter;
|
||||||
|
case bluetooth:
|
||||||
|
return BluetoothReceiver.isBluetoothEnabled() == triggerParameter;
|
||||||
|
default:
|
||||||
|
Miscellaneous.logEvent("w", "checkSubSystemState()", "Invalid subSystemState: " + state.name(), 3);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("e", "checkSubSystemState()", Log.getStackTraceString(e), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean checkVariable()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Map<String,String> map = AutomationService.getInstance().getVariableMap();
|
||||||
|
|
||||||
|
String[] conditions = this.getTriggerParameter2().split(Trigger.triggerParameter2Split);
|
||||||
|
|
||||||
|
if(conditions.length == 1) // no real condition
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (map.containsKey(conditions[0]))
|
||||||
|
{
|
||||||
|
if (map.get(conditions[0]).equals(conditions[1]))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("e", "checkVariable()", Log.getStackTraceString(e), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
boolean checkBluetooth()
|
boolean checkBluetooth()
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format("Checking for bluetooth...", this.getParentRule().getName()), 4);
|
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format("Checking for bluetooth...", this.getParentRule().getName()), 4);
|
||||||
@ -728,7 +802,10 @@ public class Trigger
|
|||||||
if(this.getTriggerParameter2().length() > 0) // only check if any wifi name specified, otherwise any wifi will do
|
if(this.getTriggerParameter2().length() > 0) // only check if any wifi name specified, otherwise any wifi will do
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format("Wifi name specified, checking that.", this.getParentRule().getName()), 4);
|
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format("Wifi name specified, checking that.", this.getParentRule().getName()), 4);
|
||||||
if(!WifiBroadcastReceiver.getLastWifiSsid().equals(this.getTriggerParameter2()))
|
|
||||||
|
if(WifiBroadcastReceiver.lastConnectedState) //when connected
|
||||||
|
{
|
||||||
|
if (!WifiBroadcastReceiver.getLastWifiSsid().equals(this.getTriggerParameter2()) && !(Miscellaneous.isRegularExpression(this.getTriggerParameter2()) && WifiBroadcastReceiver.getLastWifiSsid().matches(this.getTriggerParameter2())))
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyNotTheCorrectSsid), getParentRule().getName(), this.getTriggerParameter2(), WifiBroadcastReceiver.getLastWifiSsid()), this.getParentRule().getName()), 3);
|
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyNotTheCorrectSsid), getParentRule().getName(), this.getTriggerParameter2(), WifiBroadcastReceiver.getLastWifiSsid()), this.getParentRule().getName()), 3);
|
||||||
return false;
|
return false;
|
||||||
@ -736,6 +813,20 @@ public class Trigger
|
|||||||
else
|
else
|
||||||
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format("Wifi name matches. Rule will apply.", this.getParentRule().getName()), 4);
|
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format("Wifi name matches. Rule will apply.", this.getParentRule().getName()), 4);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (
|
||||||
|
!Settings.serviceStartDone
|
||||||
|
||
|
||||||
|
(!WifiBroadcastReceiver.getLastWifiSsidReal().equals(this.getTriggerParameter2()) && !(Miscellaneous.isRegularExpression(this.getTriggerParameter2()) && WifiBroadcastReceiver.getLastWifiSsidReal().matches(this.getTriggerParameter2()))))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyNotTheCorrectSsid), getParentRule().getName(), this.getTriggerParameter2(), WifiBroadcastReceiver.getLastWifiSsidReal()), this.getParentRule().getName()), 3);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format("Wifi name matches. Rule will apply.", this.getParentRule().getName()), 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format("No wifi name specified, any will do.", this.getParentRule().getName()), 4);
|
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format("No wifi name specified, any will do.", this.getParentRule().getName()), 4);
|
||||||
}
|
}
|
||||||
@ -794,9 +885,21 @@ public class Trigger
|
|||||||
|
|
||||||
boolean checkBatteryLevel()
|
boolean checkBatteryLevel()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
-1 means value is not known, yet.
|
||||||
|
*/
|
||||||
|
if(BatteryReceiver.getBatteryLevel() == -1)
|
||||||
|
return false;
|
||||||
|
|
||||||
if(this.getTriggerParameter())
|
if(this.getTriggerParameter())
|
||||||
{
|
{
|
||||||
if(BatteryReceiver.getBatteryLevel() <= this.getBatteryLevel())
|
if(this.getBatteryLevel() == 100)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), "Rule " + this.getParentRule().getName() + " doesn't apply. Can never exceed 100%.", 3);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(BatteryReceiver.getBatteryLevel() < this.getBatteryLevel())
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyBatteryLowerThan) + " " + String.valueOf(this.getBatteryLevel()), this.getParentRule().getName()), 3);
|
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyBatteryLowerThan) + " " + String.valueOf(this.getBatteryLevel()), this.getParentRule().getName()), 3);
|
||||||
return false;
|
return false;
|
||||||
@ -804,7 +907,16 @@ public class Trigger
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(this.getBatteryLevel() >= this.getBatteryLevel())
|
if(this.getBatteryLevel() == 0)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), "Rule " + this.getParentRule().getName() + " doesn't apply. Can never drop below 0%.", 3);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(BatteryReceiver.getBatteryLevel() < 100 && BatteryReceiver.getBatteryLevel() >= this.getBatteryLevel()
|
||||||
|
||
|
||||||
|
BatteryReceiver.getBatteryLevel() > this.getBatteryLevel()
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyBatteryHigherThan) + " " + String.valueOf(this.getBatteryLevel()), this.getParentRule().getName()), 3);
|
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyBatteryHigherThan) + " " + String.valueOf(this.getBatteryLevel()), this.getParentRule().getName()), 3);
|
||||||
return false;
|
return false;
|
||||||
@ -928,7 +1040,24 @@ public class Trigger
|
|||||||
|
|
||||||
boolean checkTetheringActive()
|
boolean checkTetheringActive()
|
||||||
{
|
{
|
||||||
return TetheringReceiver.isTetheringActive() == triggerParameter;
|
if(TetheringReceiver.isTetheringActive() == triggerParameter)
|
||||||
|
{
|
||||||
|
if(getTriggerParameter2().equals(ActivityManageTriggerTethering.tetheringTypeAny))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
for(String oneOfLastTypes : TetheringReceiver.getLastTetheringTypes())
|
||||||
|
{
|
||||||
|
if(oneOfLastTypes.equals(getTriggerParameter2()))
|
||||||
|
{
|
||||||
|
if(triggerParameter)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkDateTime(Object triggeringObject, boolean checkifStateChangedSinceLastRuleExecution)
|
public boolean checkDateTime(Object triggeringObject, boolean checkifStateChangedSinceLastRuleExecution)
|
||||||
@ -1317,7 +1446,7 @@ public class Trigger
|
|||||||
|
|
||||||
public void setTriggerParameter2(String triggerParameter2)
|
public void setTriggerParameter2(String triggerParameter2)
|
||||||
{
|
{
|
||||||
this.triggerParameter2 = triggerParameter2;
|
this.triggerParameter2 = triggerParameter2.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeFrame getTimeFrame()
|
public TimeFrame getTimeFrame()
|
||||||
@ -1634,11 +1763,11 @@ public class Trigger
|
|||||||
break;
|
break;
|
||||||
case deviceStarts:
|
case deviceStarts:
|
||||||
// This type doesn't have an activate/deactivate equivalent
|
// This type doesn't have an activate/deactivate equivalent
|
||||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.deviceHasJustStarted));
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.deviceIsStarting) + ": " + String.valueOf(triggerParameter));
|
||||||
break;
|
break;
|
||||||
case serviceStarts:
|
case serviceStarts:
|
||||||
// This type doesn't have an activate/deactivate equivalent
|
// This type doesn't have an activate/deactivate equivalent
|
||||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.serviceHasJustStarted));
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.serviceIsStarting) + ": " + String.valueOf(triggerParameter));
|
||||||
break;
|
break;
|
||||||
case broadcastReceived:
|
case broadcastReceived:
|
||||||
if (triggerParameter)
|
if (triggerParameter)
|
||||||
@ -1653,6 +1782,36 @@ public class Trigger
|
|||||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.tetheringActive));
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.tetheringActive));
|
||||||
else
|
else
|
||||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.tetheringNotActive));
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.tetheringNotActive));
|
||||||
|
|
||||||
|
returnString.append(" (" + Miscellaneous.getAnyContext().getResources().getString(R.string.type) + ": " + triggerParameter2 + ")");
|
||||||
|
break;
|
||||||
|
case subSystemState:
|
||||||
|
Trigger.subSystemStates desiredState = subSystemStates.valueOf(triggerParameter2);
|
||||||
|
switch (desiredState)
|
||||||
|
{
|
||||||
|
case wifi:
|
||||||
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.wifi));
|
||||||
|
break;
|
||||||
|
case bluetooth:
|
||||||
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.bluetooth));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.is) + " ");
|
||||||
|
|
||||||
|
if (triggerParameter)
|
||||||
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.activated));
|
||||||
|
else
|
||||||
|
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.deactivated));
|
||||||
|
break;
|
||||||
|
case checkVariable:
|
||||||
|
if (triggerParameter2.contains(triggerParameter2Split))
|
||||||
|
{
|
||||||
|
String[] parts = triggerParameter2.split(triggerParameter2Split);
|
||||||
|
returnString.append(String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.variableCheckString), parts[0], parts[1]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
returnString.append(String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.variableCheckStringDeleted), triggerParameter2));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
returnString.append("error");
|
returnString.append("error");
|
||||||
|
@ -160,9 +160,9 @@ public class XmlFileInterface
|
|||||||
serializer.text(String.valueOf(Profile.getProfileCollection().get(i).getChangeIncomingCallsRingtone()));
|
serializer.text(String.valueOf(Profile.getProfileCollection().get(i).getChangeIncomingCallsRingtone()));
|
||||||
serializer.endTag(null, "changeIncomingCallsRingtone");//
|
serializer.endTag(null, "changeIncomingCallsRingtone");//
|
||||||
serializer.startTag(null, "incomingCallsRingtone");
|
serializer.startTag(null, "incomingCallsRingtone");
|
||||||
File incomingFile = Profile.getProfileCollection().get(i).getIncomingCallsRingtone();
|
String incomingFile = Profile.getProfileCollection().get(i).getIncomingCallsRingtone();
|
||||||
if(incomingFile != null)
|
if(incomingFile != null)
|
||||||
serializer.text(String.valueOf(Profile.getProfileCollection().get(i).getIncomingCallsRingtone().getPath()));
|
serializer.text(String.valueOf(Profile.getProfileCollection().get(i).getIncomingCallsRingtone()));
|
||||||
else
|
else
|
||||||
serializer.text("null");
|
serializer.text("null");
|
||||||
serializer.endTag(null, "incomingCallsRingtone");
|
serializer.endTag(null, "incomingCallsRingtone");
|
||||||
@ -178,9 +178,9 @@ public class XmlFileInterface
|
|||||||
serializer.text(String.valueOf(Profile.getProfileCollection().get(i).getChangeNotificationRingtone()));
|
serializer.text(String.valueOf(Profile.getProfileCollection().get(i).getChangeNotificationRingtone()));
|
||||||
serializer.endTag(null, "changeNotificationRingtone");//
|
serializer.endTag(null, "changeNotificationRingtone");//
|
||||||
serializer.startTag(null, "notificationRingtone");
|
serializer.startTag(null, "notificationRingtone");
|
||||||
File notificationFile = Profile.getProfileCollection().get(i).getNotificationRingtone();
|
String notificationFile = Profile.getProfileCollection().get(i).getNotificationRingtone();
|
||||||
if(notificationFile != null)
|
if(notificationFile != null)
|
||||||
serializer.text(String.valueOf(Profile.getProfileCollection().get(i).getNotificationRingtone().getPath()));
|
serializer.text(String.valueOf(Profile.getProfileCollection().get(i).getNotificationRingtone()));
|
||||||
else
|
else
|
||||||
serializer.text("null");
|
serializer.text("null");
|
||||||
serializer.endTag(null, "notificationRingtone");
|
serializer.endTag(null, "notificationRingtone");
|
||||||
@ -631,7 +631,7 @@ public class XmlFileInterface
|
|||||||
{
|
{
|
||||||
String path = readTag(parser, "incomingCallsRingtone");
|
String path = readTag(parser, "incomingCallsRingtone");
|
||||||
if(!path.equals("null"))
|
if(!path.equals("null"))
|
||||||
newProfile.setIncomingCallsRingtone(new File(path));
|
newProfile.setIncomingCallsRingtone(path);
|
||||||
else
|
else
|
||||||
newProfile.setIncomingCallsRingtone(null);
|
newProfile.setIncomingCallsRingtone(null);
|
||||||
}
|
}
|
||||||
@ -643,7 +643,7 @@ public class XmlFileInterface
|
|||||||
{
|
{
|
||||||
String path = readTag(parser, "notificationRingtone");
|
String path = readTag(parser, "notificationRingtone");
|
||||||
if(!path.equals("null"))
|
if(!path.equals("null"))
|
||||||
newProfile.setNotificationRingtone(new File(path));
|
newProfile.setNotificationRingtone(path);
|
||||||
else
|
else
|
||||||
newProfile.setNotificationRingtone(null);
|
newProfile.setNotificationRingtone(null);
|
||||||
}
|
}
|
||||||
|
@ -400,12 +400,12 @@ public class LocationProvider
|
|||||||
Miscellaneous.logEvent("i", "LocationProvider", this.getParentService().getResources().getString(R.string.applyingSettingsAndRules), 3);
|
Miscellaneous.logEvent("i", "LocationProvider", this.getParentService().getResources().getString(R.string.applyingSettingsAndRules), 3);
|
||||||
|
|
||||||
// *********** SETTING CHANGES ***********
|
// *********** SETTING CHANGES ***********
|
||||||
if(Settings.useWifiForPositioning && !WifiBroadcastReceiver.isWifiListenerActive())
|
if(Settings.useWifiForPositioning && !WifiBroadcastReceiver.isWifiListenerActive() || Rule.isAnyRuleUsing(Trigger_Enum.wifiConnection))
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "LocationProvider", "Starting WifiReceiver because settings now allow to.", 4);
|
Miscellaneous.logEvent("i", "LocationProvider", "Starting WifiReceiver because settings now allow to.", 4);
|
||||||
WifiBroadcastReceiver.startWifiReceiver(this);
|
WifiBroadcastReceiver.startWifiReceiver(this);
|
||||||
}
|
}
|
||||||
else if(!Settings.useWifiForPositioning && WifiBroadcastReceiver.isWifiListenerActive())
|
else if(!Settings.useWifiForPositioning && WifiBroadcastReceiver.isWifiListenerActive() && !Rule.isAnyRuleUsing(Trigger_Enum.wifiConnection))
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "LocationProvider", "Shutting down WifiReceiver because settings forbid to.", 4);
|
Miscellaneous.logEvent("i", "LocationProvider", "Shutting down WifiReceiver because settings forbid to.", 4);
|
||||||
WifiBroadcastReceiver.stopWifiReceiver();
|
WifiBroadcastReceiver.stopWifiReceiver();
|
||||||
|
@ -25,12 +25,20 @@ public class WifiBroadcastReceiver extends BroadcastReceiver
|
|||||||
public static LocationProvider parentLocationProvider;
|
public static LocationProvider parentLocationProvider;
|
||||||
public static Boolean wasConnected = false;
|
public static Boolean wasConnected = false;
|
||||||
protected static String lastWifiSsid = "";
|
protected static String lastWifiSsid = "";
|
||||||
|
protected static String lastWifiSsidReal = "";
|
||||||
public static boolean lastConnectedState = false;
|
public static boolean lastConnectedState = false;
|
||||||
protected static boolean mayCellLocationChangedReceiverBeActivatedFromWifiPointOfView = true;
|
protected static boolean mayCellLocationChangedReceiverBeActivatedFromWifiPointOfView = true;
|
||||||
protected static WifiBroadcastReceiver wifiBrInstance;
|
protected static WifiBroadcastReceiver wifiBrInstance;
|
||||||
protected static IntentFilter wifiListenerIntentFilter;
|
protected static IntentFilter wifiListenerIntentFilter;
|
||||||
protected static boolean wifiListenerActive=false;
|
protected static boolean wifiListenerActive=false;
|
||||||
|
|
||||||
|
final static String unknownSsidName = "<unknown ssid>";
|
||||||
|
|
||||||
|
public static String getLastWifiSsidReal()
|
||||||
|
{
|
||||||
|
return lastWifiSsidReal;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getLastWifiSsid()
|
public static String getLastWifiSsid()
|
||||||
{
|
{
|
||||||
return lastWifiSsid;
|
return lastWifiSsid;
|
||||||
@ -42,8 +50,12 @@ public class WifiBroadcastReceiver extends BroadcastReceiver
|
|||||||
newWifiSsid = newWifiSsid.substring(1, newWifiSsid.length()-1);
|
newWifiSsid = newWifiSsid.substring(1, newWifiSsid.length()-1);
|
||||||
|
|
||||||
if(newWifiSsid.length() > 0)
|
if(newWifiSsid.length() > 0)
|
||||||
|
{
|
||||||
|
if(newWifiSsid.equals(unknownSsidName))
|
||||||
|
WifiBroadcastReceiver.lastWifiSsidReal = lastWifiSsid;
|
||||||
WifiBroadcastReceiver.lastWifiSsid = newWifiSsid;
|
WifiBroadcastReceiver.lastWifiSsid = newWifiSsid;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isWifiListenerActive()
|
public static boolean isWifiListenerActive()
|
||||||
{
|
{
|
||||||
@ -63,7 +75,7 @@ public class WifiBroadcastReceiver extends BroadcastReceiver
|
|||||||
// int state = -1;
|
// int state = -1;
|
||||||
NetworkInfo myWifi = null;
|
NetworkInfo myWifi = null;
|
||||||
|
|
||||||
if(intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) //gefeuert bei Trennung
|
if(intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) // fired upon disconnection
|
||||||
{
|
{
|
||||||
// state = intent.getIntExtra(WifiManager.NETWORK_STATE_CHANGED_ACTION, -1);
|
// state = intent.getIntExtra(WifiManager.NETWORK_STATE_CHANGED_ACTION, -1);
|
||||||
// Miscellaneous.logEvent("i", "WifiReceiver", "NETWORK_STATE_CHANGED_ACTION: " + String.valueOf(state));
|
// Miscellaneous.logEvent("i", "WifiReceiver", "NETWORK_STATE_CHANGED_ACTION: " + String.valueOf(state));
|
||||||
|
@ -19,14 +19,13 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class BatteryReceiver extends BroadcastReceiver implements AutomationListenerInterface
|
public class BatteryReceiver extends BroadcastReceiver implements AutomationListenerInterface
|
||||||
{
|
{
|
||||||
private static int batteryLevel = -1; // initialize with a better value than this
|
|
||||||
public static AutomationService automationServiceRef = null;
|
public static AutomationService automationServiceRef = null;
|
||||||
private static boolean usbHostConnected = false;
|
static int batteryLevel = -1; // initialize with a better value than this
|
||||||
|
static boolean usbHostConnected = false;
|
||||||
private static boolean batteryReceiverActive = false;
|
static boolean batteryReceiverActive = false;
|
||||||
private static IntentFilter batteryIntentFilter = null;
|
static IntentFilter batteryIntentFilter = null;
|
||||||
private static Intent batteryStatus = null;
|
static Intent batteryStatus = null;
|
||||||
private static BroadcastReceiver batteryInfoReceiverInstance = null;
|
static BroadcastReceiver batteryInfoReceiverInstance = null;
|
||||||
|
|
||||||
public static void startBatteryReceiver(final AutomationService automationServiceRef)
|
public static void startBatteryReceiver(final AutomationService automationServiceRef)
|
||||||
{
|
{
|
||||||
@ -90,7 +89,7 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent)
|
public void onReceive(Context context, Intent intent)
|
||||||
{
|
{
|
||||||
// Log.i("Battery", "Some battery event");
|
Miscellaneous.logEvent("i", "BatteryReceiver", "Received event " + intent.getAction(), 5);
|
||||||
|
|
||||||
if (intent == null)
|
if (intent == null)
|
||||||
return;
|
return;
|
||||||
@ -133,11 +132,13 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
|||||||
|
|
||||||
switch(status)
|
switch(status)
|
||||||
{
|
{
|
||||||
|
case BatteryManager.BATTERY_STATUS_CHARGING:
|
||||||
case BatteryManager.BATTERY_STATUS_FULL:
|
case BatteryManager.BATTERY_STATUS_FULL:
|
||||||
Miscellaneous.logEvent("i", "BatteryReceiver", "Device has been fully charged.", 5);
|
Miscellaneous.logEvent("i", "BatteryReceiver", "Device has been fully charged.", 5);
|
||||||
this.actionCharging(context);
|
this.actionCharging(context);
|
||||||
break;
|
break;
|
||||||
case BatteryManager.BATTERY_STATUS_DISCHARGING:
|
case BatteryManager.BATTERY_STATUS_DISCHARGING:
|
||||||
|
case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
|
||||||
this.actionDischarging(context);
|
this.actionDischarging(context);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -225,7 +226,7 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
|||||||
{
|
{
|
||||||
usbHostConnected = true;
|
usbHostConnected = true;
|
||||||
Miscellaneous.logEvent("i", "BatteryReceiver", "Connected to computer.", 3);
|
Miscellaneous.logEvent("i", "BatteryReceiver", "Connected to computer.", 3);
|
||||||
Toast.makeText(context, "Connected to computer.", Toast.LENGTH_LONG).show();
|
// Toast.makeText(context, "Connected to computer.", Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.usb_host_connection);
|
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.usb_host_connection);
|
||||||
// ArrayList<Rule> ruleCandidates = Rule.findRuleCandidatesByUsbHost(true);
|
// ArrayList<Rule> ruleCandidates = Rule.findRuleCandidatesByUsbHost(true);
|
||||||
@ -247,7 +248,7 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
|||||||
{
|
{
|
||||||
usbHostConnected = false;
|
usbHostConnected = false;
|
||||||
Miscellaneous.logEvent("i", "BatteryReceiver", "Disconnected from computer.", 3);
|
Miscellaneous.logEvent("i", "BatteryReceiver", "Disconnected from computer.", 3);
|
||||||
Toast.makeText(context, "Disconnected from computer.", Toast.LENGTH_LONG).show();
|
// Toast.makeText(context, "Disconnected from computer.", Toast.LENGTH_LONG).show();
|
||||||
|
|
||||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.usb_host_connection);
|
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.usb_host_connection);
|
||||||
// ArrayList<Rule> ruleCandidates = Rule.findRuleCandidatesByUsbHost(false);
|
// ArrayList<Rule> ruleCandidates = Rule.findRuleCandidatesByUsbHost(false);
|
||||||
|
@ -94,12 +94,13 @@ public class BluetoothReceiver extends BroadcastReceiver implements AutomationLi
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent)
|
public void onReceive(Context context, Intent intent)
|
||||||
{
|
{
|
||||||
// Miscellaneous.logEvent("i", "BluetoothReceiver", "Bluetooth event.", 4);
|
|
||||||
|
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
|
|
||||||
|
Miscellaneous.logEvent("i", "BluetoothReceiver", "Bluetooth event: " + action, 5);
|
||||||
|
|
||||||
BluetoothDevice bluetoothDevice = null;
|
BluetoothDevice bluetoothDevice = null;
|
||||||
|
|
||||||
if(action.equals(BluetoothDevice.ACTION_ACL_CONNECTED) | action.equals("android.bluetooth.device.action.ACL_CONNECTED"))
|
if(action.equals(BluetoothDevice.ACTION_ACL_CONNECTED) || action.equals("android.bluetooth.device.action.ACL_CONNECTED"))
|
||||||
{
|
{
|
||||||
bluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
bluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||||
lastAffectedDevice = bluetoothDevice;
|
lastAffectedDevice = bluetoothDevice;
|
||||||
@ -107,7 +108,7 @@ public class BluetoothReceiver extends BroadcastReceiver implements AutomationLi
|
|||||||
connectedDevices.add(bluetoothDevice);
|
connectedDevices.add(bluetoothDevice);
|
||||||
Miscellaneous.logEvent("i", "BluetoothReceiver", String.format(context.getResources().getString(R.string.bluetoothConnectionTo), bluetoothDevice.getName()), 3);
|
Miscellaneous.logEvent("i", "BluetoothReceiver", String.format(context.getResources().getString(R.string.bluetoothConnectionTo), bluetoothDevice.getName()), 3);
|
||||||
}
|
}
|
||||||
else if(action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED) | action.equals(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED) | action.equals("android.bluetooth.device.ACTION_ACL_DISCONNECTED") | action.equals("android.bluetooth.device.ACTION_ACL_DISCONNECT_REQUESTED"))
|
else if(action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED) || action.equals(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED) || action.equals("android.bluetooth.device.ACTION_ACL_DISCONNECTED") || action.equals("android.bluetooth.device.ACTION_ACL_DISCONNECT_REQUESTED"))
|
||||||
{
|
{
|
||||||
bluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
bluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||||
lastAffectedDevice = bluetoothDevice;
|
lastAffectedDevice = bluetoothDevice;
|
||||||
@ -115,7 +116,7 @@ public class BluetoothReceiver extends BroadcastReceiver implements AutomationLi
|
|||||||
connectedDevices.remove(bluetoothDevice);
|
connectedDevices.remove(bluetoothDevice);
|
||||||
Miscellaneous.logEvent("i", "BluetoothReceiver", String.format(context.getResources().getString(R.string.bluetoothDisconnectFrom), bluetoothDevice.getName()), 3);
|
Miscellaneous.logEvent("i", "BluetoothReceiver", String.format(context.getResources().getString(R.string.bluetoothDisconnectFrom), bluetoothDevice.getName()), 3);
|
||||||
}
|
}
|
||||||
else if(action.equals(BluetoothDevice.ACTION_FOUND) | action.equals("android.bluetooth.device.ACTION_FOUND"))
|
else if(action.equals(BluetoothDevice.ACTION_FOUND) || action.equals("android.bluetooth.device.ACTION_FOUND"))
|
||||||
{
|
{
|
||||||
bluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
bluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||||
lastAffectedDevice = bluetoothDevice;
|
lastAffectedDevice = bluetoothDevice;
|
||||||
@ -300,4 +301,16 @@ public class BluetoothReceiver extends BroadcastReceiver implements AutomationLi
|
|||||||
{
|
{
|
||||||
return new Trigger_Enum[] { Trigger_Enum.bluetoothConnection };
|
return new Trigger_Enum[] { Trigger_Enum.bluetoothConnection };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for Bluetooth.
|
||||||
|
*
|
||||||
|
* @return true if Bluetooth is available.
|
||||||
|
*/
|
||||||
|
public static boolean isBluetoothEnabled()
|
||||||
|
{
|
||||||
|
final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
|
|
||||||
|
return bluetoothAdapter != null && bluetoothAdapter.isEnabled() && bluetoothAdapter.getState() == BluetoothAdapter.STATE_ON;
|
||||||
|
}
|
||||||
}
|
}
|
@ -76,7 +76,6 @@ public class HeadphoneJackListener extends BroadcastReceiver implements Automati
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.headsetPlugged);
|
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.headsetPlugged);
|
||||||
// ArrayList<Rule> ruleCandidates = Rule.findRuleCandidatesByHeadphoneJack(isHeadsetConnected());
|
|
||||||
for(int i=0; i<ruleCandidates.size(); i++)
|
for(int i=0; i<ruleCandidates.size(); i++)
|
||||||
{
|
{
|
||||||
if(ruleCandidates.get(i).getsGreenLight(context))
|
if(ruleCandidates.get(i).getsGreenLight(context))
|
||||||
@ -104,13 +103,12 @@ public class HeadphoneJackListener extends BroadcastReceiver implements Automati
|
|||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "HeadsetJackListener", "Starting HeadsetJackListener", 4);
|
Miscellaneous.logEvent("i", "HeadsetJackListener", "Starting HeadsetJackListener", 4);
|
||||||
headphoneJackListenerActive = true;
|
headphoneJackListenerActive = true;
|
||||||
// getInstance().startHeadphoneJackListener(AutomationService.getInstance(), headphoneJackListenerIntentFilter);
|
|
||||||
automationService.registerReceiver(this, headphoneJackListenerIntentFilter);
|
automationService.registerReceiver(this, headphoneJackListenerIntentFilter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("e", "ActivityDetectionReceiver", "Error starting HeadsetJackListener: " + Log.getStackTraceString(ex), 3);
|
Miscellaneous.logEvent("e", "HeadsetJackListener", "Error starting HeadsetJackListener: " + Log.getStackTraceString(ex), 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +120,6 @@ public class HeadphoneJackListener extends BroadcastReceiver implements Automati
|
|||||||
if(headphoneJackListenerActive)
|
if(headphoneJackListenerActive)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "HeadsetJackListener", "Stopping HeadsetJackListener", 4);
|
Miscellaneous.logEvent("i", "HeadsetJackListener", "Stopping HeadsetJackListener", 4);
|
||||||
// getInstance().stopHeadphoneJackListener(AutomationService.getInstance());
|
|
||||||
automationService.unregisterReceiver(this);
|
automationService.unregisterReceiver(this);
|
||||||
headphoneJackListenerActive = false;
|
headphoneJackListenerActive = false;
|
||||||
}
|
}
|
||||||
@ -150,5 +147,4 @@ public class HeadphoneJackListener extends BroadcastReceiver implements Automati
|
|||||||
{
|
{
|
||||||
return new Trigger_Enum[] { Trigger_Enum.headsetPlugged };
|
return new Trigger_Enum[] { Trigger_Enum.headsetPlugged };
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -2,11 +2,10 @@ package com.jens.automation2.receivers;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.app.PendingIntent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcelable;
|
|
||||||
import android.service.notification.NotificationListenerService;
|
import android.service.notification.NotificationListenerService;
|
||||||
import android.service.notification.StatusBarNotification;
|
import android.service.notification.StatusBarNotification;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -149,51 +148,6 @@ public class NotificationListener extends NotificationListenerService// implemen
|
|||||||
return returnNotification;
|
return returnNotification;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Override
|
|
||||||
public void startListener(AutomationService automationService)
|
|
||||||
{
|
|
||||||
if(instance == null)
|
|
||||||
instance = new NotificationListener();
|
|
||||||
|
|
||||||
if(notificationReceiverIntentFilter == null)
|
|
||||||
{
|
|
||||||
notificationReceiverIntentFilter = new IntentFilter();
|
|
||||||
notificationReceiverIntentFilter.addAction("android.service.notification.NotificationListenerService");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if(!listenerRunning)
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("i", "NotificationListener", "Starting NotificationListener", 4);
|
|
||||||
listenerRunning = true;
|
|
||||||
AutomationService.getInstance().registerReceiver(instance, notificationReceiverIntentFilter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("e", "BluetoothReceiver", "Error starting BluetoothReceiver: " + Log.getStackTraceString(ex), 3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stopListener(AutomationService automationService)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isListenerRunning()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Trigger.Trigger_Enum[] getMonitoredTrigger()
|
|
||||||
{
|
|
||||||
return new Trigger.Trigger_Enum[0];
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public static class SimpleNotification
|
public static class SimpleNotification
|
||||||
{
|
{
|
||||||
boolean created;
|
boolean created;
|
||||||
@ -283,4 +237,35 @@ public class NotificationListener extends NotificationListenerService// implemen
|
|||||||
cancelNotification(sbn.getKey());
|
cancelNotification(sbn.getKey());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
||||||
|
public void clickNotificationButton(StatusBarNotification sbn, String buttonText)
|
||||||
|
{
|
||||||
|
boolean buttonFound = false;
|
||||||
|
|
||||||
|
if(sbn.getNotification().actions != null)
|
||||||
|
{
|
||||||
|
for (Notification.Action a : sbn.getNotification().actions)
|
||||||
|
{
|
||||||
|
if((Miscellaneous.isRegularExpression(buttonText) && a.title.toString().matches(buttonText)) || a.title.toString().equalsIgnoreCase(buttonText))
|
||||||
|
{
|
||||||
|
if (!buttonFound)
|
||||||
|
buttonFound = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("w", "clickNotificationButton()", "Pressing button with text \"" + a.title.toString() + "\".", 2);
|
||||||
|
a.actionIntent.send();
|
||||||
|
}
|
||||||
|
catch (PendingIntent.CanceledException e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("w", "clickNotificationButton()", Log.getStackTraceString(e), 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!buttonFound)
|
||||||
|
Miscellaneous.logEvent("w", "clickNotificationButton()", "Button with text \n" + buttonText + "\n could not found.", 2);
|
||||||
|
}
|
||||||
}
|
}
|
@ -6,10 +6,15 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.os.Build;
|
||||||
import android.telephony.PhoneStateListener;
|
import android.telephony.PhoneStateListener;
|
||||||
|
import android.telephony.TelephonyCallback;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
import com.jens.automation2.ActivityPermissions;
|
import com.jens.automation2.ActivityPermissions;
|
||||||
import com.jens.automation2.AutomationService;
|
import com.jens.automation2.AutomationService;
|
||||||
import com.jens.automation2.Miscellaneous;
|
import com.jens.automation2.Miscellaneous;
|
||||||
@ -22,8 +27,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class PhoneStatusListener implements AutomationListenerInterface
|
public class PhoneStatusListener implements AutomationListenerInterface
|
||||||
{
|
{
|
||||||
// protected static int currentStateIncoming = -1;
|
static int problematicAndroidLevel = 29;
|
||||||
// protected static int currentStateOutgoing = -1;
|
|
||||||
protected static String lastPhoneNumber="";
|
protected static String lastPhoneNumber="";
|
||||||
protected static int lastPhoneDirection = -1; //0=incoming, 1=outgoing
|
protected static int lastPhoneDirection = -1; //0=incoming, 1=outgoing
|
||||||
protected static int currentState = -1;
|
protected static int currentState = -1;
|
||||||
@ -72,22 +76,13 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
|||||||
return currentState;
|
return currentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class IncomingCallsReceiver extends PhoneStateListener
|
public static interface IncomingCallsReceiver
|
||||||
{
|
{
|
||||||
@Override
|
|
||||||
public void onCallStateChanged(int state, String incomingNumber)
|
}
|
||||||
|
|
||||||
|
protected static void workWithIncomingCallData(int state, String incomingNumber)
|
||||||
{
|
{
|
||||||
// Miscellaneous.logEvent("i", "Call state", "New call state: " + String.valueOf(state), 4);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Unfortunately receivers for incoming and outgoing calls behave pretty differently:
|
|
||||||
|
|
||||||
The Outgoing-Receiver is called when starting a call (ringing)
|
|
||||||
It is not called when that outgoing call ends however, only the incoming receiver.
|
|
||||||
|
|
||||||
If the last call was outgoing the state has not changed to idle this is kind of a fake alert.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if(lastPhoneDirection == 2 && currentState != TelephonyManager.CALL_STATE_IDLE)
|
if(lastPhoneDirection == 2 && currentState != TelephonyManager.CALL_STATE_IDLE)
|
||||||
{
|
{
|
||||||
// This status update is actually for an outgoing call
|
// This status update is actually for an outgoing call
|
||||||
@ -120,8 +115,6 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// state != TelephonyManager.CALL_STATE_IDLE &&
|
|
||||||
|
|
||||||
setCurrentState(state);
|
setCurrentState(state);
|
||||||
setLastPhoneDirection(1);
|
setLastPhoneDirection(1);
|
||||||
|
|
||||||
@ -151,6 +144,61 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class IncomingCallsReceiverOld extends PhoneStateListener implements IncomingCallsReceiver
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onCallStateChanged(int state, String incomingNumber)
|
||||||
|
{
|
||||||
|
// Miscellaneous.logEvent("i", "Call state", "New call state: " + String.valueOf(state), 4);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Unfortunately receivers for incoming and outgoing calls behave pretty differently:
|
||||||
|
|
||||||
|
The Outgoing-Receiver is called when starting a call (ringing)
|
||||||
|
It is not called when that outgoing call ends however, only the incoming receiver.
|
||||||
|
|
||||||
|
If the last call was outgoing the state has not changed to idle this is kind of a fake alert.
|
||||||
|
*/
|
||||||
|
|
||||||
|
workWithIncomingCallData(state, incomingNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.S)
|
||||||
|
public static class IncomingCallsReceiverNew extends BroadcastReceiver implements IncomingCallsReceiver
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
this code detects both incoming and outgoing,
|
||||||
|
if the state changes idle => ringing you know it's an incoming call,
|
||||||
|
if the state changes idle => offhook, you know it's an outgoing call
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL))
|
||||||
|
{
|
||||||
|
String stateStr = intent.getExtras().getString(TelephonyManager.EXTRA_STATE);
|
||||||
|
int state = 99;
|
||||||
|
|
||||||
|
switch(stateStr)
|
||||||
|
{
|
||||||
|
case "RINGING":
|
||||||
|
state = TelephonyManager.CALL_STATE_RINGING;
|
||||||
|
break;
|
||||||
|
case "IDLE":
|
||||||
|
state = TelephonyManager.CALL_STATE_IDLE;
|
||||||
|
break;
|
||||||
|
case "OFFHOOK":
|
||||||
|
state = TelephonyManager.CALL_STATE_OFFHOOK;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
String number = intent.getExtras().getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
|
||||||
|
Log.i("test", "test");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setLastPhoneDirection(int i)
|
static void setLastPhoneDirection(int i)
|
||||||
@ -205,7 +253,12 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(incomingCallsReceiverInstance == null)
|
if(incomingCallsReceiverInstance == null)
|
||||||
incomingCallsReceiverInstance = new IncomingCallsReceiver();
|
{
|
||||||
|
// if(Build.VERSION.SDK_INT >= 31)
|
||||||
|
// incomingCallsReceiverInstance = new IncomingCallsReceiverNew();
|
||||||
|
// else
|
||||||
|
incomingCallsReceiverInstance = new IncomingCallsReceiverOld();
|
||||||
|
}
|
||||||
|
|
||||||
if(outgoingCallsReceiverInstance == null)
|
if(outgoingCallsReceiverInstance == null)
|
||||||
outgoingCallsReceiverInstance = new OutgoingCallsReceiver();
|
outgoingCallsReceiverInstance = new OutgoingCallsReceiver();
|
||||||
@ -215,8 +268,17 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
|||||||
if(!incomingCallsReceiverActive)
|
if(!incomingCallsReceiverActive)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "PhoneStatusListener", "Starting PhoneStatusListener->incomingCallsReceiver", 4);
|
Miscellaneous.logEvent("i", "PhoneStatusListener", "Starting PhoneStatusListener->incomingCallsReceiver", 4);
|
||||||
|
// if(Build.VERSION.SDK_INT >= problematicAndroidLevel)
|
||||||
|
// {
|
||||||
|
// IntentFilter callsFilter = new IntentFilter();
|
||||||
|
// callsFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
|
||||||
|
// automationService.registerReceiver((IncomingCallsReceiverNew)incomingCallsReceiverInstance, callsFilter);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
TelephonyManager tm = (TelephonyManager) automationService.getSystemService(Context.TELEPHONY_SERVICE);
|
TelephonyManager tm = (TelephonyManager) automationService.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
tm.listen(incomingCallsReceiverInstance, PhoneStateListener.LISTEN_CALL_STATE);
|
tm.listen((IncomingCallsReceiverOld)incomingCallsReceiverInstance, PhoneStateListener.LISTEN_CALL_STATE);
|
||||||
|
// }
|
||||||
incomingCallsReceiverActive = true;
|
incomingCallsReceiverActive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,8 +302,15 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
|||||||
if(incomingCallsReceiverActive)
|
if(incomingCallsReceiverActive)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "PhoneStatusListener", "Stopping phoneStatusListener", 4);
|
Miscellaneous.logEvent("i", "PhoneStatusListener", "Stopping phoneStatusListener", 4);
|
||||||
|
// if(Build.VERSION.SDK_INT >= 31)
|
||||||
|
// {
|
||||||
|
// automationService.unregisterReceiver((IncomingCallsReceiverNew)incomingCallsReceiverInstance);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
TelephonyManager tm = (TelephonyManager) automationService.getSystemService(Context.TELEPHONY_SERVICE);
|
TelephonyManager tm = (TelephonyManager) automationService.getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
tm.listen(incomingCallsReceiverInstance, PhoneStateListener.LISTEN_NONE);
|
tm.listen((IncomingCallsReceiverOld)incomingCallsReceiverInstance, PhoneStateListener.LISTEN_NONE);
|
||||||
|
// }
|
||||||
incomingCallsReceiverActive = false;
|
incomingCallsReceiverActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,12 +11,13 @@ import com.jens.automation2.Settings;
|
|||||||
|
|
||||||
public class StartupIntentReceiver extends BroadcastReceiver
|
public class StartupIntentReceiver extends BroadcastReceiver
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent)
|
public void onReceive(Context context, Intent intent)
|
||||||
{
|
{
|
||||||
Settings.readFromPersistentStorage(context);
|
Settings.readFromPersistentStorage(context);
|
||||||
|
|
||||||
|
Miscellaneous.startupContext = context;
|
||||||
|
|
||||||
// Miscellaneous.logEvent("i", "Boot event", "Received event: " + intent.getAction(), 5);
|
// Miscellaneous.logEvent("i", "Boot event", "Received event: " + intent.getAction(), 5);
|
||||||
|
|
||||||
if(Settings.startServiceAtSystemBoot)
|
if(Settings.startServiceAtSystemBoot)
|
||||||
|
@ -0,0 +1,151 @@
|
|||||||
|
package com.jens.automation2.receivers;
|
||||||
|
|
||||||
|
import android.bluetooth.BluetoothAdapter;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.IntentFilter;
|
||||||
|
import android.net.wifi.WifiManager;
|
||||||
|
|
||||||
|
import com.jens.automation2.AutomationService;
|
||||||
|
import com.jens.automation2.Miscellaneous;
|
||||||
|
import com.jens.automation2.Rule;
|
||||||
|
import com.jens.automation2.Trigger;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class SubSystemStateReceiver extends BroadcastReceiver implements AutomationListenerInterface
|
||||||
|
{
|
||||||
|
public static AutomationService automationServiceRef = null;
|
||||||
|
private static IntentFilter subSystemStateIntentFilter = null;
|
||||||
|
private static BroadcastReceiver subSystemStateReceiverInstance = null;
|
||||||
|
private static Intent subSystemStatusIntent = null;
|
||||||
|
private static boolean subSystemStateReceiverActive = false;
|
||||||
|
static SubSystemStateReceiver instance;
|
||||||
|
|
||||||
|
final static String stateBluetooth = "android.bluetooth.adapter.action.STATE_CHANGED";
|
||||||
|
final static String stateWifi = "android.net.wifi.STATE_CHANGE";
|
||||||
|
final static String connectivityBroadcast = "android.net.conn.CONNECTIVITY_CHANGE";
|
||||||
|
|
||||||
|
static Map<String, Boolean> stateMap = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent)
|
||||||
|
{
|
||||||
|
if (intent == null)
|
||||||
|
return;
|
||||||
|
if (context == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Miscellaneous.logEvent("e", "ScreenStateReceiver", "Received: " + intent.getAction(), 3);
|
||||||
|
|
||||||
|
if(stateMap == null)
|
||||||
|
stateMap = new HashMap<>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
/*if (intent.getAction().equals(stateWifi) || intent.getAction().equals(connectivityBroadcast))
|
||||||
|
{
|
||||||
|
if(intent.hasExtra(WifiManager.EXTRA_WIFI_STATE))
|
||||||
|
{
|
||||||
|
int wifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_UNKNOWN);
|
||||||
|
|
||||||
|
if (wifiState == WifiManager.WIFI_STATE_ENABLED)
|
||||||
|
stateMap.put("wifi", true);
|
||||||
|
else if (wifiState == WifiManager.WIFI_STATE_DISABLED)
|
||||||
|
stateMap.put("wifi", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (intent.getAction().equals(stateBluetooth))
|
||||||
|
{
|
||||||
|
if(intent.hasExtra(BluetoothAdapter.EXTRA_STATE))
|
||||||
|
{
|
||||||
|
int bluetoothState = intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, BluetoothAdapter.ERROR);
|
||||||
|
|
||||||
|
if (bluetoothState == BluetoothAdapter.STATE_ON)
|
||||||
|
stateMap.put("bluetooth", true);
|
||||||
|
else if (bluetoothState == BluetoothAdapter.STATE_OFF)
|
||||||
|
stateMap.put("bluetooth", false);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
if (intent.getAction().equals(stateWifi) || intent.getAction().equals(connectivityBroadcast) || intent.getAction().equals(stateBluetooth))
|
||||||
|
{
|
||||||
|
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.subSystemState);
|
||||||
|
for (int i = 0; i < ruleCandidates.size(); i++)
|
||||||
|
{
|
||||||
|
if (ruleCandidates.get(i).getsGreenLight(context))
|
||||||
|
ruleCandidates.get(i).activate(automationServiceRef, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("e", "SubSystemStateReceiver", "Unknown state received: " + intent.getAction(), 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("e", "SubSystemStateReceiver", "Error receiving screen state: " + e.getMessage(), 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SubSystemStateReceiver getInstance()
|
||||||
|
{
|
||||||
|
if(instance == null)
|
||||||
|
instance = new SubSystemStateReceiver();
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startListener(AutomationService automationService)
|
||||||
|
{
|
||||||
|
if (!subSystemStateReceiverActive)
|
||||||
|
{
|
||||||
|
automationServiceRef = automationService;
|
||||||
|
|
||||||
|
if (subSystemStateReceiverInstance == null)
|
||||||
|
subSystemStateReceiverInstance = new SubSystemStateReceiver();
|
||||||
|
|
||||||
|
if (subSystemStateIntentFilter == null)
|
||||||
|
{
|
||||||
|
subSystemStateIntentFilter = new IntentFilter();
|
||||||
|
subSystemStateIntentFilter.addAction(stateWifi);
|
||||||
|
subSystemStateIntentFilter.addAction(connectivityBroadcast);
|
||||||
|
subSystemStateIntentFilter.addAction(stateBluetooth);
|
||||||
|
}
|
||||||
|
|
||||||
|
subSystemStatusIntent = automationServiceRef.registerReceiver(subSystemStateReceiverInstance, subSystemStateIntentFilter);
|
||||||
|
|
||||||
|
subSystemStateReceiverActive = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stopListener(AutomationService automationService)
|
||||||
|
{
|
||||||
|
if (subSystemStateReceiverActive)
|
||||||
|
{
|
||||||
|
if (subSystemStateReceiverInstance != null)
|
||||||
|
{
|
||||||
|
automationServiceRef.unregisterReceiver(subSystemStateReceiverInstance);
|
||||||
|
subSystemStateReceiverInstance = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
subSystemStateReceiverActive = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isListenerRunning()
|
||||||
|
{
|
||||||
|
return subSystemStateReceiverActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Trigger.Trigger_Enum[] getMonitoredTrigger()
|
||||||
|
{
|
||||||
|
return new Trigger.Trigger_Enum[]{Trigger.Trigger_Enum.subSystemState};
|
||||||
|
}
|
||||||
|
}
|
@ -6,12 +6,17 @@ import android.content.IntentFilter;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.jens.automation2.ActivityManageTriggerTethering;
|
||||||
import com.jens.automation2.AutomationService;
|
import com.jens.automation2.AutomationService;
|
||||||
import com.jens.automation2.Miscellaneous;
|
import com.jens.automation2.Miscellaneous;
|
||||||
import com.jens.automation2.Rule;
|
import com.jens.automation2.Rule;
|
||||||
import com.jens.automation2.Trigger;
|
import com.jens.automation2.Trigger;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.NetworkInterface;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class TetheringReceiver extends android.content.BroadcastReceiver implements AutomationListenerInterface
|
public class TetheringReceiver extends android.content.BroadcastReceiver implements AutomationListenerInterface
|
||||||
{
|
{
|
||||||
@ -20,8 +25,14 @@ public class TetheringReceiver extends android.content.BroadcastReceiver impleme
|
|||||||
private static TetheringReceiver receiverInstance = null;
|
private static TetheringReceiver receiverInstance = null;
|
||||||
private static IntentFilter intentFilter = null;
|
private static IntentFilter intentFilter = null;
|
||||||
|
|
||||||
|
private static List<String> lastTetheringTypes = null;
|
||||||
private static boolean tetheringActive = false;
|
private static boolean tetheringActive = false;
|
||||||
|
|
||||||
|
public static List<String> getLastTetheringTypes()
|
||||||
|
{
|
||||||
|
return lastTetheringTypes;
|
||||||
|
}
|
||||||
|
|
||||||
public static TetheringReceiver getInstance()
|
public static TetheringReceiver getInstance()
|
||||||
{
|
{
|
||||||
if(receiverInstance == null)
|
if(receiverInstance == null)
|
||||||
@ -38,28 +49,91 @@ public class TetheringReceiver extends android.content.BroadcastReceiver impleme
|
|||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent)
|
public void onReceive(Context context, Intent intent)
|
||||||
{
|
{
|
||||||
|
Miscellaneous.logEvent("i", "TetheringReceiver", "Received " + intent.getAction(), 5);
|
||||||
|
|
||||||
|
/*
|
||||||
|
DETECT BY DATA DELIVERED IN INTENT
|
||||||
|
*/
|
||||||
|
|
||||||
|
// if(intent.getAction().equals("android.net.conn.TETHER_STATE_CHANGED"))
|
||||||
|
// {
|
||||||
|
String searchArray = null;
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 26)
|
||||||
|
searchArray = "tetherArray";
|
||||||
|
else
|
||||||
|
searchArray = "activeArray";
|
||||||
|
|
||||||
for (String key : intent.getExtras().keySet())
|
for (String key : intent.getExtras().keySet())
|
||||||
{
|
{
|
||||||
// Miscellaneous.logEvent("i", "Broadcast extra", "Broadcast " + intent.getAction() + " has extra " + key + " and type " + intent.getExtras().get(key).getClass().getName(), 4);
|
// Miscellaneous.logEvent("i", "Broadcast extra", "Broadcast " + intent.getAction() + " has extra " + key + " and type " + intent.getExtras().get(key).getClass().getName(), 4);
|
||||||
Object ob = intent.getExtras().get(key);
|
Object ob = intent.getExtras().get(key);
|
||||||
|
|
||||||
String target = null;
|
if (key.equals(searchArray) && ob instanceof ArrayList)
|
||||||
|
|
||||||
if(Build.VERSION.SDK_INT >= 26)
|
|
||||||
target = "tetherArray";
|
|
||||||
else
|
|
||||||
target = "activeArray";
|
|
||||||
|
|
||||||
if(key.equals(target) && ob instanceof ArrayList)
|
|
||||||
{
|
{
|
||||||
if (((ArrayList<String>) ob).size() > 0)
|
if (((ArrayList<String>) ob).size() > 0)
|
||||||
|
{
|
||||||
tetheringActive = true;
|
tetheringActive = true;
|
||||||
|
if (lastTetheringTypes == null)
|
||||||
|
lastTetheringTypes = new ArrayList<>();
|
||||||
|
else
|
||||||
|
lastTetheringTypes.clear();
|
||||||
|
|
||||||
|
for (String adapterName : (ArrayList<String>) ob)
|
||||||
|
{
|
||||||
|
if (adapterName.contains("wlan"))
|
||||||
|
lastTetheringTypes.add(ActivityManageTriggerTethering.tetheringTypeWifi);
|
||||||
|
else if (adapterName.contains("bluetooth"))
|
||||||
|
lastTetheringTypes.add(ActivityManageTriggerTethering.tetheringTypeBluetooth);
|
||||||
|
else if (adapterName.contains("rndis"))
|
||||||
|
lastTetheringTypes.add(ActivityManageTriggerTethering.tetheringTypeUsb);
|
||||||
|
else if (adapterName.contains("ndis"))
|
||||||
|
lastTetheringTypes.add(ActivityManageTriggerTethering.tetheringTypeCable);
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
tetheringActive = false;
|
tetheringActive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Miscellaneous.logEvent("i", "Broadcast extra", "Broadcast " + intent.getAction() + " has extra " + key + " and type " + intent.getExtras().get(key).getClass().getName(), 4);
|
// Miscellaneous.logEvent("i", "Broadcast extra", "Broadcast " + intent.getAction() + " has extra " + key + " and type " + intent.getExtras().get(key).getClass().getName(), 4);
|
||||||
}
|
}
|
||||||
|
// }
|
||||||
|
// else if(intent.getAction().equals("android.net.conn.CONNECTIVITY_CHANGE"))
|
||||||
|
/*
|
||||||
|
DETECT BY CHECKING ALL NETWORK INTERFACES
|
||||||
|
*/
|
||||||
|
// {
|
||||||
|
/*try
|
||||||
|
{
|
||||||
|
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements(); )
|
||||||
|
{
|
||||||
|
NetworkInterface intf = en.nextElement();
|
||||||
|
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements(); )
|
||||||
|
{
|
||||||
|
InetAddress inetAddress = enumIpAddr.nextElement();
|
||||||
|
if (!intf.isLoopback())
|
||||||
|
{
|
||||||
|
if (intf.getName().contains("rndis"))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "TetheringReceiver", "Tethering on interface " + intf.getName() + " seems to be active.", 4);
|
||||||
|
lastTetheringTypes.add(ActivityManageTriggerTethering.tetheringTypeUsb);
|
||||||
|
tetheringActive = true;
|
||||||
|
}
|
||||||
|
else if (intf.getName().contains("ndis"))
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("i", "TetheringReceiver", "Tethering on interface " + intf.getName() + " seems to be active.", 4);
|
||||||
|
lastTetheringTypes.add(ActivityManageTriggerTethering.tetheringTypeCable);
|
||||||
|
tetheringActive = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("e", "TetheringReceiver", Log.getStackTraceString(e), 1);
|
||||||
|
}*/
|
||||||
|
// }
|
||||||
|
|
||||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.tethering);
|
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.tethering);
|
||||||
for(int i=0; i<ruleCandidates.size(); i++)
|
for(int i=0; i<ruleCandidates.size(); i++)
|
||||||
@ -83,6 +157,7 @@ public class TetheringReceiver extends android.content.BroadcastReceiver impleme
|
|||||||
{
|
{
|
||||||
intentFilter = new IntentFilter();
|
intentFilter = new IntentFilter();
|
||||||
intentFilter.addAction("android.net.conn.TETHER_STATE_CHANGED");
|
intentFilter.addAction("android.net.conn.TETHER_STATE_CHANGED");
|
||||||
|
// intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
BIN
app/src/main/res/drawable-hdpi/clipboard.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
app/src/main/res/drawable-hdpi/coffee.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
app/src/main/res/drawable-hdpi/crane.png
Normal file
After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 679 B After Width: | Height: | Size: 679 B |
BIN
app/src/main/res/drawable-hdpi/subsystemstate.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
app/src/main/res/drawable-ldpi/crane.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
app/src/main/res/drawable-mdpi/crane.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
app/src/main/res/drawable-v24/crane.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
app/src/main/res/drawable-xhdpi/crane.png
Normal file
After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 3.7 KiB |
BIN
app/src/main/res/drawable/crane.png
Normal file
After Width: | Height: | Size: 13 KiB |
@ -100,6 +100,7 @@
|
|||||||
android:id="@+id/bSendEmailToDev"
|
android:id="@+id/bSendEmailToDev"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/default_margin"
|
||||||
android:text="@string/sendEmailToDev" />
|
android:text="@string/sendEmailToDev" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/generalText" />
|
android:text="@string/generalText" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
@ -76,6 +76,14 @@
|
|||||||
android:text="@string/comparisonCaseInsensitive"
|
android:text="@string/comparisonCaseInsensitive"
|
||||||
android:layout_marginBottom="@dimen/default_margin"/>
|
android:layout_marginBottom="@dimen/default_margin"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="@string/regularExpressionsIfEquals"
|
||||||
|
android:layout_marginBottom="@dimen/default_margin"/>
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
android:layout_marginBottom="@dimen/activity_vertical_margin">
|
android:layout_marginBottom="@dimen/activity_vertical_margin">
|
||||||
|
|
||||||
@ -112,6 +120,22 @@
|
|||||||
android:layout_marginVertical="@dimen/default_margin"
|
android:layout_marginVertical="@dimen/default_margin"
|
||||||
android:background="#aa000000" />
|
android:background="#aa000000" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="@string/comparisonCaseInsensitive"
|
||||||
|
android:layout_marginBottom="@dimen/default_margin"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="@string/regularExpressionsIfEquals"
|
||||||
|
android:layout_marginBottom="@dimen/default_margin"/>
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
android:layout_marginBottom="@dimen/activity_vertical_margin">
|
android:layout_marginBottom="@dimen/activity_vertical_margin">
|
||||||
|
|
||||||
@ -141,6 +165,69 @@
|
|||||||
|
|
||||||
</TableRow>>
|
</TableRow>>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:layout_marginVertical="@dimen/default_margin"
|
||||||
|
android:background="#aa000000" />
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<RadioGroup>
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbNotificationDismissSimple"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/simplyDismissNotification" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbNotificationDismissButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/clickNotificationButton" />
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:id="@+id/etNotificationDismissalButtonText"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:enabled="false"
|
||||||
|
android:inputType="text" />
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="@string/comparisonCaseInsensitive"
|
||||||
|
android:layout_marginBottom="@dimen/default_margin"/>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="@string/mayUseRegularExpressions"
|
||||||
|
android:layout_marginBottom="@dimen/default_margin"/>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_margin="@dimen/default_margin" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/textToCopy" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etCopyToClipboard"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ems="10"
|
||||||
|
android:inputType="textShortMessage|textMultiLine" >
|
||||||
|
</EditText>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvTextMessageAnnotations"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dip"
|
||||||
|
android:text="@string/textMessageAnnotations" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvLegend"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/urlLegend" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bSaveCopyToClipboard"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/save" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
@ -0,0 +1,64 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_margin="@dimen/default_margin" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_span="2"
|
||||||
|
android:textSize="25dp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:layout_marginBottom="@dimen/default_margin"
|
||||||
|
android:text="@string/startPhoneCall"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvMakePhoneCallExplanation1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/makePhoneCallExplanation1" />
|
||||||
|
|
||||||
|
<TableLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/default_margin"
|
||||||
|
android:stretchColumns="1"
|
||||||
|
android:shrinkColumns="1" >
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:layout_marginTop="@dimen/default_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="@dimen/default_margin"
|
||||||
|
android:text="@string/phoneNumber" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etTargetPhoneNumber"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="phone"/>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bActionMakePhoneCallSave"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/default_margin"
|
||||||
|
android:text="@string/save" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
@ -41,6 +41,32 @@
|
|||||||
<requestFocus />
|
<requestFocus />
|
||||||
</EditText>
|
</EditText>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/messageType" />
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbMessageTypeSms"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:checked="true"
|
||||||
|
android:text="@string/sms" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbMessageTypeMms"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/mms" />
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
@ -67,6 +93,23 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/urlLegend" />
|
android:text="@string/urlLegend" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/attachment" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvSendMmsFileAttachment"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bMmsAttachment"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:enabled="false"
|
||||||
|
android:text="@string/chooseFile" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/bSaveSendTextMessage"
|
android:id="@+id/bSaveSendTextMessage"
|
||||||
android:layout_marginTop="15dp"
|
android:layout_marginTop="15dp"
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="@dimen/default_margin" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/setVariable"
|
||||||
|
android:textSize="25dp"
|
||||||
|
android:layout_marginBottom="@dimen/default_margin" />
|
||||||
|
|
||||||
|
<TableLayout
|
||||||
|
android:layout_marginLeft="@dimen/default_margin"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:shrinkColumns="1"
|
||||||
|
android:stretchColumns="1" >
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="@string/VariableKey"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etVariableSetKey"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="text" />
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="@string/variableValue"
|
||||||
|
android:layout_marginRight="@dimen/default_margin"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etVariableSetValue"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginVertical="@dimen/default_margin"
|
||||||
|
android:text="@string/setVariableExplanation" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bSaveVariable"
|
||||||
|
android:layout_marginTop="@dimen/default_margin"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/save" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
@ -113,6 +113,7 @@
|
|||||||
android:text="@string/startAppStartType" />
|
android:text="@string/startAppStartType" />
|
||||||
|
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
|
android:id="@+id/rgAppStartupType"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
@ -129,6 +130,18 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/startAppBySendBroadcast" />
|
android:text="@string/startAppBySendBroadcast" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbStartAppByService"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/startAppByStartService" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbStartAppByForegroundService"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/startAppByStartForegroundService" />
|
||||||
|
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
@ -181,6 +194,25 @@
|
|||||||
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="@string/className" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etClassName"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="textMultiLine"
|
||||||
|
android:text=""
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
@ -298,6 +330,24 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/addIntentValue" />
|
android:text="@string/addIntentValue" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginVertical="@dimen/default_margin"
|
||||||
|
android:text="@string/intentParametersHint" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="25dp"
|
||||||
|
android:text="@string/variablesOnlyForTypes" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvLegend"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/urlLegend" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
|
100
app/src/main/res/layout/activity_manage_action_wakelock.xml
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_margin="@dimen/default_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_span="2"
|
||||||
|
android:textSize="25dp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:layout_marginBottom="@dimen/default_margin"
|
||||||
|
android:text="@string/keepDeviceAwake" />
|
||||||
|
|
||||||
|
<TableLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:shrinkColumns="1"
|
||||||
|
android:stretchColumns="1">
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:text="@string/direction" />
|
||||||
|
|
||||||
|
<RadioGroup>
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbWakeLockActivate"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:checked="true"
|
||||||
|
android:text="@string/activate" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbWakeLockDeactivate"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/deactivate" />
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="@string/wakeLockExplanation"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_span="2"
|
||||||
|
android:layout_marginVertical="@dimen/default_margin" />
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:text="@string/wakeLockTimeout"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/chkWakeLockTimeout"
|
||||||
|
android:text=""
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content" />
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/duration" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etWakeLockDuration"
|
||||||
|
android:inputType="number"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content" />
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bSaveWakelock"
|
||||||
|
android:layout_marginTop="@dimen/default_margin"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/save" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -0,0 +1,80 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_margin="@dimen/default_margin" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_span="2"
|
||||||
|
android:textSize="25dp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:layout_marginBottom="@dimen/default_margin"
|
||||||
|
android:text="@string/checkVariable"/>
|
||||||
|
|
||||||
|
<TableLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/default_margin"
|
||||||
|
android:stretchColumns="1"
|
||||||
|
android:shrinkColumns="1" >
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:layout_marginTop="@dimen/default_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="@dimen/default_margin"
|
||||||
|
android:text="@string/VariableKey" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etVariableKeyTrigger"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow
|
||||||
|
android:layout_marginTop="@dimen/default_margin">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="@dimen/default_margin"
|
||||||
|
android:text="@string/variableValue" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/etVariableValueTrigger"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
|
</TableLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/default_margin"
|
||||||
|
android:text="@string/checkVariableExplanation" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bTriggerVariableSave"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/default_margin"
|
||||||
|
android:text="@string/save" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
@ -96,6 +96,7 @@
|
|||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:layout_marginVertical="@dimen/default_margin"
|
android:layout_marginVertical="@dimen/default_margin"
|
||||||
android:background="#aa000000" />
|
android:background="#aa000000" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -104,6 +105,14 @@
|
|||||||
android:text="@string/comparisonCaseInsensitive"
|
android:text="@string/comparisonCaseInsensitive"
|
||||||
android:layout_marginBottom="@dimen/default_margin"/>
|
android:layout_marginBottom="@dimen/default_margin"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="@string/regularExpressionsIfEquals"
|
||||||
|
android:layout_marginBottom="@dimen/default_margin"/>
|
||||||
|
|
||||||
<TableRow
|
<TableRow
|
||||||
android:layout_marginBottom="@dimen/activity_vertical_margin">
|
android:layout_marginBottom="@dimen/activity_vertical_margin">
|
||||||
|
|
||||||
|
@ -0,0 +1,75 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_margin="@dimen/default_margin" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_span="2"
|
||||||
|
android:textSize="25dp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:layout_marginBottom="@dimen/default_margin"
|
||||||
|
android:text="@string/subSystemState" />
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbSubSystemStateWifi"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:checked="true"
|
||||||
|
android:text="@string/wifi" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbSubSystemStateBluetooth"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/bluetooth" />
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_span="2"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:background="#aa000000" />
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbSubSystemStateEnabled"
|
||||||
|
android:checked="true"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/activated" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbSubSystemStateDisabled"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/deactivated" />
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/bSubSystemStateSave"
|
||||||
|
android:layout_marginTop="@dimen/default_margin"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/save" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
@ -58,8 +58,68 @@
|
|||||||
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_margin="10dp"
|
||||||
|
android:background="#aa000000" />
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="@dimen/default_margin"
|
||||||
|
android:text="@string/type" />
|
||||||
|
|
||||||
|
<RadioGroup>
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbTetheringTypeAny"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:checked="true"
|
||||||
|
android:text="@string/any" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbTetheringTypeWifi"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/wifi" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:visibility="gone"
|
||||||
|
android:id="@+id/rbTetheringTypeBluetooth"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/bluetooth" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbTetheringTypeUsb"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/usb" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbTetheringTypeCable"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/cable" />
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="@color/red"
|
||||||
|
android:layout_marginTop="@dimen/default_margin"
|
||||||
|
android:text="@string/tetheringBluetoothNotPossible" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/bTriggerTetheringSave"
|
android:id="@+id/bTriggerTetheringSave"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -47,6 +47,19 @@
|
|||||||
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvWifiTriggerNameLocationNotice"
|
||||||
|
android:layout_span="2"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:textColor="@color/red"
|
||||||
|
android:text="@string/locationRequiredToDetermineWifiName"
|
||||||
|
android:layout_marginVertical="@dimen/default_margin"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -62,6 +75,16 @@
|
|||||||
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/mayUseRegularExpressions"/>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
@ -80,8 +103,16 @@
|
|||||||
|
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvWifiTriggerDisconnectionHint"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginVertical="@dimen/default_margin"
|
||||||
|
android:textColor="@color/red"
|
||||||
|
android:text="@string/wifiTriggerDisconnectionHint" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btriggerWifiSave"
|
android:id="@+id/bTriggerWifiSave"
|
||||||
android:layout_marginTop="@dimen/default_margin"
|
android:layout_marginTop="@dimen/default_margin"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|