Compare commits
229 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
f1f3be56cb | |||
5856c93fc8 | |||
8201b1d4e4 | |||
ce9480d188 | |||
a69bbb1e05 | |||
16817e6f53 | |||
26ed906521 | |||
d1ca9ab56b | |||
9c76340f24 | |||
aca5572f40 | |||
944e165dd0 | |||
7f2fc4b5de | |||
cd163afc47 | |||
6179f0e9ae | |||
581cdafb87 | |||
9162bcb451 | |||
5272b56032 | |||
2361c758c9 | |||
f738e02b72 | |||
f5a3636222 | |||
bb1b3b0149 | |||
b35208b7aa | |||
b3ad72cc50 | |||
92e58149a7 | |||
c1809bd23c | |||
88a3ab8241 | |||
00f296d2d1 | |||
e84842361c | |||
efaf0ed270 | |||
7167f0c03d | |||
a9673e65b9 | |||
592abe5b0d | |||
dd7c3cb1d6 | |||
38665ccd92 | |||
c60347b990 | |||
1e7ccf5200 | |||
9b84b8dad7 | |||
a19c84ea51 | |||
3a14a56fd0 | |||
2dfc538343 | |||
67a58077cc | |||
df68f7ca5c | |||
ad18313284 | |||
29a93e0e43 | |||
a5d54c18d8 | |||
62f5ad0005 | |||
4eb7133d9d | |||
343cbba8f8 | |||
51caae0794 | |||
e39a2411ba | |||
98b49036a7 | |||
a7c4cc0965 | |||
5d67452486 | |||
7e12a0f3e5 | |||
5786c1bfd4 | |||
cf500c740e | |||
41efa7c11b | |||
7046cccabe | |||
bdbed3dbef | |||
3f36c4c6b3 | |||
52a10fe626 | |||
9fce7d987e | |||
d5ce04f80b | |||
62c97832a9 | |||
391edc59bf | |||
0d3a13e753 | |||
152b0c3c49 | |||
7ed04c7ae2 | |||
c688a4c460 | |||
5a09962cc9 | |||
0368b2a8c8 | |||
965bf55811 | |||
217f459833 | |||
13fd4c2aae | |||
195a60cfe0 | |||
76563eb89b | |||
4c9e61618b | |||
e719114166 | |||
7733d57435 | |||
481e4d1896 | |||
0bd64e4a53 | |||
5af59e1754 | |||
c569ab798c | |||
4e46878009 | |||
619f348a28 | |||
72ccdd99f9 | |||
c9d7399068 | |||
9bf353ea3a | |||
af90b566c8 | |||
0e51c577d5 | |||
275091f9d7 | |||
bc31c9a4c8 | |||
b02220609b | |||
da244d1bbe | |||
d402986dc3 | |||
85eee6c4da | |||
34883519e4 | |||
92e405d396 | |||
1a8ce579a7 | |||
5899dd86f5 | |||
9387e8bdb2 | |||
5ed024774e | |||
e76f9f69db | |||
0f1a12d28f | |||
abaa961d3a | |||
5f0eab5b30 | |||
92cb71ff2d | |||
71adc83b39 | |||
88f4d65b19 | |||
0c5b4d3874 | |||
d64ea8454e | |||
94f6418076 | |||
83ee19b4fa | |||
5ed6097ed6 | |||
7e9d03104c | |||
2e3e829abb | |||
06080bb456 | |||
a5fd23949d | |||
59c7a2d313 | |||
ec61a3ffa5 | |||
a0c4cb7b6f | |||
22899347a1 | |||
4b84a0c2f5 | |||
724192e80b | |||
e6a7e2c5b5 | |||
e010e3392f | |||
f0853b3a30 | |||
98185a79df | |||
246a02371a | |||
9b8ae2271b | |||
b2cd3cf17c | |||
cf4ec286ae | |||
12f44aca8b | |||
87edd595ba |
2
.gitignore
vendored
2
.gitignore
vendored
@ -145,7 +145,7 @@ fabric.properties
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/androidstudio
|
||||
|
||||
|
||||
output-metadata.json
|
||||
/app/app-release.apk
|
||||
Automation_settings.xml
|
||||
/app/googlePlayFlavor/
|
||||
|
@ -8,11 +8,11 @@ android {
|
||||
defaultConfig {
|
||||
applicationId "com.jens.automation2"
|
||||
minSdkVersion 16
|
||||
compileSdkVersion 29
|
||||
compileSdkVersion 31
|
||||
buildToolsVersion '29.0.2'
|
||||
useLibrary 'org.apache.http.legacy'
|
||||
versionCode 117
|
||||
versionName "1.7.3"
|
||||
versionCode 130
|
||||
versionName "1.7.14"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@ -28,11 +28,6 @@ android {
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
flavorDimensions "version"
|
||||
|
||||
productFlavors
|
||||
@ -41,7 +36,7 @@ android {
|
||||
{
|
||||
dimension "version"
|
||||
versionNameSuffix "-googlePlay"
|
||||
targetSdkVersion 30
|
||||
targetSdkVersion 31
|
||||
}
|
||||
|
||||
fdroidFlavor
|
||||
@ -57,9 +52,15 @@ android {
|
||||
targetSdkVersion 28
|
||||
}
|
||||
}
|
||||
lint {
|
||||
abortOnError false
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
namespace 'com.jens.automation2'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.jetbrains:annotations:15.0'
|
||||
googlePlayFlavorImplementation 'com.google.firebase:firebase-appindexing:20.0.0'
|
||||
googlePlayFlavorImplementation 'com.google.android.gms:play-services-location:18.0.0'
|
||||
|
||||
@ -71,9 +72,9 @@ dependencies {
|
||||
|
||||
//implementation "androidx.security:security-crypto:1.0.0"
|
||||
//implementation "androidx.security:security-identity-credential:1.0.0-alpha02"
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0'
|
||||
implementation 'com.google.android.material:material:1.3.0'
|
||||
testImplementation 'junit:junit:4.+'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
implementation 'androidx.appcompat:appcompat:1.4.2'
|
||||
implementation 'com.google.android.material:material:1.6.1'
|
||||
testImplementation 'junit:junit:4'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.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": 117,
|
||||
"versionName": "1.7.3-googlePlay",
|
||||
"outputFile": "app-googlePlayFlavor-release.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File"
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.jens.automation2">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<supports-screens
|
||||
android:anyDensity="true"
|
||||
@ -66,6 +65,11 @@
|
||||
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
|
||||
<uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/>
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
|
||||
<uses-permission android:name="android.permission.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
|
||||
android:name="android.hardware.telephony"
|
||||
@ -73,6 +77,12 @@
|
||||
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
|
||||
<uses-permission android:name="android.permission.SEND_SMS"/>
|
||||
|
||||
<queries>
|
||||
<intent>
|
||||
<action
|
||||
android:name="android.intent.action.TTS_SERVICE" />
|
||||
</intent>
|
||||
</queries>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@ -147,14 +157,29 @@
|
||||
<activity android:name=".ActivityDisplayLongMessage" />
|
||||
<activity android:name=".ActivityManageActionSendTextMessage" />
|
||||
<activity android:name=".ActivityManageActionPlaySound" />
|
||||
<activity android:name=".ActivityManageActionCloseNotification" />
|
||||
<activity android:name=".ActivityManageTriggerProfile" />
|
||||
<activity android:name=".ActivityManageTriggerTimeFrame" />
|
||||
<activity android:name=".ActivityMaintenance" />
|
||||
<activity android:name=".ActivityControlCenter" />
|
||||
<activity android:name=".ActivityManageTriggerPhoneCall" />
|
||||
<activity android:name=".ActivityManageTriggerBroadcast" />
|
||||
<activity android:name=".ActivityManageActionBrightnessSetting" />
|
||||
<activity android:name=".ActivityManageActionCreateNotification" />
|
||||
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
|
||||
<activity android:name=".ActivityHelp" />
|
||||
<activity android:name=".ActivityManageActionVibrate" />
|
||||
<activity android:name=".ActivityManageActionControlMedia" />
|
||||
<activity android:name=".ActivityManageActionSendBroadcast" />
|
||||
<activity android:name=".ActivityManageActionRunExecutable" />
|
||||
<activity android:name=".ActivityManageActionWifi" />
|
||||
<activity android:name=".ActivityManageTriggerTethering" />
|
||||
<activity android:name=".ActivityManageActionWakeLock" />
|
||||
<activity android:name=".ActivityManageTriggerSubSystemState" />
|
||||
<activity android:name=".ActivityManageActionMakePhoneCall" />
|
||||
<activity android:name=".ActivityManageActionSetVariable" />
|
||||
<activity android:name=".ActivityManageTriggerCheckVariable" />
|
||||
<activity android:name=".ActivityManageActionCopyToClipboard" />
|
||||
|
||||
<activity
|
||||
android:name=".ActivityMainTabLayout"
|
||||
android:launchMode="singleTask">
|
||||
|
@ -5,12 +5,14 @@ import static com.jens.automation2.Trigger.triggerParameter2Split;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.gms.location.DetectedActivity;
|
||||
import com.jens.automation2.receivers.ActivityDetectionReceiver;
|
||||
import com.jens.automation2.receivers.BroadcastListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@ -20,24 +22,23 @@ import java.util.List;
|
||||
|
||||
public class Rule implements Comparable<Rule>
|
||||
{
|
||||
private static ArrayList<Rule> ruleCollection = new ArrayList<Rule>();
|
||||
public static boolean isAnyRuleActive = false;
|
||||
|
||||
private static List<Rule> ruleRunHistory = new ArrayList<Rule>();
|
||||
protected static ArrayList<Rule> ruleCollection = new ArrayList<Rule>();
|
||||
|
||||
protected static List<Rule> ruleRunHistory = new ArrayList<Rule>();
|
||||
|
||||
public static List<Rule> getRuleRunHistory()
|
||||
{
|
||||
return ruleRunHistory;
|
||||
}
|
||||
|
||||
private ArrayList<Trigger> triggerSet;
|
||||
private ArrayList<Action> actionSet;
|
||||
private String name;
|
||||
private boolean ruleActive = true; // rules can be deactivated, so they won't fire if you don't want them temporarily
|
||||
private boolean ruleToggle = false; // rule will run again and do the opposite of its actions if applicable
|
||||
private Calendar lastExecution;
|
||||
|
||||
private static Date lastActivatedRuleActivationTime;
|
||||
protected ArrayList<Trigger> triggerSet;
|
||||
protected ArrayList<Action> actionSet;
|
||||
protected String name;
|
||||
protected boolean ruleActive = true; // rules can be deactivated, so they won't fire if you don't want them temporarily
|
||||
protected boolean ruleToggle = false; // rule will run again and do the opposite of its actions if applicable
|
||||
protected Calendar lastExecution;
|
||||
|
||||
protected static Date lastActivatedRuleActivationTime;
|
||||
|
||||
public Calendar getLastExecution()
|
||||
{
|
||||
@ -106,7 +107,7 @@ public class Rule implements Comparable<Rule>
|
||||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
this.name = name.trim();
|
||||
}
|
||||
|
||||
public static void readFromFile()
|
||||
@ -185,6 +186,7 @@ public class Rule implements Comparable<Rule>
|
||||
if(this.checkBeforeSaving(context, true))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Rule", "Changing rule: " + this.toString(), 3);
|
||||
|
||||
boolean returnValue = XmlFileInterface.writeFile();
|
||||
|
||||
if(returnValue)
|
||||
@ -233,20 +235,24 @@ public class Rule implements Comparable<Rule>
|
||||
}
|
||||
|
||||
if(!changeExistingRule)
|
||||
for(Rule rule : Rule.ruleCollection)
|
||||
if(rule.getName().equals(this.getName()))
|
||||
{
|
||||
for (Rule rule : Rule.ruleCollection)
|
||||
{
|
||||
if (rule.getName().equals(this.getName()))
|
||||
{
|
||||
Toast.makeText(context, context.getResources().getString(R.string.anotherRuleByThatName), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.getTriggerSet().size()==0)
|
||||
}
|
||||
}
|
||||
|
||||
if(this.getTriggerSet().size() == 0)
|
||||
{
|
||||
Toast.makeText(context, context.getResources().getString(R.string.pleaseSpecifiyTrigger), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.getActionSet().size()==0)
|
||||
if(this.getActionSet().size() == 0)
|
||||
{
|
||||
Toast.makeText(context, context.getResources().getString(R.string.pleaseSpecifiyAction), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
@ -312,19 +318,12 @@ public class Rule implements Comparable<Rule>
|
||||
switch(action.getAction())
|
||||
{
|
||||
case setAirplaneMode:
|
||||
return true;
|
||||
case setBluetooth:
|
||||
return true;
|
||||
case setDataConnection:
|
||||
return true;
|
||||
case setDisplayRotation:
|
||||
return true;
|
||||
case setUsbTethering:
|
||||
return true;
|
||||
case setWifi:
|
||||
return true;
|
||||
case setWifiTethering:
|
||||
return true;
|
||||
case setBluetoothTethering:
|
||||
return true;
|
||||
default:
|
||||
@ -341,6 +340,28 @@ public class Rule implements Comparable<Rule>
|
||||
{
|
||||
if (oneTrigger.hasStateNotAppliedSinceLastRuleExecution())
|
||||
return true;
|
||||
|
||||
/*
|
||||
Workaround for repetition in TimeFrame triggers
|
||||
*/
|
||||
if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.timeFrame))
|
||||
{
|
||||
if(oneTrigger.getTimeFrame().repetition > 0)
|
||||
{
|
||||
if(this.getLastExecution() != null)
|
||||
{
|
||||
Calendar now = Calendar.getInstance();
|
||||
if (this.getLastExecution().getTimeInMillis() + oneTrigger.getTimeFrame().getRepetition() * 1000 <= now.getTimeInMillis())
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.broadcastReceived))
|
||||
{
|
||||
return oneTrigger.getTriggerParameter() == BroadcastListener.getInstance().hasBroadcastOccurredSince(oneTrigger.getTriggerParameter2(), getLastExecution());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -351,7 +372,10 @@ public class Rule implements Comparable<Rule>
|
||||
if(applies(context))
|
||||
{
|
||||
if(hasNotAppliedSinceLastExecution())
|
||||
{
|
||||
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " applies and has flipped since its last execution.", 4);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " has not flipped since its last execution.", 4);
|
||||
}
|
||||
@ -376,11 +400,12 @@ public class Rule implements Comparable<Rule>
|
||||
if (!oneTrigger.applies(null, context))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format("Rule %1$s generally applies currently. Checking if it's really due, yet will be done separately.", this.getName()), 3);
|
||||
return true;
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3);
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 4);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -433,7 +458,7 @@ public class Rule implements Comparable<Rule>
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler(Miscellaneous.uncaughtExceptionHandler);
|
||||
|
||||
// without this line debugger will - for some reason - skip all breakpoints in this class
|
||||
// without this line the debugger will - for some reason - skip all breakpoints in this class
|
||||
if(android.os.Debug.isDebuggerConnected())
|
||||
android.os.Debug.waitForDebugger();
|
||||
|
||||
@ -441,7 +466,7 @@ public class Rule implements Comparable<Rule>
|
||||
Looper.prepare();
|
||||
|
||||
setLastExecution(Calendar.getInstance());
|
||||
wasActivated = activateInternally((AutomationService)params[0], (Boolean)params[1]);
|
||||
wasActivated = activateInternally((AutomationService)params[0]);
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -451,7 +476,9 @@ public class Rule implements Comparable<Rule>
|
||||
{
|
||||
AutomationService service = AutomationService.getInstance();
|
||||
service.speak(messages[0], false);
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
|
||||
if(Settings.showToasts)
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
|
||||
super.onProgressUpdate(messages);
|
||||
}
|
||||
@ -476,66 +503,57 @@ public class Rule implements Comparable<Rule>
|
||||
* Will activate the rule. Should be called by a separate execution thread
|
||||
* @param automationService
|
||||
*/
|
||||
protected boolean activateInternally(AutomationService automationService, boolean force)
|
||||
protected boolean activateInternally(AutomationService automationService)
|
||||
{
|
||||
boolean isActuallyToggable = isActuallyToggable();
|
||||
boolean isActuallyToggleable = isActuallyToggable();
|
||||
|
||||
boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
|
||||
boolean doToggle = ruleToggle && isActuallyToggable;
|
||||
boolean doToggle = ruleToggle && isActuallyToggleable;
|
||||
|
||||
//if(notLastActive || force || doToggle)
|
||||
// if(force || doToggle)
|
||||
// {
|
||||
String message;
|
||||
if(!doToggle)
|
||||
message = String.format(automationService.getResources().getString(R.string.ruleActivate), Rule.this.getName());
|
||||
else
|
||||
message = String.format(automationService.getResources().getString(R.string.ruleActivateToggle), Rule.this.getName());
|
||||
Miscellaneous.logEvent("i", "Rule", message, 2);
|
||||
// automationService.speak(message);
|
||||
// Toast.makeText(automationService, message, Toast.LENGTH_LONG).show();
|
||||
if(Settings.startNewThreadForRuleActivation)
|
||||
publishProgress(message);
|
||||
String message;
|
||||
if(!doToggle)
|
||||
message = String.format(automationService.getResources().getString(R.string.ruleActivate), Rule.this.getName());
|
||||
else
|
||||
message = String.format(automationService.getResources().getString(R.string.ruleActivateToggle), Rule.this.getName());
|
||||
|
||||
for(int i = 0; i< Rule.this.getActionSet().size(); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
Rule.this.getActionSet().get(i).run(automationService, doToggle);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "RuleExecution", "Error running action of rule " + Rule.this.getName() + ": " + Log.getStackTraceString(e), 1);
|
||||
}
|
||||
}
|
||||
Miscellaneous.logEvent("i", "Rule", message, 2);
|
||||
|
||||
// Keep log of last x rule activations (Settings)
|
||||
if(Settings.startNewThreadForRuleActivation)
|
||||
publishProgress(message);
|
||||
|
||||
for(int i = 0; i< Rule.this.getActionSet().size(); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
Rule.ruleRunHistory.add(0, Rule.this); // add at beginning for better visualization
|
||||
Rule.lastActivatedRuleActivationTime = new Date();
|
||||
|
||||
while(ruleRunHistory.size() > Settings.rulesThatHaveBeenRanHistorySize)
|
||||
ruleRunHistory.remove(ruleRunHistory.size()-1);
|
||||
String history = "";
|
||||
for(Rule rule : ruleRunHistory)
|
||||
history += rule.getName() + ", ";
|
||||
if(history.length() > 0)
|
||||
history = history.substring(0, history.length()-2);
|
||||
Miscellaneous.logEvent("i", "Rule history", "Most recent first: " + history, 4);
|
||||
Rule.this.getActionSet().get(i).run(automationService, doToggle);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "Rule history error", Log.getStackTraceString(e), 3);
|
||||
Miscellaneous.logEvent("e", "RuleExecution", "Error running action of rule " + Rule.this.getName() + ": " + Log.getStackTraceString(e), 1);
|
||||
}
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", "Rule", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleActivationComplete), Rule.this.getName()), 2);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Miscellaneous.logEvent("i", "Rule", "Request to activate rule " + Rule.this.getName() + ", but it is the last one that was activated. Won't do it again.", 3);
|
||||
// return false;
|
||||
// }
|
||||
// Keep log of last x rule activations (Settings)
|
||||
try
|
||||
{
|
||||
Rule.ruleRunHistory.add(0, Rule.this); // add at beginning for better visualization
|
||||
Rule.lastActivatedRuleActivationTime = new Date();
|
||||
|
||||
while(ruleRunHistory.size() > Settings.rulesThatHaveBeenRanHistorySize)
|
||||
ruleRunHistory.remove(ruleRunHistory.size()-1);
|
||||
String history = "";
|
||||
for(Rule rule : ruleRunHistory)
|
||||
history += rule.getName() + ", ";
|
||||
if(history.length() > 0)
|
||||
history = history.substring(0, history.length()-2);
|
||||
Miscellaneous.logEvent("i", "Rule history", "Most recent first: " + history, 4);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "Rule history error", Log.getStackTraceString(e), 3);
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", "Rule", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleActivationComplete), Rule.this.getName()), 2);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -544,7 +562,10 @@ public class Rule implements Comparable<Rule>
|
||||
public void activate(AutomationService automationService, boolean force)
|
||||
{
|
||||
ActivateRuleTask task = new ActivateRuleTask();
|
||||
task.execute(automationService, force);
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, automationService, force);
|
||||
else
|
||||
task.execute(automationService, force);
|
||||
}
|
||||
|
||||
public static ArrayList<Rule> findRuleCandidates(Trigger.Trigger_Enum triggerType)
|
||||
@ -553,13 +574,33 @@ public class Rule implements Comparable<Rule>
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
innerLoop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == triggerType)
|
||||
if(oneTrigger.getTriggerType().equals(triggerType))
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; // we don't need to check the other triggers in the same rule
|
||||
break innerLoop; // we don't need to check the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}
|
||||
|
||||
public static ArrayList<Rule> findRuleCandidates(Action.Action_Enum actionType)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Action oneAction : oneRule.getActionSet())
|
||||
{
|
||||
if(oneAction.getAction().equals(actionType))
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; // we don't need to check the other actions in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -608,186 +649,6 @@ public class Rule implements Comparable<Rule>
|
||||
return ruleCandidates;
|
||||
}
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByTimeFrame(TimeFrame searchTimeFrame, boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(int i=0; i<ruleCollection.size(); i++)
|
||||
{
|
||||
innerloop:
|
||||
for(int j=0; j<ruleCollection.get(i).getTriggerSet().size(); j++)
|
||||
{
|
||||
if(ruleCollection.get(i).getTriggerSet().get(j).getTriggerType() == Trigger.Trigger_Enum.timeFrame)
|
||||
{
|
||||
if(ruleCollection.get(i).getTriggerSet().get(j).getTimeFrame().equals(searchTimeFrame) && ruleCollection.get(i).getTriggerSet().get(j).getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(ruleCollection.get(i));
|
||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByTime(Time searchTime)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "Searching for rules with TimeFrame with time " + searchTime.toString() + ". RuleCollection-Size: " + String.valueOf(ruleCollection.size()), 3);;
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.timeFrame)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "Searching interval: " + oneTrigger.getTimeFrame().getTriggerTimeStart().toString() + " to " + oneTrigger.getTimeFrame().getTriggerTimeStop().toString(), 5);
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "interval start: " + String.valueOf(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime()), 5);
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "search time: " + String.valueOf(searchTime.getTime()), 5);
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "interval stop: " + String.valueOf(oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()), 5);
|
||||
|
||||
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() > oneTrigger.getTimeFrame().getTriggerTimeStop().getTime())
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Timeframe search", "Rule (" + oneRule.getName() + ") stretches over midnight.", 5);
|
||||
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() <= searchTime.getTime() || searchTime.getTime() <= oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()+20000) //add 20 seconds because of delay
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
else if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() <= searchTime.getTime() && searchTime.getTime() <= oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()+20000) //add 20 seconds because of delay
|
||||
{
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "Rule found (" + oneRule.getName() + ") with TimeFrame with time " + searchTime.toString(), 3);
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", "RuleSearch", String.valueOf(ruleCandidates.size()) + " Rule(s) found with TimeFrame with time " + searchTime.toString(), 3);
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByCharging(boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.charging)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByUsbHost(boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.usb_host_connection)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByAirplaneMode(boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.airplaneMode)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByRoaming(boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.roaming)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByPhoneCall(String direction)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.phoneCall)
|
||||
{
|
||||
String[] elements = oneTrigger.getTriggerParameter2().split(triggerParameter2Split);
|
||||
if(elements[1].equals(Trigger.triggerPhoneCallDirectionAny) || elements[1].equals(direction))
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
public static ArrayList<Rule> findRuleCandidatesByPoi(PointOfInterest searchPoi)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
@ -810,29 +671,6 @@ public class Rule implements Comparable<Rule>
|
||||
|
||||
return ruleCandidates;
|
||||
}
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByHeadphoneJack(boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.headsetPlugged)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
public static ArrayList<Rule> findRuleCandidatesByTriggerProfile(Profile profile)
|
||||
{
|
||||
@ -931,4 +769,15 @@ public class Rule implements Comparable<Rule>
|
||||
{
|
||||
return ActivityPermissions.havePermissionsForRule(this, Miscellaneous.getAnyContext());
|
||||
}
|
||||
}
|
||||
|
||||
public static Rule getByName(String ruleName)
|
||||
{
|
||||
for(Rule r : Rule.getRuleCollection())
|
||||
{
|
||||
if(r.getName().equals(ruleName))
|
||||
return r;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.jens.automation2">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<supports-screens
|
||||
android:anyDensity="true"
|
||||
@ -64,6 +63,11 @@
|
||||
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
|
||||
<uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/>
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
||||
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
|
||||
<uses-permission android:name="android.permission.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
|
||||
android:name="android.hardware.telephony"
|
||||
@ -71,6 +75,12 @@
|
||||
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
|
||||
<uses-permission android:name="android.permission.SEND_SMS"/>
|
||||
|
||||
<queries>
|
||||
<intent>
|
||||
<action
|
||||
android:name="android.intent.action.TTS_SERVICE" />
|
||||
</intent>
|
||||
</queries>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@ -145,14 +155,28 @@
|
||||
<activity android:name=".ActivityDisplayLongMessage" />
|
||||
<activity android:name=".ActivityManageActionSendTextMessage" />
|
||||
<activity android:name=".ActivityManageActionPlaySound" />
|
||||
<activity android:name=".ActivityManageActionCloseNotification" />
|
||||
<activity android:name=".ActivityManageTriggerProfile" />
|
||||
<activity android:name=".ActivityManageTriggerTimeFrame" />
|
||||
<activity android:name=".ActivityMaintenance" />
|
||||
<activity android:name=".ActivityControlCenter" />
|
||||
<activity android:name=".ActivityManageTriggerPhoneCall" />
|
||||
<activity android:name=".ActivityManageTriggerBroadcast" />
|
||||
<activity android:name=".ActivityManageActionBrightnessSetting" />
|
||||
<activity android:name=".ActivityManageActionCreateNotification" />
|
||||
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
|
||||
<activity android:name=".ActivityHelp" />
|
||||
<activity android:name=".ActivityManageActionVibrate" />
|
||||
<activity android:name=".ActivityManageActionControlMedia" />
|
||||
<activity android:name=".ActivityManageActionSendBroadcast" />
|
||||
<activity android:name=".ActivityManageActionRunExecutable" />
|
||||
<activity android:name=".ActivityManageActionWifi" />
|
||||
<activity android:name=".ActivityManageTriggerTethering" />
|
||||
<activity android:name=".ActivityManageActionWakeLock" />
|
||||
<activity android:name=".ActivityManageTriggerSubSystemState" />
|
||||
<activity android:name=".ActivityManageMakePhoneCall" />
|
||||
<activity android:name=".ActivityManageActionSetVariable" />
|
||||
<activity android:name=".ActivityManageTriggerCheckVariable" />
|
||||
<activity android:name=".ActivityManageActionCopyToClipboard" />
|
||||
<activity
|
||||
android:name=".ActivityMainTabLayout"
|
||||
android:launchMode="singleTask">
|
||||
|
@ -5,10 +5,12 @@ import static com.jens.automation2.Trigger.triggerParameter2Split;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.jens.automation2.receivers.BroadcastListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@ -17,24 +19,23 @@ import java.util.List;
|
||||
|
||||
public class Rule implements Comparable<Rule>
|
||||
{
|
||||
private static ArrayList<Rule> ruleCollection = new ArrayList<Rule>();
|
||||
public static boolean isAnyRuleActive = false;
|
||||
|
||||
private static List<Rule> ruleRunHistory = new ArrayList<Rule>();
|
||||
protected static ArrayList<Rule> ruleCollection = new ArrayList<Rule>();
|
||||
|
||||
protected static List<Rule> ruleRunHistory = new ArrayList<Rule>();
|
||||
|
||||
public static List<Rule> getRuleRunHistory()
|
||||
{
|
||||
return ruleRunHistory;
|
||||
}
|
||||
|
||||
private ArrayList<Trigger> triggerSet;
|
||||
private ArrayList<Action> actionSet;
|
||||
private String name;
|
||||
private boolean ruleActive = true; // rules can be deactivated, so they won't fire if you don't want them temporarily
|
||||
private boolean ruleToggle = false; // rule will run again and do the opposite of its actions if applicable
|
||||
private Calendar lastExecution;
|
||||
|
||||
private static Date lastActivatedRuleActivationTime;
|
||||
protected ArrayList<Trigger> triggerSet;
|
||||
protected ArrayList<Action> actionSet;
|
||||
protected String name;
|
||||
protected boolean ruleActive = true; // rules can be deactivated, so they won't fire if you don't want them temporarily
|
||||
protected boolean ruleToggle = false; // rule will run again and do the opposite of its actions if applicable
|
||||
protected Calendar lastExecution;
|
||||
|
||||
protected static Date lastActivatedRuleActivationTime;
|
||||
|
||||
public Calendar getLastExecution()
|
||||
{
|
||||
@ -45,7 +46,7 @@ public class Rule implements Comparable<Rule>
|
||||
{
|
||||
this.lastExecution = lastExecution;
|
||||
}
|
||||
|
||||
|
||||
public boolean isRuleToggle()
|
||||
{
|
||||
return ruleToggle;
|
||||
@ -103,7 +104,7 @@ public class Rule implements Comparable<Rule>
|
||||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
this.name = name.trim();
|
||||
}
|
||||
|
||||
public static void readFromFile()
|
||||
@ -182,6 +183,7 @@ public class Rule implements Comparable<Rule>
|
||||
if(this.checkBeforeSaving(context, true))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Rule", "Changing rule: " + this.toString(), 3);
|
||||
|
||||
boolean returnValue = XmlFileInterface.writeFile();
|
||||
|
||||
if(returnValue)
|
||||
@ -230,20 +232,24 @@ public class Rule implements Comparable<Rule>
|
||||
}
|
||||
|
||||
if(!changeExistingRule)
|
||||
for(Rule rule : Rule.ruleCollection)
|
||||
if(rule.getName().equals(this.getName()))
|
||||
{
|
||||
for (Rule rule : Rule.ruleCollection)
|
||||
{
|
||||
if (rule.getName().equals(this.getName()))
|
||||
{
|
||||
Toast.makeText(context, context.getResources().getString(R.string.anotherRuleByThatName), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.getTriggerSet().size()==0)
|
||||
}
|
||||
}
|
||||
|
||||
if(this.getTriggerSet().size() == 0)
|
||||
{
|
||||
Toast.makeText(context, context.getResources().getString(R.string.pleaseSpecifiyTrigger), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.getActionSet().size()==0)
|
||||
if(this.getActionSet().size() == 0)
|
||||
{
|
||||
Toast.makeText(context, context.getResources().getString(R.string.pleaseSpecifiyAction), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
@ -309,19 +315,12 @@ public class Rule implements Comparable<Rule>
|
||||
switch(action.getAction())
|
||||
{
|
||||
case setAirplaneMode:
|
||||
return true;
|
||||
case setBluetooth:
|
||||
return true;
|
||||
case setDataConnection:
|
||||
return true;
|
||||
case setDisplayRotation:
|
||||
return true;
|
||||
case setUsbTethering:
|
||||
return true;
|
||||
case setWifi:
|
||||
return true;
|
||||
case setWifiTethering:
|
||||
return true;
|
||||
case setBluetoothTethering:
|
||||
return true;
|
||||
default:
|
||||
@ -338,6 +337,19 @@ public class Rule implements Comparable<Rule>
|
||||
{
|
||||
if (oneTrigger.hasStateNotAppliedSinceLastRuleExecution())
|
||||
return true;
|
||||
|
||||
/*
|
||||
Workaround for repetition in TimeFrame triggers
|
||||
*/
|
||||
if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.timeFrame))
|
||||
{
|
||||
if(oneTrigger.getTimeFrame().repetition > 0)
|
||||
return true;
|
||||
}
|
||||
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.broadcastReceived))
|
||||
{
|
||||
return oneTrigger.getTriggerParameter() == BroadcastListener.getInstance().hasBroadcastOccurredSince(oneTrigger.getTriggerParameter2(), getLastExecution());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -348,7 +360,10 @@ public class Rule implements Comparable<Rule>
|
||||
if(applies(context))
|
||||
{
|
||||
if(hasNotAppliedSinceLastExecution())
|
||||
{
|
||||
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " applies and has flipped since its last execution.", 4);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " has not flipped since its last execution.", 4);
|
||||
}
|
||||
@ -373,11 +388,12 @@ public class Rule implements Comparable<Rule>
|
||||
if (!oneTrigger.applies(null, context))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format("Rule %1$s generally applies currently. Checking if it's really due, yet will be done separately.", this.getName()), 3);
|
||||
return true;
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3);
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 4);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -406,7 +422,7 @@ public class Rule implements Comparable<Rule>
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler(Miscellaneous.uncaughtExceptionHandler);
|
||||
|
||||
// without this line debugger will - for some reason - skip all breakpoints in this class
|
||||
// without this line the debugger will - for some reason - skip all breakpoints in this class
|
||||
if(android.os.Debug.isDebuggerConnected())
|
||||
android.os.Debug.waitForDebugger();
|
||||
|
||||
@ -414,7 +430,7 @@ public class Rule implements Comparable<Rule>
|
||||
Looper.prepare();
|
||||
|
||||
setLastExecution(Calendar.getInstance());
|
||||
wasActivated = activateInternally((AutomationService)params[0], (Boolean)params[1]);
|
||||
wasActivated = activateInternally((AutomationService)params[0]);
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -424,7 +440,9 @@ public class Rule implements Comparable<Rule>
|
||||
{
|
||||
AutomationService service = AutomationService.getInstance();
|
||||
service.speak(messages[0], false);
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
|
||||
if(Settings.showToasts)
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
|
||||
super.onProgressUpdate(messages);
|
||||
}
|
||||
@ -449,66 +467,57 @@ public class Rule implements Comparable<Rule>
|
||||
* Will activate the rule. Should be called by a separate execution thread
|
||||
* @param automationService
|
||||
*/
|
||||
protected boolean activateInternally(AutomationService automationService, boolean force)
|
||||
protected boolean activateInternally(AutomationService automationService)
|
||||
{
|
||||
boolean isActuallyToggable = isActuallyToggable();
|
||||
boolean isActuallyToggleable = isActuallyToggable();
|
||||
|
||||
boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
|
||||
boolean doToggle = ruleToggle && isActuallyToggable;
|
||||
boolean doToggle = ruleToggle && isActuallyToggleable;
|
||||
|
||||
//if(notLastActive || force || doToggle)
|
||||
// if(force || doToggle)
|
||||
// {
|
||||
String message;
|
||||
if(!doToggle)
|
||||
message = String.format(automationService.getResources().getString(R.string.ruleActivate), Rule.this.getName());
|
||||
else
|
||||
message = String.format(automationService.getResources().getString(R.string.ruleActivateToggle), Rule.this.getName());
|
||||
Miscellaneous.logEvent("i", "Rule", message, 2);
|
||||
// automationService.speak(message);
|
||||
// Toast.makeText(automationService, message, Toast.LENGTH_LONG).show();
|
||||
if(Settings.startNewThreadForRuleActivation)
|
||||
publishProgress(message);
|
||||
String message;
|
||||
if(!doToggle)
|
||||
message = String.format(automationService.getResources().getString(R.string.ruleActivate), Rule.this.getName());
|
||||
else
|
||||
message = String.format(automationService.getResources().getString(R.string.ruleActivateToggle), Rule.this.getName());
|
||||
|
||||
for(int i = 0; i< Rule.this.getActionSet().size(); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
Rule.this.getActionSet().get(i).run(automationService, doToggle);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "RuleExecution", "Error running action of rule " + Rule.this.getName() + ": " + Log.getStackTraceString(e), 1);
|
||||
}
|
||||
}
|
||||
Miscellaneous.logEvent("i", "Rule", message, 2);
|
||||
|
||||
// Keep log of last x rule activations (Settings)
|
||||
if(Settings.startNewThreadForRuleActivation)
|
||||
publishProgress(message);
|
||||
|
||||
for(int i = 0; i< Rule.this.getActionSet().size(); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
Rule.ruleRunHistory.add(0, Rule.this); // add at beginning for better visualization
|
||||
Rule.lastActivatedRuleActivationTime = new Date();
|
||||
|
||||
while(ruleRunHistory.size() > Settings.rulesThatHaveBeenRanHistorySize)
|
||||
ruleRunHistory.remove(ruleRunHistory.size()-1);
|
||||
String history = "";
|
||||
for(Rule rule : ruleRunHistory)
|
||||
history += rule.getName() + ", ";
|
||||
if(history.length() > 0)
|
||||
history = history.substring(0, history.length()-2);
|
||||
Miscellaneous.logEvent("i", "Rule history", "Most recent first: " + history, 4);
|
||||
Rule.this.getActionSet().get(i).run(automationService, doToggle);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "Rule history error", Log.getStackTraceString(e), 3);
|
||||
Miscellaneous.logEvent("e", "RuleExecution", "Error running action of rule " + Rule.this.getName() + ": " + Log.getStackTraceString(e), 1);
|
||||
}
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", "Rule", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleActivationComplete), Rule.this.getName()), 2);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Miscellaneous.logEvent("i", "Rule", "Request to activate rule " + Rule.this.getName() + ", but it is the last one that was activated. Won't do it again.", 3);
|
||||
// return false;
|
||||
// }
|
||||
// Keep log of last x rule activations (Settings)
|
||||
try
|
||||
{
|
||||
Rule.ruleRunHistory.add(0, Rule.this); // add at beginning for better visualization
|
||||
Rule.lastActivatedRuleActivationTime = new Date();
|
||||
|
||||
while(ruleRunHistory.size() > Settings.rulesThatHaveBeenRanHistorySize)
|
||||
ruleRunHistory.remove(ruleRunHistory.size()-1);
|
||||
String history = "";
|
||||
for(Rule rule : ruleRunHistory)
|
||||
history += rule.getName() + ", ";
|
||||
if(history.length() > 0)
|
||||
history = history.substring(0, history.length()-2);
|
||||
Miscellaneous.logEvent("i", "Rule history", "Most recent first: " + history, 4);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "Rule history error", Log.getStackTraceString(e), 3);
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", "Rule", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleActivationComplete), Rule.this.getName()), 2);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -517,7 +526,10 @@ public class Rule implements Comparable<Rule>
|
||||
public void activate(AutomationService automationService, boolean force)
|
||||
{
|
||||
ActivateRuleTask task = new ActivateRuleTask();
|
||||
task.execute(automationService, force);
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, automationService, force);
|
||||
else
|
||||
task.execute(automationService, force);
|
||||
}
|
||||
|
||||
public static ArrayList<Rule> findRuleCandidates(Trigger.Trigger_Enum triggerType)
|
||||
@ -526,13 +538,33 @@ public class Rule implements Comparable<Rule>
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
innerLoop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == triggerType)
|
||||
if(oneTrigger.getTriggerType().equals(triggerType))
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; // we don't need to check the other triggers in the same rule
|
||||
break innerLoop; // we don't need to check the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}
|
||||
|
||||
public static ArrayList<Rule> findRuleCandidates(Action.Action_Enum actionType)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Action oneAction : oneRule.getActionSet())
|
||||
{
|
||||
if(oneAction.getAction().equals(actionType))
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; // we don't need to check the other actions in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -581,186 +613,6 @@ public class Rule implements Comparable<Rule>
|
||||
return ruleCandidates;
|
||||
}
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByTimeFrame(TimeFrame searchTimeFrame, boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(int i=0; i<ruleCollection.size(); i++)
|
||||
{
|
||||
innerloop:
|
||||
for(int j=0; j<ruleCollection.get(i).getTriggerSet().size(); j++)
|
||||
{
|
||||
if(ruleCollection.get(i).getTriggerSet().get(j).getTriggerType() == Trigger.Trigger_Enum.timeFrame)
|
||||
{
|
||||
if(ruleCollection.get(i).getTriggerSet().get(j).getTimeFrame().equals(searchTimeFrame) && ruleCollection.get(i).getTriggerSet().get(j).getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(ruleCollection.get(i));
|
||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByTime(Time searchTime)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "Searching for rules with TimeFrame with time " + searchTime.toString() + ". RuleCollection-Size: " + String.valueOf(ruleCollection.size()), 3);;
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.timeFrame)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "Searching interval: " + oneTrigger.getTimeFrame().getTriggerTimeStart().toString() + " to " + oneTrigger.getTimeFrame().getTriggerTimeStop().toString(), 5);
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "interval start: " + String.valueOf(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime()), 5);
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "search time: " + String.valueOf(searchTime.getTime()), 5);
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "interval stop: " + String.valueOf(oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()), 5);
|
||||
|
||||
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() > oneTrigger.getTimeFrame().getTriggerTimeStop().getTime())
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Timeframe search", "Rule (" + oneRule.getName() + ") stretches over midnight.", 5);
|
||||
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() <= searchTime.getTime() || searchTime.getTime() <= oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()+20000) //add 20 seconds because of delay
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
else if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() <= searchTime.getTime() && searchTime.getTime() <= oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()+20000) //add 20 seconds because of delay
|
||||
{
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "Rule found (" + oneRule.getName() + ") with TimeFrame with time " + searchTime.toString(), 3);
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", "RuleSearch", String.valueOf(ruleCandidates.size()) + " Rule(s) found with TimeFrame with time " + searchTime.toString(), 3);
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByCharging(boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.charging)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByUsbHost(boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.usb_host_connection)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByAirplaneMode(boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.airplaneMode)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByRoaming(boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.roaming)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByPhoneCall(String direction)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.phoneCall)
|
||||
{
|
||||
String[] elements = oneTrigger.getTriggerParameter2().split(triggerParameter2Split);
|
||||
if(elements[1].equals(Trigger.triggerPhoneCallDirectionAny) || elements[1].equals(direction))
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
public static ArrayList<Rule> findRuleCandidatesByPoi(PointOfInterest searchPoi)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
@ -783,29 +635,6 @@ public class Rule implements Comparable<Rule>
|
||||
|
||||
return ruleCandidates;
|
||||
}
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByHeadphoneJack(boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.headsetPlugged)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
public static ArrayList<Rule> findRuleCandidatesByTriggerProfile(Profile profile)
|
||||
{
|
||||
@ -904,4 +733,15 @@ public class Rule implements Comparable<Rule>
|
||||
{
|
||||
return ActivityPermissions.havePermissionsForRule(this, Miscellaneous.getAnyContext());
|
||||
}
|
||||
|
||||
public static Rule getByName(String ruleName)
|
||||
{
|
||||
for(Rule r : Rule.getRuleCollection())
|
||||
{
|
||||
if(r.getName().equals(ruleName))
|
||||
return r;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.jens.automation2">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<supports-screens
|
||||
android:anyDensity="true"
|
||||
@ -65,6 +64,8 @@
|
||||
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
|
||||
<uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/>
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.READ_CALL_LOG" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@ -112,6 +113,7 @@
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
<receiver android:name=".receivers.PackageReplacedReceiver"
|
||||
android:exported="true"
|
||||
android:enabled="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
|
||||
@ -123,6 +125,7 @@
|
||||
|
||||
<receiver
|
||||
android:name=".DeviceAdmin"
|
||||
android:exported="true"
|
||||
android:description="@string/app_name"
|
||||
android:label="@string/app_name"
|
||||
android:permission= "android.permission.BIND_DEVICE_ADMIN" >
|
||||
@ -139,16 +142,30 @@
|
||||
<activity android:name=".ActivityDisplayLongMessage" />
|
||||
<activity android:name=".ActivityManageActionSendTextMessage" />
|
||||
<activity android:name=".ActivityManageActionPlaySound" />
|
||||
<activity android:name=".ActivityManageActionCloseNotification" />
|
||||
<activity android:name=".ActivityManageTriggerProfile" />
|
||||
<activity android:name=".ActivityManageTriggerTimeFrame" />
|
||||
<activity android:name=".ActivityMaintenance" />
|
||||
<activity android:name=".ActivityControlCenter" />
|
||||
<activity android:name=".ActivityManageTriggerPhoneCall" />
|
||||
<activity android:name=".ActivityManageTriggerBroadcast" />
|
||||
<activity android:name=".ActivityManageActionBrightnessSetting" />
|
||||
<activity android:name=".ActivityManageActionCreateNotification" />
|
||||
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
|
||||
<activity android:name=".ActivityHelp" />
|
||||
<activity android:name=".ActivityManageActionVibrate" />
|
||||
<activity android:name=".ActivityManageActionControlMedia" />
|
||||
<activity android:name=".ActivityManageActionSendBroadcast" />
|
||||
<activity android:name=".ActivityManageActionRunExecutable" />
|
||||
<activity android:name=".ActivityManageActionWifi" />
|
||||
<activity android:name=".ActivityManageTriggerTethering" />
|
||||
<activity android:name=".ActivityManageActionWakeLock" />
|
||||
<activity android:name=".ActivityManageTriggerSubSystemState" />
|
||||
<activity android:name=".ActivityManageActionSetVariable" />
|
||||
<activity android:name=".ActivityManageTriggerCheckVariable" />
|
||||
<activity android:name=".ActivityManageActionCopyToClipboard" />
|
||||
<activity
|
||||
android:name=".ActivityMainTabLayout"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
@ -197,6 +214,7 @@
|
||||
|
||||
<service
|
||||
android:name=".receivers.NotificationListener"
|
||||
android:exported="true"
|
||||
android:label="@string/app_name"
|
||||
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" >
|
||||
<intent-filter>
|
||||
|
@ -5,12 +5,14 @@ import static com.jens.automation2.Trigger.triggerParameter2Split;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.gms.location.DetectedActivity;
|
||||
import com.jens.automation2.receivers.ActivityDetectionReceiver;
|
||||
import com.jens.automation2.receivers.BroadcastListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@ -20,24 +22,23 @@ import java.util.List;
|
||||
|
||||
public class Rule implements Comparable<Rule>
|
||||
{
|
||||
private static ArrayList<Rule> ruleCollection = new ArrayList<Rule>();
|
||||
public static boolean isAnyRuleActive = false;
|
||||
|
||||
private static List<Rule> ruleRunHistory = new ArrayList<Rule>();
|
||||
protected static ArrayList<Rule> ruleCollection = new ArrayList<Rule>();
|
||||
|
||||
protected static List<Rule> ruleRunHistory = new ArrayList<Rule>();
|
||||
|
||||
public static List<Rule> getRuleRunHistory()
|
||||
{
|
||||
return ruleRunHistory;
|
||||
}
|
||||
|
||||
private ArrayList<Trigger> triggerSet;
|
||||
private ArrayList<Action> actionSet;
|
||||
private String name;
|
||||
private boolean ruleActive = true; // rules can be deactivated, so they won't fire if you don't want them temporarily
|
||||
private boolean ruleToggle = false; // rule will run again and do the opposite of its actions if applicable
|
||||
private Calendar lastExecution;
|
||||
|
||||
private static Date lastActivatedRuleActivationTime;
|
||||
protected ArrayList<Trigger> triggerSet;
|
||||
protected ArrayList<Action> actionSet;
|
||||
protected String name;
|
||||
protected boolean ruleActive = true; // rules can be deactivated, so they won't fire if you don't want them temporarily
|
||||
protected boolean ruleToggle = false; // rule will run again and do the opposite of its actions if applicable
|
||||
protected Calendar lastExecution;
|
||||
|
||||
protected static Date lastActivatedRuleActivationTime;
|
||||
|
||||
public Calendar getLastExecution()
|
||||
{
|
||||
@ -106,7 +107,7 @@ public class Rule implements Comparable<Rule>
|
||||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
this.name = name.trim();
|
||||
}
|
||||
|
||||
public static void readFromFile()
|
||||
@ -185,6 +186,7 @@ public class Rule implements Comparable<Rule>
|
||||
if(this.checkBeforeSaving(context, true))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Rule", "Changing rule: " + this.toString(), 3);
|
||||
|
||||
boolean returnValue = XmlFileInterface.writeFile();
|
||||
|
||||
if(returnValue)
|
||||
@ -233,20 +235,24 @@ public class Rule implements Comparable<Rule>
|
||||
}
|
||||
|
||||
if(!changeExistingRule)
|
||||
for(Rule rule : Rule.ruleCollection)
|
||||
if(rule.getName().equals(this.getName()))
|
||||
{
|
||||
for (Rule rule : Rule.ruleCollection)
|
||||
{
|
||||
if (rule.getName().equals(this.getName()))
|
||||
{
|
||||
Toast.makeText(context, context.getResources().getString(R.string.anotherRuleByThatName), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.getTriggerSet().size()==0)
|
||||
}
|
||||
}
|
||||
|
||||
if(this.getTriggerSet().size() == 0)
|
||||
{
|
||||
Toast.makeText(context, context.getResources().getString(R.string.pleaseSpecifiyTrigger), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(this.getActionSet().size()==0)
|
||||
if(this.getActionSet().size() == 0)
|
||||
{
|
||||
Toast.makeText(context, context.getResources().getString(R.string.pleaseSpecifiyAction), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
@ -312,19 +318,12 @@ public class Rule implements Comparable<Rule>
|
||||
switch(action.getAction())
|
||||
{
|
||||
case setAirplaneMode:
|
||||
return true;
|
||||
case setBluetooth:
|
||||
return true;
|
||||
case setDataConnection:
|
||||
return true;
|
||||
case setDisplayRotation:
|
||||
return true;
|
||||
case setUsbTethering:
|
||||
return true;
|
||||
case setWifi:
|
||||
return true;
|
||||
case setWifiTethering:
|
||||
return true;
|
||||
case setBluetoothTethering:
|
||||
return true;
|
||||
default:
|
||||
@ -341,6 +340,19 @@ public class Rule implements Comparable<Rule>
|
||||
{
|
||||
if (oneTrigger.hasStateNotAppliedSinceLastRuleExecution())
|
||||
return true;
|
||||
|
||||
/*
|
||||
Workaround for repetition in TimeFrame triggers
|
||||
*/
|
||||
if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.timeFrame))
|
||||
{
|
||||
if(oneTrigger.getTimeFrame().repetition > 0)
|
||||
return true;
|
||||
}
|
||||
else if(oneTrigger.getTriggerType().equals(Trigger.Trigger_Enum.broadcastReceived))
|
||||
{
|
||||
return oneTrigger.getTriggerParameter() == BroadcastListener.getInstance().hasBroadcastOccurredSince(oneTrigger.getTriggerParameter2(), getLastExecution());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -351,7 +363,10 @@ public class Rule implements Comparable<Rule>
|
||||
if(applies(context))
|
||||
{
|
||||
if(hasNotAppliedSinceLastExecution())
|
||||
{
|
||||
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " applies and has flipped since its last execution.", 4);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " has not flipped since its last execution.", 4);
|
||||
}
|
||||
@ -376,11 +391,12 @@ public class Rule implements Comparable<Rule>
|
||||
if (!oneTrigger.applies(null, context))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format("Rule %1$s generally applies currently. Checking if it's really due, yet will be done separately.", this.getName()), 3);
|
||||
return true;
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3);
|
||||
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 4);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -433,7 +449,7 @@ public class Rule implements Comparable<Rule>
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler(Miscellaneous.uncaughtExceptionHandler);
|
||||
|
||||
// without this line debugger will - for some reason - skip all breakpoints in this class
|
||||
// without this line the debugger will - for some reason - skip all breakpoints in this class
|
||||
if(android.os.Debug.isDebuggerConnected())
|
||||
android.os.Debug.waitForDebugger();
|
||||
|
||||
@ -441,7 +457,7 @@ public class Rule implements Comparable<Rule>
|
||||
Looper.prepare();
|
||||
|
||||
setLastExecution(Calendar.getInstance());
|
||||
wasActivated = activateInternally((AutomationService)params[0], (Boolean)params[1]);
|
||||
wasActivated = activateInternally((AutomationService)params[0]);
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -451,7 +467,9 @@ public class Rule implements Comparable<Rule>
|
||||
{
|
||||
AutomationService service = AutomationService.getInstance();
|
||||
service.speak(messages[0], false);
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
|
||||
if(Settings.showToasts)
|
||||
Toast.makeText(service, messages[0], Toast.LENGTH_LONG).show();
|
||||
|
||||
super.onProgressUpdate(messages);
|
||||
}
|
||||
@ -476,66 +494,57 @@ public class Rule implements Comparable<Rule>
|
||||
* Will activate the rule. Should be called by a separate execution thread
|
||||
* @param automationService
|
||||
*/
|
||||
protected boolean activateInternally(AutomationService automationService, boolean force)
|
||||
protected boolean activateInternally(AutomationService automationService)
|
||||
{
|
||||
boolean isActuallyToggable = isActuallyToggable();
|
||||
boolean isActuallyToggleable = isActuallyToggable();
|
||||
|
||||
boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
|
||||
boolean doToggle = ruleToggle && isActuallyToggable;
|
||||
boolean doToggle = ruleToggle && isActuallyToggleable;
|
||||
|
||||
//if(notLastActive || force || doToggle)
|
||||
// if(force || doToggle)
|
||||
// {
|
||||
String message;
|
||||
if(!doToggle)
|
||||
message = String.format(automationService.getResources().getString(R.string.ruleActivate), Rule.this.getName());
|
||||
else
|
||||
message = String.format(automationService.getResources().getString(R.string.ruleActivateToggle), Rule.this.getName());
|
||||
Miscellaneous.logEvent("i", "Rule", message, 2);
|
||||
// automationService.speak(message);
|
||||
// Toast.makeText(automationService, message, Toast.LENGTH_LONG).show();
|
||||
if(Settings.startNewThreadForRuleActivation)
|
||||
publishProgress(message);
|
||||
String message;
|
||||
if(!doToggle)
|
||||
message = String.format(automationService.getResources().getString(R.string.ruleActivate), Rule.this.getName());
|
||||
else
|
||||
message = String.format(automationService.getResources().getString(R.string.ruleActivateToggle), Rule.this.getName());
|
||||
|
||||
for(int i = 0; i< Rule.this.getActionSet().size(); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
Rule.this.getActionSet().get(i).run(automationService, doToggle);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "RuleExecution", "Error running action of rule " + Rule.this.getName() + ": " + Log.getStackTraceString(e), 1);
|
||||
}
|
||||
}
|
||||
Miscellaneous.logEvent("i", "Rule", message, 2);
|
||||
|
||||
// Keep log of last x rule activations (Settings)
|
||||
if(Settings.startNewThreadForRuleActivation)
|
||||
publishProgress(message);
|
||||
|
||||
for(int i = 0; i< Rule.this.getActionSet().size(); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
Rule.ruleRunHistory.add(0, Rule.this); // add at beginning for better visualization
|
||||
Rule.lastActivatedRuleActivationTime = new Date();
|
||||
|
||||
while(ruleRunHistory.size() > Settings.rulesThatHaveBeenRanHistorySize)
|
||||
ruleRunHistory.remove(ruleRunHistory.size()-1);
|
||||
String history = "";
|
||||
for(Rule rule : ruleRunHistory)
|
||||
history += rule.getName() + ", ";
|
||||
if(history.length() > 0)
|
||||
history = history.substring(0, history.length()-2);
|
||||
Miscellaneous.logEvent("i", "Rule history", "Most recent first: " + history, 4);
|
||||
Rule.this.getActionSet().get(i).run(automationService, doToggle);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "Rule history error", Log.getStackTraceString(e), 3);
|
||||
Miscellaneous.logEvent("e", "RuleExecution", "Error running action of rule " + Rule.this.getName() + ": " + Log.getStackTraceString(e), 1);
|
||||
}
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", "Rule", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleActivationComplete), Rule.this.getName()), 2);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Miscellaneous.logEvent("i", "Rule", "Request to activate rule " + Rule.this.getName() + ", but it is the last one that was activated. Won't do it again.", 3);
|
||||
// return false;
|
||||
// }
|
||||
// Keep log of last x rule activations (Settings)
|
||||
try
|
||||
{
|
||||
Rule.ruleRunHistory.add(0, Rule.this); // add at beginning for better visualization
|
||||
Rule.lastActivatedRuleActivationTime = new Date();
|
||||
|
||||
while(ruleRunHistory.size() > Settings.rulesThatHaveBeenRanHistorySize)
|
||||
ruleRunHistory.remove(ruleRunHistory.size()-1);
|
||||
String history = "";
|
||||
for(Rule rule : ruleRunHistory)
|
||||
history += rule.getName() + ", ";
|
||||
if(history.length() > 0)
|
||||
history = history.substring(0, history.length()-2);
|
||||
Miscellaneous.logEvent("i", "Rule history", "Most recent first: " + history, 4);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "Rule history error", Log.getStackTraceString(e), 3);
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", "Rule", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleActivationComplete), Rule.this.getName()), 2);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -544,7 +553,10 @@ public class Rule implements Comparable<Rule>
|
||||
public void activate(AutomationService automationService, boolean force)
|
||||
{
|
||||
ActivateRuleTask task = new ActivateRuleTask();
|
||||
task.execute(automationService, force);
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
|
||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, automationService, force);
|
||||
else
|
||||
task.execute(automationService, force);
|
||||
}
|
||||
|
||||
public static ArrayList<Rule> findRuleCandidates(Trigger.Trigger_Enum triggerType)
|
||||
@ -553,13 +565,33 @@ public class Rule implements Comparable<Rule>
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
innerLoop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == triggerType)
|
||||
if(oneTrigger.getTriggerType().equals(triggerType))
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; // we don't need to check the other triggers in the same rule
|
||||
break innerLoop; // we don't need to check the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}
|
||||
|
||||
public static ArrayList<Rule> findRuleCandidates(Action.Action_Enum actionType)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Action oneAction : oneRule.getActionSet())
|
||||
{
|
||||
if(oneAction.getAction().equals(actionType))
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; // we don't need to check the other actions in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -608,186 +640,6 @@ public class Rule implements Comparable<Rule>
|
||||
return ruleCandidates;
|
||||
}
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByTimeFrame(TimeFrame searchTimeFrame, boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(int i=0; i<ruleCollection.size(); i++)
|
||||
{
|
||||
innerloop:
|
||||
for(int j=0; j<ruleCollection.get(i).getTriggerSet().size(); j++)
|
||||
{
|
||||
if(ruleCollection.get(i).getTriggerSet().get(j).getTriggerType() == Trigger.Trigger_Enum.timeFrame)
|
||||
{
|
||||
if(ruleCollection.get(i).getTriggerSet().get(j).getTimeFrame().equals(searchTimeFrame) && ruleCollection.get(i).getTriggerSet().get(j).getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(ruleCollection.get(i));
|
||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByTime(Time searchTime)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "Searching for rules with TimeFrame with time " + searchTime.toString() + ". RuleCollection-Size: " + String.valueOf(ruleCollection.size()), 3);;
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.timeFrame)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "Searching interval: " + oneTrigger.getTimeFrame().getTriggerTimeStart().toString() + " to " + oneTrigger.getTimeFrame().getTriggerTimeStop().toString(), 5);
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "interval start: " + String.valueOf(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime()), 5);
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "search time: " + String.valueOf(searchTime.getTime()), 5);
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "interval stop: " + String.valueOf(oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()), 5);
|
||||
|
||||
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() > oneTrigger.getTimeFrame().getTriggerTimeStop().getTime())
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Timeframe search", "Rule (" + oneRule.getName() + ") stretches over midnight.", 5);
|
||||
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() <= searchTime.getTime() || searchTime.getTime() <= oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()+20000) //add 20 seconds because of delay
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
else if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() <= searchTime.getTime() && searchTime.getTime() <= oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()+20000) //add 20 seconds because of delay
|
||||
{
|
||||
Miscellaneous.logEvent("i", "RuleSearch", "Rule found (" + oneRule.getName() + ") with TimeFrame with time " + searchTime.toString(), 3);
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", "RuleSearch", String.valueOf(ruleCandidates.size()) + " Rule(s) found with TimeFrame with time " + searchTime.toString(), 3);
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByCharging(boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.charging)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByUsbHost(boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.usb_host_connection)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByAirplaneMode(boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.airplaneMode)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByRoaming(boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.roaming)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByPhoneCall(String direction)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.phoneCall)
|
||||
{
|
||||
String[] elements = oneTrigger.getTriggerParameter2().split(triggerParameter2Split);
|
||||
if(elements[1].equals(Trigger.triggerPhoneCallDirectionAny) || elements[1].equals(direction))
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
public static ArrayList<Rule> findRuleCandidatesByPoi(PointOfInterest searchPoi)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
@ -810,29 +662,6 @@ public class Rule implements Comparable<Rule>
|
||||
|
||||
return ruleCandidates;
|
||||
}
|
||||
|
||||
/*public static ArrayList<Rule> findRuleCandidatesByHeadphoneJack(boolean triggerParameter)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = new ArrayList<Rule>();
|
||||
|
||||
for(Rule oneRule : ruleCollection)
|
||||
{
|
||||
innerloop:
|
||||
for(Trigger oneTrigger : oneRule.getTriggerSet())
|
||||
{
|
||||
if(oneTrigger.getTriggerType() == Trigger.Trigger_Enum.headsetPlugged)
|
||||
{
|
||||
if(oneTrigger.getTriggerParameter() == triggerParameter)
|
||||
{
|
||||
ruleCandidates.add(oneRule);
|
||||
break innerloop; //we don't need to search the other triggers in the same rule
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ruleCandidates;
|
||||
}*/
|
||||
|
||||
public static ArrayList<Rule> findRuleCandidatesByTriggerProfile(Profile profile)
|
||||
{
|
||||
@ -931,4 +760,15 @@ public class Rule implements Comparable<Rule>
|
||||
{
|
||||
return ActivityPermissions.havePermissionsForRule(this, Miscellaneous.getAnyContext());
|
||||
}
|
||||
|
||||
public static Rule getByName(String ruleName)
|
||||
{
|
||||
for(Rule r : Rule.getRuleCollection())
|
||||
{
|
||||
if(r.getName().equals(ruleName))
|
||||
return r;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.jens.automation2">
|
||||
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
</manifest>
|
@ -2,6 +2,7 @@ package com.jens.automation2;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -17,102 +18,133 @@ public class Action
|
||||
Rule parentRule = null;
|
||||
|
||||
public static final String actionParameter2Split = "ap2split";
|
||||
public static final String intentPairSeperator = "intPairSplit";
|
||||
public static final String intentPairSeparator = "intPairSplit";
|
||||
public static final String vibrateSeparator = ",";
|
||||
|
||||
public enum Action_Enum {
|
||||
setWifi,
|
||||
setBluetooth,
|
||||
setUsbTethering,
|
||||
setWifiTethering,
|
||||
setBluetoothTethering,
|
||||
setDisplayRotation,
|
||||
turnWifiOn,turnWifiOff,
|
||||
turnBluetoothOn,turnBluetoothOff,
|
||||
triggerUrl,
|
||||
changeSoundProfile,
|
||||
turnUsbTetheringOn,turnUsbTetheringOff,
|
||||
turnWifiTetheringOn,turnWifiTetheringOff,
|
||||
enableScreenRotation,disableScreenRotation,
|
||||
startOtherActivity,
|
||||
waitBeforeNextAction,
|
||||
turnScreenOnOrOff,
|
||||
setAirplaneMode,
|
||||
setDataConnection,
|
||||
speakText,
|
||||
playMusic,
|
||||
setScreenBrightness,
|
||||
playSound,
|
||||
vibrate,
|
||||
sendTextMessage;
|
||||
|
||||
public String getFullName(Context context)
|
||||
{
|
||||
switch(this)
|
||||
{
|
||||
case setWifi:
|
||||
return context.getResources().getString(R.string.actionSetWifi);
|
||||
case setBluetooth:
|
||||
return context.getResources().getString(R.string.actionSetBluetooth);
|
||||
case setWifiTethering:
|
||||
return context.getResources().getString(R.string.actionSetWifiTethering);
|
||||
case setBluetoothTethering:
|
||||
return context.getResources().getString(R.string.actionSetBluetoothTethering);
|
||||
case setUsbTethering:
|
||||
return context.getResources().getString(R.string.actionSetUsbTethering);
|
||||
case setDisplayRotation:
|
||||
return context.getResources().getString(R.string.actionSetDisplayRotation);
|
||||
case turnWifiOn:
|
||||
return context.getResources().getString(R.string.actionTurnWifiOn);
|
||||
case turnWifiOff:
|
||||
return context.getResources().getString(R.string.actionTurnWifiOff);
|
||||
case turnBluetoothOn:
|
||||
return context.getResources().getString(R.string.actionTurnBluetoothOn);
|
||||
case turnBluetoothOff:
|
||||
return context.getResources().getString(R.string.actionTurnBluetoothOff);
|
||||
case triggerUrl:
|
||||
return context.getResources().getString(R.string.actionTriggerUrl);
|
||||
case changeSoundProfile:
|
||||
return context.getResources().getString(R.string.actionChangeSoundProfile);
|
||||
case turnUsbTetheringOn:
|
||||
return context.getResources().getString(R.string.actionTurnUsbTetheringOn);
|
||||
case turnUsbTetheringOff:
|
||||
return context.getResources().getString(R.string.actionTurnUsbTetheringOff);
|
||||
case turnWifiTetheringOn:
|
||||
return context.getResources().getString(R.string.actionTurnWifiTetheringOn);
|
||||
case turnWifiTetheringOff:
|
||||
return context.getResources().getString(R.string.actionTurnWifiTetheringOff);
|
||||
case enableScreenRotation:
|
||||
return context.getResources().getString(R.string.actionEnableScreenRotation);
|
||||
case disableScreenRotation:
|
||||
return context.getResources().getString(R.string.actionDisableScreenRotation);
|
||||
case startOtherActivity:
|
||||
return context.getResources().getString(R.string.startOtherActivity);
|
||||
case waitBeforeNextAction:
|
||||
return context.getResources().getString(R.string.waitBeforeNextAction);
|
||||
case turnScreenOnOrOff:
|
||||
return context.getResources().getString(R.string.turnScreenOnOrOff);
|
||||
case vibrate:
|
||||
return context.getResources().getString(R.string.vibrate);
|
||||
case setAirplaneMode:
|
||||
return context.getResources().getString(R.string.airplaneMode);
|
||||
case setDataConnection:
|
||||
return context.getResources().getString(R.string.actionDataConnection);
|
||||
case speakText:
|
||||
return context.getResources().getString(R.string.actionSpeakText);
|
||||
case playMusic:
|
||||
return context.getResources().getString(R.string.actionPlayMusic);
|
||||
case playSound:
|
||||
return context.getResources().getString(R.string.playSound);
|
||||
case sendTextMessage:
|
||||
return context.getResources().getString(R.string.sendTextMessage);
|
||||
case setScreenBrightness:
|
||||
return context.getResources().getString(R.string.setScreenBrightness);
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
};
|
||||
public enum Action_Enum
|
||||
{
|
||||
setWifi,
|
||||
setBluetooth,
|
||||
setUsbTethering,
|
||||
setWifiTethering,
|
||||
setBluetoothTethering,
|
||||
setDisplayRotation,
|
||||
turnWifiOn,turnWifiOff,
|
||||
turnBluetoothOn,turnBluetoothOff,
|
||||
triggerUrl,
|
||||
changeSoundProfile,
|
||||
turnUsbTetheringOn,turnUsbTetheringOff,
|
||||
turnWifiTetheringOn,turnWifiTetheringOff,
|
||||
enableScreenRotation,disableScreenRotation,
|
||||
startOtherActivity,
|
||||
waitBeforeNextAction,
|
||||
turnScreenOnOrOff,
|
||||
setAirplaneMode,
|
||||
setDataConnection,
|
||||
speakText,
|
||||
playMusic,
|
||||
controlMediaPlayback,
|
||||
setScreenBrightness,
|
||||
playSound,
|
||||
vibrate,
|
||||
createNotification,
|
||||
closeNotification,
|
||||
sendBroadcast,
|
||||
runExecutable,
|
||||
wakelock,
|
||||
setVariable,
|
||||
startPhoneCall,
|
||||
stopPhoneCall,
|
||||
copyToClipboard,
|
||||
sendTextMessage;
|
||||
|
||||
public String getFullName(Context context)
|
||||
{
|
||||
switch(this)
|
||||
{
|
||||
case setWifi:
|
||||
return context.getResources().getString(R.string.actionSetWifi);
|
||||
case setBluetooth:
|
||||
return context.getResources().getString(R.string.actionSetBluetooth);
|
||||
case setWifiTethering:
|
||||
return context.getResources().getString(R.string.actionSetWifiTethering);
|
||||
case setBluetoothTethering:
|
||||
return context.getResources().getString(R.string.actionSetBluetoothTethering);
|
||||
case setUsbTethering:
|
||||
return context.getResources().getString(R.string.actionSetUsbTethering);
|
||||
case setDisplayRotation:
|
||||
return context.getResources().getString(R.string.actionSetDisplayRotation);
|
||||
case turnWifiOn:
|
||||
return context.getResources().getString(R.string.actionTurnWifiOn);
|
||||
case turnWifiOff:
|
||||
return context.getResources().getString(R.string.actionTurnWifiOff);
|
||||
case turnBluetoothOn:
|
||||
return context.getResources().getString(R.string.actionTurnBluetoothOn);
|
||||
case turnBluetoothOff:
|
||||
return context.getResources().getString(R.string.actionTurnBluetoothOff);
|
||||
case triggerUrl:
|
||||
return context.getResources().getString(R.string.actionTriggerUrl);
|
||||
case changeSoundProfile:
|
||||
return context.getResources().getString(R.string.actionChangeSoundProfile);
|
||||
case turnUsbTetheringOn:
|
||||
return context.getResources().getString(R.string.actionTurnUsbTetheringOn);
|
||||
case turnUsbTetheringOff:
|
||||
return context.getResources().getString(R.string.actionTurnUsbTetheringOff);
|
||||
case turnWifiTetheringOn:
|
||||
return context.getResources().getString(R.string.actionTurnWifiTetheringOn);
|
||||
case turnWifiTetheringOff:
|
||||
return context.getResources().getString(R.string.actionTurnWifiTetheringOff);
|
||||
case enableScreenRotation:
|
||||
return context.getResources().getString(R.string.actionEnableScreenRotation);
|
||||
case disableScreenRotation:
|
||||
return context.getResources().getString(R.string.actionDisableScreenRotation);
|
||||
case startOtherActivity:
|
||||
return context.getResources().getString(R.string.startOtherActivity);
|
||||
case waitBeforeNextAction:
|
||||
return context.getResources().getString(R.string.waitBeforeNextAction);
|
||||
case turnScreenOnOrOff:
|
||||
return context.getResources().getString(R.string.turnScreenOnOrOff);
|
||||
case vibrate:
|
||||
return context.getResources().getString(R.string.vibrate);
|
||||
case setAirplaneMode:
|
||||
return context.getResources().getString(R.string.airplaneMode);
|
||||
case setDataConnection:
|
||||
return context.getResources().getString(R.string.actionDataConnection);
|
||||
case speakText:
|
||||
return context.getResources().getString(R.string.actionSpeakText);
|
||||
case playMusic:
|
||||
return context.getResources().getString(R.string.actionPlayMusic);
|
||||
case controlMediaPlayback:
|
||||
return context.getResources().getString(R.string.actionMediaControl);
|
||||
case playSound:
|
||||
return context.getResources().getString(R.string.playSound);
|
||||
case sendTextMessage:
|
||||
return context.getResources().getString(R.string.sendTextMessage);
|
||||
case setScreenBrightness:
|
||||
return context.getResources().getString(R.string.setScreenBrightness);
|
||||
case createNotification:
|
||||
return context.getResources().getString(R.string.createNotification);
|
||||
case closeNotification:
|
||||
return context.getResources().getString(R.string.closeNotifications);
|
||||
case sendBroadcast:
|
||||
return context.getResources().getString(R.string.sendBroadcast);
|
||||
case runExecutable:
|
||||
return context.getResources().getString(R.string.runExecutable);
|
||||
case wakelock:
|
||||
return context.getResources().getString(R.string.keepDeviceAwake);
|
||||
case setVariable:
|
||||
return context.getResources().getString(R.string.setVariable);
|
||||
case startPhoneCall:
|
||||
return context.getResources().getString(R.string.startPhoneCall);
|
||||
case stopPhoneCall:
|
||||
return context.getResources().getString(R.string.endPhoneCall);
|
||||
case copyToClipboard:
|
||||
return context.getResources().getString(R.string.copyTextToClipboard);
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private Action_Enum action;
|
||||
private boolean parameter1 = false;
|
||||
@ -154,134 +186,243 @@ public class Action
|
||||
{
|
||||
StringBuilder returnString = new StringBuilder();
|
||||
|
||||
switch(getAction())
|
||||
try
|
||||
{
|
||||
case setWifi:
|
||||
if (this.getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnWifiOn));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnWifiOff));
|
||||
break;
|
||||
case setBluetooth:
|
||||
if (this.getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnBluetoothOn));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnBluetoothOff));
|
||||
break;
|
||||
case setUsbTethering:
|
||||
if (this.getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnUsbTetheringOn));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnUsbTetheringOff));
|
||||
break;
|
||||
case setWifiTethering:
|
||||
if (this.getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnWifiTetheringOn));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnWifiTetheringOff));
|
||||
break;
|
||||
case setBluetoothTethering:
|
||||
if (this.getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnBluetoothTetheringOn));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnBluetoothTetheringOff));
|
||||
break;
|
||||
case setDisplayRotation:
|
||||
if (this.getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionEnableScreenRotation));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionDisableScreenRotation));
|
||||
break;
|
||||
case setAirplaneMode:
|
||||
if (this.getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnAirplaneModeOn));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnAirplaneModeOff));
|
||||
break;
|
||||
case setDataConnection:
|
||||
if (this.getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionSetDataConnectionOn));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionSetDataConnectionOff));
|
||||
break;
|
||||
case startOtherActivity:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.startOtherActivity));
|
||||
break;
|
||||
case triggerUrl:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTriggerUrl));
|
||||
break;
|
||||
case speakText:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionSpeakText));
|
||||
break;
|
||||
case playMusic:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionPlayMusic));
|
||||
break;
|
||||
case sendTextMessage:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.sendTextMessage));
|
||||
break;
|
||||
case turnScreenOnOrOff:
|
||||
if (getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.turnScreenOn));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.turnScreenOff));
|
||||
break;
|
||||
case playSound:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.playSound));
|
||||
break;
|
||||
case changeSoundProfile:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionChangeSoundProfile));
|
||||
break;
|
||||
case waitBeforeNextAction:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.waitBeforeNextAction));
|
||||
break;
|
||||
case setScreenBrightness:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.setScreenBrightness));
|
||||
break;
|
||||
default:
|
||||
returnString.append(action.toString());
|
||||
}
|
||||
|
||||
if(this.getAction().equals(Action_Enum.triggerUrl))
|
||||
{
|
||||
String[] components = parameter2.split(";");
|
||||
if(components.length >= 3)
|
||||
switch (getAction())
|
||||
{
|
||||
returnString.append(": " + components[2]);
|
||||
|
||||
if(parameter1)
|
||||
returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.usingAuthentication) + ".");
|
||||
case setWifi:
|
||||
if (this.getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnWifiOn));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnWifiOff));
|
||||
break;
|
||||
case setBluetooth:
|
||||
if (this.getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnBluetoothOn));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnBluetoothOff));
|
||||
break;
|
||||
case setUsbTethering:
|
||||
if (this.getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnUsbTetheringOn));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnUsbTetheringOff));
|
||||
break;
|
||||
case setWifiTethering:
|
||||
if (this.getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnWifiTetheringOn));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnWifiTetheringOff));
|
||||
break;
|
||||
case setBluetoothTethering:
|
||||
if (this.getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnBluetoothTetheringOn));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnBluetoothTetheringOff));
|
||||
break;
|
||||
case setDisplayRotation:
|
||||
if (this.getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionEnableScreenRotation));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionDisableScreenRotation));
|
||||
break;
|
||||
case setAirplaneMode:
|
||||
if (this.getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnAirplaneModeOn));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTurnAirplaneModeOff));
|
||||
break;
|
||||
case setDataConnection:
|
||||
if (this.getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionSetDataConnectionOn));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionSetDataConnectionOff));
|
||||
break;
|
||||
case startOtherActivity:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.startOtherActivity));
|
||||
break;
|
||||
case triggerUrl:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionTriggerUrl));
|
||||
break;
|
||||
case speakText:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionSpeakText));
|
||||
break;
|
||||
case playMusic:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionPlayMusic));
|
||||
break;
|
||||
case controlMediaPlayback:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionMediaControl));
|
||||
break;
|
||||
case sendTextMessage:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.sendTextMessage));
|
||||
break;
|
||||
case turnScreenOnOrOff:
|
||||
if (getParameter1())
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.turnScreenOn));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.turnScreenOff));
|
||||
break;
|
||||
case playSound:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.playSound));
|
||||
break;
|
||||
case changeSoundProfile:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.actionChangeSoundProfile));
|
||||
break;
|
||||
case waitBeforeNextAction:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.waitBeforeNextAction));
|
||||
break;
|
||||
case setScreenBrightness:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.setScreenBrightness));
|
||||
break;
|
||||
case createNotification:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.createNotification));
|
||||
break;
|
||||
case closeNotification:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.closeNotifications));
|
||||
break;
|
||||
case sendBroadcast:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.sendBroadcast));
|
||||
break;
|
||||
case runExecutable:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.runExecutable));
|
||||
break;
|
||||
case wakelock:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.keepDeviceAwake) + " (" + String.valueOf(getParameter1()) + ")");
|
||||
break;
|
||||
case setVariable:
|
||||
String[] variableParams = getParameter2().split(actionParameter2Split);
|
||||
String addition;
|
||||
if (variableParams.length >= 2)
|
||||
addition = " (key: " + variableParams[0] + ", value: " + variableParams[1] + ")";
|
||||
else
|
||||
addition = " (delete key: " + variableParams[0] + ")";
|
||||
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.setVariable) + addition);
|
||||
break;
|
||||
case startPhoneCall:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.startPhoneCall));
|
||||
break;
|
||||
case stopPhoneCall:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.endPhoneCall));
|
||||
break;
|
||||
case copyToClipboard:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.copyTextToClipboard));
|
||||
default:
|
||||
returnString.append(action.toString());
|
||||
}
|
||||
else
|
||||
returnString.append(": " + components[0]);
|
||||
}
|
||||
else if(this.getAction().equals(Action_Enum.startOtherActivity))
|
||||
{
|
||||
returnString.append(": " + parameter2.replace(Action.intentPairSeperator, "/"));
|
||||
}
|
||||
else if(this.getAction().equals(Action_Enum.sendTextMessage))
|
||||
{
|
||||
String[] components = parameter2.split(Actions.smsSeparator);
|
||||
if(components.length >= 2)
|
||||
|
||||
if (this.getAction().equals(Action_Enum.triggerUrl))
|
||||
{
|
||||
returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.toNumber) + " " + components[0]);
|
||||
String[] components = parameter2.split(";");
|
||||
if (components.length >= 3)
|
||||
{
|
||||
returnString.append(": " + components[2]);
|
||||
|
||||
returnString.append(". " + Miscellaneous.getAnyContext().getResources().getString(R.string.message) + ": " + components[1]);
|
||||
if (parameter1)
|
||||
returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.usingAuthentication) + ".");
|
||||
}
|
||||
else
|
||||
returnString.append(": " + components[0]);
|
||||
}
|
||||
else if (this.getAction().equals(Action_Enum.startOtherActivity))
|
||||
{
|
||||
returnString.append(": " + parameter2.replace(Action.intentPairSeparator, "/"));
|
||||
}
|
||||
else if (this.getAction().equals(Action_Enum.sendTextMessage))
|
||||
{
|
||||
String[] components = parameter2.split(Actions.smsSeparator);
|
||||
if (components.length >= 2)
|
||||
{
|
||||
returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.toNumber) + " " + components[0]);
|
||||
|
||||
returnString.append(". " + Miscellaneous.getAnyContext().getResources().getString(R.string.message) + ": " + components[1]);
|
||||
}
|
||||
}
|
||||
else if (this.getAction().equals(Action_Enum.setScreenBrightness))
|
||||
{
|
||||
returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.to) + " ");
|
||||
|
||||
if (parameter1)
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.brightnessAuto));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.brightnessManual));
|
||||
|
||||
returnString.append(" / " + Integer.parseInt(parameter2) + "%");
|
||||
}
|
||||
else if (this.getAction().equals(Action_Enum.closeNotification))
|
||||
{
|
||||
returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.from) + " ");
|
||||
|
||||
String parts[] = this.getParameter2().split(Action.actionParameter2Split);
|
||||
if (parts[0].equals(Trigger.anyAppString))
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.anyApp));
|
||||
else
|
||||
returnString.append(parts[0]);
|
||||
|
||||
if (!StringUtils.isBlank(parts[2]))
|
||||
returnString.append(", " + Miscellaneous.getAnyContext().getResources().getString(R.string.ifString) + " " + Miscellaneous.getAnyContext().getResources().getString(R.string.title) + " " + Trigger.getMatchString(parts[1]) + " " + parts[2]);
|
||||
|
||||
if (parts.length > 4 && !StringUtils.isBlank(parts[4]))
|
||||
returnString.append(", " + Miscellaneous.getAnyContext().getResources().getString(R.string.ifString) + " " + Miscellaneous.getAnyContext().getResources().getString(R.string.text) + " " + Trigger.getMatchString(parts[3]) + " " + parts[4]);
|
||||
|
||||
if (parts.length >= 6)
|
||||
{
|
||||
if (!parts[5].equals(ActivityManageActionCloseNotification.dismissRegularString))
|
||||
{
|
||||
returnString.append(" " + String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.withButton), parts[5]));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (this.getAction().equals(Action_Enum.setWifi))
|
||||
{
|
||||
if (!StringUtils.isEmpty(this.parameter2))
|
||||
{
|
||||
boolean useRoot = Boolean.parseBoolean(this.parameter2);
|
||||
if (useRoot)
|
||||
returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.usingRoot));
|
||||
}
|
||||
}
|
||||
else if (this.getAction().equals(Action_Enum.controlMediaPlayback))
|
||||
{
|
||||
returnString.append(": ");
|
||||
|
||||
switch (this.getParameter2())
|
||||
{
|
||||
case "0":
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.playPause));
|
||||
break;
|
||||
case "1":
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.play));
|
||||
break;
|
||||
case "2":
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.pause));
|
||||
break;
|
||||
case "3":
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.stop));
|
||||
break;
|
||||
case "4":
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.previous));
|
||||
break;
|
||||
case "5":
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.next));
|
||||
break;
|
||||
default:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.unknown));
|
||||
}
|
||||
}
|
||||
else if (this.getAction().equals(Action_Enum.sendBroadcast))
|
||||
{
|
||||
returnString.append(": " + parameter2.replace(Action.actionParameter2Split, "; ").replace(Action.intentPairSeparator, "/"));
|
||||
}
|
||||
else if(this.getAction().equals(Action_Enum.setVariable) || this.getAction().equals(Action_Enum.copyToClipboard))
|
||||
; // it's completed further above already
|
||||
else if (parameter2 != null && parameter2.length() > 0)
|
||||
returnString.append(": " + parameter2.replace(Action.actionParameter2Split, "; "));
|
||||
}
|
||||
else if(this.getAction().equals(Action_Enum.setScreenBrightness))
|
||||
catch (Exception e)
|
||||
{
|
||||
returnString.append(" " + Miscellaneous.getAnyContext().getResources().getString(R.string.to) + " ");
|
||||
|
||||
if(parameter1)
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.brightnessAuto));
|
||||
else
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.brightnessManual));
|
||||
|
||||
returnString.append(" / " + Integer.parseInt(parameter2) + "%");
|
||||
returnString.append(": " + Miscellaneous.getAnyContext().getResources().getString(R.string.error));
|
||||
}
|
||||
else
|
||||
if (parameter2 != null && parameter2.length() > 0)
|
||||
returnString.append(": " + parameter2);
|
||||
|
||||
return returnString.toString();
|
||||
}
|
||||
@ -360,7 +501,7 @@ public class Action
|
||||
|
||||
return (String[])actionTypesList.toArray(new String[actionTypesList.size()]);
|
||||
}
|
||||
|
||||
|
||||
public void run(Context context, boolean toggleActionIfPossible)
|
||||
{
|
||||
try
|
||||
@ -388,7 +529,7 @@ public class Action
|
||||
Actions.setUsbTethering(context, getParameter1(), toggleActionIfPossible);
|
||||
break;
|
||||
case setWifi:
|
||||
Actions.WifiStuff.setWifi(context, getParameter1(), toggleActionIfPossible);
|
||||
Actions.WifiStuff.setWifi(context, getParameter1(), getParameter2(), toggleActionIfPossible);
|
||||
break;
|
||||
case setWifiTethering:
|
||||
Actions.setWifiTethering(context, getParameter1(), toggleActionIfPossible);
|
||||
@ -439,6 +580,9 @@ public class Action
|
||||
case playMusic:
|
||||
Actions.playMusic(this.getParameter1(), toggleActionIfPossible);
|
||||
break;
|
||||
case controlMediaPlayback:
|
||||
Actions.controlMediaPlayback(context, Integer.parseInt(getParameter2()));
|
||||
break;
|
||||
case sendTextMessage:
|
||||
Actions.sendTextMessage(context, this.getParameter2().split(Actions.smsSeparator));
|
||||
break;
|
||||
@ -451,6 +595,43 @@ public class Action
|
||||
case playSound:
|
||||
Actions.playSound(getParameter1(), getParameter2());
|
||||
break;
|
||||
case createNotification:
|
||||
Actions.createNotification(this);
|
||||
break;
|
||||
case closeNotification:
|
||||
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.M)
|
||||
Actions.closeNotification(this);
|
||||
else
|
||||
Miscellaneous.logEvent("w", "Close notification", "Close notification was requested, but OS version is too low: " + String.valueOf(Build.VERSION.SDK_INT), 2);
|
||||
break;
|
||||
case sendBroadcast:
|
||||
Actions.sendBroadcast(context, this.getParameter2());
|
||||
break;
|
||||
case runExecutable:
|
||||
String[] execParts = this.getParameter2().split(Action.actionParameter2Split);
|
||||
if(execParts.length == 1)
|
||||
Actions.runExecutable(context, this.getParameter1(), execParts[0], null);
|
||||
else if(execParts.length == 2)
|
||||
Actions.runExecutable(context, this.getParameter1(), execParts[0], execParts[1]);
|
||||
break;
|
||||
case wakelock:
|
||||
if(this.getParameter1())
|
||||
Actions.wakeLockStart(context, Long.parseLong(this.getParameter2()));
|
||||
else
|
||||
Actions.wakeLockStop();
|
||||
break;
|
||||
case setVariable:
|
||||
Actions.setVariable(this.getParameter2());
|
||||
break;
|
||||
case startPhoneCall:
|
||||
Actions.startPhoneCall(context, this.getParameter2());
|
||||
break;
|
||||
case stopPhoneCall:
|
||||
Actions.endPhoneCall(context);
|
||||
break;
|
||||
case copyToClipboard:
|
||||
Actions.copyToClipboard(context, Miscellaneous.replaceVariablesInText(this.getParameter2(), context));
|
||||
break;
|
||||
default:
|
||||
Miscellaneous.logEvent("w", "Action", context.getResources().getString(R.string.unknownActionSpecified), 3);
|
||||
break;
|
||||
@ -554,7 +735,7 @@ public class Action
|
||||
//Do something with result
|
||||
//Toast.makeText(context, text, duration) result;
|
||||
Miscellaneous.logEvent("i", "HTTP RESULT", result, 3);
|
||||
Actions myAction=new Actions();
|
||||
Actions myAction = new Actions();
|
||||
myAction.useDownloadedWebpage(result);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,7 @@ import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -20,8 +21,9 @@ import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ActivityMaintenance extends Activity
|
||||
public class ActivityControlCenter extends Activity
|
||||
{
|
||||
final static int requestCodeImport = 1001;
|
||||
final static int requestCodeExport = 1002;
|
||||
@ -30,13 +32,14 @@ public class ActivityMaintenance extends Activity
|
||||
final static String prefsFileName = "com.jens.automation2_preferences.xml";
|
||||
|
||||
TextView tvFileStoreLocation, tvAppVersion;
|
||||
Button bVolumeTest, bMoreSettings, bSettingsSetToDefault, bShareConfigAndLog, bImportConfiguration, bExportConfiguration;
|
||||
Button bVolumeTest, bMoreSettings, bSettingsSetToDefault, bSendEmailToDev, bImportConfiguration, bExportConfiguration;
|
||||
CheckBox chkShareConfigAndLog;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_maintenance);
|
||||
setContentView(R.layout.activity_control_center);
|
||||
|
||||
bVolumeTest = (Button) findViewById(R.id.bVolumeTest);
|
||||
bVolumeTest.setOnClickListener(new View.OnClickListener()
|
||||
@ -44,18 +47,25 @@ public class ActivityMaintenance extends Activity
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
Intent intent = new Intent(ActivityMaintenance.this, ActivityVolumeTest.class);
|
||||
Intent intent = new Intent(ActivityControlCenter.this, ActivityVolumeTest.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
bShareConfigAndLog = (Button) findViewById(R.id.bShareConfigAndLog);
|
||||
bShareConfigAndLog.setOnClickListener(new View.OnClickListener()
|
||||
chkShareConfigAndLog = (CheckBox)findViewById(R.id.chkShareConfigAndLog);
|
||||
bSendEmailToDev = (Button) findViewById(R.id.bSendEmailToDev);
|
||||
bSendEmailToDev.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
getShareConfigAndLogDialogue(ActivityMaintenance.this).show();
|
||||
if(chkShareConfigAndLog.isChecked())
|
||||
getShareConfigAndLogDialogue(ActivityControlCenter.this).show();
|
||||
else
|
||||
{
|
||||
String subject = "Automation";
|
||||
Miscellaneous.sendEmail(ActivityControlCenter.this, "android-development@gmx.de", "Automation logs", getSystemInfo(), null);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -65,17 +75,17 @@ public class ActivityMaintenance extends Activity
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
getDefaultSettingsDialog(ActivityMaintenance.this).show();
|
||||
getDefaultSettingsDialog(ActivityControlCenter.this).show();
|
||||
}
|
||||
});
|
||||
|
||||
Button bMoreSettings = (Button) findViewById(R.id.bMoreSettings);
|
||||
bMoreSettings = (Button) findViewById(R.id.bMoreSettings);
|
||||
bMoreSettings.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
Intent myIntent = new Intent(ActivityMaintenance.this, ActivitySettings.class);
|
||||
Intent myIntent = new Intent(ActivityControlCenter.this, ActivitySettings.class);
|
||||
startActivityForResult(myIntent, requestCodeMoreSettings);
|
||||
}
|
||||
});
|
||||
@ -123,7 +133,7 @@ public class ActivityMaintenance extends Activity
|
||||
if (AutomationService.isMyServiceRunning(this))
|
||||
AutomationService.getInstance().serviceInterface(AutomationService.serviceCommands.reloadSettings);
|
||||
|
||||
if (AutomationService.isMyServiceRunning(ActivityMaintenance.this))
|
||||
if (AutomationService.isMyServiceRunning(ActivityControlCenter.this))
|
||||
Toast.makeText(this, getResources().getString(R.string.settingsWillTakeTime), Toast.LENGTH_LONG).show();
|
||||
|
||||
break;
|
||||
@ -170,7 +180,7 @@ public class ActivityMaintenance extends Activity
|
||||
if (Miscellaneous.copyDocumentFileToFile(file, dstRules))
|
||||
filesImported++;
|
||||
else
|
||||
Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.rulesImportError), Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.rulesImportError), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
else if (file.getName().equals(prefsFileName))
|
||||
@ -183,7 +193,7 @@ public class ActivityMaintenance extends Activity
|
||||
if (Miscellaneous.copyDocumentFileToFile(file, dstPrefs))
|
||||
filesImported++;
|
||||
else
|
||||
Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.prefsImportError), Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.prefsImportError), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -191,12 +201,12 @@ public class ActivityMaintenance extends Activity
|
||||
if(applicableFilesFound > 0)
|
||||
{
|
||||
if(filesImported == 0)
|
||||
Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.noFilesImported), Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.noFilesImported), Toast.LENGTH_LONG).show();
|
||||
else if(filesImported < applicableFilesFound)
|
||||
Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.notAllFilesImported), Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.notAllFilesImported), Toast.LENGTH_LONG).show();
|
||||
else if (filesImported == applicableFilesFound)
|
||||
{
|
||||
Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.configurationImportedSuccessfully), Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.configurationImportedSuccessfully), Toast.LENGTH_LONG).show();
|
||||
|
||||
try
|
||||
{
|
||||
@ -208,19 +218,23 @@ public class ActivityMaintenance extends Activity
|
||||
catch (Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "Reading import", "Rules re-read failed: " + Log.getStackTraceString(e), 1);
|
||||
Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.errorReadingPoisAndRulesFromFile), Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.errorReadingPoisAndRulesFromFile), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
Settings.readFromPersistentStorage(ActivityMaintenance.this);
|
||||
Settings.readFromPersistentStorage(ActivityControlCenter.this);
|
||||
|
||||
AutomationService service = AutomationService.getInstance();
|
||||
if(service != null && service.isRunning)
|
||||
service.applySettingsAndRules();
|
||||
}
|
||||
else
|
||||
Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.noFilesImported), Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.noFilesImported), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
else
|
||||
Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.noApplicableFilesFoundInDirectory), Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.noApplicableFilesFoundInDirectory), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
else
|
||||
Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.noApplicableFilesFoundInDirectory), Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.noApplicableFilesFoundInDirectory), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
void exportFiles(Uri uriTree)
|
||||
@ -252,12 +266,12 @@ public class ActivityMaintenance extends Activity
|
||||
if(dstRules.canWrite() && dstPrefs.canWrite())
|
||||
{
|
||||
if(Miscellaneous.copyFileToDocumentFile(srcRules, dstRules) && Miscellaneous.copyFileToDocumentFile(srcPrefs, dstPrefs))
|
||||
Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.configurationExportedSuccessfully), Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.configurationExportedSuccessfully), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.ConfigurationExportError), Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.ConfigurationExportError), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
else
|
||||
Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.ConfigurationExportError), Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.ConfigurationExportError), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
private static AlertDialog getDefaultSettingsDialog(final Context context)
|
||||
@ -296,32 +310,33 @@ public class ActivityMaintenance extends Activity
|
||||
srcFilesList.add(Miscellaneous.getWriteableFolder() + "/../shared_prefs/" + prefsFileName);
|
||||
|
||||
String logFilePath = Miscellaneous.getWriteableFolder() + "/" + Miscellaneous.logFileName;
|
||||
if((new File(logFilePath)).exists())
|
||||
if ((new File(logFilePath)).exists())
|
||||
srcFilesList.add(logFilePath);
|
||||
|
||||
String logFilePathArchive = Miscellaneous.getWriteableFolder() + "/" + Miscellaneous.logFileName + "-old";
|
||||
if((new File(logFilePathArchive)).exists())
|
||||
if ((new File(logFilePathArchive)).exists())
|
||||
srcFilesList.add(logFilePathArchive);
|
||||
|
||||
String[] srcFiles = srcFilesList.toArray(new String[srcFilesList.size()]);
|
||||
|
||||
if(dstZipFile.exists())
|
||||
if (dstZipFile.exists())
|
||||
dstZipFile.delete();
|
||||
|
||||
Miscellaneous.zip(srcFiles, dstZipFile.getAbsolutePath());
|
||||
|
||||
/*
|
||||
Without root the zip file in the cache directory is not directly accessible.
|
||||
But have to route it through this content provider crap.
|
||||
*/
|
||||
/*
|
||||
Without root the zip file in the cache directory is not directly accessible.
|
||||
But have to route it through this content provider crap.
|
||||
*/
|
||||
|
||||
String subject = "Automation logs";
|
||||
|
||||
Uri uri = Uri.parse("content://com.jens.automation2/" + Settings.zipFileName);
|
||||
|
||||
Miscellaneous.sendEmail(ActivityMaintenance.this, "android-development@gmx.de", "Automation logs", getSystemInfo(), uri);
|
||||
Miscellaneous.sendEmail(ActivityControlCenter.this, "android-development@gmx.de", "Automation logs", getSystemInfo(), uri);
|
||||
}
|
||||
});
|
||||
|
||||
alertDialogBuilder.setNegativeButton(context.getResources().getString(R.string.no), null);
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
|
||||
@ -331,13 +346,37 @@ public class ActivityMaintenance extends Activity
|
||||
public static String getSystemInfo()
|
||||
{
|
||||
StringBuilder systemInfoText = new StringBuilder();
|
||||
systemInfoText.append("App details" + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Version name: " + BuildConfig.VERSION_NAME + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Version code: " + BuildConfig.VERSION_CODE + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Flavor: " + BuildConfig.FLAVOR + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Device details" + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("OS version: " + System.getProperty("os.version") + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("API Level: " + android.os.Build.VERSION.SDK + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Target SDK: " + Miscellaneous.getAnyContext().getApplicationInfo().targetSdkVersion + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Device: " + android.os.Build.DEVICE + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Model: " + android.os.Build.MODEL + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Product: " + android.os.Build.PRODUCT + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Flavor: " + BuildConfig.FLAVOR);
|
||||
systemInfoText.append("Rooted: " + String.valueOf(Miscellaneous.isPhoneRooted()) + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Country: " + Miscellaneous.getUserCountry(Miscellaneous.getAnyContext()) + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("OS language: " + Locale.getDefault().getDisplayName() + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Logfile written: " + String.valueOf(Settings.writeLogFile) + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Log level: " + String.valueOf(Settings.logLevel));
|
||||
|
||||
/*
|
||||
I've checked the Locale methods on my Android 4.1.2 device, and the results:
|
||||
|
||||
Locale.getDefault().getLanguage() ---> en
|
||||
Locale.getDefault().getISO3Language() ---> eng
|
||||
Locale.getDefault().getCountry() ---> US
|
||||
Locale.getDefault().getISO3Country() ---> USA
|
||||
Locale.getDefault().getDisplayCountry() ---> United States
|
||||
Locale.getDefault().getDisplayName() ---> English (United States)
|
||||
Locale.getDefault().toString() ---> en_US
|
||||
Locale.getDefault().getDisplayLanguage()---> English
|
||||
Locale.getDefault().toLanguageTag() ---> en-US
|
||||
*/
|
||||
|
||||
return systemInfoText.toString();
|
||||
}
|
||||
|
||||
@ -367,7 +406,7 @@ public class ActivityMaintenance extends Activity
|
||||
{
|
||||
// if you reach this place, it means there is no any file
|
||||
// explorer app installed on your device
|
||||
Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.noFileManageInstalled), Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.noFileManageInstalled), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
}
|
@ -13,7 +13,7 @@ public class ActivityHelp extends Activity
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(layout.help_text);
|
||||
setContentView(layout.activity_help_text);
|
||||
|
||||
TextView tvHelpTextEnergySaving = (TextView) findViewById(R.id.tvHelpTextEnergySaving);
|
||||
tvHelpTextEnergySaving.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
@ -44,6 +44,7 @@ public class ActivityMainPoi extends ActivityGeneric
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
Miscellaneous.setDisplayLanguage(ActivityMainPoi.this);
|
||||
setContentView(R.layout.main_poi_layout);
|
||||
|
||||
instance = this;
|
||||
@ -190,8 +191,27 @@ public class ActivityMainPoi extends ActivityGeneric
|
||||
startActivityForResult(manageSpecificPoiIntent, 2000);
|
||||
break;
|
||||
case 1:
|
||||
if(pointOfInterest.delete(Miscellaneous.getAnyContext()))
|
||||
updateListView();
|
||||
AlertDialog.Builder deleteDialog = new AlertDialog.Builder(ActivityMainPoi.this);
|
||||
deleteDialog.setMessage(getResources().getString(R.string.areYouSure));
|
||||
deleteDialog.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i)
|
||||
{
|
||||
if(pointOfInterest.delete(Miscellaneous.getAnyContext()))
|
||||
updateListView();
|
||||
}
|
||||
});
|
||||
deleteDialog.setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i)
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
deleteDialog.show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ public class ActivityMainProfiles extends ActivityGeneric
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
Miscellaneous.setDisplayLanguage(ActivityMainProfiles.this);
|
||||
setContentView(R.layout.main_profile_layout);
|
||||
|
||||
instance = this;
|
||||
@ -187,10 +188,29 @@ public class ActivityMainProfiles extends ActivityGeneric
|
||||
Rule user = profile.isInUseByRules();
|
||||
if(user == null)
|
||||
{
|
||||
if (profile.delete(ActivityMainProfiles.this))
|
||||
updateListView();
|
||||
else
|
||||
Toast.makeText(ActivityMainProfiles.this, getResources().getString(R.string.profileCouldNotBeDeleted), Toast.LENGTH_LONG).show();
|
||||
AlertDialog.Builder deleteDialog = new AlertDialog.Builder(ActivityMainProfiles.this);
|
||||
deleteDialog.setMessage(getResources().getString(R.string.areYouSure));
|
||||
deleteDialog.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i)
|
||||
{
|
||||
if (profile.delete(ActivityMainProfiles.this))
|
||||
updateListView();
|
||||
else
|
||||
Toast.makeText(ActivityMainProfiles.this, getResources().getString(R.string.profileCouldNotBeDeleted), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
deleteDialog.setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i)
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
deleteDialog.show();
|
||||
}
|
||||
else
|
||||
Toast.makeText(ActivityMainProfiles.this, String.format(getResources().getString(R.string.ruleXIsUsingProfileY), user.getName(), profile.getName()), Toast.LENGTH_LONG).show();
|
||||
|
@ -18,6 +18,7 @@ import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.jens.automation2.AutomationService.serviceCommands;
|
||||
import com.jens.automation2.receivers.DateTimeListener;
|
||||
|
||||
@ -25,6 +26,7 @@ import java.util.ArrayList;
|
||||
|
||||
public class ActivityMainRules extends ActivityGeneric
|
||||
{
|
||||
public static final String intentNameRuleName = "ruleName";
|
||||
private ListView ruleListView;
|
||||
ArrayList<Rule> ruleList = new ArrayList<>();
|
||||
private ArrayAdapter<Rule> ruleListViewAdapter;
|
||||
@ -45,7 +47,8 @@ public class ActivityMainRules extends ActivityGeneric
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
super.onCreate(savedInstanceState);
|
||||
Miscellaneous.setDisplayLanguage(ActivityMainRules.this);
|
||||
setContentView(R.layout.main_rule_layout);
|
||||
|
||||
instance = this;
|
||||
@ -135,7 +138,7 @@ public class ActivityMainRules extends ActivityGeneric
|
||||
else
|
||||
holder = (RuleHolder) v.getTag();
|
||||
|
||||
System.out.println("Position ["+position+"]");
|
||||
// System.out.println("Position ["+position+"]");
|
||||
Rule r = Rule.getRuleCollection().get(position);
|
||||
holder.tvRuleName.setText(r.getName());
|
||||
if(r.isRuleActive())
|
||||
@ -199,6 +202,7 @@ public class ActivityMainRules extends ActivityGeneric
|
||||
AutomationService runContext = AutomationService.getInstance();
|
||||
if(runContext != null)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "ActivityMainRules", "Initiating manual execution of rule " + ruleThisIsAbout.getName(), 3);
|
||||
ruleThisIsAbout.activate(runContext, true);
|
||||
break;
|
||||
}
|
||||
@ -206,16 +210,35 @@ public class ActivityMainRules extends ActivityGeneric
|
||||
Toast.makeText(ActivityMainRules.this, getResources().getString(R.string.serviceHasToRunForThat), Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case 1:
|
||||
ruleToEdit = ruleThisIsAbout;
|
||||
Intent manageSpecificRuleIntent = new Intent (ActivityMainRules.this, ActivityManageRule.class);
|
||||
manageSpecificRuleIntent.putExtra(intentNameRuleName, ruleThisIsAbout.getName());
|
||||
startActivityForResult(manageSpecificRuleIntent, requestCodeChangeRule);
|
||||
break;
|
||||
case 2:
|
||||
if(ruleThisIsAbout.delete())
|
||||
AlertDialog.Builder deleteDialog = new AlertDialog.Builder(ActivityMainRules.this);
|
||||
deleteDialog.setMessage(getResources().getString(R.string.areYouSure));
|
||||
deleteDialog.setPositiveButton(getResources().getString(R.string.yes), new DialogInterface.OnClickListener()
|
||||
{
|
||||
ruleToEdit = null; //clear cache
|
||||
updateListView();
|
||||
}
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i)
|
||||
{
|
||||
if(ruleThisIsAbout.delete())
|
||||
{
|
||||
ruleToEdit = null; //clear cache
|
||||
updateListView();
|
||||
}
|
||||
}
|
||||
});
|
||||
deleteDialog.setNegativeButton(getResources().getString(R.string.no), new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i)
|
||||
{
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
deleteDialog.show();
|
||||
break;
|
||||
case 3:
|
||||
ruleToEdit = ruleThisIsAbout;
|
||||
@ -250,15 +273,5 @@ public class ActivityMainRules extends ActivityGeneric
|
||||
}
|
||||
catch(NullPointerException e)
|
||||
{}
|
||||
|
||||
try
|
||||
{
|
||||
if(AutomationService.isMyServiceRunning(this))
|
||||
DateTimeListener.reloadAlarms();
|
||||
}
|
||||
catch(NullPointerException e)
|
||||
{
|
||||
// AlarmManager instance not prepared, yet.
|
||||
}
|
||||
}
|
||||
}
|
@ -3,15 +3,16 @@ package com.jens.automation2;
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.Xml;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@ -29,34 +30,32 @@ import androidx.core.text.HtmlCompat;
|
||||
|
||||
import com.jens.automation2.AutomationService.serviceCommands;
|
||||
import com.jens.automation2.Trigger.Trigger_Enum;
|
||||
import com.jens.automation2.location.CellLocationChangedReceiver;
|
||||
import com.jens.automation2.location.LocationProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public class ActivityMainScreen extends ActivityGeneric
|
||||
{
|
||||
private static boolean guiChangeInProgress = false;
|
||||
static boolean guiChangeInProgress = false;
|
||||
static ActivityMainScreen activityMainScreenInstance = null;
|
||||
static boolean updateNoteDisplayed = false;
|
||||
static boolean uiUpdateRunning = false;
|
||||
|
||||
private static ActivityMainScreen activityMainScreenInstance = null;
|
||||
private ToggleButton toggleService, tbLockSound;
|
||||
private Button bShowHelp, bPrivacy, bSettingsErase, bAddSoundLockTIme, bDonate;
|
||||
private TextView tvActivePoi, tvClosestPoi, tvLastRule, tvMainScreenNotePermissions, tvMainScreenNoteFeaturesFromOtherFlavor, tvMainScreenNoteLocationImpossibleBlameGoogle, tvMainScreenNoteNews, tvlockSoundDuration;
|
||||
private static boolean updateNoteDisplayed = false;
|
||||
ToggleButton toggleService, tbLockSound;
|
||||
Button bShowHelp, bPrivacy, bAddSoundLockTIme, bDonate, bControlCenter;
|
||||
TextView tvActivePoi, tvClosestPoi, tvLastRule, tvLastProfile, tvMainScreenNotePermissions, tvMainScreenNoteFeaturesFromOtherFlavor, tvMainScreenNoteLocationImpossibleBlameGoogle, tvMainScreenNoteNews, tvLockSoundDuration;
|
||||
|
||||
private ListView lvRuleHistory;
|
||||
private ArrayAdapter<Rule> ruleHistoryListViewAdapter;
|
||||
|
||||
private static boolean uiUpdateRunning = false;
|
||||
ListView lvRuleHistory;
|
||||
ArrayAdapter<Rule> ruleHistoryListViewAdapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
Miscellaneous.setDisplayLanguage(ActivityMainScreen.this);
|
||||
setContentView(R.layout.main_overview_layout);
|
||||
|
||||
activityMainScreenInstance = this;
|
||||
@ -74,18 +73,18 @@ public class ActivityMainScreen extends ActivityGeneric
|
||||
tvActivePoi = (TextView) findViewById(R.id.tvActivePoi);
|
||||
tvClosestPoi = (TextView) findViewById(R.id.tvClosestPoi);
|
||||
lvRuleHistory = (ListView) findViewById(R.id.lvRuleHistory);
|
||||
tvLastRule = (TextView) findViewById(R.id.tvTimeFrameHelpText);
|
||||
tvLastRule = (TextView) findViewById(R.id.tvLastRule);
|
||||
tvLastProfile = (TextView)findViewById(R.id.tvLastProfile);
|
||||
tvMainScreenNotePermissions = (TextView) findViewById(R.id.tvMainScreenNotePermissions);
|
||||
tvMainScreenNoteFeaturesFromOtherFlavor = (TextView) findViewById(R.id.tvMainScreenNoteFeaturesFromOtherFlavor);
|
||||
tvMainScreenNoteLocationImpossibleBlameGoogle = (TextView) findViewById(R.id.tvMainScreenNoteLocationImpossibleBlameGoogle);
|
||||
tvMainScreenNoteNews = (TextView) findViewById(R.id.tvMainScreenNoteNews);
|
||||
tvlockSoundDuration = (TextView)findViewById(R.id.tvlockSoundDuration);
|
||||
tvLockSoundDuration = (TextView)findViewById(R.id.tvlockSoundDuration);
|
||||
tbLockSound = (ToggleButton) findViewById(R.id.tbLockSound);
|
||||
toggleService = (ToggleButton) findViewById(R.id.tbArmMastListener);
|
||||
|
||||
bDonate = (Button)findViewById(R.id.bDonate);
|
||||
|
||||
if(!BuildConfig.FLAVOR.equalsIgnoreCase("googlePlayFlavor"))
|
||||
if(!BuildConfig.FLAVOR.equalsIgnoreCase(AutomationService.flavor_name_googleplay))
|
||||
bDonate.setVisibility(View.VISIBLE);
|
||||
|
||||
toggleService.setChecked(AutomationService.isMyServiceRunning(this));
|
||||
@ -99,7 +98,8 @@ public class ActivityMainScreen extends ActivityGeneric
|
||||
if (toggleService.isChecked())
|
||||
{
|
||||
startAutomationService(getBaseContext(), false);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
stopAutomationService();
|
||||
}
|
||||
@ -147,13 +147,13 @@ public class ActivityMainScreen extends ActivityGeneric
|
||||
}
|
||||
});
|
||||
|
||||
Button bSettings = (Button) findViewById(R.id.bSettings);
|
||||
bSettings.setOnClickListener(new OnClickListener()
|
||||
bControlCenter = (Button) findViewById(R.id.bControlCenter);
|
||||
bControlCenter.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
Intent myIntent = new Intent(ActivityMainScreen.this, ActivityMaintenance.class);
|
||||
Intent myIntent = new Intent(ActivityMainScreen.this, ActivityControlCenter.class);
|
||||
startActivity(myIntent);
|
||||
}
|
||||
});
|
||||
@ -275,9 +275,14 @@ public class ActivityMainScreen extends ActivityGeneric
|
||||
activityMainScreenInstance.tvMainScreenNotePermissions.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(Miscellaneous.restrictedFeaturesConfigured())
|
||||
if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_fdroid) && Miscellaneous.restrictedFeaturesConfiguredFdroid())
|
||||
{
|
||||
activityMainScreenInstance.tvMainScreenNoteFeaturesFromOtherFlavor.setText(R.string.settingsReferringToRestrictedFeatures);
|
||||
activityMainScreenInstance.tvMainScreenNoteFeaturesFromOtherFlavor.setText(R.string.settingsReferringToRestrictedFeaturesInFdroid);
|
||||
activityMainScreenInstance.tvMainScreenNoteFeaturesFromOtherFlavor.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_googleplay) && Miscellaneous.restrictedFeaturesConfiguredGoogle())
|
||||
{
|
||||
activityMainScreenInstance.tvMainScreenNoteFeaturesFromOtherFlavor.setText(R.string.settingsReferringToRestrictedFeaturesInGoogle);
|
||||
activityMainScreenInstance.tvMainScreenNoteFeaturesFromOtherFlavor.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else
|
||||
@ -288,14 +293,6 @@ public class ActivityMainScreen extends ActivityGeneric
|
||||
|
||||
if(Miscellaneous.googleToBlameForLocation(true))
|
||||
{
|
||||
// Intent intent = new Intent(AutomationService.this, ActivityDisplayLongMessage.class);
|
||||
// intent.putExtra("longMessage", getResources().getString(R.string.locationEngineDisabledLong));
|
||||
// PendingIntent pi = PendingIntent.getActivity(AutomationService.this, 0, intent, 0);
|
||||
// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1)
|
||||
// Miscellaneous.createDismissableNotificationWithDelay(2200, getResources().getString(R.string.featuresDisabled), notificationIdLocationRestriction, pi);
|
||||
// else
|
||||
// Miscellaneous.createDismissableNotification(getResources().getString(R.string.featuresDisabled), notificationIdLocationRestriction, pi);
|
||||
|
||||
activityMainScreenInstance.tvMainScreenNoteLocationImpossibleBlameGoogle.setText(R.string.locationEngineDisabledShort);
|
||||
activityMainScreenInstance.tvMainScreenNoteLocationImpossibleBlameGoogle.setVisibility(View.VISIBLE);
|
||||
activityMainScreenInstance.tvMainScreenNoteLocationImpossibleBlameGoogle.setOnClickListener(new OnClickListener()
|
||||
@ -320,8 +317,7 @@ public class ActivityMainScreen extends ActivityGeneric
|
||||
uiUpdateRunning = true;
|
||||
activityMainScreenInstance.toggleService.setChecked(true);
|
||||
uiUpdateRunning = false;
|
||||
// if(activityMainScreenInstance.hasWindowFocus())
|
||||
// {
|
||||
|
||||
try
|
||||
{
|
||||
PointOfInterest activePoi = PointOfInterest.getActivePoi();
|
||||
@ -370,6 +366,16 @@ public class ActivityMainScreen extends ActivityGeneric
|
||||
{
|
||||
activityMainScreenInstance.tvLastRule.setText("n./a.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
activityMainScreenInstance.tvLastProfile.setText(Profile.getLastActivatedProfile().getName());
|
||||
activityMainScreenInstance.updateListView();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activityMainScreenInstance.tvLastProfile.setText("n./a.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -378,6 +384,7 @@ public class ActivityMainScreen extends ActivityGeneric
|
||||
activityMainScreenInstance.tvActivePoi.setText(activityMainScreenInstance.getResources().getString(R.string.serviceNotRunning));
|
||||
activityMainScreenInstance.tvClosestPoi.setText("");
|
||||
activityMainScreenInstance.tvLastRule.setText("");
|
||||
activityMainScreenInstance.tvLastProfile.setText("");
|
||||
}
|
||||
|
||||
// uiUpdateRunning = true;
|
||||
@ -395,21 +402,21 @@ public class ActivityMainScreen extends ActivityGeneric
|
||||
long millis = end.getTimeInMillis() - now.getTimeInMillis();
|
||||
long minutes = millis/1000/60;
|
||||
if(minutes < 60)
|
||||
activityMainScreenInstance.tvlockSoundDuration.setText(String.valueOf(minutes + " min..."));
|
||||
activityMainScreenInstance.tvLockSoundDuration.setText(String.valueOf(minutes + " min..."));
|
||||
else
|
||||
{
|
||||
double hours = (double)minutes / 60.0;
|
||||
activityMainScreenInstance.tvlockSoundDuration.setText(String.valueOf(Math.round(hours * 100.0) / 100.0) + " h...");
|
||||
activityMainScreenInstance.tvLockSoundDuration.setText(String.valueOf(Math.round(hours * 100.0) / 100.0) + " h...");
|
||||
}
|
||||
}
|
||||
else
|
||||
activityMainScreenInstance.tvlockSoundDuration.setText(String.valueOf(""));
|
||||
activityMainScreenInstance.tvLockSoundDuration.setText(String.valueOf(""));
|
||||
}
|
||||
else
|
||||
{
|
||||
activityMainScreenInstance.tbLockSound.setChecked(false);
|
||||
activityMainScreenInstance.tbLockSound.setEnabled(false);
|
||||
activityMainScreenInstance.tvlockSoundDuration.setText("");
|
||||
activityMainScreenInstance.tvLockSoundDuration.setText("");
|
||||
}
|
||||
Settings.writeSettings(activityMainScreenInstance);
|
||||
// uiUpdateRunning = false;
|
||||
|
@ -3,12 +3,17 @@ package com.jens.automation2;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.TabActivity;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.widget.TabHost;
|
||||
import android.widget.TabHost.TabSpec;
|
||||
|
||||
import com.jens.automation2.receivers.NfcReceiver;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public class ActivityMainTabLayout extends TabActivity
|
||||
@ -17,8 +22,8 @@ public class ActivityMainTabLayout extends TabActivity
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
Settings.readFromPersistentStorage(ActivityMainTabLayout.this);
|
||||
Miscellaneous.setDisplayLanguage(ActivityMainTabLayout.this);
|
||||
|
||||
if(Settings.tabsPlacement == 1)
|
||||
setContentView(R.layout.main_tab_layout_tabs_at_bottom);
|
||||
|
@ -10,10 +10,13 @@ import android.widget.CompoundButton;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ActivityManageActionBrightnessSetting extends Activity
|
||||
{
|
||||
public static final String intentNameAutoBrightness = "autoBrightness";
|
||||
public static final String intentNameBrightnessValue = "brightnessValue";
|
||||
|
||||
CheckBox chkAutoBrightness;
|
||||
SeekBar sbBrightness;
|
||||
Button bApplyBrightness;
|
||||
@ -22,7 +25,7 @@ public class ActivityManageActionBrightnessSetting extends Activity
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
setContentView(R.layout.activity_manage_brightness_setting);
|
||||
setContentView(R.layout.activity_manage_action_brightness_settings);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
chkAutoBrightness = (CheckBox)findViewById(R.id.chkAutoBrightness);
|
||||
@ -32,11 +35,11 @@ public class ActivityManageActionBrightnessSetting extends Activity
|
||||
|
||||
Intent input = getIntent();
|
||||
|
||||
if(input.hasExtra("autoBrightness"))
|
||||
chkAutoBrightness.setChecked(input.getBooleanExtra("autoBrightness", false));
|
||||
if(input.hasExtra(intentNameAutoBrightness))
|
||||
chkAutoBrightness.setChecked(input.getBooleanExtra(intentNameAutoBrightness, false));
|
||||
|
||||
if(input.hasExtra("brightnessValue"))
|
||||
sbBrightness.setProgress(input.getIntExtra("brightnessValue", 0));
|
||||
if(input.hasExtra(intentNameBrightnessValue))
|
||||
sbBrightness.setProgress(input.getIntExtra(intentNameBrightnessValue, 0));
|
||||
|
||||
bApplyBrightness.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@ -44,8 +47,8 @@ public class ActivityManageActionBrightnessSetting extends Activity
|
||||
public void onClick(View view)
|
||||
{
|
||||
Intent answer = new Intent();
|
||||
answer.putExtra("autoBrightness", chkAutoBrightness.isChecked());
|
||||
answer.putExtra("brightnessValue", sbBrightness.getProgress());
|
||||
answer.putExtra(intentNameAutoBrightness, chkAutoBrightness.isChecked());
|
||||
answer.putExtra(intentNameBrightnessValue, sbBrightness.getProgress());
|
||||
setResult(RESULT_OK, answer);
|
||||
finish();
|
||||
}
|
||||
|
@ -0,0 +1,430 @@
|
||||
package com.jens.automation2;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class ActivityManageActionCloseNotification extends Activity
|
||||
{
|
||||
public static final String intentNameNotificationApp = "app";
|
||||
public static final String intentNameNotificationTitleDir = "titleDir";
|
||||
public static final String intentNameNotificationTitle = "title";
|
||||
public static final String intentNameNotificationTextDir = "textDir";
|
||||
public static final String intentNameNotificationText = "text";
|
||||
public static final String intentNameNotificationDirection = "direction";
|
||||
|
||||
boolean edit = false;
|
||||
ProgressDialog progressDialog = null;
|
||||
|
||||
EditText etNotificationTitle, etNotificationText, etNotificationDismissalButtonText;
|
||||
Button bSelectApp, bSaveActionCloseNotification;
|
||||
Spinner spinnerTitleDirection, spinnerTextDirection;
|
||||
TextView tvSelectedApplication;
|
||||
RadioButton rbNotificationDismissSimple, rbNotificationDismissButton;
|
||||
|
||||
private static List<PackageInfo> pInfos = null;
|
||||
|
||||
final static String dismissRegularString = "p0815DismissString";
|
||||
|
||||
private static String[] directions;
|
||||
|
||||
ArrayAdapter<String> directionSpinnerAdapter;
|
||||
|
||||
public static void getActivityList(final Context context)
|
||||
{
|
||||
if(pInfos == null)
|
||||
{
|
||||
pInfos = context.getPackageManager().getInstalledPackages(PackageManager.GET_ACTIVITIES);
|
||||
Collections.sort(pInfos, new Comparator<PackageInfo>()
|
||||
{
|
||||
public int compare(PackageInfo obj1, PackageInfo obj2)
|
||||
{
|
||||
String name1 = "";
|
||||
String name2 = "";
|
||||
|
||||
ApplicationInfo aInfo1 = obj1.applicationInfo;
|
||||
if (aInfo1 != null)
|
||||
{
|
||||
name1 = (String) context.getPackageManager().getApplicationLabel(aInfo1);
|
||||
}
|
||||
ApplicationInfo aInfo2 = obj2.applicationInfo;
|
||||
if (aInfo2 != null)
|
||||
{
|
||||
name2 = (String) context.getPackageManager().getApplicationLabel(aInfo2);
|
||||
}
|
||||
|
||||
return name1.compareTo(name2);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static String[] getApplicationNameListString(Context myContext)
|
||||
{
|
||||
// Generate the actual list
|
||||
getActivityList(myContext);
|
||||
|
||||
ArrayList<String> returnList = new ArrayList<String>();
|
||||
|
||||
for (PackageInfo pInfo : pInfos)
|
||||
{
|
||||
ApplicationInfo aInfo = pInfo.applicationInfo;
|
||||
if (aInfo != null)
|
||||
{
|
||||
String aLabel;
|
||||
|
||||
aLabel = (String) myContext.getPackageManager().getApplicationLabel(aInfo);
|
||||
|
||||
ActivityInfo[] aInfos = pInfo.activities;
|
||||
if (aInfos != null && aInfos.length > 0) // Only put Applications into the list that have packages.
|
||||
{
|
||||
if(!returnList.contains(aLabel))
|
||||
returnList.add(aLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnList.toArray(new String[returnList.size()]);
|
||||
}
|
||||
|
||||
public static String[] getPackageListString(Context myContext, String applicationLabel)
|
||||
{
|
||||
// Generate the actual list
|
||||
getActivityList(myContext);
|
||||
|
||||
ArrayList<String> returnList = new ArrayList<String>();
|
||||
|
||||
for (PackageInfo pInfo : pInfos)
|
||||
{
|
||||
if(myContext.getPackageManager().getApplicationLabel(pInfo.applicationInfo).equals(applicationLabel))
|
||||
{
|
||||
ActivityInfo[] aInfos = pInfo.activities;
|
||||
if (aInfos != null && aInfos.length > 0)
|
||||
{
|
||||
returnList.add(pInfo.packageName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnList.toArray(new String[returnList.size()]);
|
||||
}
|
||||
|
||||
public static String[] getPackageListString(Context myContext)
|
||||
{
|
||||
// Generate the actual list
|
||||
getActivityList(myContext);
|
||||
|
||||
ArrayList<String> returnList = new ArrayList<String>();
|
||||
|
||||
for (PackageInfo pInfo : pInfos)
|
||||
{
|
||||
ActivityInfo[] aInfos = pInfo.activities;
|
||||
if (aInfos != null && aInfos.length > 0)
|
||||
{
|
||||
returnList.add(pInfo.packageName);
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("w", "Empty Application", "Application " + myContext.getPackageManager().getApplicationLabel(pInfo.applicationInfo) + " doesn\'t have packages.", 5);
|
||||
}
|
||||
|
||||
return returnList.toArray(new String[returnList.size()]);
|
||||
}
|
||||
|
||||
public static String[] getActivityListForPackageName(String packageName)
|
||||
{
|
||||
ArrayList<String> returnList = new ArrayList<String>();
|
||||
|
||||
for (PackageInfo pInfo : pInfos)
|
||||
{
|
||||
if(pInfo.packageName.equals(packageName))
|
||||
{
|
||||
ActivityInfo[] aInfos = pInfo.activities;
|
||||
if (aInfos != null)
|
||||
{
|
||||
for (ActivityInfo activityInfo : aInfos)
|
||||
{
|
||||
returnList.add(activityInfo.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returnList.toArray(new String[returnList.size()]);
|
||||
}
|
||||
|
||||
public static ActivityInfo getActivityInfoForPackageNameAndActivityName(String packageName, String activityName)
|
||||
{
|
||||
for (PackageInfo pInfo : pInfos)
|
||||
{
|
||||
if(pInfo.packageName.equals(packageName))
|
||||
{
|
||||
ActivityInfo[] aInfos = pInfo.activities;
|
||||
if (aInfos != null)
|
||||
{
|
||||
for (ActivityInfo activityInfo : aInfos)
|
||||
{
|
||||
if(activityInfo.name.equals(activityName))
|
||||
return activityInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private AlertDialog getActionStartActivityDialog1()
|
||||
{
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
|
||||
alertDialogBuilder.setTitle(getResources().getString(R.string.selectApplication));
|
||||
final String[] applicationArray = ActivityManageActionCloseNotification.getApplicationNameListString(this);
|
||||
alertDialogBuilder.setItems(applicationArray, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
dialog.dismiss();
|
||||
getActionStartActivityDialog2(applicationArray[which]).show();
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
|
||||
return alertDialog;
|
||||
}
|
||||
private AlertDialog getActionStartActivityDialog2(String applicationName)
|
||||
{
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
|
||||
alertDialogBuilder.setTitle(getResources().getString(R.string.selectPackageOfApplication));
|
||||
final String[] packageArray = ActivityManageActionCloseNotification.getPackageListString(this, applicationName);
|
||||
alertDialogBuilder.setItems(packageArray, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
//getActionStartActivityDialog3(packageArray[which]).show();
|
||||
//Miscellaneous.messageBox(getResources().getString(R.string.hint), getResources().getString(R.string.chooseActivityHint), ActivityManageNotificationTrigger.this).show();
|
||||
tvSelectedApplication.setText(packageArray[which]);
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
|
||||
return alertDialog;
|
||||
}
|
||||
private AlertDialog getActionStartActivityDialog3(final String packageName)
|
||||
{
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
|
||||
alertDialogBuilder.setTitle(getResources().getString(R.string.selectActivityToBeStarted));
|
||||
final String activityArray[] = ActivityManageActionCloseNotification.getActivityListForPackageName(packageName);
|
||||
alertDialogBuilder.setItems(activityArray, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
ActivityInfo ai = ActivityManageActionCloseNotification.getActivityInfoForPackageNameAndActivityName(packageName, activityArray[which]);
|
||||
tvSelectedApplication.setText(ai.packageName + ";" + ai.name);
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
|
||||
return alertDialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_action_close_notification);
|
||||
|
||||
etNotificationTitle = (EditText)findViewById(R.id.etNotificationTitle);
|
||||
etNotificationText = (EditText)findViewById(R.id.etNotificationText);
|
||||
bSelectApp = (Button)findViewById(R.id.bSelectApp);
|
||||
bSaveActionCloseNotification = (Button)findViewById(R.id.bSaveActionCloseNotification);
|
||||
spinnerTitleDirection = (Spinner)findViewById(R.id.spinnerTitleDirection);
|
||||
spinnerTextDirection = (Spinner)findViewById(R.id.spinnerTextDirection);
|
||||
tvSelectedApplication = (TextView)findViewById(R.id.etActivityOrActionPath);
|
||||
etNotificationDismissalButtonText = (EditText)findViewById(R.id.etNotificationDismissalButtonText);
|
||||
rbNotificationDismissSimple = (RadioButton)findViewById(R.id.rbNotificationDismissSimple);
|
||||
rbNotificationDismissButton = (RadioButton)findViewById(R.id.rbNotificationDismissButton);
|
||||
|
||||
directions = new String[] {
|
||||
getResources().getString(R.string.directionStringEquals),
|
||||
getResources().getString(R.string.directionStringContains),
|
||||
getResources().getString(R.string.directionStringDoesNotContain),
|
||||
getResources().getString(R.string.directionStringStartsWith),
|
||||
getResources().getString(R.string.directionStringEndsWith),
|
||||
getResources().getString(R.string.directionStringNotEquals)
|
||||
};
|
||||
|
||||
directionSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, ActivityManageActionCloseNotification.directions);
|
||||
spinnerTitleDirection.setAdapter(directionSpinnerAdapter);
|
||||
spinnerTextDirection.setAdapter(directionSpinnerAdapter);
|
||||
directionSpinnerAdapter.notifyDataSetChanged();
|
||||
|
||||
bSelectApp.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
GetActivityListTask getActivityListTask = new GetActivityListTask();
|
||||
getActivityListTask.execute();
|
||||
progressDialog = ProgressDialog.show(ActivityManageActionCloseNotification.this, "", ActivityManageActionCloseNotification.this.getResources().getString(R.string.gettingListOfInstalledApplications));
|
||||
}
|
||||
});
|
||||
|
||||
bSaveActionCloseNotification.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
String app;
|
||||
if (tvSelectedApplication.getText().toString().equalsIgnoreCase(getResources().getString(R.string.anyApp)))
|
||||
app = Trigger.anyAppString;
|
||||
else
|
||||
app = tvSelectedApplication.getText().toString();
|
||||
|
||||
String titleDir = Trigger.getMatchCode(spinnerTitleDirection.getSelectedItem().toString());
|
||||
String title = etNotificationTitle.getText().toString();
|
||||
String textDir = Trigger.getMatchCode(spinnerTextDirection.getSelectedItem().toString());
|
||||
String text = etNotificationText.getText().toString();
|
||||
|
||||
Intent responseData = new Intent();
|
||||
|
||||
String dismissMethod;
|
||||
if (rbNotificationDismissSimple.isChecked())
|
||||
dismissMethod = dismissRegularString;
|
||||
else
|
||||
{
|
||||
if(StringUtils.isEmpty(etNotificationDismissalButtonText.getText().toString()))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionCloseNotification.this, getResources().getString(R.string.enterText), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else
|
||||
dismissMethod = etNotificationDismissalButtonText.getText().toString();
|
||||
}
|
||||
|
||||
responseData.putExtra(ActivityManageRule.intentNameActionParameter2,
|
||||
app + Action.actionParameter2Split +
|
||||
titleDir + Action.actionParameter2Split +
|
||||
title + Action.actionParameter2Split +
|
||||
textDir + Action.actionParameter2Split +
|
||||
text + Action.actionParameter2Split +
|
||||
dismissMethod
|
||||
);
|
||||
|
||||
ActivityManageActionCloseNotification.this.setResult(RESULT_OK, responseData);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
rbNotificationDismissSimple.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b)
|
||||
{
|
||||
etNotificationDismissalButtonText.setEnabled(!b);
|
||||
}
|
||||
});
|
||||
|
||||
Intent i = getIntent();
|
||||
if(!StringUtils.isBlank(i.getStringExtra(ActivityManageRule.intentNameActionParameter2)))
|
||||
{
|
||||
edit = true;
|
||||
loadValuesIntoGui(i.getStringExtra(ActivityManageRule.intentNameActionParameter2));
|
||||
}
|
||||
}
|
||||
|
||||
private void loadValuesIntoGui(String param)
|
||||
{
|
||||
String[] params = param.split(Action.actionParameter2Split);
|
||||
|
||||
String app = params[0];
|
||||
String titleDir = params[1];
|
||||
String title = params[2];
|
||||
String textDir = params[3];
|
||||
String text;
|
||||
if (params.length >= 5)
|
||||
text = params[4];
|
||||
else
|
||||
text = "";
|
||||
|
||||
/*
|
||||
That's not reliable, yet. Last parameter may be empty, hence the method might
|
||||
be incorrectly interpreted as a text notification text.
|
||||
*/
|
||||
|
||||
if (params.length >= 6 && !params[5].equals(dismissRegularString))
|
||||
{
|
||||
rbNotificationDismissButton.setChecked(true);
|
||||
etNotificationDismissalButtonText.setText(params[5]);
|
||||
etNotificationDismissalButtonText.setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
rbNotificationDismissSimple.setChecked(true);
|
||||
etNotificationDismissalButtonText.setText("");
|
||||
etNotificationDismissalButtonText.setEnabled(false);
|
||||
}
|
||||
|
||||
if(!app.equals(Trigger.anyAppString))
|
||||
tvSelectedApplication.setText(app);
|
||||
|
||||
for(int i = 0; i < directions.length; i++)
|
||||
{
|
||||
if(Trigger.getMatchCode(directions[i]).equalsIgnoreCase(titleDir))
|
||||
spinnerTitleDirection.setSelection(i);
|
||||
|
||||
if(Trigger.getMatchCode(directions[i]).equalsIgnoreCase(textDir))
|
||||
spinnerTextDirection.setSelection(i);
|
||||
}
|
||||
|
||||
if(title.length() > 0)
|
||||
etNotificationTitle.setText(title);
|
||||
|
||||
if(text.length() > 0)
|
||||
etNotificationText.setText(text);
|
||||
}
|
||||
|
||||
private class GetActivityListTask extends AsyncTask<Void, Void, Void>
|
||||
{
|
||||
@Override
|
||||
protected Void doInBackground(Void... params)
|
||||
{
|
||||
getActivityList(ActivityManageActionCloseNotification.this);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result)
|
||||
{
|
||||
progressDialog.dismiss();
|
||||
getActionStartActivityDialog1().show();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
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 android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class ActivityManageActionControlMedia extends Activity
|
||||
{
|
||||
RadioButton rbMediaPlayPause, rbMediaPlay, rbMediaPause, rbMediaStop, rbMediaPrevious, rbMediaNext;
|
||||
Button bSaveControlMediaAction;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_action_control_media);
|
||||
|
||||
rbMediaPlayPause = (RadioButton)findViewById(R.id.rbMediaPlayPause);
|
||||
rbMediaPlay = (RadioButton)findViewById(R.id.rbMediaPlay);
|
||||
rbMediaPause = (RadioButton)findViewById(R.id.rbMediaPause);
|
||||
rbMediaStop = (RadioButton)findViewById(R.id.rbMediaStop);
|
||||
rbMediaPrevious = (RadioButton)findViewById(R.id.rbMediaPrevious);
|
||||
rbMediaNext = (RadioButton)findViewById(R.id.rbMediaNext);
|
||||
|
||||
bSaveControlMediaAction = (Button)findViewById(R.id.bSaveControlMediaAction);
|
||||
|
||||
bSaveControlMediaAction.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
if(checkInput())
|
||||
{
|
||||
Intent answer = new Intent();
|
||||
|
||||
if(rbMediaPlayPause.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "0");
|
||||
else if(rbMediaPlay.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "1");
|
||||
else if(rbMediaPause.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "2");
|
||||
else if(rbMediaStop.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "3");
|
||||
else if(rbMediaPrevious.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "4");
|
||||
else if(rbMediaNext.isChecked())
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, "5");
|
||||
|
||||
setResult(RESULT_OK, answer);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Intent input = getIntent();
|
||||
|
||||
if(input.hasExtra(ActivityManageRule.intentNameActionParameter2))
|
||||
{
|
||||
String existing = input.getStringExtra(ActivityManageRule.intentNameActionParameter2);
|
||||
switch (existing)
|
||||
{
|
||||
case "0":
|
||||
rbMediaPlayPause.setChecked(true);
|
||||
break;
|
||||
case "1":
|
||||
rbMediaPlay.setChecked(true);
|
||||
break;
|
||||
case "2":
|
||||
rbMediaPause.setChecked(true);
|
||||
break;
|
||||
case "3":
|
||||
rbMediaStop.setChecked(true);
|
||||
break;
|
||||
case "4":
|
||||
rbMediaPrevious.setChecked(true);
|
||||
break;
|
||||
case "5":
|
||||
rbMediaNext.setChecked(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean checkInput()
|
||||
{
|
||||
if(
|
||||
!rbMediaPlayPause.isChecked()
|
||||
&&
|
||||
!rbMediaPlay.isChecked()
|
||||
&&
|
||||
!rbMediaPause.isChecked()
|
||||
&&
|
||||
!rbMediaStop.isChecked()
|
||||
&&
|
||||
!rbMediaPrevious.isChecked()
|
||||
&&
|
||||
!rbMediaNext.isChecked()
|
||||
)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionControlMedia.this, getResources().getString(R.string.pleaseSelectActionValue), Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
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 ActivityManageActionCreateNotification extends Activity
|
||||
{
|
||||
public static final String intentNameNotificationTitle = "notificationTitle";
|
||||
public static final String intentNameNotificationText = "notificationText";
|
||||
|
||||
EditText etNotificationTitle, etNotificationText;
|
||||
Button bSaveActionNotification;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_action_create_notification);
|
||||
|
||||
etNotificationTitle = (EditText) findViewById(R.id.etNotificationTitle);
|
||||
etNotificationText = (EditText)findViewById(R.id.etNotificationText);
|
||||
bSaveActionNotification = (Button)findViewById(R.id.bSaveActionNotification);
|
||||
|
||||
Intent input = getIntent();
|
||||
|
||||
if(input.hasExtra(intentNameNotificationTitle))
|
||||
etNotificationTitle.setText(input.getStringExtra(intentNameNotificationTitle));
|
||||
|
||||
if(input.hasExtra(intentNameNotificationText))
|
||||
etNotificationText.setText(input.getStringExtra(intentNameNotificationText));
|
||||
|
||||
bSaveActionNotification.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
if(StringUtils.isBlank(etNotificationTitle.getText().toString()))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionCreateNotification.this, getResources().getString(R.string.enterTitle), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if(StringUtils.isBlank(etNotificationText.getText().toString()))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionCreateNotification.this, getResources().getString(R.string.enterText), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
Intent answer = new Intent();
|
||||
answer.putExtra(intentNameNotificationTitle, etNotificationTitle.getText().toString());
|
||||
answer.putExtra(intentNameNotificationText, etNotificationText.getText().toString());
|
||||
setResult(RESULT_OK, answer);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.jens.automation2;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import 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);
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,114 @@
|
||||
package com.jens.automation2;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ActivityManageActionRunExecutable extends Activity
|
||||
{
|
||||
final static int PICKFILE_RESULT_CODE = 4711;
|
||||
|
||||
CheckBox chkRunExecAsRoot;
|
||||
EditText etRunExecutablePath, etRunExecutableParameters;
|
||||
Button bChooseExecutable, bSaveActionRunExec;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_action_run_executable);
|
||||
|
||||
chkRunExecAsRoot = (CheckBox)findViewById(R.id.chkRunExecAsRoot);
|
||||
etRunExecutablePath = (EditText) findViewById(R.id.etRunExecutablePath);
|
||||
etRunExecutableParameters = (EditText) findViewById(R.id.etRunExecutableParameters);
|
||||
bChooseExecutable = (Button) findViewById(R.id.bChooseExecutable);
|
||||
bSaveActionRunExec = (Button) findViewById(R.id.bSaveActionRunExec);
|
||||
|
||||
bChooseExecutable.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
//Need to check for storage permissions
|
||||
Intent chooseFile = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
chooseFile.setType("*/*");
|
||||
chooseFile = Intent.createChooser(chooseFile, getResources().getString(R.string.selectSoundFile));
|
||||
startActivityForResult(chooseFile, PICKFILE_RESULT_CODE);
|
||||
}
|
||||
});
|
||||
|
||||
bSaveActionRunExec.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
saveExecSettings();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void saveExecSettings()
|
||||
{
|
||||
if(etRunExecutablePath.getText().toString() == null || etRunExecutablePath.getText().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionRunExecutable.this, getResources().getString(R.string.selectValidExecutable), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
File executableFile = new File(etRunExecutablePath.getText().toString());
|
||||
if(!executableFile.exists())
|
||||
{
|
||||
Toast.makeText(ActivityManageActionRunExecutable.this, getResources().getString(R.string.fileDoesNotExist), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!chkRunExecAsRoot.isChecked() && !executableFile.canExecute())
|
||||
{
|
||||
Toast.makeText(ActivityManageActionRunExecutable.this, getResources().getString(R.string.fileNotExecutable), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Intent returnData = new Intent();
|
||||
returnData.putExtra(ActivityManageRule.intentNameActionParameter1, chkRunExecAsRoot.isChecked());
|
||||
|
||||
if(etRunExecutableParameters.getText() != null && !StringUtils.isEmpty(etRunExecutableParameters.getText().toString()))
|
||||
returnData.putExtra(ActivityManageRule.intentNameActionParameter2, etRunExecutablePath.getText().toString() + Action.actionParameter2Split + etRunExecutableParameters.getText().toString());
|
||||
else
|
||||
returnData.putExtra(ActivityManageRule.intentNameActionParameter2, etRunExecutablePath.getText().toString());
|
||||
|
||||
setResult(RESULT_OK, returnData);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
||||
{
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
|
||||
if(resultCode == RESULT_OK)
|
||||
{
|
||||
if(requestCode == PICKFILE_RESULT_CODE)
|
||||
{
|
||||
Uri fileUri = data.getData();
|
||||
String filePath = CompensateCrappyAndroidPaths.getPath(ActivityManageActionRunExecutable.this, fileUri);
|
||||
etRunExecutablePath.setText(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,281 @@
|
||||
package com.jens.automation2;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ActivityManageActionSendBroadcast extends Activity
|
||||
{
|
||||
EditText etBroadcastToSend;
|
||||
Button bBroadcastSendShowSuggestions, bSaveSendBroadcast, bAddIntentPair;
|
||||
ListView lvIntentPairs;
|
||||
EditText etParameterName, etParameterValue;
|
||||
Spinner spinnerParameterType;
|
||||
ArrayAdapter<String> intentTypeSpinnerAdapter, intentPairAdapter;
|
||||
private static final String[] supportedIntentTypes = { "boolean", "byte", "char", "double", "float", "int", "long", "short", "String", "Uri" };
|
||||
private ArrayList<String> intentPairList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_action_send_broadcast);
|
||||
|
||||
etBroadcastToSend = (EditText)findViewById(R.id.etBroadcastToSend);
|
||||
bBroadcastSendShowSuggestions = (Button)findViewById(R.id.bBroadcastSendShowSuggestions);
|
||||
bSaveSendBroadcast = (Button)findViewById(R.id.bSaveSendBroadcast);
|
||||
bAddIntentPair = (Button)findViewById(R.id.bAddIntentPair);
|
||||
lvIntentPairs = (ListView) findViewById(R.id.lvIntentPairs);
|
||||
etParameterName = (EditText) findViewById(R.id.etParameterName);
|
||||
etParameterValue = (EditText) findViewById(R.id.etParameterValue);
|
||||
spinnerParameterType = (Spinner) findViewById(R.id.spinnerParameterType);
|
||||
|
||||
intentTypeSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, ActivityManageActionSendBroadcast.supportedIntentTypes);
|
||||
spinnerParameterType.setAdapter(intentTypeSpinnerAdapter);
|
||||
intentTypeSpinnerAdapter.notifyDataSetChanged();
|
||||
intentPairAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, intentPairList);
|
||||
|
||||
bSaveSendBroadcast.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
if(checkInput())
|
||||
{
|
||||
Intent answer = new Intent();
|
||||
|
||||
String param2 = etBroadcastToSend.getText().toString();
|
||||
|
||||
if(intentPairList.size() > 0)
|
||||
{
|
||||
param2 += Action.actionParameter2Split;
|
||||
|
||||
for (String s : intentPairList)
|
||||
param2 += s + ";";
|
||||
|
||||
param2 = param2.substring(0, param2.length() - 1);
|
||||
}
|
||||
|
||||
answer.putExtra(ActivityManageRule.intentNameActionParameter2, param2);
|
||||
setResult(RESULT_OK, answer);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
bBroadcastSendShowSuggestions.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ActivityManageActionSendBroadcast.this);
|
||||
builder.setTitle(getResources().getString(R.string.selectBroadcast));
|
||||
builder.setItems(ActivityManageTriggerBroadcast.broadcastSuggestions, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int which)
|
||||
{
|
||||
etBroadcastToSend.setText(ActivityManageTriggerBroadcast.broadcastSuggestions[which]);
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
});
|
||||
|
||||
Intent input = getIntent();
|
||||
|
||||
if(input.hasExtra(ActivityManageRule.intentNameActionParameter2))
|
||||
{
|
||||
String param2 = input.getStringExtra(ActivityManageRule.intentNameActionParameter2);
|
||||
if(!param2.contains(Action.actionParameter2Split))
|
||||
etBroadcastToSend.setText(input.getStringExtra(ActivityManageRule.intentNameActionParameter2));
|
||||
else
|
||||
{
|
||||
String[] param2Parts = param2.split(Action.actionParameter2Split);
|
||||
etBroadcastToSend.setText(param2Parts[0]);
|
||||
|
||||
String[] params = param2Parts[1].split(";");
|
||||
|
||||
intentPairList.clear();
|
||||
|
||||
for(int i = 0; i < params.length; i++)
|
||||
{
|
||||
if(lvIntentPairs.getVisibility() != View.VISIBLE)
|
||||
lvIntentPairs.setVisibility(View.VISIBLE);
|
||||
|
||||
intentPairList.add(params[i]);
|
||||
}
|
||||
|
||||
updateIntentPairList();
|
||||
}
|
||||
}
|
||||
|
||||
bAddIntentPair.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
// type;name;value
|
||||
if(spinnerParameterType.getSelectedItem().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, getResources().getString(R.string.selectTypeOfIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if(etParameterName.getText().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, getResources().getString(R.string.enterNameForIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterName.getText().toString().contains(Action.intentPairSeparator))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterName.getText().toString().contains(";"))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if(etParameterValue.getText().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, getResources().getString(R.string.enterValueForIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterValue.getText().toString().contains(Action.intentPairSeparator))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterValue.getText().toString().contains(";"))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
switch(supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()])
|
||||
{
|
||||
case "int":
|
||||
case "long":
|
||||
case "short":
|
||||
if(!Miscellaneous.isNumeric(etParameterValue.getText().toString()))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "double":
|
||||
case "float":
|
||||
if(!Miscellaneous.isNumericDecimal(etParameterValue.getText().toString()))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ActivityManageActionSendBroadcast.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
}
|
||||
|
||||
String param = supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()] + Action.intentPairSeparator + etParameterName.getText().toString() + Action.intentPairSeparator + etParameterValue.getText().toString();
|
||||
intentPairList.add(param);
|
||||
|
||||
spinnerParameterType.setSelection(0);
|
||||
etParameterName.setText("");
|
||||
etParameterValue.setText("");
|
||||
|
||||
updateIntentPairList();
|
||||
|
||||
if(lvIntentPairs.getVisibility() != View.VISIBLE)
|
||||
lvIntentPairs.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
lvIntentPairs.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
|
||||
{
|
||||
getIntentPairDialog(arg2).show();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
spinnerParameterType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
|
||||
{
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3)
|
||||
{
|
||||
if(supportedIntentTypes[arg2].equals("int") || supportedIntentTypes[arg2].equals("long") || supportedIntentTypes[arg2].equals("short"))
|
||||
ActivityManageActionSendBroadcast.this.etParameterValue.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
|
||||
else if(supportedIntentTypes[arg2].equals("double") || supportedIntentTypes[arg2].equals("float"))
|
||||
ActivityManageActionSendBroadcast.this.etParameterValue.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||||
else
|
||||
ActivityManageActionSendBroadcast.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
boolean checkInput()
|
||||
{
|
||||
String broadcastToSend = etBroadcastToSend.getText().toString();
|
||||
if(StringUtils.isEmpty(broadcastToSend))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSendBroadcast.this, getResources().getString(R.string.enterBroadcast), Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void updateIntentPairList()
|
||||
{
|
||||
if(lvIntentPairs.getAdapter() == null)
|
||||
lvIntentPairs.setAdapter(intentPairAdapter);
|
||||
|
||||
intentPairAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private AlertDialog getIntentPairDialog(final int itemPosition)
|
||||
{
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ActivityManageActionSendBroadcast.this);
|
||||
alertDialogBuilder.setTitle(getResources().getString(R.string.whatToDoWithIntentPair));
|
||||
alertDialogBuilder.setItems(new String[]{getResources().getString(R.string.delete)}, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
// Only 1 choice at the moment, no need to check
|
||||
ActivityManageActionSendBroadcast.this.intentPairList.remove(itemPosition);
|
||||
updateIntentPairList();
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
return alertDialog;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.jens.automation2;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
@ -8,26 +9,37 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.ContactsContract;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.jens.automation2.Action.Action_Enum;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
||||
public class ActivityManageActionSendTextMessage extends Activity
|
||||
{
|
||||
Button bSaveSendTextMessage, bImportNumberFromContacts;
|
||||
Button bSaveSendTextMessage, bImportNumberFromContacts, bMmsAttachment;
|
||||
EditText etPhoneNumber, etSendTextMessage;
|
||||
RadioButton rbMessageTypeSms, rbMessageTypeMms;
|
||||
TextView tvSendMmsFileAttachment;
|
||||
|
||||
protected final static int requestCodeForContactsPermissions = 9876;
|
||||
protected final static int requestCodeGetContact = 3235;
|
||||
|
||||
// private String existingUrl = "";
|
||||
protected final static int requestCodeGetMMSattachment = 3236;
|
||||
|
||||
public static final String messageTypeSms = "sms";
|
||||
public static final String messageTypeMms = "mms";
|
||||
|
||||
public static boolean edit = false;
|
||||
public static Action resultingAction = null;
|
||||
@ -42,6 +54,10 @@ public class ActivityManageActionSendTextMessage extends Activity
|
||||
etPhoneNumber = (EditText)findViewById(R.id.etPhoneNumber);
|
||||
bSaveSendTextMessage = (Button)findViewById(R.id.bSaveSendTextMessage);
|
||||
bImportNumberFromContacts = (Button)findViewById(R.id.bImportNumberFromContacts);
|
||||
rbMessageTypeSms = (RadioButton)findViewById(R.id.rbMessageTypeSms);
|
||||
rbMessageTypeMms = (RadioButton) findViewById(R.id.rbMessageTypeMms);
|
||||
bMmsAttachment = (Button)findViewById(R.id.bMmsAttachment);
|
||||
tvSendMmsFileAttachment = (TextView)findViewById(R.id.tvSendMmsFileAttachment);
|
||||
|
||||
bSaveSendTextMessage.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@ -50,13 +66,29 @@ public class ActivityManageActionSendTextMessage extends Activity
|
||||
{
|
||||
if(etSendTextMessage.getText().toString().length() > 0 && etPhoneNumber.getText().toString().length() > 0)
|
||||
{
|
||||
if(resultingAction == null)
|
||||
if(rbMessageTypeMms.isChecked() && StringUtils.isEmpty(tvSendMmsFileAttachment.getText().toString()))
|
||||
Toast.makeText(getBaseContext(), getResources().getString(R.string.chooseFile), Toast.LENGTH_LONG).show();
|
||||
else
|
||||
{
|
||||
resultingAction = new Action();
|
||||
resultingAction.setAction(Action_Enum.sendTextMessage);
|
||||
resultingAction.setParameter2(etPhoneNumber.getText().toString() + Actions.smsSeparator + etSendTextMessage.getText().toString());
|
||||
if (resultingAction == null)
|
||||
{
|
||||
resultingAction = new Action();
|
||||
resultingAction.setAction(Action_Enum.sendTextMessage);
|
||||
String messageType = null;
|
||||
String path = "";
|
||||
|
||||
if(rbMessageTypeSms.isChecked())
|
||||
messageType = messageTypeSms;
|
||||
else
|
||||
{
|
||||
messageType = messageTypeMms;
|
||||
path = Actions.smsSeparator + tvSendMmsFileAttachment.getText().toString();
|
||||
}
|
||||
|
||||
resultingAction.setParameter2(etPhoneNumber.getText().toString() + Actions.smsSeparator + etSendTextMessage.getText().toString() + Actions.smsSeparator + messageType + path);
|
||||
}
|
||||
backToRuleManager();
|
||||
}
|
||||
backToRuleManager();
|
||||
}
|
||||
else
|
||||
Toast.makeText(getBaseContext(), getResources().getString(R.string.enterPhoneNumberAndText), Toast.LENGTH_LONG).show();
|
||||
@ -77,6 +109,28 @@ public class ActivityManageActionSendTextMessage extends Activity
|
||||
}
|
||||
});
|
||||
|
||||
RadioButton.OnCheckedChangeListener checkedChangedListener = new RadioButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean b)
|
||||
{
|
||||
bMmsAttachment.setEnabled(rbMessageTypeMms.isChecked());
|
||||
}
|
||||
};
|
||||
rbMessageTypeSms.setOnCheckedChangeListener(checkedChangedListener);
|
||||
rbMessageTypeMms.setOnCheckedChangeListener(checkedChangedListener);
|
||||
|
||||
bMmsAttachment.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
Intent chooseFileIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
chooseFileIntent.setType("*/*");
|
||||
chooseFileIntent = Intent.createChooser(chooseFileIntent, getResources().getString(R.string.chooseFile));
|
||||
startActivityForResult(chooseFileIntent, requestCodeGetMMSattachment);
|
||||
}
|
||||
});
|
||||
|
||||
ActivityManageActionSendTextMessage.edit = getIntent().getBooleanExtra("edit", false);
|
||||
if(edit)
|
||||
{
|
||||
@ -123,7 +177,7 @@ public class ActivityManageActionSendTextMessage extends Activity
|
||||
{
|
||||
for(int i=0; i<permissions.length; i++)
|
||||
{
|
||||
if(permissions[i].equals("android.permission.READ_CONTACTS"))
|
||||
if(permissions[i].equals(Manifest.permission.READ_CONTACTS))
|
||||
{
|
||||
if(grantResults[i] == PackageManager.PERMISSION_GRANTED)
|
||||
{
|
||||
@ -143,10 +197,10 @@ public class ActivityManageActionSendTextMessage extends Activity
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
||||
{
|
||||
if(requestCode == requestCodeGetContact)
|
||||
{
|
||||
if(resultCode == Activity.RESULT_OK)
|
||||
{
|
||||
if(resultCode == Activity.RESULT_OK)
|
||||
{
|
||||
if(requestCode == requestCodeGetContact)
|
||||
{
|
||||
String phoneNo = null;
|
||||
String name = null;
|
||||
|
||||
@ -164,6 +218,12 @@ public class ActivityManageActionSendTextMessage extends Activity
|
||||
etPhoneNumber.setText(phoneNo);
|
||||
}
|
||||
}
|
||||
else if (requestCode == requestCodeGetMMSattachment)
|
||||
{
|
||||
Uri fileUri = data.getData();
|
||||
String filePath = fileUri.getPath();
|
||||
tvSendMmsFileAttachment.setText(filePath);
|
||||
}
|
||||
}
|
||||
//super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
@ -0,0 +1,64 @@
|
||||
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);
|
||||
this.setContentView(R.layout.activity_manage_action_set_variable);
|
||||
|
||||
etVariableSetKey = (EditText)findViewById(R.id.etVariableSetKey);
|
||||
etVariableSetValue = (EditText)findViewById(R.id.etVariableSetValue);
|
||||
bSaveVariable = (Button)findViewById(R.id.bSaveVariable);
|
||||
bSaveVariable.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
if(StringUtils.isEmpty(etVariableSetKey.getText().toString()))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionSetVariable.this, getResources().getString(R.string.enterVariableKey), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Intent response = new Intent();
|
||||
|
||||
if(StringUtils.isEmpty(etVariableSetValue.getText().toString()))
|
||||
response.putExtra(ActivityManageRule.intentNameActionParameter2, etVariableSetKey.getText().toString());
|
||||
else
|
||||
response.putExtra(ActivityManageRule.intentNameActionParameter2, etVariableSetKey.getText().toString() + Action.actionParameter2Split + etVariableSetValue.getText().toString());
|
||||
|
||||
setResult(RESULT_OK, response);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(getIntent().hasExtra(ActivityManageRule.intentNameActionParameter2))
|
||||
{
|
||||
String[] input = getIntent().getStringExtra(ActivityManageRule.intentNameActionParameter2).split(Action.actionParameter2Split);
|
||||
etVariableSetKey.setText(input[0]);
|
||||
if(input.length > 1)
|
||||
etVariableSetValue.setText(input[1]);
|
||||
}
|
||||
}
|
||||
}
|
@ -15,8 +15,6 @@ public class ActivityManageActionSpeakText extends Activity
|
||||
private Button bSaveSpeakText;
|
||||
private EditText etSpeakText;
|
||||
|
||||
// private String existingUrl = "";
|
||||
|
||||
public static boolean edit = false;
|
||||
public static Action resultingAction = null;
|
||||
|
||||
@ -27,7 +25,7 @@ public class ActivityManageActionSpeakText extends Activity
|
||||
this.setContentView(R.layout.activity_manage_action_speak_text);
|
||||
|
||||
etSpeakText = (EditText)findViewById(R.id.etTextToSpeak);
|
||||
bSaveSpeakText = (Button)findViewById(R.id.bSaveTriggerUrl);
|
||||
bSaveSpeakText = (Button)findViewById(R.id.bSaveSpeakText);
|
||||
bSaveSpeakText.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.jens.automation2;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
@ -12,6 +13,7 @@ import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.view.MotionEvent;
|
||||
@ -30,6 +32,8 @@ import android.widget.RadioButton;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.jens.automation2.Action.Action_Enum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -49,11 +53,260 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
Spinner spinnerParameterType;
|
||||
boolean edit = false;
|
||||
ProgressDialog progressDialog = null;
|
||||
RadioButton rbStartAppSelectByActivity, rbStartAppSelectByAction, rbStartAppByActivity, rbStartAppByBroadcast;
|
||||
RadioButton rbStartAppSelectByActivity, rbStartAppSelectByAction, rbStartAppByActivity, rbStartAppByBroadcast, rbStartAppByService;
|
||||
|
||||
final String urlShowExamples = "https://server47.de/automation/examples_startProgram.html";
|
||||
final static String startByActivityString = "0";
|
||||
final static String startByBroadcastString = "1";
|
||||
final static String startByServiceString = "2";
|
||||
|
||||
final static int requestCodeForRequestQueryAllPackagesPermission = 4711;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_action_start_activity);
|
||||
|
||||
lvIntentPairs = (ListView)findViewById(R.id.lvIntentPairs);
|
||||
etParameterName = (EditText)findViewById(R.id.etParameterName);
|
||||
etParameterValue = (EditText)findViewById(R.id.etParameterValue);
|
||||
bSelectApp = (Button)findViewById(R.id.bSelectApp);
|
||||
bAddIntentPair = (Button)findViewById(R.id.bAddIntentPair);
|
||||
bSaveActionStartOtherActivity = (Button)findViewById(R.id.bSaveActionStartOtherActivity);
|
||||
spinnerParameterType = (Spinner)findViewById(R.id.spinnerParameterType);
|
||||
etPackageName = (EditText) findViewById(R.id.etPackageName);
|
||||
etActivityOrActionPath = (EditText) findViewById(R.id.etActivityOrActionPath);
|
||||
rbStartAppSelectByActivity = (RadioButton)findViewById(R.id.rbStartAppSelectByActivity);
|
||||
rbStartAppSelectByAction = (RadioButton)findViewById(R.id.rbStartAppSelectByAction);
|
||||
showStartProgramExamples = (Button)findViewById(R.id.showStartProgramExamples);
|
||||
rbStartAppByActivity = (RadioButton)findViewById(R.id.rbStartAppByActivity);
|
||||
rbStartAppByBroadcast = (RadioButton)findViewById(R.id.rbStartAppByBroadcast);
|
||||
rbStartAppByService = (RadioButton)findViewById(R.id.rbStartAppByService);
|
||||
|
||||
intentTypeSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, ActivityManageActionStartActivity.supportedIntentTypes);
|
||||
spinnerParameterType.setAdapter(intentTypeSpinnerAdapter);
|
||||
intentTypeSpinnerAdapter.notifyDataSetChanged();
|
||||
|
||||
intentPairAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, intentPairList);
|
||||
|
||||
bSelectApp.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
int targetSdkVersion = getApplicationContext().getApplicationInfo().targetSdkVersion;
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && targetSdkVersion >= 30 && !ActivityPermissions.havePermission(Manifest.permission.QUERY_ALL_PACKAGES, ActivityManageActionStartActivity.this))// && shouldShowRequestPermissionRationale(Manifest.permission.QUERY_ALL_PACKAGES))
|
||||
{
|
||||
if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_googleplay))
|
||||
{
|
||||
// This ain't possible anymore.
|
||||
Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.featureNotInGooglePlayVersion) + Miscellaneous.lineSeparator + Miscellaneous.lineSeparator + getResources().getString(R.string.startActivityInsertManually), ActivityManageActionStartActivity.this).show();
|
||||
}
|
||||
else
|
||||
requestPermissions(new String[] {Manifest.permission.QUERY_ALL_PACKAGES}, requestCodeForRequestQueryAllPackagesPermission);
|
||||
}
|
||||
else
|
||||
getAppList();
|
||||
}
|
||||
});
|
||||
|
||||
bAddIntentPair.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
// type;name;value
|
||||
if(spinnerParameterType.getSelectedItem().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.selectTypeOfIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if(etParameterName.getText().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterNameForIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterName.getText().toString().contains(Action.intentPairSeparator))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterName.getText().toString().contains(";"))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if(etParameterValue.getText().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterValueForIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterValue.getText().toString().contains(Action.intentPairSeparator))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeparator), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterValue.getText().toString().contains(";"))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
switch(supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()])
|
||||
{
|
||||
case "int":
|
||||
case "long":
|
||||
case "short":
|
||||
if(!Miscellaneous.isNumeric(etParameterValue.getText().toString()))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "double":
|
||||
case "float":
|
||||
if(!Miscellaneous.isNumericDecimal(etParameterValue.getText().toString()))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
}
|
||||
|
||||
String param = supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()] + Action.intentPairSeparator + etParameterName.getText().toString() + Action.intentPairSeparator + etParameterValue.getText().toString();
|
||||
intentPairList.add(param);
|
||||
|
||||
spinnerParameterType.setSelection(0);
|
||||
etParameterName.setText("");
|
||||
etParameterValue.setText("");
|
||||
|
||||
updateIntentPairList();
|
||||
|
||||
if(lvIntentPairs.getVisibility() != View.VISIBLE)
|
||||
lvIntentPairs.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
showStartProgramExamples.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlShowExamples));
|
||||
startActivity(browserIntent);
|
||||
}
|
||||
});
|
||||
|
||||
lvIntentPairs.setOnItemLongClickListener(new OnItemLongClickListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
|
||||
{
|
||||
getIntentPairDialog(arg2).show();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
bSaveActionStartOtherActivity.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
if(checkInput())
|
||||
{
|
||||
Intent returnData = new Intent();
|
||||
|
||||
returnData.putExtra(ActivityManageRule.intentNameActionParameter1, rbStartAppSelectByAction.isChecked());
|
||||
|
||||
String parameter2 = "";
|
||||
|
||||
if (rbStartAppSelectByActivity.isChecked())
|
||||
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString();
|
||||
else {
|
||||
if (etPackageName.getText().toString() != null && etPackageName.getText().toString().length() > 0)
|
||||
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString();
|
||||
else
|
||||
parameter2 += Actions.dummyPackageString + ";" + etActivityOrActionPath.getText().toString();
|
||||
}
|
||||
|
||||
if (rbStartAppByActivity.isChecked())
|
||||
parameter2 += ";" + startByActivityString;
|
||||
else if(rbStartAppByService.isChecked())
|
||||
parameter2 += ";" + startByServiceString;
|
||||
else
|
||||
parameter2 += ";" + startByBroadcastString;
|
||||
|
||||
for (String s : intentPairList)
|
||||
parameter2 += ";" + s;
|
||||
|
||||
returnData.putExtra(ActivityManageRule.intentNameActionParameter2, parameter2);
|
||||
|
||||
setResult(RESULT_OK, returnData);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
lvIntentPairs.setOnTouchListener(new OnTouchListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event)
|
||||
{
|
||||
v.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
spinnerParameterType.setOnItemSelectedListener(new OnItemSelectedListener()
|
||||
{
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3)
|
||||
{
|
||||
if(supportedIntentTypes[arg2].equals("int") || supportedIntentTypes[arg2].equals("long") || supportedIntentTypes[arg2].equals("short"))
|
||||
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
|
||||
else if(supportedIntentTypes[arg2].equals("double") || supportedIntentTypes[arg2].equals("float"))
|
||||
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||||
else
|
||||
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
rbStartAppSelectByActivity.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
||||
{
|
||||
if(isChecked)
|
||||
bSelectApp.setEnabled(isChecked);
|
||||
}
|
||||
});
|
||||
|
||||
rbStartAppSelectByAction.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
||||
{
|
||||
if(isChecked)
|
||||
bSelectApp.setEnabled(!isChecked);
|
||||
}
|
||||
});
|
||||
|
||||
Intent i = getIntent();
|
||||
if(i.hasExtra(ActivityManageRule.intentNameActionParameter1))
|
||||
loadValuesIntoGui(i);
|
||||
}
|
||||
|
||||
private class CustomPackageInfo extends PackageInfo implements Comparable<CustomPackageInfo>
|
||||
{
|
||||
@ -76,11 +329,9 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
|
||||
return name1.compareTo(name2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static List<PackageInfo> pInfos = null;
|
||||
public static Action resultingAction;
|
||||
|
||||
private static final String[] supportedIntentTypes = { "boolean", "byte", "char", "double", "float", "int", "long", "short", "String", "Uri" };
|
||||
private ArrayList<String> intentPairList = new ArrayList<String>();
|
||||
@ -331,203 +582,24 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
return alertDialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
void getAppList()
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_action_start_activity);
|
||||
|
||||
lvIntentPairs = (ListView)findViewById(R.id.lvIntentPairs);
|
||||
etParameterName = (EditText)findViewById(R.id.etParameterName);
|
||||
etParameterValue = (EditText)findViewById(R.id.etParameterValue);
|
||||
bSelectApp = (Button)findViewById(R.id.bSelectApp);
|
||||
bAddIntentPair = (Button)findViewById(R.id.bAddIntentPair);
|
||||
bSaveActionStartOtherActivity = (Button)findViewById(R.id.bSaveActionStartOtherActivity);
|
||||
spinnerParameterType = (Spinner)findViewById(R.id.spinnerParameterType);
|
||||
etPackageName = (EditText) findViewById(R.id.etPackageName);
|
||||
etActivityOrActionPath = (EditText) findViewById(R.id.etActivityOrActionPath);
|
||||
rbStartAppSelectByActivity = (RadioButton)findViewById(R.id.rbStartAppSelectByActivity);
|
||||
rbStartAppSelectByAction = (RadioButton)findViewById(R.id.rbStartAppSelectByAction);
|
||||
showStartProgramExamples = (Button)findViewById(R.id.showStartProgramExamples);
|
||||
|
||||
rbStartAppByActivity = (RadioButton)findViewById(R.id.rbStartAppByActivity);
|
||||
rbStartAppByBroadcast = (RadioButton)findViewById(R.id.rbStartAppByBroadcast);
|
||||
|
||||
intentTypeSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, ActivityManageActionStartActivity.supportedIntentTypes);
|
||||
spinnerParameterType.setAdapter(intentTypeSpinnerAdapter);
|
||||
intentTypeSpinnerAdapter.notifyDataSetChanged();
|
||||
|
||||
intentPairAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, intentPairList);
|
||||
|
||||
bSelectApp.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
GetActivityListTask getActivityListTask = new GetActivityListTask();
|
||||
getActivityListTask.execute();
|
||||
progressDialog = ProgressDialog.show(ActivityManageActionStartActivity.this, "", ActivityManageActionStartActivity.this.getResources().getString(R.string.gettingListOfInstalledApplications));
|
||||
}
|
||||
});
|
||||
|
||||
bAddIntentPair.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
// type;name;value
|
||||
if(spinnerParameterType.getSelectedItem().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.selectTypeOfIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if(etParameterName.getText().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterNameForIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterName.getText().toString().contains(Action.intentPairSeperator))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeperator), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterName.getText().toString().contains(";"))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if(etParameterValue.getText().toString().length() == 0)
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterValueForIntentPair), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterValue.getText().toString().contains(Action.intentPairSeperator))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), Action.intentPairSeperator), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else if(etParameterValue.getText().toString().contains(";"))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionStartActivity.this, String.format(getResources().getString(R.string.stringNotAllowed), ";"), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
String param = supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()] + Action.intentPairSeperator + etParameterName.getText().toString() + Action.intentPairSeperator + etParameterValue.getText().toString();
|
||||
intentPairList.add(param);
|
||||
|
||||
spinnerParameterType.setSelection(0);
|
||||
etParameterName.setText("");
|
||||
etParameterValue.setText("");
|
||||
|
||||
updateIntentPairList();
|
||||
|
||||
if(lvIntentPairs.getVisibility() != View.VISIBLE)
|
||||
lvIntentPairs.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
showStartProgramExamples.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlShowExamples));
|
||||
startActivity(browserIntent);
|
||||
}
|
||||
});
|
||||
|
||||
lvIntentPairs.setOnItemLongClickListener(new OnItemLongClickListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
|
||||
{
|
||||
getIntentPairDialog(arg2).show();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
bSaveActionStartOtherActivity.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
if(saveAction())
|
||||
{
|
||||
ActivityManageActionStartActivity.this.setResult(RESULT_OK);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
lvIntentPairs.setOnTouchListener(new OnTouchListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event)
|
||||
{
|
||||
v.getParent().requestDisallowInterceptTouchEvent(true);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
spinnerParameterType.setOnItemSelectedListener(new OnItemSelectedListener()
|
||||
{
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3)
|
||||
{
|
||||
if(supportedIntentTypes[arg2].equals("double") | supportedIntentTypes[arg2].equals("float") | supportedIntentTypes[arg2].equals("int") | supportedIntentTypes[arg2].equals("long") | supportedIntentTypes[arg2].equals("short"))
|
||||
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
else
|
||||
ActivityManageActionStartActivity.this.etParameterValue.setInputType(InputType.TYPE_CLASS_TEXT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> arg0)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
rbStartAppSelectByActivity.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
||||
{
|
||||
if(isChecked)
|
||||
bSelectApp.setEnabled(isChecked);
|
||||
}
|
||||
});
|
||||
|
||||
rbStartAppSelectByAction.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
|
||||
{
|
||||
if(isChecked)
|
||||
bSelectApp.setEnabled(!isChecked);
|
||||
}
|
||||
});
|
||||
|
||||
Intent i = getIntent();
|
||||
if(i.getBooleanExtra("edit", false) == true)
|
||||
{
|
||||
edit = true;
|
||||
loadValuesIntoGui();
|
||||
}
|
||||
GetActivityListTask getActivityListTask = new GetActivityListTask();
|
||||
getActivityListTask.execute();
|
||||
progressDialog = ProgressDialog.show(ActivityManageActionStartActivity.this, "", ActivityManageActionStartActivity.this.getResources().getString(R.string.gettingListOfInstalledApplications));
|
||||
}
|
||||
|
||||
private void loadValuesIntoGui()
|
||||
private void loadValuesIntoGui(Intent input)
|
||||
{
|
||||
boolean selectionByAction = resultingAction.getParameter1();
|
||||
boolean selectionByAction = input.getBooleanExtra(ActivityManageRule.intentNameActionParameter1, true);
|
||||
rbStartAppSelectByActivity.setChecked(!selectionByAction);
|
||||
rbStartAppSelectByAction.setChecked(selectionByAction);
|
||||
|
||||
String[] params = resultingAction.getParameter2().split(";");
|
||||
String[] params = input.getStringExtra(ActivityManageRule.intentNameActionParameter2).split(";");
|
||||
|
||||
rbStartAppByActivity.setChecked(params[2].equals(startByActivityString));
|
||||
rbStartAppByBroadcast.setChecked(params[2].equals(startByBroadcastString));
|
||||
rbStartAppByService.setChecked(params[2].equals(startByServiceString));
|
||||
|
||||
int startIndex = -1;
|
||||
|
||||
@ -570,8 +642,8 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
|
||||
intentPairAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
private boolean saveAction()
|
||||
|
||||
boolean checkInput()
|
||||
{
|
||||
if(rbStartAppSelectByActivity.isChecked())
|
||||
{
|
||||
@ -594,36 +666,7 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(resultingAction == null)
|
||||
resultingAction = new Action();
|
||||
|
||||
resultingAction.setParameter1(rbStartAppSelectByAction.isChecked());
|
||||
|
||||
resultingAction.setAction(Action_Enum.startOtherActivity);
|
||||
|
||||
String parameter2 = "";
|
||||
|
||||
if(rbStartAppSelectByActivity.isChecked())
|
||||
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString();
|
||||
else
|
||||
{
|
||||
if(etPackageName.getText().toString() != null && etPackageName.getText().toString().length() > 0)
|
||||
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString();
|
||||
else
|
||||
parameter2 += Actions.dummyPackageString + ";" + etActivityOrActionPath.getText().toString();
|
||||
}
|
||||
|
||||
if(rbStartAppByActivity.isChecked())
|
||||
parameter2 += ";" + startByActivityString;
|
||||
else
|
||||
parameter2 += ";" + startByBroadcastString;
|
||||
|
||||
for(String s : intentPairList)
|
||||
parameter2 += ";" + s;
|
||||
|
||||
resultingAction.setParameter2(parameter2);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -661,4 +704,22 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
getActionStartActivityDialog1Application().show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults)
|
||||
{
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
if(requestCode == requestCodeForRequestQueryAllPackagesPermission)
|
||||
{
|
||||
for(int i = 0; i < permissions.length; i++)
|
||||
{
|
||||
if(permissions[i].equals(Manifest.permission.QUERY_ALL_PACKAGES) && grantResults[i] == PackageManager.PERMISSION_GRANTED)
|
||||
{
|
||||
getAppList();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -47,7 +47,7 @@ public class ActivityManageActionTriggerUrl extends Activity
|
||||
chkTriggerUrlUseAuthentication = (CheckBox)findViewById(R.id.chkTriggerUrlUseAuthentication);
|
||||
lvTriggerUrlPostParameters = (ListView)findViewById(R.id.lvTriggerUrlPostParameters);
|
||||
tlTriggerUrlAuthentication = (TableLayout)findViewById(R.id.tlTriggerUrlAuthentication);
|
||||
bSaveTriggerUrl = (Button)findViewById(R.id.bSaveTriggerUrl);
|
||||
bSaveTriggerUrl = (Button)findViewById(R.id.bSaveSpeakText);
|
||||
bSaveTriggerUrl.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
|
@ -0,0 +1,99 @@
|
||||
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);
|
||||
setContentView(R.layout.activity_manage_action_wakelock);
|
||||
|
||||
rbWakeLockActivate = (RadioButton)findViewById(R.id.rbWakeLockActivate);
|
||||
rbWakeLockDeactivate = (RadioButton)findViewById(R.id.rbWakeLockDeactivate);
|
||||
chkWakeLockTimeout = (CheckBox)findViewById(R.id.chkWakeLockTimeout);
|
||||
etWakeLockDuration = (EditText)findViewById(R.id.etWakeLockDuration);
|
||||
bSaveWakelock = (Button)findViewById(R.id.bSaveWakelock);
|
||||
|
||||
etWakeLockDuration.setEnabled(chkWakeLockTimeout.isChecked());
|
||||
|
||||
chkWakeLockTimeout.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean wakeLockTimeoutSet)
|
||||
{
|
||||
etWakeLockDuration.setEnabled(wakeLockTimeoutSet);
|
||||
|
||||
if(wakeLockTimeoutSet)
|
||||
etWakeLockDuration.setText(String.valueOf(Actions.wakeLockTimeoutDisabled));
|
||||
}
|
||||
});
|
||||
|
||||
if(getIntent().hasExtra(ActivityManageRule.intentNameActionParameter1))
|
||||
{
|
||||
rbWakeLockActivate.setChecked(getIntent().getBooleanExtra(ActivityManageRule.intentNameActionParameter1, true));
|
||||
rbWakeLockDeactivate.setChecked(!getIntent().getBooleanExtra(ActivityManageRule.intentNameActionParameter1, false));
|
||||
|
||||
if(getIntent().hasExtra(ActivityManageRule.intentNameActionParameter2))
|
||||
{
|
||||
if(Miscellaneous.isNumeric(getIntent().getStringExtra(ActivityManageRule.intentNameActionParameter2)))
|
||||
{
|
||||
long timeout = Long.parseLong((getIntent().getStringExtra(ActivityManageRule.intentNameActionParameter2)));
|
||||
chkWakeLockTimeout.setChecked(timeout != Actions.wakeLockTimeoutDisabled);
|
||||
etWakeLockDuration.setText(String.valueOf(timeout));
|
||||
}
|
||||
else
|
||||
{
|
||||
chkWakeLockTimeout.setChecked(false);
|
||||
etWakeLockDuration.setText(String.valueOf(Actions.wakeLockTimeoutDisabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bSaveWakelock.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
if(chkWakeLockTimeout.isChecked())
|
||||
{
|
||||
if((StringUtils.isEmpty(etWakeLockDuration.getText().toString()) || Integer.parseInt(etWakeLockDuration.getText().toString()) <= 0))
|
||||
{
|
||||
Toast.makeText(ActivityManageActionWakeLock.this, getResources().getString(R.string.enterAPositiveValidNonDecimalNumber), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Intent response = new Intent();
|
||||
response.putExtra(ActivityManageRule.intentNameActionParameter1, rbWakeLockActivate.isChecked());
|
||||
if(chkWakeLockTimeout.isChecked())
|
||||
response.putExtra(ActivityManageRule.intentNameActionParameter2, etWakeLockDuration.getText().toString());
|
||||
else
|
||||
response.putExtra(ActivityManageRule.intentNameActionParameter2, String.valueOf(Actions.wakeLockTimeoutDisabled));
|
||||
setResult(RESULT_OK, response);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.jens.automation2;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class ActivityManageActionWifi extends Activity
|
||||
{
|
||||
CheckBox chkWifiRunAsRoot;
|
||||
RadioButton rbActionWifiOn, rbActionWifiOff;
|
||||
Button bActionWifiSave;
|
||||
TextView tvWifiExplanation1, tvWifiExplanation2;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_action_wifi);
|
||||
|
||||
chkWifiRunAsRoot = (CheckBox)findViewById(R.id.chkWifiRunAsRoot);
|
||||
rbActionWifiOn = (RadioButton) findViewById(R.id.rbActionWifiOn);
|
||||
rbActionWifiOff = (RadioButton)findViewById(R.id.rbActionWifiOff);
|
||||
bActionWifiSave = (Button) findViewById(R.id.bActionWifiSave);
|
||||
tvWifiExplanation1 = (TextView)findViewById(R.id.tvWifiExplanation1);
|
||||
tvWifiExplanation2 = (TextView)findViewById(R.id.tvWifiExplanation2);
|
||||
|
||||
Intent input = getIntent();
|
||||
if(input.hasExtra(ActivityManageRule.intentNameActionParameter1))
|
||||
rbActionWifiOn.setChecked(input.getBooleanExtra(ActivityManageRule.intentNameActionParameter1, true));
|
||||
|
||||
if(input.hasExtra(ActivityManageRule.intentNameActionParameter2))
|
||||
chkWifiRunAsRoot.setChecked(Boolean.parseBoolean(input.getStringExtra(ActivityManageRule.intentNameActionParameter2)));
|
||||
|
||||
// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
|
||||
// Miscellaneous.messageBox(getResources().getString(R.string.app_name), getResources().getString(R.string.android10WifiToggleNotice), ActivityManageActionWifi.this).show();
|
||||
|
||||
if(getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.Q)
|
||||
tvWifiExplanation1.setVisibility(View.VISIBLE);
|
||||
else
|
||||
tvWifiExplanation1.setVisibility(View.GONE);
|
||||
|
||||
bActionWifiSave.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
Intent response = new Intent();
|
||||
response.putExtra(ActivityManageRule.intentNameActionParameter1, rbActionWifiOn.isChecked());
|
||||
response.putExtra(ActivityManageRule.intentNameActionParameter2, String.valueOf(chkWifiRunAsRoot.isChecked()));
|
||||
setResult(RESULT_OK, response);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.view.View;
|
||||
@ -33,7 +34,6 @@ public class ActivityManagePoi extends Activity
|
||||
public LocationManager myLocationManager;
|
||||
MyLocationListenerGps myLocationListenerGps = new MyLocationListenerGps();
|
||||
Location locationGps = null, locationNetwork = null;
|
||||
// Location locationWifi = null;
|
||||
MyLocationListenerNetwork myLocationListenerNetwork = new MyLocationListenerNetwork();
|
||||
Button bGetPosition, bSavePoi;
|
||||
ImageButton ibShowOnMap;
|
||||
@ -83,17 +83,17 @@ public class ActivityManagePoi extends Activity
|
||||
bSavePoi = (Button)findViewById(R.id.bSavePoi);
|
||||
bSavePoi.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
hideKeyboard();
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
hideKeyboard();
|
||||
|
||||
if(ActivityMainPoi.poiToEdit == null)
|
||||
createPoi();
|
||||
else
|
||||
changePoi();
|
||||
}
|
||||
});
|
||||
if(ActivityMainPoi.poiToEdit == null)
|
||||
createPoi();
|
||||
else
|
||||
changePoi();
|
||||
}
|
||||
});
|
||||
|
||||
ibShowOnMap.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@ -136,42 +136,45 @@ public class ActivityManagePoi extends Activity
|
||||
|
||||
private void getLocation()
|
||||
{
|
||||
Criteria critNetwork = new Criteria();
|
||||
critNetwork.setPowerRequirement(Criteria.POWER_LOW);
|
||||
critNetwork.setAltitudeRequired(false);
|
||||
critNetwork.setSpeedRequired(false);
|
||||
critNetwork.setBearingRequired(false);
|
||||
critNetwork.setCostAllowed(false);
|
||||
critNetwork.setAccuracy(Criteria.ACCURACY_COARSE);
|
||||
Criteria criteriaNetwork = new Criteria();
|
||||
criteriaNetwork.setPowerRequirement(Criteria.POWER_LOW);
|
||||
criteriaNetwork.setAltitudeRequired(false);
|
||||
criteriaNetwork.setSpeedRequired(false);
|
||||
criteriaNetwork.setBearingRequired(false);
|
||||
criteriaNetwork.setCostAllowed(false);
|
||||
criteriaNetwork.setAccuracy(Criteria.ACCURACY_COARSE);
|
||||
|
||||
Criteria criteriaGps = new Criteria();
|
||||
criteriaGps.setAltitudeRequired(false);
|
||||
criteriaGps.setSpeedRequired(false);
|
||||
criteriaGps.setBearingRequired(false);
|
||||
criteriaGps.setCostAllowed(true);
|
||||
criteriaGps.setAccuracy(Criteria.ACCURACY_FINE);
|
||||
|
||||
Criteria critGps = new Criteria();
|
||||
critGps.setAltitudeRequired(false);
|
||||
critGps.setSpeedRequired(false);
|
||||
critGps.setBearingRequired(false);
|
||||
critGps.setCostAllowed(true);
|
||||
critGps.setAccuracy(Criteria.ACCURACY_FINE);
|
||||
|
||||
String provider1 = myLocationManager.getBestProvider(critNetwork, true);
|
||||
String provider2 = myLocationManager.getBestProvider(critGps, true);
|
||||
String provider1 = myLocationManager.getBestProvider(criteriaNetwork, true);
|
||||
String provider2 = myLocationManager.getBestProvider(criteriaGps, true);
|
||||
// String provider3 = myLocationManager.getProvider("wifi");
|
||||
|
||||
if(provider1 == null | provider2 == null)
|
||||
if(provider1 == null || provider2 == null)
|
||||
{
|
||||
Toast.makeText(this, getResources().getString(R.string.logNoSuitableProvider), Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(provider1.equals(provider2))
|
||||
Miscellaneous.logEvent("i", "POI Manager", "Both location providers are equal. Only one will be used.", 4);
|
||||
|
||||
locationSearchStart = Calendar.getInstance();
|
||||
startTimeout();
|
||||
|
||||
if(!Settings.privacyLocationing || !ConnectivityReceiver.isDataConnectionAvailable(AutomationService.getInstance()))
|
||||
if(!Settings.privacyLocationing && !ConnectivityReceiver.isDataConnectionAvailable(Miscellaneous.getAnyContext()) && !provider1.equals(provider2))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "POI Manager", getResources().getString(R.string.logGettingPositionWithProvider) + " " + provider1, 3);
|
||||
myLocationManager.requestLocationUpdates(provider1, 500, Settings.satisfactoryAccuracyNetwork, myLocationListenerNetwork);
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("i", "POI Manager", "Skipping network location query because private locationing is active.", 4);
|
||||
Miscellaneous.logEvent("i", "POI Manager", "Skipping network location.", 4);
|
||||
|
||||
Miscellaneous.logEvent("i", "POI Manager", getResources().getString(R.string.logGettingPositionWithProvider) + " " + provider2, 3);
|
||||
myLocationManager.requestLocationUpdates(provider2, 500, Settings.satisfactoryAccuracyGps, myLocationListenerGps);
|
||||
@ -310,7 +313,21 @@ public class ActivityManagePoi extends Activity
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
progressDialog = ProgressDialog.show(ActivityManagePoi.this, "", getResources().getString(R.string.gettingPosition), true, true);
|
||||
getLocation();
|
||||
if(Build.VERSION.SDK_INT >= 31)
|
||||
{
|
||||
AlertDialog dia = Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.locationNotWorkingOn12), ActivityManagePoi.this);
|
||||
dia.setOnDismissListener(new DialogInterface.OnDismissListener()
|
||||
{
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialogInterface)
|
||||
{
|
||||
getLocation();
|
||||
}
|
||||
});
|
||||
dia.show();
|
||||
}
|
||||
else
|
||||
getLocation();
|
||||
}
|
||||
};
|
||||
alertDialogBuilder.setMessage(text).setPositiveButton("Ok", dialogClickListener);
|
||||
|
@ -44,38 +44,40 @@ public class ActivityManageProfile extends Activity
|
||||
Button bChangeSoundIncomingCalls, bChangeSoundNotifications, bSaveProfile;
|
||||
TextView tvIncomingCallsRingtone, tvNotificationsRingtone;
|
||||
EditText etName;
|
||||
|
||||
boolean guiUpdate = false;
|
||||
|
||||
File incomingCallsRingtone = null, notificationsRingtone = null;
|
||||
String incomingCallsRingtone = null, notificationsRingtone = null;
|
||||
|
||||
ArrayAdapter<String> soundModeAdapter;
|
||||
ArrayAdapter<String> dndModeAdapter;
|
||||
|
||||
public void setIncomingCallsRingtone(File incomingCallsRingtone)
|
||||
public void setIncomingCallsRingtone(String incomingCallsRingtone)
|
||||
{
|
||||
this.incomingCallsRingtone = incomingCallsRingtone;
|
||||
|
||||
if(incomingCallsRingtone != null)
|
||||
tvIncomingCallsRingtone.setText(this.incomingCallsRingtone.getAbsolutePath());
|
||||
tvIncomingCallsRingtone.setText(this.incomingCallsRingtone);
|
||||
else
|
||||
tvIncomingCallsRingtone.setText(getResources().getString(R.string.none));
|
||||
}
|
||||
|
||||
public File getIncomingCallsRingtone()
|
||||
public String getIncomingCallsRingtone()
|
||||
{
|
||||
return incomingCallsRingtone;
|
||||
}
|
||||
|
||||
public void setNotificationsRingtone(File notificationsRingtone)
|
||||
public void setNotificationsRingtone(String notificationsRingtone)
|
||||
{
|
||||
this.notificationsRingtone = notificationsRingtone;
|
||||
|
||||
if(this.notificationsRingtone != null)
|
||||
tvNotificationsRingtone.setText(this.notificationsRingtone.getAbsolutePath());
|
||||
tvNotificationsRingtone.setText(this.notificationsRingtone);
|
||||
else
|
||||
tvNotificationsRingtone.setText(getResources().getString(R.string.none));
|
||||
}
|
||||
|
||||
public File getNotificationsRingtone()
|
||||
public String getNotificationsRingtone()
|
||||
{
|
||||
return notificationsRingtone;
|
||||
}
|
||||
@ -282,26 +284,26 @@ public class ActivityManageProfile extends Activity
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
try
|
||||
{
|
||||
Intent fileIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
fileIntent.setType("audio/*");
|
||||
startActivityForResult(Intent.createChooser(fileIntent, "Select a ringtone"), intentCodeRingtonePickerCallsFile);
|
||||
}
|
||||
catch(ActivityNotFoundException e)
|
||||
{
|
||||
// try
|
||||
// {
|
||||
// Intent fileIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
// fileIntent.setType("audio/*");
|
||||
// startActivityForResult(Intent.createChooser(fileIntent, "Select a ringtone"), intentCodeRingtonePickerCallsFile);
|
||||
// }
|
||||
// catch(ActivityNotFoundException e)
|
||||
// {
|
||||
// Use media browser instead
|
||||
Intent fileSelectionIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
|
||||
|
||||
if(ActivityMainProfiles.profileToEdit != null)
|
||||
{
|
||||
Uri currenturi = Uri.parse(ActivityMainProfiles.profileToEdit.incomingCallsRingtone.getAbsolutePath());
|
||||
Uri currenturi = Uri.parse(ActivityMainProfiles.profileToEdit.incomingCallsRingtone);
|
||||
if(ActivityMainProfiles.profileToEdit.changeIncomingCallsRingtone)
|
||||
fileSelectionIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currenturi);
|
||||
}
|
||||
|
||||
startActivityForResult(fileSelectionIntent, intentCodeRingtonePickerCallsRingtone);
|
||||
}
|
||||
// }
|
||||
}
|
||||
});
|
||||
bChangeSoundNotifications.setOnClickListener(new OnClickListener()
|
||||
@ -322,7 +324,7 @@ public class ActivityManageProfile extends Activity
|
||||
|
||||
if(ActivityMainProfiles.profileToEdit != null)
|
||||
{
|
||||
Uri currenturi = Uri.parse(ActivityMainProfiles.profileToEdit.notificationRingtone.getAbsolutePath());
|
||||
Uri currenturi = Uri.parse(ActivityMainProfiles.profileToEdit.notificationRingtone);
|
||||
if(ActivityMainProfiles.profileToEdit.changeNotificationRingtone)
|
||||
fileSelectionIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currenturi);
|
||||
}
|
||||
@ -368,6 +370,8 @@ public class ActivityManageProfile extends Activity
|
||||
|
||||
public void editProfile(Profile profileToEdit)
|
||||
{
|
||||
guiUpdate = true;
|
||||
|
||||
etName.setText(ActivityMainProfiles.profileToEdit.getName());
|
||||
checkBoxChangeSoundMode.setChecked(ActivityMainProfiles.profileToEdit.getChangeSoundMode());
|
||||
checkBoxChangeDnd.setChecked(ActivityMainProfiles.profileToEdit.getChangeDndMode());
|
||||
@ -393,6 +397,8 @@ public class ActivityManageProfile extends Activity
|
||||
|
||||
setIncomingCallsRingtone(ActivityMainProfiles.profileToEdit.getIncomingCallsRingtone());
|
||||
setNotificationsRingtone(ActivityMainProfiles.profileToEdit.getNotificationRingtone());
|
||||
|
||||
guiUpdate = false;
|
||||
}
|
||||
|
||||
private boolean loadFormValuesToVariable()
|
||||
@ -489,15 +495,20 @@ public class ActivityManageProfile extends Activity
|
||||
Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
||||
if (uri != null)
|
||||
{
|
||||
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, uri);
|
||||
setIncomingCallsRingtone(new File(ringTonePath));
|
||||
// if(Build.VERSION.SDK_INT < 26)
|
||||
// {
|
||||
// String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, uri);
|
||||
// setIncomingCallsRingtone(ringTonePath);
|
||||
// }
|
||||
// else
|
||||
setIncomingCallsRingtone(uri.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case intentCodeRingtonePickerCallsFile:
|
||||
{
|
||||
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, data.getData());
|
||||
setIncomingCallsRingtone(new File(ringTonePath));
|
||||
setIncomingCallsRingtone(ringTonePath);
|
||||
break;
|
||||
}
|
||||
case intentCodeRingtonePickerNotificationsRingtone: // notifications
|
||||
@ -505,15 +516,20 @@ public class ActivityManageProfile extends Activity
|
||||
Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
||||
if (uri != null)
|
||||
{
|
||||
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, data.getData());
|
||||
setNotificationsRingtone(new File(ringTonePath));
|
||||
// if(Build.VERSION.SDK_INT < 26)
|
||||
// {
|
||||
// String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, uri);
|
||||
// setNotificationsRingtone(ringTonePath);
|
||||
// }
|
||||
// else
|
||||
setNotificationsRingtone(uri.toString());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case intentCodeRingtonePickerNotificationsFile:
|
||||
{
|
||||
String ringTonePath = CompensateCrappyAndroidPaths.getPath(ActivityManageProfile.this, data.getData());
|
||||
setNotificationsRingtone(new File(ringTonePath));
|
||||
setNotificationsRingtone(ringTonePath);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2,6 +2,7 @@ package com.jens.automation2;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@ -12,6 +13,7 @@ import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.jens.automation2.receivers.BluetoothReceiver;
|
||||
@ -22,6 +24,7 @@ public class ActivityManageTriggerBluetooth extends Activity
|
||||
RadioButton radioAnyBluetoothDevice, radioNoDevice, radioDeviceFromList, radioBluetoothConnected, radioBluetoothDisconnected, radioBluetoothInRange, radioBluetoothOutRange;
|
||||
Button bSaveBluetoothTrigger;
|
||||
Spinner spinnerBluetoothDevices;
|
||||
TextView tvBluetoothNotPresentNotice;
|
||||
|
||||
ArrayAdapter<String> bluetoothDevicesSpinnerAdapter;
|
||||
|
||||
@ -40,9 +43,15 @@ public class ActivityManageTriggerBluetooth extends Activity
|
||||
radioBluetoothOutRange = (RadioButton)findViewById(R.id.radioBluetoothOutRange);
|
||||
bSaveBluetoothTrigger = (Button)findViewById(R.id.bSaveBluetoothTrigger);
|
||||
spinnerBluetoothDevices = (Spinner)findViewById(R.id.spinnerBluetoothDevices);
|
||||
tvBluetoothNotPresentNotice = (TextView)findViewById(R.id.tvBluetoothNotPresentNotice);
|
||||
|
||||
bluetoothDevicesSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, BluetoothReceiver.getAllPairedBluetoothDevicesStrings());
|
||||
|
||||
|
||||
if(!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH))
|
||||
tvBluetoothNotPresentNotice.setVisibility(View.VISIBLE);
|
||||
else
|
||||
tvBluetoothNotPresentNotice.setVisibility(View.GONE);
|
||||
|
||||
radioDeviceFromList.setOnCheckedChangeListener(new OnCheckedChangeListener()
|
||||
{
|
||||
@Override
|
||||
|
@ -0,0 +1,421 @@
|
||||
package com.jens.automation2;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class ActivityManageTriggerBroadcast extends Activity
|
||||
{
|
||||
RadioButton rbBroadcastReceived, rbBroadcastNotReceived;
|
||||
EditText etBroadcastTriggerAction;
|
||||
Button bBroadcastShowSuggestions, bSaveTriggerBroadcast;
|
||||
TextView tvBroadcastUrl;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_trigger_broadcasts);
|
||||
|
||||
bBroadcastShowSuggestions = findViewById(R.id.bBroadcastShowSuggestions);
|
||||
bSaveTriggerBroadcast = findViewById(R.id.bSaveTriggerBroadcast);
|
||||
etBroadcastTriggerAction = findViewById(R.id.etBroadcastTriggerAction);
|
||||
rbBroadcastReceived = findViewById(R.id.rbBroadcastReceived);
|
||||
rbBroadcastNotReceived = findViewById(R.id.rbBroadcastNotReceived);
|
||||
tvBroadcastUrl = findViewById(R.id.tvBroadcastUrl);
|
||||
|
||||
if(getIntent().hasExtra(ActivityManageRule.intentNameTriggerParameter1) && getIntent().hasExtra(ActivityManageRule.intentNameTriggerParameter2))
|
||||
{
|
||||
if(getIntent().getBooleanExtra(ActivityManageRule.intentNameTriggerParameter1, true))
|
||||
rbBroadcastReceived.setChecked(true);
|
||||
else
|
||||
rbBroadcastNotReceived.setChecked(true);
|
||||
|
||||
etBroadcastTriggerAction.setText(getIntent().getStringExtra(ActivityManageRule.intentNameTriggerParameter2));
|
||||
}
|
||||
|
||||
tvBroadcastUrl.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().getString(R.string.broadcastListUrl)));
|
||||
startActivity(browserIntent);
|
||||
}
|
||||
});
|
||||
|
||||
bBroadcastShowSuggestions.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ActivityManageTriggerBroadcast.this);
|
||||
builder.setTitle(getResources().getString(R.string.selectBroadcast));
|
||||
builder.setItems(broadcastSuggestions, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int which)
|
||||
{
|
||||
etBroadcastTriggerAction.setText(broadcastSuggestions[which]);
|
||||
}
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
});
|
||||
|
||||
bSaveTriggerBroadcast.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
if(etBroadcastTriggerAction.getText() != null && !StringUtils.isEmpty(etBroadcastTriggerAction.getText().toString()))
|
||||
{
|
||||
Intent data = new Intent();
|
||||
data.putExtra(ActivityManageRule.intentNameTriggerParameter1, rbBroadcastReceived.isChecked());
|
||||
data.putExtra(ActivityManageRule.intentNameTriggerParameter2, etBroadcastTriggerAction.getText().toString());
|
||||
ActivityManageTriggerBroadcast.this.setResult(RESULT_OK, data);
|
||||
|
||||
finish();
|
||||
}
|
||||
else
|
||||
Toast.makeText(ActivityManageTriggerBroadcast.this, getResources().getString(R.string.enterText), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static String[] broadcastSuggestions = {
|
||||
"android.accounts.LOGIN_ACCOUNTS_CHANGED",
|
||||
"android.accounts.action.ACCOUNT_REMOVED",
|
||||
"android.app.action.ACTION_PASSWORD_CHANGED",
|
||||
"android.app.action.ACTION_PASSWORD_EXPIRING",
|
||||
"android.app.action.ACTION_PASSWORD_FAILED",
|
||||
"android.app.action.ACTION_PASSWORD_SUCCEEDED",
|
||||
"android.app.action.AFFILIATED_PROFILE_TRANSFER_OWNERSHIP_COMPLETE",
|
||||
"android.app.action.APPLICATION_DELEGATION_SCOPES_CHANGED",
|
||||
"android.app.action.APP_BLOCK_STATE_CHANGED",
|
||||
"android.app.action.AUTOMATIC_ZEN_RULE_STATUS_CHANGED",
|
||||
"android.app.action.BUGREPORT_FAILED",
|
||||
"android.app.action.BUGREPORT_SHARE",
|
||||
"android.app.action.BUGREPORT_SHARING_DECLINED",
|
||||
"android.app.action.DATA_SHARING_RESTRICTION_APPLIED",
|
||||
"android.app.action.DATA_SHARING_RESTRICTION_CHANGED",
|
||||
"android.app.action.DEVICE_ADMIN_DISABLED",
|
||||
"android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED",
|
||||
"android.app.action.DEVICE_ADMIN_ENABLED",
|
||||
"android.app.action.DEVICE_OWNER_CHANGED",
|
||||
"android.app.action.INTERRUPTION_FILTER_CHANGED",
|
||||
"android.app.action.INTERRUPTION_FILTER_CHANGED_INTERNAL",
|
||||
"android.app.action.LOCK_TASK_ENTERING",
|
||||
"android.app.action.LOCK_TASK_EXITING",
|
||||
"android.app.action.MANAGED_USER_CREATED",
|
||||
"android.app.action.NETWORK_LOGS_AVAILABLE",
|
||||
"android.app.action.NEXT_ALARM_CLOCK_CHANGED",
|
||||
"android.app.action.NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED",
|
||||
"android.app.action.NOTIFICATION_CHANNEL_GROUP_BLOCK_STATE_CHANGED",
|
||||
"android.app.action.NOTIFICATION_POLICY_ACCESS_GRANTED_CHANGED",
|
||||
"android.app.action.NOTIFICATION_POLICY_CHANGED",
|
||||
"android.app.action.NOTIFY_PENDING_SYSTEM_UPDATE",
|
||||
"android.app.action.PROFILE_OWNER_CHANGED",
|
||||
"android.app.action.PROFILE_PROVISIONING_COMPLETE",
|
||||
"android.app.action.SECURITY_LOGS_AVAILABLE",
|
||||
"android.app.action.SYSTEM_UPDATE_POLICY_CHANGED",
|
||||
"android.app.action.TRANSFER_OWNERSHIP_COMPLETE",
|
||||
"android.app.action.USER_ADDED",
|
||||
"android.app.action.USER_REMOVED",
|
||||
"android.app.action.USER_STARTED",
|
||||
"android.app.action.USER_STOPPED",
|
||||
"android.app.action.USER_SWITCHED",
|
||||
"android.appwidget.action.APPWIDGET_DELETED",
|
||||
"android.appwidget.action.APPWIDGET_DISABLED",
|
||||
"android.appwidget.action.APPWIDGET_ENABLED",
|
||||
"android.appwidget.action.APPWIDGET_HOST_RESTORED",
|
||||
"android.appwidget.action.APPWIDGET_RESTORED",
|
||||
"android.appwidget.action.APPWIDGET_UPDATE",
|
||||
"android.appwidget.action.APPWIDGET_UPDATE_OPTIONS",
|
||||
"android.bluetooth.a2dp.profile.action.ACTIVE_DEVICE_CHANGED",
|
||||
"android.bluetooth.a2dp.profile.action.AVRCP_CONNECTION_STATE_CHANGED",
|
||||
"android.bluetooth.a2dp.profile.action.CODEC_CONFIG_CHANGED",
|
||||
"android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED",
|
||||
"android.bluetooth.a2dp.profile.action.PLAYING_STATE_CHANGED",
|
||||
"android.bluetooth.adapter.action.CONNECTION_STATE_CHANGED",
|
||||
"android.bluetooth.adapter.action.DISCOVERY_FINISHED",
|
||||
"android.bluetooth.adapter.action.DISCOVERY_STARTED",
|
||||
"android.bluetooth.adapter.action.LOCAL_NAME_CHANGED",
|
||||
"android.bluetooth.adapter.action.SCAN_MODE_CHANGED",
|
||||
"android.bluetooth.adapter.action.STATE_CHANGED",
|
||||
"android.bluetooth.device.action.ACL_CONNECTED",
|
||||
"android.bluetooth.device.action.ACL_DISCONNECTED",
|
||||
"android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED",
|
||||
"android.bluetooth.device.action.ALIAS_CHANGED",
|
||||
"android.bluetooth.device.action.BATTERY_LEVEL_CHANGED",
|
||||
"android.bluetooth.device.action.BOND_STATE_CHANGED",
|
||||
"android.bluetooth.device.action.CLASS_CHANGED",
|
||||
"android.bluetooth.device.action.CONNECTION_ACCESS_CANCEL",
|
||||
"android.bluetooth.device.action.CONNECTION_ACCESS_REPLY",
|
||||
"android.bluetooth.device.action.CONNECTION_ACCESS_REQUEST",
|
||||
"android.bluetooth.device.action.FOUND",
|
||||
"android.bluetooth.device.action.MAS_INSTANCE",
|
||||
"android.bluetooth.device.action.NAME_CHANGED",
|
||||
"android.bluetooth.device.action.NAME_FAILED",
|
||||
"android.bluetooth.device.action.PAIRING_CANCEL",
|
||||
"android.bluetooth.device.action.PAIRING_REQUEST",
|
||||
"android.bluetooth.device.action.SDP_RECORD",
|
||||
"android.bluetooth.device.action.SILENCE_MODE_CHANGED",
|
||||
"android.bluetooth.device.action.UUID",
|
||||
"android.bluetooth.devicepicker.action.DEVICE_SELECTED",
|
||||
"android.bluetooth.devicepicker.action.LAUNCH",
|
||||
"android.bluetooth.headset.action.VENDOR_SPECIFIC_HEADSET_EVENT",
|
||||
"android.bluetooth.headset.profile.action.ACTIVE_DEVICE_CHANGED",
|
||||
"android.bluetooth.headset.profile.action.AUDIO_STATE_CHANGED",
|
||||
"android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED",
|
||||
"android.bluetooth.hearingaid.profile.action.ACTIVE_DEVICE_CHANGED",
|
||||
"android.bluetooth.hearingaid.profile.action.CONNECTION_STATE_CHANGED",
|
||||
"android.bluetooth.hiddevice.profile.action.CONNECTION_STATE_CHANGED",
|
||||
"android.bluetooth.input.profile.action.CONNECTION_STATE_CHANGED",
|
||||
"android.bluetooth.input.profile.action.HANDSHAKE",
|
||||
"android.bluetooth.input.profile.action.IDLE_TIME_CHANGED",
|
||||
"android.bluetooth.input.profile.action.PROTOCOL_MODE_CHANGED",
|
||||
"android.bluetooth.input.profile.action.REPORT",
|
||||
"android.bluetooth.input.profile.action.VIRTUAL_UNPLUG_STATUS",
|
||||
"android.bluetooth.pan.profile.action.CONNECTION_STATE_CHANGED",
|
||||
"android.bluetooth.pbap.profile.action.CONNECTION_STATE_CHANGED",
|
||||
"android.content.pm.action.SESSION_COMMITTED",
|
||||
"android.content.pm.action.SESSION_UPDATED",
|
||||
"android.hardware.action.NEW_PICTURE",
|
||||
"android.hardware.action.NEW_VIDEO",
|
||||
"android.hardware.hdmi.action.OSD_MESSAGE",
|
||||
"android.hardware.input.action.QUERY_KEYBOARD_LAYOUTS",
|
||||
"android.hardware.usb.action.USB_ACCESSORY_ATTACHED",
|
||||
"android.hardware.usb.action.USB_ACCESSORY_DETACHED",
|
||||
"android.hardware.usb.action.USB_DEVICE_ATTACHED",
|
||||
"android.hardware.usb.action.USB_DEVICE_DETACHED",
|
||||
"android.intent.action.ACTION_IDLE_MAINTENANCE_END",
|
||||
"android.intent.action.ACTION_IDLE_MAINTENANCE_START",
|
||||
"android.intent.action.ACTION_POWER_CONNECTED",
|
||||
"android.intent.action.ACTION_POWER_DISCONNECTED",
|
||||
"android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED",
|
||||
"android.intent.action.ACTION_SHUTDOWN",
|
||||
"android.intent.action.AIRPLANE_MODE",
|
||||
"android.intent.action.ALARM_CHANGED",
|
||||
"android.intent.action.APPLICATION_RESTRICTIONS_CHANGED",
|
||||
"android.intent.action.BATTERY_CHANGED",
|
||||
"android.intent.action.BATTERY_LOW",
|
||||
"android.intent.action.BATTERY_OKAY",
|
||||
"android.intent.action.BOOT_COMPLETED",
|
||||
"android.intent.action.CALL_DISCONNECT_CAUSE",
|
||||
"android.intent.action.CAMERA_BUTTON",
|
||||
"android.intent.action.CANCEL_ENABLE_ROLLBACK",
|
||||
"android.intent.action.CLEAR_DNS_CACHE",
|
||||
"android.intent.action.CLOSE_SYSTEM_DIALOGS",
|
||||
"android.intent.action.CONFIGURATION_CHANGED",
|
||||
"android.intent.action.CONTENT_CHANGED",
|
||||
"android.intent.action.DATA_SMS_RECEIVED",
|
||||
"android.intent.action.DATA_STALL_DETECTED",
|
||||
"android.intent.action.DATE_CHANGED",
|
||||
"android.intent.action.DEVICE_STORAGE_FULL",
|
||||
"android.intent.action.DEVICE_STORAGE_LOW",
|
||||
"android.intent.action.DEVICE_STORAGE_NOT_FULL",
|
||||
"android.intent.action.DEVICE_STORAGE_OK",
|
||||
"android.intent.action.DISTRACTING_PACKAGES_CHANGED",
|
||||
"android.intent.action.DOCK_EVENT",
|
||||
"android.intent.action.DOWNLOAD_COMPLETE",
|
||||
"android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED",
|
||||
"android.intent.action.DREAMING_STARTED",
|
||||
"android.intent.action.DREAMING_STOPPED",
|
||||
"android.intent.action.DROPBOX_ENTRY_ADDED",
|
||||
"android.intent.action.DYNAMIC_SENSOR_CHANGED",
|
||||
"android.intent.action.EMERGENCY_CALLBACK_MODE_CHANGED",
|
||||
"android.intent.action.EMERGENCY_CALL_STATE_CHANGED",
|
||||
"android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE",
|
||||
"android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE",
|
||||
"android.intent.action.FACTORY_RESET",
|
||||
"android.intent.action.FETCH_VOICEMAIL",
|
||||
"android.intent.action.GTALK_CONNECTED",
|
||||
"android.intent.action.GTALK_DISCONNECTED",
|
||||
"android.intent.action.HEADSET_PLUG",
|
||||
"android.intent.action.HEADSET_PLUG",
|
||||
"android.intent.action.INPUT_METHOD_CHANGED",
|
||||
"android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION",
|
||||
"android.intent.action.LOCALE_CHANGED",
|
||||
"android.intent.action.LOCKED_BOOT_COMPLETED",
|
||||
"android.intent.action.MANAGE_PACKAGE_STORAGE",
|
||||
"android.intent.action.MASTER_CLEAR_NOTIFICATION",
|
||||
"android.intent.action.MEDIA_BAD_REMOVAL",
|
||||
"android.intent.action.MEDIA_BUTTON",
|
||||
"android.intent.action.MEDIA_CHECKING",
|
||||
"android.intent.action.MEDIA_EJECT",
|
||||
"android.intent.action.MEDIA_MOUNTED",
|
||||
"android.intent.action.MEDIA_NOFS",
|
||||
"android.intent.action.MEDIA_REMOVED",
|
||||
"android.intent.action.MEDIA_SCANNER_FINISHED",
|
||||
"android.intent.action.MEDIA_SCANNER_SCAN_FILE",
|
||||
"android.intent.action.MEDIA_SCANNER_STARTED",
|
||||
"android.intent.action.MEDIA_SHARED",
|
||||
"android.intent.action.MEDIA_UNMOUNTABLE",
|
||||
"android.intent.action.MEDIA_UNMOUNTED",
|
||||
"android.intent.action.MY_PACKAGE_REPLACED",
|
||||
"android.intent.action.MY_PACKAGE_SUSPENDED",
|
||||
"android.intent.action.MY_PACKAGE_UNSUSPENDED",
|
||||
"android.intent.action.NEW_OUTGOING_CALL",
|
||||
"android.intent.action.NEW_VOICEMAIL",
|
||||
"android.intent.action.PACKAGES_SUSPENDED",
|
||||
"android.intent.action.PACKAGES_UNSUSPENDED",
|
||||
"android.intent.action.PACKAGE_ADDED",
|
||||
"android.intent.action.PACKAGE_CHANGED",
|
||||
"android.intent.action.PACKAGE_DATA_CLEARED",
|
||||
"android.intent.action.PACKAGE_ENABLE_ROLLBACK",
|
||||
"android.intent.action.PACKAGE_FIRST_LAUNCH",
|
||||
"android.intent.action.PACKAGE_FULLY_REMOVED",
|
||||
"android.intent.action.PACKAGE_INSTALL",
|
||||
"android.intent.action.PACKAGE_NEEDS_INTEGRITY_VERIFICATION",
|
||||
"android.intent.action.PACKAGE_NEEDS_VERIFICATION",
|
||||
"android.intent.action.PACKAGE_REMOVED",
|
||||
"android.intent.action.PACKAGE_REPLACED",
|
||||
"android.intent.action.PACKAGE_RESTARTED",
|
||||
"android.intent.action.PACKAGE_UNSUSPENDED_MANUALLY",
|
||||
"android.intent.action.PACKAGE_VERIFIED",
|
||||
"android.intent.action.PHONE_STATE",
|
||||
"android.intent.action.PROVIDER_CHANGED",
|
||||
"android.intent.action.PROXY_CHANGE",
|
||||
"android.intent.action.QUERY_PACKAGE_RESTART",
|
||||
"android.intent.action.REBOOT",
|
||||
"android.intent.action.ROLLBACK_COMMITTED",
|
||||
"android.intent.action.SCREEN_OFF",
|
||||
"android.intent.action.SCREEN_ON",
|
||||
"android.intent.action.SERVICE_STATE",
|
||||
"android.intent.action.SIM_STATE_CHANGED",
|
||||
"android.intent.action.SPLIT_CONFIGURATION_CHANGED",
|
||||
"android.intent.action.SUB_DEFAULT_CHANGED",
|
||||
"android.intent.action.TIMEZONE_CHANGED",
|
||||
"android.intent.action.TIME_SET",
|
||||
"android.intent.action.TIME_TICK",
|
||||
"android.intent.action.UID_REMOVED",
|
||||
"android.intent.action.UMS_CONNECTED",
|
||||
"android.intent.action.UMS_DISCONNECTED",
|
||||
"android.intent.action.USER_PRESENT",
|
||||
"android.intent.action.USER_UNLOCKED",
|
||||
"android.intent.action.WALLPAPER_CHANGED",
|
||||
"android.media.ACTION_SCO_AUDIO_STATE_UPDATED",
|
||||
"android.media.AUDIO_BECOMING_NOISY",
|
||||
"android.media.INTERNAL_RINGER_MODE_CHANGED_ACTION",
|
||||
"android.media.MASTER_MUTE_CHANGED_ACTION",
|
||||
"android.media.RINGER_MODE_CHANGED",
|
||||
"android.media.SCO_AUDIO_STATE_CHANGED",
|
||||
"android.media.STREAM_DEVICES_CHANGED_ACTION",
|
||||
"android.media.STREAM_MUTE_CHANGED_ACTION",
|
||||
"android.media.VIBRATE_SETTING_CHANGED",
|
||||
"android.media.VOLUME_CHANGED_ACTION",
|
||||
"android.media.action.CLOSE_AUDIO_EFFECT_CONTROL_SESSION",
|
||||
"android.media.action.HDMI_AUDIO_PLUG",
|
||||
"android.media.action.MICROPHONE_MUTE_CHANGED",
|
||||
"android.media.action.OPEN_AUDIO_EFFECT_CONTROL_SESSION",
|
||||
"android.media.action.SPEAKERPHONE_STATE_CHANGED",
|
||||
"android.media.tv.action.CHANNEL_BROWSABLE_REQUESTED",
|
||||
"android.media.tv.action.INITIALIZE_PROGRAMS",
|
||||
"android.media.tv.action.PREVIEW_PROGRAM_ADDED_TO_WATCH_NEXT",
|
||||
"android.media.tv.action.PREVIEW_PROGRAM_BROWSABLE_DISABLED",
|
||||
"android.media.tv.action.WATCH_NEXT_PROGRAM_BROWSABLE_DISABLED",
|
||||
"android.net.conn.BACKGROUND_DATA_SETTING_CHANGED",
|
||||
"android.net.conn.CAPTIVE_PORTAL_TEST_COMPLETED",
|
||||
"android.net.conn.CONNECTIVITY_CHANGE",
|
||||
"android.net.conn.DATA_ACTIVITY_CHANGE",
|
||||
"android.net.conn.INET_CONDITION_ACTION",
|
||||
"android.net.conn.RESTRICT_BACKGROUND_CHANGED",
|
||||
"android.net.conn.TETHER_STATE_CHANGED",
|
||||
"android.net.nsd.STATE_CHANGED",
|
||||
"android.net.scoring.SCORER_CHANGED",
|
||||
"android.net.scoring.SCORE_NETWORKS",
|
||||
"android.net.sip.action.SIP_CALL_OPTION_CHANGED",
|
||||
"android.net.sip.action.SIP_INCOMING_CALL",
|
||||
"android.net.sip.action.SIP_REMOVE_PROFILE",
|
||||
"android.net.sip.action.SIP_SERVICE_UP",
|
||||
"android.net.sip.action.START_SIP",
|
||||
"android.net.wifi.BATCHED_RESULTS",
|
||||
"android.net.wifi.NETWORK_IDS_CHANGED",
|
||||
"android.net.wifi.RSSI_CHANGED",
|
||||
"android.net.wifi.SCAN_RESULTS",
|
||||
"android.net.wifi.STATE_CHANGE",
|
||||
"android.net.wifi.WIFI_STATE_CHANGED",
|
||||
"android.net.wifi.action.WIFI_NETWORK_SUGGESTION_POST_CONNECTION",
|
||||
"android.net.wifi.action.WIFI_SCAN_AVAILABILITY_CHANGED",
|
||||
"android.net.wifi.aware.action.WIFI_AWARE_STATE_CHANGED",
|
||||
"android.net.wifi.p2p.CONNECTION_STATE_CHANGE",
|
||||
"android.net.wifi.p2p.DISCOVERY_STATE_CHANGE",
|
||||
"android.net.wifi.p2p.PEERS_CHANGED",
|
||||
"android.net.wifi.p2p.STATE_CHANGED",
|
||||
"android.net.wifi.p2p.THIS_DEVICE_CHANGED",
|
||||
"android.net.wifi.rtt.action.WIFI_RTT_STATE_CHANGED",
|
||||
"android.net.wifi.supplicant.CONNECTION_CHANGE",
|
||||
"android.net.wifi.supplicant.STATE_CHANGE",
|
||||
"android.nfc.action.ADAPTER_STATE_CHANGED",
|
||||
"android.nfc.action.PREFERRED_PAYMENT_CHANGED",
|
||||
"android.nfc.action.TRANSACTION_DETECTED",
|
||||
"android.os.action.ACTION_EFFECTS_SUPPRESSOR_CHANGED",
|
||||
"android.os.action.DEVICE_IDLE_MODE_CHANGED",
|
||||
"android.os.action.LIGHT_DEVICE_IDLE_MODE_CHANGED",
|
||||
"android.os.action.POWER_SAVE_MODE_CHANGED",
|
||||
"android.os.action.POWER_SAVE_MODE_CHANGED_INTERNAL",
|
||||
"android.os.action.POWER_SAVE_MODE_CHANGING",
|
||||
"android.os.action.POWER_SAVE_TEMP_WHITELIST_CHANGED",
|
||||
"android.os.action.POWER_SAVE_WHITELIST_CHANGED",
|
||||
"android.os.action.UPDATE_EMERGENCY_NUMBER_DB",
|
||||
"android.provider.Telephony.MMS_DOWNLOADED",
|
||||
"android.provider.Telephony.SECRET_CODE",
|
||||
"android.provider.Telephony.SIM_FULL",
|
||||
"android.provider.Telephony.SMS_CARRIER_PROVISION",
|
||||
"android.provider.Telephony.SMS_CB_RECEIVED",
|
||||
"android.provider.Telephony.SMS_DELIVER",
|
||||
"android.provider.Telephony.SMS_RECEIVED",
|
||||
"android.provider.Telephony.SMS_REJECTED",
|
||||
"android.provider.Telephony.SMS_SERVICE_CATEGORY_PROGRAM_DATA_RECEIVED",
|
||||
"android.provider.Telephony.WAP_PUSH_DELIVER",
|
||||
"android.provider.Telephony.WAP_PUSH_RECEIVED",
|
||||
"android.provider.action.DEFAULT_SMS_PACKAGE_CHANGED",
|
||||
"android.provider.action.EXTERNAL_PROVIDER_CHANGE",
|
||||
"android.provider.action.SMS_EMERGENCY_CB_RECEIVED",
|
||||
"android.provider.action.SMS_MMS_DB_CREATED",
|
||||
"android.provider.action.SMS_MMS_DB_LOST",
|
||||
"android.provider.action.SYNC_VOICEMAIL",
|
||||
"android.security.STORAGE_CHANGED",
|
||||
"android.security.action.KEYCHAIN_CHANGED",
|
||||
"android.security.action.KEY_ACCESS_CHANGED",
|
||||
"android.security.action.TRUST_STORE_CHANGED",
|
||||
"android.service.controls.action.ADD_CONTROL",
|
||||
"android.settings.ENABLE_MMS_DATA_REQUEST",
|
||||
"android.speech.tts.TTS_QUEUE_PROCESSING_COMPLETED",
|
||||
"android.speech.tts.engine.TTS_DATA_INSTALLED",
|
||||
"android.telephony.action.AREA_INFO_UPDATED",
|
||||
"android.telephony.action.DEFAULT_SMS_SUBSCRIPTION_CHANGED",
|
||||
"android.telephony.action.DEFAULT_SUBSCRIPTION_CHANGED",
|
||||
"android.telephony.action.PRIMARY_SUBSCRIPTION_LIST_CHANGED",
|
||||
"android.telephony.action.REFRESH_SUBSCRIPTION_PLANS",
|
||||
"android.telephony.action.SECRET_CODE",
|
||||
"android.telephony.action.SERVICE_PROVIDERS_UPDATED",
|
||||
"android.telephony.action.SIM_APPLICATION_STATE_CHANGED",
|
||||
"android.telephony.action.SIM_CARD_STATE_CHANGED",
|
||||
"android.telephony.action.SIM_SLOT_STATUS_CHANGED",
|
||||
"android.telephony.action.SUBSCRIPTION_CARRIER_IDENTITY_CHANGED",
|
||||
"android.telephony.action.SUBSCRIPTION_PLANS_CHANGED",
|
||||
"android.telephony.action.SUBSCRIPTION_SPECIFIC_CARRIER_IDENTITY_CHANGED",
|
||||
"android.telephony.euicc.action.NOTIFY_CARRIER_SETUP_INCOMPLETE",
|
||||
"android.telephony.euicc.action.OTA_STATUS_CHANGED",
|
||||
"android.telephony.ims.action.WFC_IMS_REGISTRATION_ERROR",
|
||||
"com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS",
|
||||
"com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS",
|
||||
"com.android.internal.intent.action.ACTION_FORBIDDEN_NO_SERVICE_AUTHORIZATION",
|
||||
"com.android.internal.provider.action.VOICEMAIL_SMS_RECEIVED"
|
||||
};
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.jens.automation2;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import 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);
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -263,7 +263,7 @@ public class ActivityManageTriggerNotification extends Activity
|
||||
etNotificationTitle = (EditText)findViewById(R.id.etNotificationTitle);
|
||||
etNotificationText = (EditText)findViewById(R.id.etNotificationText);
|
||||
bSelectApp = (Button)findViewById(R.id.bSelectApp);
|
||||
bSaveTriggerNotification = (Button)findViewById(R.id.bSaveTriggerNotification);
|
||||
bSaveTriggerNotification = (Button)findViewById(R.id.bSaveActionCloseNotification);
|
||||
spinnerTitleDirection = (Spinner)findViewById(R.id.spinnerTitleDirection);
|
||||
spinnerTextDirection = (Spinner)findViewById(R.id.spinnerTextDirection);
|
||||
tvSelectedApplication = (TextView)findViewById(R.id.etActivityOrActionPath);
|
||||
@ -272,6 +272,7 @@ public class ActivityManageTriggerNotification extends Activity
|
||||
directions = new String[] {
|
||||
getResources().getString(R.string.directionStringEquals),
|
||||
getResources().getString(R.string.directionStringContains),
|
||||
getResources().getString(R.string.directionStringDoesNotContain),
|
||||
getResources().getString(R.string.directionStringStartsWith),
|
||||
getResources().getString(R.string.directionStringEndsWith),
|
||||
getResources().getString(R.string.directionStringNotEquals)
|
||||
@ -312,7 +313,7 @@ public class ActivityManageTriggerNotification extends Activity
|
||||
{
|
||||
String app;
|
||||
if(tvSelectedApplication.getText().toString().equalsIgnoreCase(getResources().getString(R.string.anyApp)))
|
||||
app = "-1";
|
||||
app = Trigger.anyAppString;
|
||||
else
|
||||
app = tvSelectedApplication.getText().toString();
|
||||
|
||||
@ -321,23 +322,14 @@ public class ActivityManageTriggerNotification extends Activity
|
||||
String textDir = Trigger.getMatchCode(spinnerTextDirection.getSelectedItem().toString());
|
||||
String text = etNotificationText.getText().toString();
|
||||
|
||||
if(edit)
|
||||
{
|
||||
editedNotificationTrigger.setTriggerParameter(chkNotificationDirection.isChecked());
|
||||
editedNotificationTrigger.setTriggerParameter2(app + triggerParameter2Split + titleDir + triggerParameter2Split + title + triggerParameter2Split + textDir + triggerParameter2Split + text);
|
||||
ActivityManageTriggerNotification.this.setResult(RESULT_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
Intent data = new Intent();
|
||||
data.putExtra(intentNameNotificationDirection, chkNotificationDirection.isChecked());
|
||||
data.putExtra(intentNameNotificationApp, app);
|
||||
data.putExtra(intentNameNotificationTitleDir, titleDir);
|
||||
data.putExtra(intentNameNotificationTitle, title);
|
||||
data.putExtra(intentNameNotificationTextDir, textDir);
|
||||
data.putExtra(intentNameNotificationText, text);
|
||||
ActivityManageTriggerNotification.this.setResult(RESULT_OK, data);
|
||||
}
|
||||
Intent data = new Intent();
|
||||
data.putExtra(intentNameNotificationDirection, chkNotificationDirection.isChecked());
|
||||
data.putExtra(intentNameNotificationApp, app);
|
||||
data.putExtra(intentNameNotificationTitleDir, titleDir);
|
||||
data.putExtra(intentNameNotificationTitle, title);
|
||||
data.putExtra(intentNameNotificationTextDir, textDir);
|
||||
data.putExtra(intentNameNotificationText, text);
|
||||
ActivityManageTriggerNotification.this.setResult(RESULT_OK, data);
|
||||
|
||||
finish();
|
||||
}
|
||||
@ -367,7 +359,7 @@ public class ActivityManageTriggerNotification extends Activity
|
||||
else
|
||||
text = "";
|
||||
|
||||
if(!app.equals("-1"))
|
||||
if(!app.equals(Trigger.anyAppString))
|
||||
tvSelectedApplication.setText(app);
|
||||
|
||||
for(int i = 0; i < directions.length; i++)
|
||||
|
@ -86,8 +86,8 @@ public class ActivityManageTriggerPhoneCall extends Activity
|
||||
else
|
||||
{
|
||||
Intent data = new Intent();
|
||||
data.putExtra("triggerParameter", false);
|
||||
data.putExtra("triggerParameter2", tp2Result);
|
||||
data.putExtra(ActivityManageRule.intentNameTriggerParameter1, false);
|
||||
data.putExtra(ActivityManageRule.intentNameTriggerParameter2, tp2Result);
|
||||
ActivityManageTriggerPhoneCall.this.setResult(RESULT_OK, data);
|
||||
}
|
||||
|
||||
|
@ -66,14 +66,21 @@ public class ActivityManageTriggerProfile extends Activity
|
||||
String profileName = values[0];
|
||||
|
||||
List<Profile> profileList = Profile.getProfileCollection();
|
||||
|
||||
boolean found = false;
|
||||
|
||||
for(int i = 0; i < profileList.size(); i++)
|
||||
{
|
||||
if(profileList.get(i).getName().equals(profileName))
|
||||
{
|
||||
spinnerProfiles.setSelection(i);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!found)
|
||||
Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.profileWasNotFound), ActivityManageTriggerProfile.this).show();
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
|
@ -0,0 +1,72 @@
|
||||
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);
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
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 org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class ActivityManageTriggerTethering extends Activity
|
||||
{
|
||||
RadioButton rbTetheringOn, rbTetheringOff, rbTetheringTypeAny, rbTetheringTypeWifi, rbTetheringTypeBluetooth, rbTetheringTypeUsb, rbTetheringTypeCable;
|
||||
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
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_trigger_tethering);
|
||||
|
||||
rbTetheringOn = (RadioButton) findViewById(R.id.rbTetheringOn);
|
||||
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);
|
||||
|
||||
Intent input = getIntent();
|
||||
if(input.hasExtra(ActivityManageRule.intentNameTriggerParameter1))
|
||||
{
|
||||
rbTetheringOn.setChecked(input.getBooleanExtra(ActivityManageRule.intentNameTriggerParameter1, true));
|
||||
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()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View view)
|
||||
{
|
||||
Intent response = new Intent();
|
||||
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);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.jens.automation2;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@ -9,13 +10,13 @@ import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.sql.Time;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
||||
@ -26,8 +27,9 @@ public class ActivityManageTriggerTimeFrame extends Activity
|
||||
CheckBox checkMonday, checkTuesday, checkWednesday, checkThursday, checkFriday, checkSaturday, checkSunday, chkRepeat;
|
||||
RadioButton radioTimeFrameEntering, radioTimeFrameLeaving;
|
||||
EditText etRepeatEvery;
|
||||
TextView tvDaysHint;
|
||||
|
||||
public static Trigger editedTimeFrameTrigger = null;
|
||||
static Trigger editedTimeFrameTrigger = null;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState)
|
||||
@ -52,17 +54,18 @@ public class ActivityManageTriggerTimeFrame extends Activity
|
||||
radioTimeFrameLeaving = (RadioButton)findViewById(R.id.radioTimeFrameLeaving);
|
||||
chkRepeat = (CheckBox)findViewById(R.id.chkRepeat);
|
||||
etRepeatEvery = (EditText)findViewById(R.id.etRepeatEvery);
|
||||
tvDaysHint = (TextView)findViewById(R.id.tvDaysHint);
|
||||
|
||||
bSaveTimeFrame.setOnClickListener(new OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
{
|
||||
Time startTime = new Time(0);
|
||||
TimeObject startTime = new TimeObject();
|
||||
startTime.setHours(startPicker.getCurrentHour());
|
||||
startTime.setMinutes(startPicker.getCurrentMinute());
|
||||
|
||||
Time stopTime = new Time(0);
|
||||
TimeObject stopTime = new TimeObject();
|
||||
stopTime.setHours(stopPicker.getCurrentHour());
|
||||
stopTime.setMinutes(stopPicker.getCurrentMinute());
|
||||
|
||||
@ -152,8 +155,13 @@ public class ActivityManageTriggerTimeFrame extends Activity
|
||||
}
|
||||
|
||||
editedTimeFrameTrigger.setTriggerParameter(radioTimeFrameEntering.isChecked());
|
||||
|
||||
setResult(RESULT_OK);
|
||||
editedTimeFrameTrigger.setTriggerParameter2(editedTimeFrameTrigger.getTimeFrame().toTriggerParameter2String());
|
||||
|
||||
Intent response = new Intent();
|
||||
response.putExtra(ActivityManageRule.intentNameTriggerParameter1, editedTimeFrameTrigger.getTriggerParameter());
|
||||
response.putExtra(ActivityManageRule.intentNameTriggerParameter2, editedTimeFrameTrigger.getTriggerParameter2());
|
||||
|
||||
setResult(RESULT_OK, response);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
@ -166,9 +174,40 @@ public class ActivityManageTriggerTimeFrame extends Activity
|
||||
etRepeatEvery.setEnabled(isChecked);
|
||||
}
|
||||
});
|
||||
|
||||
if(editedTimeFrameTrigger.getTimeFrame() != null)
|
||||
|
||||
if(getIntent().hasExtra(ActivityManageRule.intentNameTriggerParameter2))
|
||||
{
|
||||
editedTimeFrameTrigger = new Trigger();
|
||||
editedTimeFrameTrigger.setTriggerParameter(getIntent().getBooleanExtra(ActivityManageRule.intentNameTriggerParameter1, true));
|
||||
editedTimeFrameTrigger.setTriggerParameter2(getIntent().getStringExtra(ActivityManageRule.intentNameTriggerParameter2));
|
||||
editedTimeFrameTrigger.setTimeFrame(new TimeFrame(editedTimeFrameTrigger.getTriggerParameter2()));
|
||||
loadVariableIntoGui();
|
||||
}
|
||||
|
||||
TimePicker.OnTimeChangedListener pickerListener = new TimePicker.OnTimeChangedListener()
|
||||
{
|
||||
@Override
|
||||
public void onTimeChanged(TimePicker timePicker, int i, int i1)
|
||||
{
|
||||
if(
|
||||
startPicker.getCurrentHour() > stopPicker.getCurrentHour()
|
||||
||
|
||||
(
|
||||
startPicker.getCurrentHour() == stopPicker.getCurrentHour()
|
||||
&&
|
||||
startPicker.getCurrentMinute() >= stopPicker.getCurrentMinute()
|
||||
)
|
||||
)
|
||||
tvDaysHint.setText(getResources().getString(R.string.timeFrameDaysHint));
|
||||
else
|
||||
tvDaysHint.setText("");
|
||||
}
|
||||
};
|
||||
startPicker.setOnTimeChangedListener(pickerListener);
|
||||
stopPicker.setOnTimeChangedListener(pickerListener);
|
||||
|
||||
// Perform check once
|
||||
pickerListener.onTimeChanged(null, 0, 0);
|
||||
}
|
||||
|
||||
private void loadVariableIntoGui()
|
||||
@ -219,5 +258,4 @@ public class ActivityManageTriggerTimeFrame extends Activity
|
||||
etRepeatEvery.setText(String.valueOf(editedTimeFrameTrigger.getTimeFrame().getRepetition()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -20,15 +20,13 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
|
||||
import com.jens.automation2.receivers.BluetoothReceiver;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -41,10 +39,11 @@ public class ActivityManageTriggerWifi extends Activity
|
||||
RadioButton rbTriggerWifiConnected, rbTriggerWifiDisconnected;
|
||||
EditText etTriggerWifiName;
|
||||
Spinner spinnerWifiList;
|
||||
Button btriggerWifiSave, bLoadWifiList;
|
||||
Button bTriggerWifiSave, bLoadWifiList;
|
||||
List<String> wifiList = new ArrayList<>();
|
||||
ArrayAdapter<String> wifiSpinnerAdapter;
|
||||
private final static int requestCodeLocationPermission = 124;
|
||||
TextView tvWifiTriggerNameLocationNotice;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
@ -56,13 +55,21 @@ public class ActivityManageTriggerWifi extends Activity
|
||||
rbTriggerWifiDisconnected = (RadioButton) findViewById(R.id.rbTriggerWifiDisconnected);
|
||||
etTriggerWifiName = (EditText) findViewById(R.id.etTriggerWifiName);
|
||||
spinnerWifiList = (Spinner) findViewById(R.id.spinnerWifiList);
|
||||
btriggerWifiSave = (Button) findViewById(R.id.btriggerWifiSave);
|
||||
bTriggerWifiSave = (Button) findViewById(R.id.bTriggerWifiSave);
|
||||
bLoadWifiList = (Button) findViewById(R.id.bLoadWifiList);
|
||||
tvWifiTriggerNameLocationNotice = (TextView)findViewById(R.id.tvWifiTriggerNameLocationNotice);
|
||||
|
||||
wifiSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, wifiList);
|
||||
spinnerWifiList.setAdapter(wifiSpinnerAdapter);
|
||||
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"))
|
||||
{
|
||||
boolean connected = getIntent().getBooleanExtra("wifiState", false);
|
||||
@ -74,7 +81,7 @@ public class ActivityManageTriggerWifi extends Activity
|
||||
etTriggerWifiName.setText(wifiName);
|
||||
}
|
||||
|
||||
btriggerWifiSave.setOnClickListener(new View.OnClickListener()
|
||||
bTriggerWifiSave.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick(View v)
|
||||
|
@ -25,6 +25,8 @@ import android.widget.TextView;
|
||||
|
||||
import com.jens.automation2.receivers.NotificationListener;
|
||||
|
||||
import org.w3c.dom.DOMImplementationSource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -47,6 +49,8 @@ public class ActivityPermissions extends Activity
|
||||
private static final int requestCodeForPermissionsNotifications = 12046;
|
||||
private static final int requestCodeForPermissionsDeviceAdmin = 12047;
|
||||
private static final int requestCodeForPermissionsBatteryOptimization = 12048;
|
||||
private static final int requestCodeForPermissionNotificationAccessAndroid13 = 12049;
|
||||
private static final int requestCodeForPermissionsManageOverlay = 12050;
|
||||
protected String[] specificPermissionsToRequest = null;
|
||||
|
||||
public static String intentExtraName = "permissionsToBeRequested";
|
||||
@ -224,7 +228,7 @@ public class ActivityPermissions extends Activity
|
||||
}
|
||||
}
|
||||
|
||||
protected static void addToArrayListUnique(String value, ArrayList<String> list)
|
||||
public static void addToArrayListUnique(String value, List<String> list)
|
||||
{
|
||||
if (!list.contains(value))
|
||||
list.add(value);
|
||||
@ -248,14 +252,17 @@ public class ActivityPermissions extends Activity
|
||||
if (!havePermission(s, context))
|
||||
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))
|
||||
{
|
||||
if(!BuildConfig.FLAVOR.equalsIgnoreCase("fdroidFlavor"))
|
||||
if(!BuildConfig.FLAVOR.equalsIgnoreCase(AutomationService.flavor_name_fdroid))
|
||||
if (!havePermission(s, context))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (!havePermission(s, context))
|
||||
else if (!havePermission(s, context))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -293,6 +300,10 @@ public class ActivityPermissions extends Activity
|
||||
String packageName = context.getApplicationContext().getPackageName();
|
||||
return pm.isIgnoringBatteryOptimizations(packageName);
|
||||
}
|
||||
else if (s.equals(Manifest.permission.SYSTEM_ALERT_WINDOW))
|
||||
{
|
||||
return android.provider.Settings.canDrawOverlays(Miscellaneous.getAnyContext());
|
||||
}
|
||||
else
|
||||
{
|
||||
int res = context.checkCallingOrSelfPermission(s);
|
||||
@ -311,6 +322,11 @@ public class ActivityPermissions extends Activity
|
||||
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()
|
||||
{
|
||||
if(!haveDeviceAdmin())
|
||||
@ -353,14 +369,21 @@ public class ActivityPermissions extends Activity
|
||||
if(!havePermission(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, workingContext))
|
||||
addToArrayListUnique(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, requiredPermissions);
|
||||
|
||||
for(Profile p : Profile.getProfileCollection())
|
||||
{
|
||||
if(p.changeIncomingCallsRingtone || p.changeNotificationRingtone)
|
||||
addToArrayListUnique(Manifest.permission.READ_EXTERNAL_STORAGE, requiredPermissions);
|
||||
}
|
||||
|
||||
if (!onlyGeneral)
|
||||
{
|
||||
for (Rule rule : Rule.getRuleCollection())
|
||||
{
|
||||
for (String singlePermission : getPermissionsForRule(rule))
|
||||
{
|
||||
if (!havePermission(singlePermission, workingContext))
|
||||
{
|
||||
if(
|
||||
if (
|
||||
|
||||
singlePermission.equalsIgnoreCase(Manifest.permission.ACCESS_BACKGROUND_LOCATION)
|
||||
||
|
||||
@ -372,14 +395,15 @@ public class ActivityPermissions extends Activity
|
||||
if (!Miscellaneous.googleToBlameForLocation(true))
|
||||
addToArrayListUnique(singlePermission, requiredPermissions);
|
||||
}
|
||||
else if(singlePermission.equalsIgnoreCase(Manifest.permission.ACTIVITY_RECOGNITION) || singlePermission.equalsIgnoreCase(permissionNameGoogleActivityDetection))
|
||||
else if (singlePermission.equalsIgnoreCase(Manifest.permission.ACTIVITY_RECOGNITION) || singlePermission.equalsIgnoreCase(permissionNameGoogleActivityDetection))
|
||||
{
|
||||
if(!BuildConfig.FLAVOR.equalsIgnoreCase("fdroidFlavor"))
|
||||
if (!BuildConfig.FLAVOR.equalsIgnoreCase(AutomationService.flavor_name_fdroid))
|
||||
addToArrayListUnique(singlePermission, requiredPermissions);
|
||||
}
|
||||
else
|
||||
addToArrayListUnique(singlePermission, requiredPermissions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -461,6 +485,7 @@ public class ActivityPermissions extends Activity
|
||||
case phoneCall:
|
||||
addToArrayListUnique(Manifest.permission.READ_PHONE_STATE, requiredPermissions);
|
||||
addToArrayListUnique(Manifest.permission.PROCESS_OUTGOING_CALLS, requiredPermissions);
|
||||
addToArrayListUnique(Manifest.permission.READ_CALL_LOG, requiredPermissions);
|
||||
break;
|
||||
case pointOfInterest:
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
|
||||
@ -501,6 +526,16 @@ public class ActivityPermissions extends Activity
|
||||
case wifiConnection:
|
||||
addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_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;
|
||||
case notification:
|
||||
addToArrayListUnique(Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE, requiredPermissions);
|
||||
@ -518,6 +553,9 @@ public class ActivityPermissions extends Activity
|
||||
addToArrayListUnique(Manifest.permission.MODIFY_AUDIO_SETTINGS, requiredPermissions);
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||
addToArrayListUnique(Manifest.permission.ACCESS_NOTIFICATION_POLICY, requiredPermissions);
|
||||
Profile targetProfile = Profile.getByName(action.getParameter2());
|
||||
if(targetProfile.changeIncomingCallsRingtone || targetProfile.changeNotificationRingtone)
|
||||
addToArrayListUnique(Manifest.permission.READ_EXTERNAL_STORAGE, requiredPermissions);
|
||||
break;
|
||||
case disableScreenRotation:
|
||||
addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions);
|
||||
@ -527,9 +565,13 @@ public class ActivityPermissions extends Activity
|
||||
break;
|
||||
case playMusic:
|
||||
break;
|
||||
case controlMediaPlayback:
|
||||
// addToArrayListUnique(Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE, requiredPermissions);
|
||||
// addToArrayListUnique(Manifest.permission.MEDIA_CONTENT_CONTROL, requiredPermissions);
|
||||
break;
|
||||
case sendTextMessage:
|
||||
addToArrayListUnique(Manifest.permission.SEND_SMS, requiredPermissions);
|
||||
checkPermissionsInVariableUse(action.getParameter2(), requiredPermissions);
|
||||
getPermissionsForVariablesInUse(action.getParameter2(), requiredPermissions);
|
||||
break;
|
||||
case setAirplaneMode:
|
||||
addToArrayListUnique(Manifest.permission.WRITE_SETTINGS, requiredPermissions);
|
||||
@ -588,7 +630,7 @@ public class ActivityPermissions extends Activity
|
||||
// addToArrayListUnique("android.permission.TETHER_PRIVILEGED", requiredPermissions);
|
||||
break;
|
||||
case speakText:
|
||||
checkPermissionsInVariableUse(action.getParameter2(), requiredPermissions);
|
||||
getPermissionsForVariablesInUse(action.getParameter2(), requiredPermissions);
|
||||
break;
|
||||
case startOtherActivity:
|
||||
if(
|
||||
@ -605,10 +647,12 @@ public class ActivityPermissions extends Activity
|
||||
// action.getParameter2().contains("eu.faircode.netguard.STOP_PORT_FORWARD")
|
||||
// )
|
||||
// addToArrayListUnique("net.kollnig.missioncontrol.permission.ADMIN", requiredPermissions);
|
||||
if(Build.VERSION.SDK_INT >= 29)
|
||||
addToArrayListUnique(Manifest.permission.SYSTEM_ALERT_WINDOW, requiredPermissions);
|
||||
break;
|
||||
case triggerUrl:
|
||||
addToArrayListUnique(Manifest.permission.INTERNET, requiredPermissions);
|
||||
checkPermissionsInVariableUse(action.getParameter2(), requiredPermissions);
|
||||
getPermissionsForVariablesInUse(action.getParameter2(), requiredPermissions);
|
||||
break;
|
||||
case turnBluetoothOff:
|
||||
addToArrayListUnique(Manifest.permission.BLUETOOTH_ADMIN, requiredPermissions);
|
||||
@ -649,12 +693,22 @@ public class ActivityPermissions extends Activity
|
||||
case playSound:
|
||||
addToArrayListUnique(Manifest.permission.READ_EXTERNAL_STORAGE, requiredPermissions);
|
||||
break;
|
||||
case closeNotification:
|
||||
addToArrayListUnique(Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE, requiredPermissions);
|
||||
break;
|
||||
case turnScreenOnOrOff:
|
||||
if(action.getParameter1())
|
||||
addToArrayListUnique(Manifest.permission.WAKE_LOCK, requiredPermissions);
|
||||
else
|
||||
addToArrayListUnique(Manifest.permission.BIND_DEVICE_ADMIN, requiredPermissions);
|
||||
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:
|
||||
break;
|
||||
}
|
||||
@ -739,6 +793,7 @@ public class ActivityPermissions extends Activity
|
||||
break;
|
||||
case Manifest.permission.ACCESS_BACKGROUND_LOCATION:
|
||||
usingElements.add(getResources().getString(R.string.googleLocationChicanery));
|
||||
usingElements.add(getResources().getString(R.string.wifiMonitoringAlsoRequiresThis));
|
||||
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.pointOfInterest))
|
||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.speed))
|
||||
@ -823,6 +878,7 @@ public class ActivityPermissions extends Activity
|
||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||
break;
|
||||
case Manifest.permission.PROCESS_OUTGOING_CALLS:
|
||||
case Manifest.permission.READ_CALL_LOG:
|
||||
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.phoneCall))
|
||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||
break;
|
||||
@ -846,12 +902,50 @@ public class ActivityPermissions extends Activity
|
||||
for(String ruleName : getRulesUsing(Action.Action_Enum.sendTextMessage))
|
||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||
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));
|
||||
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:
|
||||
usingElements.add(getResources().getString(R.string.startAutomationAsService));
|
||||
break;
|
||||
case Manifest.permission.READ_EXTERNAL_STORAGE:
|
||||
for(String ruleName : getRulesUsing(Action.Action_Enum.playSound))
|
||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||
|
||||
for(String ruleName : getRulesUsing(Action.Action_Enum.changeSoundProfile))
|
||||
{
|
||||
Rule tempRule = Rule.getByName(ruleName);
|
||||
if(tempRule != null)
|
||||
{
|
||||
for (Action a : tempRule.getActionSet())
|
||||
{
|
||||
if (a.getAction().equals(Action.Action_Enum.changeSoundProfile))
|
||||
{
|
||||
Profile p = Profile.getByName(a.getParameter2());
|
||||
if (p.changeIncomingCallsRingtone || p.changeNotificationRingtone)
|
||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(Profile p : Profile.getProfileCollection())
|
||||
{
|
||||
if(p.changeIncomingCallsRingtone || p.changeNotificationRingtone)
|
||||
{
|
||||
usingElements.add(String.format(getResources().getString(R.string.profileXrequiresThis), p.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case Manifest.permission.BIND_DEVICE_ADMIN:
|
||||
for(String ruleName : getRulesUsing(Action.Action_Enum.turnScreenOnOrOff))
|
||||
@ -860,6 +954,9 @@ public class ActivityPermissions extends Activity
|
||||
case Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS:
|
||||
usingElements.add(getResources().getString(R.string.recommendedForBetterReliability));
|
||||
break;
|
||||
case Manifest.permission.QUERY_ALL_PACKAGES:
|
||||
usingElements.add(getResources().getString(R.string.queryAllPackages));
|
||||
break;
|
||||
}
|
||||
|
||||
return usingElements;
|
||||
@ -911,6 +1008,10 @@ public class ActivityPermissions extends Activity
|
||||
if (requestCode == requestCodeForPermissionsBatteryOptimization)
|
||||
if(havePermission(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, ActivityPermissions.this))
|
||||
requestPermissions(cachedPermissionsToRequest, true);
|
||||
|
||||
if (requestCode == requestCodeForPermissionsManageOverlay)
|
||||
if(havePermission(Manifest.permission.SYSTEM_ALERT_WINDOW, ActivityPermissions.this))
|
||||
requestPermissions(cachedPermissionsToRequest, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -961,7 +1062,7 @@ public class ActivityPermissions extends Activity
|
||||
startActivityForResult(intent, requestCodeForPermissionsWriteSettings);
|
||||
return;
|
||||
}
|
||||
if (s.equalsIgnoreCase(Manifest.permission.BIND_DEVICE_ADMIN))
|
||||
else if (s.equalsIgnoreCase(Manifest.permission.BIND_DEVICE_ADMIN))
|
||||
{
|
||||
requiredPermissions.remove(s);
|
||||
cachedPermissionsToRequest = requiredPermissions;
|
||||
@ -976,12 +1077,46 @@ public class ActivityPermissions extends Activity
|
||||
startActivityForResult(intent, requestCodeForPermissionsNotificationPolicy);
|
||||
return;
|
||||
}
|
||||
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);
|
||||
cachedPermissionsToRequest = requiredPermissions;
|
||||
requestOverlay();
|
||||
}
|
||||
});
|
||||
diag.show();
|
||||
return;
|
||||
}
|
||||
else if (s.equalsIgnoreCase(Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE))
|
||||
{
|
||||
requiredPermissions.remove(s);
|
||||
cachedPermissionsToRequest = requiredPermissions;
|
||||
Intent intent = new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS);
|
||||
startActivityForResult(intent, requestCodeForPermissionsNotifications);
|
||||
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;
|
||||
}
|
||||
else if(s.equals(Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS))
|
||||
@ -1056,6 +1191,12 @@ public class ActivityPermissions extends Activity
|
||||
}
|
||||
}
|
||||
|
||||
void requestNotificationAccess()
|
||||
{
|
||||
Intent intent = new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS);
|
||||
startActivityForResult(intent, requestCodeForPermissionsNotifications);
|
||||
}
|
||||
|
||||
protected void applyChanges()
|
||||
{
|
||||
AutomationService service = AutomationService.getInstance();
|
||||
@ -1150,7 +1291,7 @@ public class ActivityPermissions extends Activity
|
||||
}
|
||||
}
|
||||
|
||||
static ArrayList<String> checkPermissionsInVariableUse(String text, ArrayList<String> permsList)
|
||||
static ArrayList<String> getPermissionsForVariablesInUse(String text, ArrayList<String> permsList)
|
||||
{
|
||||
/*
|
||||
[uniqueid]
|
||||
|
@ -18,10 +18,10 @@ public class ActivitySettings extends PreferenceActivity
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(layout.activity_settings);
|
||||
|
||||
if(BuildConfig.FLAVOR.equals("apkFlavor"))
|
||||
if(BuildConfig.FLAVOR.equals(AutomationService.flavor_name_apk))
|
||||
{
|
||||
chkPrefUpdateCheck = (CheckBoxPreference) findPreference("automaticUpdateCheck");
|
||||
chkPrefUpdateCheck.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -12,6 +12,8 @@ import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.media.AudioManager;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
@ -20,6 +22,7 @@ import android.os.Environment;
|
||||
import android.os.IBinder;
|
||||
import android.speech.tts.TextToSpeech;
|
||||
import android.speech.tts.TextToSpeech.OnInitListener;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -28,21 +31,37 @@ import androidx.core.app.NotificationManagerCompat;
|
||||
|
||||
import com.jens.automation2.Trigger.Trigger_Enum;
|
||||
import com.jens.automation2.location.LocationProvider;
|
||||
import com.jens.automation2.receivers.DateTimeListener;
|
||||
import com.jens.automation2.receivers.PackageReplacedReceiver;
|
||||
import com.jens.automation2.receivers.PhoneStatusListener;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public class AutomationService extends Service implements OnInitListener
|
||||
{
|
||||
protected TextToSpeech ttsEngine = null;
|
||||
protected int ttsStatus = -1;
|
||||
protected final static int notificationId = 1000;
|
||||
protected final static int notificationIdRestrictions = 1005;
|
||||
protected final static int notificationIdLocationRestriction = 1006;
|
||||
|
||||
final static String NOTIFICATION_CHANNEL_ID = "com.jens.automation2";
|
||||
final static String channelName = "Service notification";
|
||||
public static final String flavor_name_apk = "apkFlavor";
|
||||
public static final String flavor_name_fdroid = "fdroidFlavor";
|
||||
public static final String flavor_name_googleplay = "googlePlayFlavor";
|
||||
|
||||
final static String NOTIFICATION_CHANNEL_ID_SERVICE = "com.jens.automation2_service";
|
||||
final static String NOTIFICATION_CHANNEL_NAME_SERVICE = "Service notification";
|
||||
|
||||
final static String NOTIFICATION_CHANNEL_ID_FUNCTIONALITY = "com.jens.automation2_functionality";
|
||||
final static String NOTIFICATION_CHANNEL_NAME_FUNCTIONALITY = "Functionality information";
|
||||
|
||||
final static String NOTIFICATION_CHANNEL_ID_RULES = "com.jens.automation2_rules";
|
||||
final static String NOTIFICATION_CHANNEL_NAME_RULES = "Rule notifications";
|
||||
|
||||
protected static Notification myNotification;
|
||||
protected static NotificationCompat.Builder notificationBuilder = null;
|
||||
@ -51,6 +70,10 @@ public class AutomationService extends Service implements OnInitListener
|
||||
protected Calendar lockSoundChangesEnd = null;
|
||||
protected boolean isRunning;
|
||||
|
||||
Map<String,String> variableMap = new HashMap();
|
||||
|
||||
protected static AutomationService centralInstance = null;
|
||||
|
||||
public void nullLockSoundChangesEnd()
|
||||
{
|
||||
lockSoundChangesEnd = null;
|
||||
@ -65,7 +88,6 @@ public class AutomationService extends Service implements OnInitListener
|
||||
lockSoundChangesEnd = Calendar.getInstance();
|
||||
|
||||
lockSoundChangesEnd.add(Calendar.MINUTE, Settings.lockSoundChangesInterval);
|
||||
// ActivityMainScreen.getActivityMainScreenInstance().updateMainScreen();
|
||||
}
|
||||
|
||||
public void checkLockSoundChangesTimeElapsed()
|
||||
@ -80,6 +102,11 @@ public class AutomationService extends Service implements OnInitListener
|
||||
this.lockSoundChangesEnd = lockSoundChangesEnd;
|
||||
}
|
||||
|
||||
public int getTtsStatus()
|
||||
{
|
||||
return ttsStatus;
|
||||
}
|
||||
|
||||
protected final IBinder myBinder = new LocalBinder();
|
||||
|
||||
protected LocationProvider myLocationProvider;
|
||||
@ -89,8 +116,6 @@ public class AutomationService extends Service implements OnInitListener
|
||||
return myLocationProvider;
|
||||
}
|
||||
|
||||
protected static AutomationService centralInstance = null;
|
||||
|
||||
public static AutomationService getInstance()
|
||||
{
|
||||
return centralInstance;
|
||||
@ -105,22 +130,12 @@ public class AutomationService extends Service implements OnInitListener
|
||||
|
||||
// Store a reference to myself. Other classes often need a context or something, this can provide that.
|
||||
centralInstance = this;
|
||||
|
||||
Miscellaneous.setDisplayLanguage(AutomationService.this);
|
||||
}
|
||||
|
||||
public boolean checkStartupRequirements(Context context, boolean startAtBoot)
|
||||
{
|
||||
// if (!ActivityPermissions.havePermission(ActivityPermissions.writeExternalStoragePermissionName, AutomationService.this))
|
||||
// {
|
||||
// /*
|
||||
// Don't have permission to access external storage. This is a show stopper as
|
||||
// the configuration file is stored on external storage.
|
||||
// */
|
||||
// Miscellaneous.logEvent("e", "Permission", "Don't have permission to access external storage. Will request it now.", 4);
|
||||
//// Toast.makeText(AutomationService.this, getResources().getString(R.string.appRequiresPermissiontoAccessExternalStorage), Toast.LENGTH_LONG).show();
|
||||
// ActivityPermissions.requestSpecificPermission(ActivityPermissions.writeExternalStoragePermissionName);
|
||||
// return false;
|
||||
// }
|
||||
|
||||
if(Build.VERSION.SDK_INT >= 28)
|
||||
{
|
||||
if (!ActivityPermissions.havePermission(Manifest.permission.FOREGROUND_SERVICE, AutomationService.this))
|
||||
@ -135,10 +150,15 @@ public class AutomationService extends Service implements OnInitListener
|
||||
}
|
||||
}
|
||||
|
||||
if (PointOfInterest.getPointOfInterestCollection() == null | PointOfInterest.getPointOfInterestCollection().size() == 0
|
||||
|
|
||||
Rule.getRuleCollection() == null | Rule.getRuleCollection().size() == 0
|
||||
)
|
||||
if (
|
||||
PointOfInterest.getPointOfInterestCollection() == null
|
||||
||
|
||||
PointOfInterest.getPointOfInterestCollection().size() == 0
|
||||
||
|
||||
Rule.getRuleCollection() == null
|
||||
||
|
||||
Rule.getRuleCollection().size() == 0
|
||||
)
|
||||
{
|
||||
if (startAtBoot)
|
||||
{
|
||||
@ -173,7 +193,7 @@ public class AutomationService extends Service implements OnInitListener
|
||||
}
|
||||
|
||||
//if still no POIs...
|
||||
if (Rule.getRuleCollection() == null | Rule.getRuleCollection().size() == 0)
|
||||
if (Rule.getRuleCollection() == null || Rule.getRuleCollection().size() == 0)
|
||||
{
|
||||
Miscellaneous.logEvent("w", "AutomationService", context.getResources().getString(R.string.serviceWontStart), 1);
|
||||
Toast.makeText(context, context.getResources().getString(R.string.serviceWontStart), Toast.LENGTH_LONG).show();
|
||||
@ -194,18 +214,21 @@ public class AutomationService extends Service implements OnInitListener
|
||||
{
|
||||
Bundle b = intent.getExtras();
|
||||
startAtBoot = b.getBoolean("startAtBoot", false);
|
||||
|
||||
if(startAtBoot)
|
||||
Settings.deviceStartDone = false;
|
||||
}
|
||||
|
||||
if (checkStartupRequirements(this, startAtBoot))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Service", this.getResources().getString(R.string.logServiceStarting) + " VERSION_CODE: " + BuildConfig.VERSION_CODE + ", VERSION_NAME: " + BuildConfig.VERSION_NAME + ", flavor: " + BuildConfig.FLAVOR, 1);
|
||||
Miscellaneous.logEvent("i", "Service", ActivityMaintenance.getSystemInfo(), 1);
|
||||
Miscellaneous.logEvent("i", "Service", ActivityControlCenter.getSystemInfo(), 1);
|
||||
|
||||
startUpRoutine();
|
||||
|
||||
Intent myIntent = new Intent(this, ActivityMainTabLayout.class);
|
||||
myPendingIntent = PendingIntent.getActivity(this, 0, myIntent, 0);
|
||||
notificationBuilder = createDefaultNotificationBuilder();
|
||||
notificationBuilder = createServiceNotificationBuilder();
|
||||
|
||||
updateNotification();
|
||||
|
||||
@ -213,14 +236,19 @@ public class AutomationService extends Service implements OnInitListener
|
||||
ActivityMainScreen.updateMainScreen();
|
||||
|
||||
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);
|
||||
Toast.makeText(this, this.getResources().getString(R.string.serviceStarted), Toast.LENGTH_LONG).show();
|
||||
// ********** Test area **********
|
||||
// Miscellaneous.logEvent("i", "setNetworkType", "bin hier.", 3);
|
||||
// Actions.setData(true);
|
||||
// ********** Test area **********
|
||||
|
||||
return START_STICKY;
|
||||
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();
|
||||
|
||||
/*
|
||||
On normal phones the app is supposed to automatically restart in case of any problems.
|
||||
In the emulator we want it to stop to be able to better pinpoint the root cause.
|
||||
*/
|
||||
if(Miscellaneous.isAndroidEmulator())
|
||||
return START_NOT_STICKY;
|
||||
else
|
||||
return START_STICKY;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -241,8 +269,6 @@ public class AutomationService extends Service implements OnInitListener
|
||||
reloadSettings, reloadPointsOfInterest, reloadRules, updateNotification
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
public void serviceInterface(serviceCommands command)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Bind", "Ahhhh, customers... How can I help you?", 5);
|
||||
@ -282,6 +308,8 @@ public class AutomationService extends Service implements OnInitListener
|
||||
myLocationProvider.applySettingsAndRules();
|
||||
|
||||
ReceiverCoordinator.applySettingsAndRules();
|
||||
|
||||
DateTimeListener.reloadAlarms();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -291,7 +319,8 @@ public class AutomationService extends Service implements OnInitListener
|
||||
|
||||
stopRoutine();
|
||||
this.isRunning = false;
|
||||
Toast.makeText(this, getResources().getString(R.string.serviceStopped), Toast.LENGTH_LONG).show();
|
||||
if(Settings.showToasts)
|
||||
Toast.makeText(this, getResources().getString(R.string.serviceStopped), Toast.LENGTH_LONG).show();
|
||||
Miscellaneous.logEvent("i", "Service", getResources().getString(R.string.serviceStopped), 1);
|
||||
}
|
||||
|
||||
@ -300,8 +329,26 @@ public class AutomationService extends Service implements OnInitListener
|
||||
if (Settings.useTextToSpeechOnNormal || Settings.useTextToSpeechOnSilent || Settings.useTextToSpeechOnVibrate || Rule.isAnyRuleUsing(Action.Action_Enum.speakText))
|
||||
{
|
||||
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)
|
||||
ttsEngine.shutdown();
|
||||
@ -310,18 +357,29 @@ public class AutomationService extends Service implements OnInitListener
|
||||
|
||||
private void startUpRoutine()
|
||||
{
|
||||
Settings.serviceStartDone = false;
|
||||
|
||||
checkForTtsEngine();
|
||||
checkForPermissions();
|
||||
checkForRestrictedFeatures();
|
||||
checkForMissingBackgroundLocationPermission();
|
||||
|
||||
Actions.context = this;
|
||||
Actions.autoMationServerRef = this;
|
||||
Actions.automationServerRef = this;
|
||||
|
||||
startLocationProvider();
|
||||
ReceiverCoordinator.startAllReceivers();
|
||||
|
||||
PackageReplacedReceiver.setHasServiceBeenRunning(true, this);
|
||||
|
||||
for(Rule r : Rule.getRuleCollection())
|
||||
{
|
||||
if(r.getsGreenLight(AutomationService.this))
|
||||
r.activate(AutomationService.this, false);
|
||||
}
|
||||
|
||||
Settings.serviceStartDone = true;
|
||||
Settings.deviceStartDone = true;
|
||||
}
|
||||
|
||||
protected void startLocationProvider()
|
||||
@ -365,9 +423,9 @@ public class AutomationService extends Service implements OnInitListener
|
||||
Miscellaneous.logEvent("w", "Features disabled", "Features disabled because of rule " + rule, 5);
|
||||
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1)
|
||||
Miscellaneous.createDismissableNotificationWithDelay(1010, getResources().getString(R.string.featuresDisabled), ActivityPermissions.notificationIdPermissions, pi);
|
||||
Miscellaneous.createDismissibleNotificationWithDelay(1010, null, getResources().getString(R.string.featuresDisabled), ActivityPermissions.notificationIdPermissions, AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE, pi);
|
||||
else
|
||||
Miscellaneous.createDismissableNotification(getResources().getString(R.string.featuresDisabled), ActivityPermissions.notificationIdPermissions, pi);
|
||||
Miscellaneous.createDismissibleNotification(null, getResources().getString(R.string.featuresDisabled), ActivityPermissions.notificationIdPermissions, false, AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE, pi);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,9 +447,9 @@ public class AutomationService extends Service implements OnInitListener
|
||||
Miscellaneous.logEvent("w", "Features disabled", "Background location disabled because Google to blame.", 5);
|
||||
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1)
|
||||
Miscellaneous.createDismissableNotificationWithDelay(3300, getResources().getString(R.string.featuresDisabled), notificationIdRestrictions, pi);
|
||||
Miscellaneous.createDismissibleNotificationWithDelay(3300, null, getResources().getString(R.string.featuresDisabled), notificationIdRestrictions, AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE, pi);
|
||||
else
|
||||
Miscellaneous.createDismissableNotification(getResources().getString(R.string.featuresDisabled), notificationIdRestrictions, pi);
|
||||
Miscellaneous.createDismissibleNotification(null, getResources().getString(R.string.featuresDisabled), notificationIdRestrictions, false, AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE, pi);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -411,9 +469,9 @@ public class AutomationService extends Service implements OnInitListener
|
||||
Miscellaneous.logEvent("w", "Features disabled", "Background location disabled because Google to blame.", 5);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1)
|
||||
Miscellaneous.createDismissableNotificationWithDelay(2200, getResources().getString(R.string.featuresDisabled), notificationIdLocationRestriction, pi);
|
||||
Miscellaneous.createDismissibleNotificationWithDelay(2200, null, getResources().getString(R.string.featuresDisabled), notificationIdLocationRestriction, AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE, pi);
|
||||
else
|
||||
Miscellaneous.createDismissableNotification(getResources().getString(R.string.featuresDisabled), notificationIdLocationRestriction, pi);
|
||||
Miscellaneous.createDismissibleNotification(null, getResources().getString(R.string.featuresDisabled), notificationIdLocationRestriction, false, AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE, pi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -435,6 +493,10 @@ public class AutomationService extends Service implements OnInitListener
|
||||
private void stopRoutine()
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Service", "Stopping service...", 3);
|
||||
|
||||
// Clear variables for trigger/action with same name
|
||||
variableMap.clear();
|
||||
|
||||
try
|
||||
{
|
||||
myLocationProvider.stopLocationService();
|
||||
@ -449,6 +511,9 @@ public class AutomationService extends Service implements OnInitListener
|
||||
ttsEngine.shutdown();
|
||||
|
||||
PackageReplacedReceiver.setHasServiceBeenRunning(false, this);
|
||||
|
||||
centralInstance = null;
|
||||
Settings.serviceStartDone = false;
|
||||
}
|
||||
|
||||
protected static Builder createDefaultNotificationBuilderOld()
|
||||
@ -482,7 +547,7 @@ public class AutomationService extends Service implements OnInitListener
|
||||
return builder;
|
||||
}
|
||||
|
||||
protected static NotificationCompat.Builder createDefaultNotificationBuilder()
|
||||
protected static NotificationCompat.Builder createServiceNotificationBuilder()
|
||||
{
|
||||
NotificationManager mNotificationManager = (NotificationManager) AutomationService.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
@ -490,14 +555,14 @@ public class AutomationService extends Service implements OnInitListener
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||
{
|
||||
NotificationChannel chan = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_LOW);
|
||||
// chan.setLightColor(Color.BLUE);
|
||||
chan.enableVibration(false);
|
||||
chan.setSound(null, null);
|
||||
chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
||||
mNotificationManager.createNotificationChannel(chan);
|
||||
NotificationChannel channel = Miscellaneous.getNotificationChannel(AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE);
|
||||
// channel.setLightColor(Color.BLUE);
|
||||
channel.enableVibration(false);
|
||||
channel.setSound(null, null);
|
||||
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
||||
mNotificationManager.createNotificationChannel(channel);
|
||||
|
||||
builder = new NotificationCompat.Builder(AutomationService.getInstance(), NOTIFICATION_CHANNEL_ID);
|
||||
builder = new NotificationCompat.Builder(AutomationService.getInstance(), NOTIFICATION_CHANNEL_ID_SERVICE);
|
||||
}
|
||||
else
|
||||
builder = new NotificationCompat.Builder(AutomationService.getInstance());
|
||||
@ -542,11 +607,11 @@ public class AutomationService extends Service implements OnInitListener
|
||||
if(activePoi == null)
|
||||
{
|
||||
PointOfInterest closestPoi = PointOfInterest.getClosestPOI(instance.getLocationProvider().getCurrentLocation());
|
||||
bodyText = AutomationService.getInstance().getResources().getString(R.string.activePoi) + ": " + AutomationService.getInstance().getResources().getString(R.string.none) + "\n" + AutomationService.getInstance().getResources().getString(R.string.closestPoi) + ": " + closestPoi.getName() + lastRuleString;
|
||||
bodyText = AutomationService.getInstance().getResources().getString(R.string.activePoi) + " " + AutomationService.getInstance().getResources().getString(R.string.none) + "\n" + AutomationService.getInstance().getResources().getString(R.string.closestPoi) + ": " + closestPoi.getName() + lastRuleString;
|
||||
}
|
||||
else
|
||||
{
|
||||
bodyText = AutomationService.getInstance().getResources().getString(R.string.activePoi) + ": " + activePoi.getName() + lastRuleString;
|
||||
bodyText = AutomationService.getInstance().getResources().getString(R.string.activePoi) + " " + activePoi.getName() + lastRuleString;
|
||||
}
|
||||
}
|
||||
catch(NullPointerException e)
|
||||
@ -576,7 +641,7 @@ public class AutomationService extends Service implements OnInitListener
|
||||
String textToDisplay = bodyText + " " + lastRuleString;
|
||||
|
||||
if(notificationBuilder == null)
|
||||
notificationBuilder = createDefaultNotificationBuilder();
|
||||
notificationBuilder = createServiceNotificationBuilder();
|
||||
|
||||
notificationBuilder.setContentText(textToDisplay);
|
||||
notificationBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(textToDisplay));
|
||||
@ -638,25 +703,26 @@ public class AutomationService extends Service implements OnInitListener
|
||||
{
|
||||
try
|
||||
{
|
||||
for(int i = 0; i < 5; i++)
|
||||
for(int i = 0; i < 60; i++)
|
||||
{
|
||||
if(ttsEngine != null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
if(ttsEngine == null || ttsStatus != TextToSpeech.SUCCESS)
|
||||
{
|
||||
try
|
||||
{
|
||||
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)
|
||||
{}
|
||||
}
|
||||
else
|
||||
{
|
||||
Miscellaneous.logEvent("i", "TextToSpeech", "Speaking \"" + text + "\" in language " + ttsEngine.getLanguage().toLanguageTag(), 3);
|
||||
this.ttsEngine.speak(text, TextToSpeech.QUEUE_ADD, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Miscellaneous.logEvent("i", "TextToSpeech", "Speaking " + text + " in language " + ttsEngine.getLanguage().toLanguageTag(), 3);
|
||||
this.ttsEngine.speak(text, TextToSpeech.QUEUE_ADD, null);
|
||||
Miscellaneous.logEvent("i", "TextToSpeech", "TTS engine not available after waiting 30 seconds, yet. Aborting.", 3);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
@ -666,14 +732,19 @@ public class AutomationService extends Service implements OnInitListener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isMainActivityRunning(Context context)
|
||||
{
|
||||
|
||||
public Map<String, String> getVariableMap()
|
||||
{
|
||||
return variableMap;
|
||||
}
|
||||
|
||||
public static boolean isMainActivityRunning(Context context)
|
||||
{
|
||||
if(ActivityMainScreen.getActivityMainScreenInstance() == null)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isMyServiceRunning(Context context)
|
||||
{
|
||||
|
@ -8,14 +8,17 @@ import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.database.Cursor;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
@ -23,11 +26,13 @@ import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.os.IBinder;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.provider.MediaStore;
|
||||
import android.provider.Settings.Secure;
|
||||
import android.telephony.PhoneNumberUtils;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Base64;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -72,17 +77,20 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.security.DigestInputStream;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.sql.Time;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Scanner;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
@ -98,16 +106,15 @@ import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.documentfile.provider.DocumentFile;
|
||||
|
||||
import static android.provider.CalendarContract.CalendarCache.URI;
|
||||
import static com.jens.automation2.AutomationService.NOTIFICATION_CHANNEL_ID;
|
||||
import static com.jens.automation2.AutomationService.channelName;
|
||||
|
||||
public class Miscellaneous extends Service
|
||||
{
|
||||
protected static String writeableFolderStringCache = null;
|
||||
public static Context startupContext;
|
||||
|
||||
public static final String lineSeparator = System.getProperty("line.separator");
|
||||
|
||||
public static String downloadURL(String url, String username, String password)
|
||||
@ -270,7 +277,7 @@ public class Miscellaneous extends Service
|
||||
{
|
||||
writeToLogFile(type, header, description);
|
||||
|
||||
if(!logCleanerRunning && Math.random() < 0.1) // tidy up with 10% probability
|
||||
if (!logCleanerRunning && Math.random() < 0.1) // tidy up with 10% probability
|
||||
{
|
||||
rotateLogFile(getLogFile());
|
||||
}
|
||||
@ -471,11 +478,16 @@ public class Miscellaneous extends Service
|
||||
switch(direction)
|
||||
{
|
||||
case Trigger.directionEquals:
|
||||
return haystack.equalsIgnoreCase(needle);
|
||||
if(Miscellaneous.isRegularExpression(needle))
|
||||
return haystack.matches(needle);
|
||||
else
|
||||
return haystack.equalsIgnoreCase(needle);
|
||||
case Trigger.directionNotEquals:
|
||||
return !haystack.equalsIgnoreCase(needle);
|
||||
case Trigger.directionContains:
|
||||
return haystack.toLowerCase().contains(needle.toLowerCase());
|
||||
case Trigger.directionNotContains:
|
||||
return !haystack.toLowerCase().contains(needle.toLowerCase());
|
||||
case Trigger.directionStartsWith:
|
||||
return haystack.toLowerCase().startsWith(needle.toLowerCase());
|
||||
case Trigger.directionEndsWith:
|
||||
@ -485,7 +497,7 @@ public class Miscellaneous extends Service
|
||||
}
|
||||
}
|
||||
|
||||
public static int compareTimes(Time time1, Time time2)
|
||||
public static int compareTimes(TimeObject time1, TimeObject time2)
|
||||
{
|
||||
// Miscellaneous.logEvent("i", "TimeCompare", "To compare: " + time1.toString() + " / " + time2.toString());
|
||||
|
||||
@ -549,7 +561,10 @@ public class Miscellaneous extends Service
|
||||
returnContext = ActivityPermissions.getInstance().getApplicationContext();
|
||||
if(returnContext != null)
|
||||
return returnContext;
|
||||
|
||||
|
||||
if(startupContext != null)
|
||||
return startupContext;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -601,59 +616,152 @@ public class Miscellaneous extends Service
|
||||
}
|
||||
|
||||
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));
|
||||
else
|
||||
source = source.replace("[serialnr]", "serialUnknown");
|
||||
}
|
||||
|
||||
if(
|
||||
source.contains("[d]") |
|
||||
source.contains("[m]") |
|
||||
source.contains("[Y]") |
|
||||
source.contains("[h]") |
|
||||
source.contains("[H]") |
|
||||
source.contains("[i]") |
|
||||
source.contains("[s]") |
|
||||
source.contains("[d]") ||
|
||||
source.contains("[m]") ||
|
||||
source.contains("[Y]") ||
|
||||
source.contains("[h]") ||
|
||||
source.contains("[H]") ||
|
||||
source.contains("[i]") ||
|
||||
source.contains("[s]") ||
|
||||
source.contains("[ms]")
|
||||
)
|
||||
{
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
||||
source = source.replace("[d]", String.valueOf(cal.get(Calendar.DAY_OF_MONTH)));
|
||||
source = source.replace("[m]", String.valueOf(cal.get(Calendar.MONTH)));
|
||||
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)));
|
||||
source = source.replace("[s]", String.valueOf(cal.get(Calendar.SECOND)));
|
||||
source = source.replace("[ms]", String.valueOf(cal.get(Calendar.MILLISECOND)));
|
||||
if(source.contains("[d]"))
|
||||
{
|
||||
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)));
|
||||
}
|
||||
|
||||
if(source.contains("[h]"))
|
||||
{
|
||||
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]", String.valueOf(cal.get(Calendar.SECOND)));
|
||||
}
|
||||
|
||||
if(source.contains("[ms]"))
|
||||
{
|
||||
source = source.replace("[ms]", String.valueOf(cal.get(Calendar.MILLISECOND)));
|
||||
}
|
||||
}
|
||||
|
||||
if(source.contains("[notificationTitle]"))
|
||||
{
|
||||
String notificationTitle = NotificationListener.getLastNotification().getTitle();
|
||||
if(NotificationListener.getLastNotification() != null)
|
||||
{
|
||||
String notificationTitle = NotificationListener.getLastNotification().getTitle();
|
||||
|
||||
if(notificationTitle != null && notificationTitle.length() > 0)
|
||||
source = source.replace("[notificationTitle]", notificationTitle);
|
||||
if (notificationTitle != null && notificationTitle.length() > 0)
|
||||
source = source.replace("[notificationTitle]", notificationTitle);
|
||||
else
|
||||
{
|
||||
source = source.replace("[notificationTitle]", "notificationTitle unknown");
|
||||
Miscellaneous.logEvent("w", "Variable replacement", "notificationTitle was empty.", 3);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
source = source.replace("notificationTitle unknown", notificationTitle);
|
||||
Miscellaneous.logEvent("w", "Variable replacement", "notificationTitle was empty.", 3);
|
||||
source = source.replace("[notificationTitle]", "notificationTitle unknown");
|
||||
Miscellaneous.logEvent("w", "Variable replacement", "lastNotification was empty.", 3);
|
||||
}
|
||||
}
|
||||
|
||||
if(source.contains("[notificationText]"))
|
||||
{
|
||||
String notificationText = NotificationListener.getLastNotification().getText();
|
||||
if(NotificationListener.getLastNotification() != null)
|
||||
{
|
||||
String notificationText = NotificationListener.getLastNotification().getText();
|
||||
|
||||
if(notificationText != null && notificationText.length() > 0)
|
||||
source = source.replace("[notificationText]", notificationText);
|
||||
if (notificationText != null && notificationText.length() > 0)
|
||||
source = source.replace("[notificationText]", notificationText);
|
||||
else
|
||||
{
|
||||
source = source.replace("[notificationText]", "notificationText unknown");
|
||||
Miscellaneous.logEvent("w", "Variable replacement", "notificationText was empty.", 3);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
source = source.replace("notificationText unknown", notificationText);
|
||||
Miscellaneous.logEvent("w", "Variable replacement", "notificationText was empty.", 3);
|
||||
source = source.replace("[notificationText]", "notificationText unknown");
|
||||
Miscellaneous.logEvent("w", "Variable replacement", "lastNotification was empty.", 3);
|
||||
}
|
||||
}
|
||||
|
||||
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) + replacement + source.substring(pos2);
|
||||
}
|
||||
|
||||
// Miscellaneous.logEvent("i", "URL after replace", source);
|
||||
|
||||
@ -689,14 +797,6 @@ public class Miscellaneous extends Service
|
||||
}
|
||||
});
|
||||
|
||||
// alertDialog.setNegativeButton(context.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener()
|
||||
// {
|
||||
// public void onClick(DialogInterface dialog, int whichButton)
|
||||
// {
|
||||
// // Canceled.
|
||||
// }
|
||||
// });
|
||||
|
||||
return alertDialog.create();
|
||||
}
|
||||
|
||||
@ -723,8 +823,8 @@ public class Miscellaneous extends Service
|
||||
*
|
||||
* @return <code>true</code> if the device is rooted, <code>false</code> otherwise.
|
||||
*/
|
||||
public static boolean isPhoneRooted()
|
||||
{
|
||||
public static boolean isPhoneRooted()
|
||||
{
|
||||
// if(true)
|
||||
// return true;
|
||||
|
||||
@ -732,30 +832,30 @@ public class Miscellaneous extends Service
|
||||
String buildTags = Build.TAGS;
|
||||
if (buildTags != null && buildTags.contains("test-keys"))
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// check if /system/app/Superuser.apk is present
|
||||
try
|
||||
{
|
||||
File file = new File("/system/app/Superuser.apk");
|
||||
if (file.exists())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
try
|
||||
{
|
||||
File file = new File("/system/app/Superuser.apk");
|
||||
if (file.exists())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e1)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
// try executing commands
|
||||
return canExecuteCommand("/system/xbin/which su")
|
||||
return canExecuteCommand("/system/xbin/which su")
|
||||
||
|
||||
canExecuteCommand("/system/bin/which su")
|
||||
||
|
||||
canExecuteCommand("which su");
|
||||
}
|
||||
}
|
||||
|
||||
// executes a command on the system
|
||||
private static boolean canExecuteCommand(String command)
|
||||
@ -773,19 +873,35 @@ public class Miscellaneous extends Service
|
||||
|
||||
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)
|
||||
{
|
||||
return str.matches("-?\\d+(\\.\\d+)?"); //match a number with optional '-' and decimal.
|
||||
}
|
||||
public static boolean isNumeric(String str)
|
||||
{
|
||||
return str.matches("-?\\d+(\\.\\d+)?"); //match a number with optional '-' and decimal.
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the SSL certificate checking for new instances of {@link HttpsURLConnection} This has been created to
|
||||
* aid testing on a local box, not for use on production.
|
||||
*/
|
||||
private static void disableSSLCertificateChecking()
|
||||
{
|
||||
try
|
||||
private static void disableSSLCertificateChecking()
|
||||
{
|
||||
try
|
||||
{
|
||||
SSLSocketFactory ssf = null;
|
||||
|
||||
@ -877,7 +993,7 @@ public class Miscellaneous extends Service
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void createDismissableNotificationWithDelay(long delay, String textToDisplay, int notificationId, PendingIntent pendingIntent)
|
||||
public static void createDismissibleNotificationWithDelay(long delay, String title, String textToDisplay, int notificationId, String notificationChannelId, PendingIntent pendingIntent)
|
||||
{
|
||||
/*
|
||||
Now what's this about?
|
||||
@ -903,7 +1019,7 @@ public class Miscellaneous extends Service
|
||||
catch(Exception e)
|
||||
{}
|
||||
|
||||
createDismissableNotification(textToDisplay, notificationId, pendingIntent);
|
||||
createDismissibleNotification(title, textToDisplay, notificationId, true, notificationChannelId, pendingIntent);
|
||||
|
||||
return null;
|
||||
}
|
||||
@ -924,40 +1040,88 @@ public class Miscellaneous extends Service
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void createDismissableNotification(String textToDisplay, int notificationId, PendingIntent pendingIntent)
|
||||
public static void createDismissibleNotification(String title, String textToDisplay, int notificationId, boolean vibrate, String notificationChannelId, PendingIntent pendingIntent)
|
||||
{
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||
{
|
||||
createDismissableNotificationSdk26(textToDisplay, notificationId, pendingIntent);
|
||||
createDismissibleNotificationSdk26(title, textToDisplay, notificationId, vibrate, notificationChannelId, pendingIntent);
|
||||
return;
|
||||
}
|
||||
|
||||
NotificationManager mNotificationManager = (NotificationManager) Miscellaneous.getAnyContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
NotificationCompat.Builder dismissableNotificationBuilder = createDismissableNotificationBuilder(pendingIntent);
|
||||
dismissableNotificationBuilder.setContentText(textToDisplay);
|
||||
dismissableNotificationBuilder.setContentIntent(pendingIntent);
|
||||
dismissableNotificationBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(textToDisplay));
|
||||
dismissableNotificationBuilder.setAutoCancel(true);
|
||||
NotificationCompat.Builder dismissibleNotificationBuilder = createDismissibleNotificationBuilder(vibrate, notificationChannelId, pendingIntent);
|
||||
|
||||
Notification dismissableNotification = dismissableNotificationBuilder.build();
|
||||
if(title == null)
|
||||
dismissibleNotificationBuilder.setContentTitle(AutomationService.getInstance().getResources().getString(R.string.app_name));
|
||||
else
|
||||
dismissibleNotificationBuilder.setContentTitle(title);
|
||||
|
||||
mNotificationManager.notify(notificationId, dismissableNotification);
|
||||
dismissibleNotificationBuilder.setContentText(textToDisplay);
|
||||
dismissibleNotificationBuilder.setContentIntent(pendingIntent);
|
||||
dismissibleNotificationBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(textToDisplay));
|
||||
dismissibleNotificationBuilder.setAutoCancel(true);
|
||||
|
||||
/*NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
|
||||
.setSmallIcon(R.drawable.ic_launcher) // notification icon
|
||||
.setContentTitle("Notification!") // title for notification
|
||||
.setContentText("Hello word") // message for notification
|
||||
.setAutoCancel(true); // clear notification after click
|
||||
Intent intent = new Intent(this, MainActivity.class);
|
||||
PendingIntent pi = PendingIntent.getActivity(this,0,intent,Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mBuilder.setContentIntent(pi);
|
||||
NotificationManager mNotificationManager =
|
||||
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.notify(0, dismissableNotification);*/
|
||||
if(notificationChannelId.equals(AutomationService.NOTIFICATION_CHANNEL_ID_RULES))
|
||||
dismissibleNotificationBuilder.setSmallIcon(R.drawable.info);
|
||||
|
||||
Notification dismissibleNotification = dismissibleNotificationBuilder.build();
|
||||
|
||||
mNotificationManager.notify(notificationId, dismissibleNotification);
|
||||
}
|
||||
|
||||
static void createDismissableNotificationSdk26(String textToDisplay, int notificationId, PendingIntent pendingIntent)
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
static NotificationChannel findExistingChannel(List<NotificationChannel> channels, String channelId)
|
||||
{
|
||||
for(NotificationChannel c : channels)
|
||||
{
|
||||
if(c.getId().equals(channelId))
|
||||
return c;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
static NotificationChannel getNotificationChannel(String channelId)
|
||||
{
|
||||
NotificationManager nm = (NotificationManager) Miscellaneous.getAnyContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
List<NotificationChannel> channels = nm.getNotificationChannels();
|
||||
|
||||
if(!Settings.hasBeenDone(Settings.constNotificationChannelCleanupApk118) && BuildConfig.VERSION_CODE < 120)
|
||||
{
|
||||
// Perform a one-time cleanup of notification channels as they have been redesigned.
|
||||
|
||||
for(NotificationChannel c : channels)
|
||||
nm.deleteNotificationChannel(c.getId());
|
||||
|
||||
Settings.considerDone(Settings.constNotificationChannelCleanupApk118);
|
||||
Settings.writeSettings(Miscellaneous.getAnyContext());
|
||||
}
|
||||
|
||||
NotificationChannel channel = findExistingChannel(channels, channelId);
|
||||
|
||||
if(channel == null)
|
||||
{
|
||||
switch (channelId)
|
||||
{
|
||||
case AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE:
|
||||
channel = new NotificationChannel(AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE, AutomationService.NOTIFICATION_CHANNEL_NAME_SERVICE, NotificationManager.IMPORTANCE_LOW);
|
||||
break;
|
||||
case AutomationService.NOTIFICATION_CHANNEL_ID_FUNCTIONALITY:
|
||||
channel = new NotificationChannel(AutomationService.NOTIFICATION_CHANNEL_ID_FUNCTIONALITY, AutomationService.NOTIFICATION_CHANNEL_NAME_FUNCTIONALITY, NotificationManager.IMPORTANCE_HIGH);
|
||||
break;
|
||||
case AutomationService.NOTIFICATION_CHANNEL_ID_RULES:
|
||||
channel = new NotificationChannel(AutomationService.NOTIFICATION_CHANNEL_ID_RULES, AutomationService.NOTIFICATION_CHANNEL_NAME_RULES, NotificationManager.IMPORTANCE_HIGH);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
static void createDismissibleNotificationSdk26(String title, String textToDisplay, int notificationId, boolean vibrate, String notificationChannelId, PendingIntent pendingIntent)
|
||||
{
|
||||
NotificationManager mNotificationManager = (NotificationManager) AutomationService.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
@ -965,29 +1129,44 @@ public class Miscellaneous extends Service
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||
{
|
||||
NotificationChannel chan = new NotificationChannel(NOTIFICATION_CHANNEL_ID, "Functionality warnings", NotificationManager.IMPORTANCE_HIGH);
|
||||
// chan.setLightColor(Color.BLUE);
|
||||
chan.enableVibration(false);
|
||||
// chan.setSound(null, null);
|
||||
chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
||||
mNotificationManager.createNotificationChannel(chan);
|
||||
NotificationChannel notificationChannel = getNotificationChannel(notificationChannelId);
|
||||
// notificationChannel.setLightColor(Color.BLUE);
|
||||
notificationChannel.enableVibration(vibrate);
|
||||
try
|
||||
{
|
||||
Uri notificationSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
|
||||
// Uri notificationSound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE+ "://" +mContext.getPackageName()+"/"+R.raw.apple_ring));
|
||||
// Ringtone r = RingtoneManager.getRingtone(Miscellaneous.getAnyContext(), notification);
|
||||
AudioAttributes.Builder b = new AudioAttributes.Builder();
|
||||
b.setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN);
|
||||
notificationChannel.setSound(notificationSound, b.build());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Notification", Log.getStackTraceString(e), 2);
|
||||
}
|
||||
notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
||||
mNotificationManager.createNotificationChannel(notificationChannel);
|
||||
|
||||
builder = new NotificationCompat.Builder(AutomationService.getInstance(), NOTIFICATION_CHANNEL_ID);
|
||||
builder = new NotificationCompat.Builder(AutomationService.getInstance(), notificationChannel.getId());
|
||||
}
|
||||
else
|
||||
builder = new NotificationCompat.Builder(AutomationService.getInstance());
|
||||
|
||||
// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
// builder.setCategory(Notification.CATEGORY_SERVICE);
|
||||
|
||||
builder.setWhen(System.currentTimeMillis());
|
||||
builder.setContentIntent(pendingIntent);
|
||||
|
||||
builder.setContentTitle(AutomationService.getInstance().getResources().getString(R.string.app_name));
|
||||
if(title == null)
|
||||
builder.setContentTitle(AutomationService.getInstance().getResources().getString(R.string.app_name));
|
||||
else
|
||||
builder.setContentTitle(title);
|
||||
|
||||
builder.setOnlyAlertOnce(true);
|
||||
|
||||
if(Settings.showIconWhenServiceIsRunning)
|
||||
if(Settings.showIconWhenServiceIsRunning && notificationChannelId.equals(AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE))
|
||||
builder.setSmallIcon(R.drawable.ic_launcher);
|
||||
else if(!notificationChannelId.equals(AutomationService.NOTIFICATION_CHANNEL_ID_SERVICE))
|
||||
builder.setSmallIcon(R.drawable.info);
|
||||
|
||||
builder.setContentText(textToDisplay);
|
||||
builder.setStyle(new NotificationCompat.BigTextStyle().bigText(textToDisplay));
|
||||
@ -995,7 +1174,6 @@ public class Miscellaneous extends Service
|
||||
NotificationManager notificationManager = (NotificationManager) Miscellaneous.getAnyContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.notify(1, builder.build());
|
||||
|
||||
|
||||
// Intent notifyIntent = new Intent(context, notification.class);
|
||||
// notifyIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
//
|
||||
@ -1017,7 +1195,7 @@ public class Miscellaneous extends Service
|
||||
// notificationManager.notify(1, notification);
|
||||
}
|
||||
|
||||
protected static NotificationCompat.Builder createDismissableNotificationBuilder(PendingIntent myPendingIntent)
|
||||
protected static NotificationCompat.Builder createDismissibleNotificationBuilder(boolean vibrate, String notificationChannelId, PendingIntent myPendingIntent)
|
||||
{
|
||||
NotificationManager mNotificationManager = (NotificationManager) AutomationService.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
@ -1025,14 +1203,14 @@ public class Miscellaneous extends Service
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||
{
|
||||
NotificationChannel chan = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_HIGH);
|
||||
// chan.setLightColor(Color.BLUE);
|
||||
// chan.enableVibration(false);
|
||||
// chan.setSound(null, null);
|
||||
chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
||||
mNotificationManager.createNotificationChannel(chan);
|
||||
NotificationChannel notificationChannel = getNotificationChannel(notificationChannelId);
|
||||
// notificationChannel.setLightColor(Color.BLUE);
|
||||
notificationChannel.enableVibration(vibrate);
|
||||
// notificationChannel.setSound(null, null);
|
||||
notificationChannel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
||||
mNotificationManager.createNotificationChannel(notificationChannel);
|
||||
|
||||
builder = new NotificationCompat.Builder(AutomationService.getInstance(), NOTIFICATION_CHANNEL_ID);
|
||||
builder = new NotificationCompat.Builder(AutomationService.getInstance(), notificationChannelId);
|
||||
}
|
||||
else
|
||||
builder = new NotificationCompat.Builder(AutomationService.getInstance());
|
||||
@ -1110,7 +1288,8 @@ public class Miscellaneous extends Service
|
||||
|
||||
public static double round(double value, int places)
|
||||
{
|
||||
if (places < 0) throw new IllegalArgumentException();
|
||||
if (places < 0)
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
BigDecimal bd = new BigDecimal(Double.toString(value));
|
||||
bd = bd.setScale(places, RoundingMode.HALF_UP);
|
||||
@ -1122,7 +1301,7 @@ public class Miscellaneous extends Service
|
||||
Cursor cursor = null;
|
||||
try
|
||||
{
|
||||
String[] proj = { MediaStore.Images.Media.DATA };
|
||||
String[] proj = { MediaStore.Images.Media.DATA, MediaStore.Audio.Media.DATA };
|
||||
cursor = context.getContentResolver().query(contentUri, proj, null, null, null);
|
||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
cursor.moveToFirst();
|
||||
@ -1142,6 +1321,114 @@ public class Miscellaneous extends Service
|
||||
}
|
||||
}
|
||||
|
||||
public static String getRealPathFromURI2(final Context context, final Uri uri)
|
||||
{
|
||||
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||
|
||||
// DocumentProvider
|
||||
if (isKitKat && DocumentsContract.isDocumentUri(context, uri))
|
||||
{
|
||||
// ExternalStorageProvider
|
||||
if (isExternalStorageDocument(uri))
|
||||
{
|
||||
final String docId = DocumentsContract.getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
final String type = split[0];
|
||||
|
||||
if ("primary".equalsIgnoreCase(type))
|
||||
{
|
||||
return Environment.getExternalStorageDirectory() + "/" + split[1];
|
||||
}
|
||||
}
|
||||
// DownloadsProvider
|
||||
else if (isDownloadsDocument(uri))
|
||||
{
|
||||
|
||||
final String id = DocumentsContract.getDocumentId(uri);
|
||||
final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
|
||||
|
||||
return getDataColumn(context, contentUri, null, null);
|
||||
}
|
||||
// MediaProvider
|
||||
else if (isMediaDocument(uri))
|
||||
{
|
||||
final String docId = DocumentsContract.getDocumentId(uri);
|
||||
final String[] split = docId.split(":");
|
||||
final String type = split[0];
|
||||
|
||||
Uri contentUri = null;
|
||||
if ("image".equals(type))
|
||||
{
|
||||
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
}
|
||||
else if ("video".equals(type))
|
||||
{
|
||||
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
|
||||
}
|
||||
else if ("audio".equals(type))
|
||||
{
|
||||
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
|
||||
}
|
||||
|
||||
final String selection = "_id=?";
|
||||
final String[] selectionArgs = new String[] { split[1] };
|
||||
|
||||
return getDataColumn(context, contentUri, selection, selectionArgs);
|
||||
}
|
||||
}
|
||||
// MediaStore (and general)
|
||||
else if ("content".equalsIgnoreCase(uri.getScheme()))
|
||||
{
|
||||
return getDataColumn(context, uri, null, null);
|
||||
}
|
||||
// File
|
||||
else if ("file".equalsIgnoreCase(uri.getScheme()))
|
||||
{
|
||||
return uri.getPath();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs)
|
||||
{
|
||||
Cursor cursor = null;
|
||||
final String column = "_data";
|
||||
final String[] projection = { column };
|
||||
|
||||
try
|
||||
{
|
||||
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
|
||||
null);
|
||||
if (cursor != null && cursor.moveToFirst())
|
||||
{
|
||||
final int column_index = cursor.getColumnIndexOrThrow(column);
|
||||
return cursor.getString(column_index);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (cursor != null)
|
||||
cursor.close();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isExternalStorageDocument(Uri uri)
|
||||
{
|
||||
return "com.android.externalstorage.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
public static boolean isDownloadsDocument(Uri uri)
|
||||
{
|
||||
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
public static boolean isMediaDocument(Uri uri)
|
||||
{
|
||||
return "com.android.providers.media.documents".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
public static Method getClassMethodReflective(String className, String methodName)
|
||||
{
|
||||
Class foundClass = null;
|
||||
@ -1187,7 +1474,7 @@ public class Miscellaneous extends Service
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean restrictedFeaturesConfigured()
|
||||
public static boolean restrictedFeaturesConfiguredFdroid()
|
||||
{
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.activityDetection))
|
||||
{
|
||||
@ -1204,6 +1491,17 @@ public class Miscellaneous extends Service
|
||||
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
|
||||
{
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
@ -1434,7 +1732,7 @@ public class Miscellaneous extends Service
|
||||
{
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
|
||||
{
|
||||
if (BuildConfig.FLAVOR.equalsIgnoreCase("googlePlayFlavor"))
|
||||
if (BuildConfig.FLAVOR.equalsIgnoreCase(AutomationService.flavor_name_googleplay))
|
||||
{
|
||||
if(checkExistingRules)
|
||||
{
|
||||
@ -1567,13 +1865,12 @@ public class Miscellaneous extends Service
|
||||
|
||||
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.Q)
|
||||
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.S)
|
||||
{
|
||||
TelephonyManager tm = (TelephonyManager)Miscellaneous.getAnyContext().getSystemService(Context.TELEPHONY_SERVICE);
|
||||
return PhoneNumberUtils.areSamePhoneNumber(number1, number2, tm.getNetworkCountryIso());
|
||||
}
|
||||
else*/
|
||||
else
|
||||
return PhoneNumberUtils.compare(number1, number2);
|
||||
}
|
||||
|
||||
@ -1593,4 +1890,139 @@ public class Miscellaneous extends Service
|
||||
|
||||
return formattedDate;
|
||||
}
|
||||
|
||||
public static boolean arraySearch(String[] haystack, String needle, boolean caseSensitive, boolean matchFullLine)
|
||||
{
|
||||
if(matchFullLine)
|
||||
{
|
||||
if(caseSensitive)
|
||||
{
|
||||
for (String s : haystack)
|
||||
{
|
||||
if (s.equals(needle))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (String s : haystack)
|
||||
{
|
||||
if (s.toLowerCase().equals(needle.toLowerCase()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(caseSensitive)
|
||||
{
|
||||
for (String s : haystack)
|
||||
{
|
||||
if (s.contains(needle))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (String s : haystack)
|
||||
{
|
||||
if (s.toLowerCase().contains(needle.toLowerCase()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean arraySearch(ArrayList<String> requestList, String needle, boolean caseSensitive, boolean matchFullLine)
|
||||
{
|
||||
return arraySearch(requestList.toArray(new String[requestList.size()]), needle, caseSensitive, matchFullLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ISO 3166-1 alpha-2 country code for this device (or null if not available)
|
||||
* @param context Context reference to get the TelephonyManager instance from
|
||||
* @return country code or null
|
||||
*/
|
||||
public static String getUserCountry(Context context)
|
||||
{
|
||||
try
|
||||
{
|
||||
final TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
final String simCountry = tm.getSimCountryIso();
|
||||
if (simCountry != null && simCountry.length() == 2)
|
||||
{ // SIM country code is available
|
||||
return simCountry.toLowerCase(Locale.US);
|
||||
}
|
||||
else if (tm.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA)
|
||||
{ // device is not 3G (would be unreliable)
|
||||
String networkCountry = tm.getNetworkCountryIso();
|
||||
if (networkCountry != null && networkCountry.length() == 2)
|
||||
{ // network country code is available
|
||||
return networkCountry.toLowerCase(Locale.US);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SecurityException se)
|
||||
{
|
||||
return "unknown";
|
||||
}
|
||||
catch (Exception e)
|
||||
{ }
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String checksumSha(String filepath) throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
MessageDigest md = null;
|
||||
md = MessageDigest.getInstance("SHA-256");
|
||||
|
||||
// file hashing with DigestInputStream
|
||||
try (DigestInputStream dis = new DigestInputStream(new FileInputStream(filepath), md))
|
||||
{
|
||||
while (dis.read() != -1)
|
||||
; //empty loop to clear the data
|
||||
md = dis.getMessageDigest();
|
||||
}
|
||||
|
||||
// bytes to hex
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (byte b : md.digest())
|
||||
{
|
||||
result.append(String.format("%02x", b));
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
catch (NoSuchAlgorithmException e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "shaChecksum", Log.getStackTraceString(e), 2);
|
||||
}
|
||||
|
||||
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 = 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -64,7 +64,7 @@ public class PointOfInterest implements Comparable<PointOfInterest>
|
||||
public void setName(String desiredName)
|
||||
{
|
||||
this.oldName = this.name;
|
||||
this.name = desiredName;
|
||||
this.name = desiredName.trim();
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
@ -421,14 +421,18 @@ public class PointOfInterest implements Comparable<PointOfInterest>
|
||||
public boolean create(Context context)
|
||||
{
|
||||
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();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(plausibilityCheck())
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Creating POI", this.toStringLong(), 3);
|
||||
|
||||
PointOfInterest.pointOfInterestCollection.add(this);
|
||||
PointOfInterest.writePoisToFile();
|
||||
|
||||
@ -490,8 +494,10 @@ public class PointOfInterest implements Comparable<PointOfInterest>
|
||||
Check for change of rule name END
|
||||
*/
|
||||
|
||||
if (plausibilityCheck())
|
||||
if(plausibilityCheck())
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Changing POI", "Old name: " + this.oldName + ", new data: " + this.toStringLong(), 3);
|
||||
|
||||
if(PointOfInterest.writePoisToFile())
|
||||
{
|
||||
AutomationService service = AutomationService.getInstance();
|
||||
|
@ -3,6 +3,7 @@ package com.jens.automation2;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.media.AudioManager;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
@ -41,13 +42,13 @@ public class Profile implements Comparable<Profile>
|
||||
protected int volumeAlarms;
|
||||
|
||||
protected boolean changeIncomingCallsRingtone;
|
||||
protected File incomingCallsRingtone;
|
||||
protected String incomingCallsRingtone;
|
||||
|
||||
protected boolean changeVibrateWhenRinging;
|
||||
protected boolean vibrateWhenRinging;
|
||||
|
||||
protected boolean changeNotificationRingtone;
|
||||
protected File notificationRingtone;
|
||||
protected String notificationRingtone;
|
||||
|
||||
protected boolean changeAudibleSelection;
|
||||
protected boolean audibleSelection;
|
||||
@ -62,7 +63,7 @@ public class Profile implements Comparable<Profile>
|
||||
public void setName(String name)
|
||||
{
|
||||
this.oldName = this.name;
|
||||
this.name = name;
|
||||
this.name = name.trim();
|
||||
}
|
||||
|
||||
public String getName()
|
||||
@ -171,11 +172,11 @@ public class Profile implements Comparable<Profile>
|
||||
return changeIncomingCallsRingtone;
|
||||
}
|
||||
|
||||
public void setIncomingCallsRingtone(File incomingCallsRingtone)
|
||||
public void setIncomingCallsRingtone(String incomingCallsRingtone)
|
||||
{
|
||||
this.incomingCallsRingtone = incomingCallsRingtone;
|
||||
}
|
||||
public File getIncomingCallsRingtone()
|
||||
public String getIncomingCallsRingtone()
|
||||
{
|
||||
return incomingCallsRingtone;
|
||||
}
|
||||
@ -207,11 +208,11 @@ public class Profile implements Comparable<Profile>
|
||||
return changeNotificationRingtone;
|
||||
}
|
||||
|
||||
public void setNotificationRingtone(File notificationsRingtone)
|
||||
public void setNotificationRingtone(String notificationsRingtone)
|
||||
{
|
||||
this.notificationRingtone = notificationsRingtone;
|
||||
}
|
||||
public File getNotificationRingtone()
|
||||
public String getNotificationRingtone()
|
||||
{
|
||||
return notificationRingtone;
|
||||
}
|
||||
@ -292,51 +293,69 @@ public class Profile implements Comparable<Profile>
|
||||
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("//"))
|
||||
{
|
||||
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();
|
||||
values.put(MediaStore.MediaColumns.DATA, ringtoneFile.getAbsolutePath());
|
||||
// values.put(MediaStore.MediaColumns.TITLE, context.getResources().getString(R.string.app_name) + " ringtone");
|
||||
// values.put(MediaStore.MediaColumns.TITLE, ringtoneFile.getName().replace(".mp3", "").replace(".", ""));
|
||||
values.put(MediaStore.MediaColumns.TITLE, ringtoneFile.getName());
|
||||
// values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/*");
|
||||
values.put(MediaStore.MediaColumns.MIME_TYPE, "audio/mp3");
|
||||
values.put(MediaStore.MediaColumns.SIZE, ringtoneFile.length());
|
||||
// values.put(MediaStore.Audio.Media.ARTIST, R.string.app_name);
|
||||
values.put(MediaStore.Audio.Media.IS_RINGTONE, ringtoneType == RingtoneManager.TYPE_RINGTONE);
|
||||
values.put(MediaStore.Audio.Media.IS_NOTIFICATION, ringtoneType == RingtoneManager.TYPE_NOTIFICATION);
|
||||
values.put(MediaStore.Audio.Media.IS_ALARM, false);
|
||||
values.put(MediaStore.Audio.Media.IS_MUSIC, false);
|
||||
|
||||
Uri existingRingTone = MediaStore.Audio.Media.getContentUriForPath(ringtoneFile.getAbsolutePath());
|
||||
if(existingRingTone != null)
|
||||
context.getContentResolver().delete(existingRingTone, MediaStore.MediaColumns.DATA + "=\"" + ringtoneFile.getAbsolutePath() + "\"", null);
|
||||
Uri newRingTone = context.getContentResolver().insert(existingRingTone, values);
|
||||
|
||||
try
|
||||
{
|
||||
RingtoneManager.setActualDefaultRingtoneUri(context, ringtoneType, newRingTone);
|
||||
Miscellaneous.logEvent("i", "Profile", "Ringtone set to: " + newRingTone.toString(), 1);
|
||||
// Ringtone tone = RingtoneManager.getRingtone(context, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE));
|
||||
// tone.play();
|
||||
Uri target = Uri.parse(ringtoneFile);
|
||||
RingtoneManager.setActualDefaultRingtoneUri(context, ringtoneType, target);
|
||||
Miscellaneous.logEvent("i", "Profile", "Ringtone set to: " + ringtoneFile, 1);
|
||||
return true;
|
||||
}
|
||||
catch (Throwable t)
|
||||
} // Set by filepath
|
||||
else
|
||||
{
|
||||
String message = "Error setting ringtone: " + Log.getStackTraceString(t);
|
||||
Miscellaneous.logEvent("e", "Profile", message, 1);
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(MediaStore.MediaColumns.DATA, ringtoneFile);
|
||||
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.SIZE, ringtoneFile.length());
|
||||
values.put(MediaStore.Audio.Media.IS_RINGTONE, ringtoneType == RingtoneManager.TYPE_RINGTONE);
|
||||
values.put(MediaStore.Audio.Media.IS_NOTIFICATION, ringtoneType == RingtoneManager.TYPE_NOTIFICATION);
|
||||
values.put(MediaStore.Audio.Media.IS_ALARM, false);
|
||||
values.put(MediaStore.Audio.Media.IS_MUSIC, false);
|
||||
|
||||
try
|
||||
{
|
||||
Uri newRingTone = null;
|
||||
|
||||
Uri existingRingTone = MediaStore.Audio.Media.getContentUriForPath(ringtoneFile);
|
||||
|
||||
try
|
||||
{
|
||||
if (existingRingTone != null)
|
||||
context.getContentResolver().delete(existingRingTone, MediaStore.MediaColumns.DATA + "=\"" + ringtoneFile + "\"", null);
|
||||
}
|
||||
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);
|
||||
|
||||
Miscellaneous.logEvent("i", "Profile", "Ringtone set to: " + newRingTone.toString(), 1);
|
||||
return true;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
String message = "Error setting ringtone: " + Log.getStackTraceString(t);
|
||||
Miscellaneous.logEvent("e", "Profile", message, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -454,29 +473,17 @@ public class Profile implements Comparable<Profile>
|
||||
|
||||
public boolean delete(Context context)
|
||||
{
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.profileActive))
|
||||
Rule usingRule = this.isInUseByRules();
|
||||
if(usingRule != null)
|
||||
{
|
||||
for (Rule rule : Rule.findRuleCandidatesByTriggerProfile(this))
|
||||
{
|
||||
Toast.makeText(context, String.format(context.getResources().getString(R.string.ruleXIsUsingProfileY), rule.getName(), this.getName()), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(Rule.isAnyRuleUsing(Action_Enum.changeSoundProfile))
|
||||
{
|
||||
for (Rule rule : Rule.findRuleCandidatesByActionProfile(this))
|
||||
{
|
||||
Toast.makeText(context, String.format(context.getResources().getString(R.string.ruleXIsUsingProfileY), rule.getName(), this.getName()), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
Toast.makeText(context, String.format(context.getResources().getString(R.string.ruleXIsUsingProfileY), usingRule.getName(), this.getName()), Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
profileCollection.remove(this);
|
||||
return XmlFileInterface.writeFile();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean plausibilityCheck()
|
||||
@ -517,7 +524,7 @@ public class Profile implements Comparable<Profile>
|
||||
Actions.setSound(context, soundMode);
|
||||
|
||||
if(changeDndMode)
|
||||
Actions.setDND(context, dndMode);
|
||||
Actions.setDoNotDisturb(context, dndMode);
|
||||
|
||||
if(changeVolumeMusicVideoGameMedia)
|
||||
am.setStreamVolume(AudioManager.STREAM_MUSIC, volumeMusic, AudioManager.FLAG_PLAY_SOUND);
|
||||
@ -578,17 +585,17 @@ public class Profile implements Comparable<Profile>
|
||||
}
|
||||
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);
|
||||
for(int i=0; i<ruleCandidates.size(); i++)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
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
|
||||
@ -604,65 +611,107 @@ public class Profile implements Comparable<Profile>
|
||||
try
|
||||
{
|
||||
AudioManager am = (AudioManager) Miscellaneous.getAnyContext().getSystemService(Context.AUDIO_SERVICE);
|
||||
NotificationManager mNotificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
if(changeSoundMode)
|
||||
if (changeSoundMode)
|
||||
{
|
||||
if(am.getRingerMode() != soundMode)
|
||||
if (am.getRingerMode() != soundMode)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(changeDndMode && Build.VERSION.SDK_INT >= 23)
|
||||
if (changeDndMode && Build.VERSION.SDK_INT >= 23)
|
||||
{
|
||||
if(mNotificationManager.getCurrentInterruptionFilter() != dndMode)
|
||||
if (mNotificationManager.getCurrentInterruptionFilter() != dndMode)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(changeVolumeMusicVideoGameMedia)
|
||||
if (changeVolumeMusicVideoGameMedia)
|
||||
{
|
||||
if(am.getStreamVolume(AudioManager.STREAM_MUSIC) != volumeMusic)
|
||||
if (am.getStreamVolume(AudioManager.STREAM_MUSIC) != volumeMusic)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(changeVolumeNotifications)
|
||||
if (changeVolumeNotifications)
|
||||
{
|
||||
if(am.getStreamVolume(AudioManager.STREAM_NOTIFICATION) != volumeNotifications)
|
||||
if (am.getStreamVolume(AudioManager.STREAM_NOTIFICATION) != volumeNotifications)
|
||||
return false;
|
||||
}
|
||||
|
||||
if(changeVolumeAlarms)
|
||||
if (changeVolumeAlarms)
|
||||
{
|
||||
if(am.getStreamVolume(AudioManager.STREAM_ALARM) != volumeAlarms)
|
||||
if (am.getStreamVolume(AudioManager.STREAM_ALARM) != volumeAlarms)
|
||||
return false;
|
||||
}
|
||||
|
||||
// if(changeIncomingCallsRingtone)
|
||||
// {
|
||||
// if (incomingCallsRingtone != null)
|
||||
// {
|
||||
// applyRingTone(incomingCallsRingtone, RingtoneManager.TYPE_RINGTONE, context);
|
||||
// }
|
||||
// }
|
||||
|
||||
if(changeVibrateWhenRinging)
|
||||
/*if (changeIncomingCallsRingtone)
|
||||
{
|
||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
if (incomingCallsRingtone != null)
|
||||
{
|
||||
Uri ringtone_uri = RingtoneManager.getActualDefaultRingtoneUri(context, RingtoneManager.TYPE_RINGTONE);
|
||||
|
||||
if (ringtone_uri != null)
|
||||
{
|
||||
// if ringtone_uri is null get Default Ringtone
|
||||
ringtone_uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
|
||||
|
||||
Ringtone currentRingtone = RingtoneManager.getRingtone(context, ringtone_uri);
|
||||
String title = currentRingtone.getTitle(context);
|
||||
*//* Ringtone desiredRingtone = RingtoneManager.getRingtone(context, Uri.fromFile(notificationRingtone));
|
||||
boolean result = currentRingtone.equals(desiredRingtone);*//*
|
||||
|
||||
Uri desired_ringtone = MediaStore.Audio.Media.getContentUriForPath(incomingCallsRingtone.getAbsolutePath());
|
||||
|
||||
// File currentRingtoneFile = new File(Miscellaneous.getRealPathFromURI(context, ringtone_uri));
|
||||
String currentChecksum = Miscellaneous.checksumSha(ringtone_uri.getPath());
|
||||
String desiredChecksum = Miscellaneous.checksumSha(incomingCallsRingtone.getAbsolutePath());
|
||||
|
||||
if (!currentChecksum.equals(desiredChecksum))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (changeVibrateWhenRinging)
|
||||
{
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
|
||||
{
|
||||
int currentSetting = android.provider.Settings.System.getInt(context.getContentResolver(), "vibrate_when_ringing");
|
||||
if(currentSetting != Miscellaneous.boolToInt(vibrateWhenRinging))
|
||||
if (currentSetting != Miscellaneous.boolToInt(vibrateWhenRinging))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int currentSetting = am.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);
|
||||
if(currentSetting != Miscellaneous.boolToInt(vibrateWhenRinging))
|
||||
if (currentSetting != Miscellaneous.boolToInt(vibrateWhenRinging))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// if(changeNotificationRingtone)
|
||||
// if(notificationRingtone != null)
|
||||
// applyRingTone(notificationRingtone, RingtoneManager.TYPE_NOTIFICATION, context);
|
||||
/*if (changeNotificationRingtone)
|
||||
{
|
||||
if (notificationRingtone != null)
|
||||
{
|
||||
Uri ringtone_uri = RingtoneManager.getActualDefaultRingtoneUri(context, RingtoneManager.TYPE_NOTIFICATION);
|
||||
|
||||
if (ringtone_uri == null)
|
||||
{
|
||||
// if ringtone_uri is null get Default Ringtone
|
||||
ringtone_uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
|
||||
|
||||
File currentRingtone = new File(Settings.System.DEFAULT_NOTIFICATION_URI.getPath());
|
||||
|
||||
// File currentRingtone = new File(Miscellaneous.getRealPathFromURI(context, ringtone_uri));
|
||||
|
||||
String currentChecksum = Miscellaneous.checksumSha(currentRingtone.getAbsolutePath());
|
||||
String desiredChecksum = Miscellaneous.checksumSha(notificationRingtone.getAbsolutePath());
|
||||
|
||||
if(!currentChecksum.equals(desiredChecksum))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
|
||||
if(changeScreenLockUnlockSound)
|
||||
{
|
||||
@ -730,4 +779,11 @@ public class Profile implements Comparable<Profile>
|
||||
return this.oldName;
|
||||
}
|
||||
|
||||
public static Profile getLastActivatedProfile()
|
||||
{
|
||||
if(Profile.profileActivationHistory != null && Profile.profileActivationHistory.size() > 0)
|
||||
return Profile.profileActivationHistory.get(Profile.profileActivationHistory.size() - 1);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import android.util.Log;
|
||||
|
||||
import com.jens.automation2.location.CellLocationChangedReceiver;
|
||||
import com.jens.automation2.location.WifiBroadcastReceiver;
|
||||
import com.jens.automation2.receivers.BroadcastListener;
|
||||
import com.jens.automation2.receivers.DateTimeListener;
|
||||
import com.jens.automation2.receivers.AutomationListenerInterface;
|
||||
import com.jens.automation2.receivers.BatteryReceiver;
|
||||
@ -12,9 +13,13 @@ import com.jens.automation2.receivers.BluetoothReceiver;
|
||||
import com.jens.automation2.receivers.ConnectivityReceiver;
|
||||
import com.jens.automation2.receivers.DeviceOrientationListener;
|
||||
import com.jens.automation2.receivers.HeadphoneJackListener;
|
||||
import com.jens.automation2.receivers.MediaPlayerListener;
|
||||
import com.jens.automation2.receivers.NoiseListener;
|
||||
import com.jens.automation2.receivers.PhoneStatusListener;
|
||||
import com.jens.automation2.receivers.ProcessListener;
|
||||
import com.jens.automation2.receivers.ScreenStateReceiver;
|
||||
import com.jens.automation2.receivers.SubSystemStateReceiver;
|
||||
import com.jens.automation2.receivers.TetheringReceiver;
|
||||
import com.jens.automation2.receivers.TimeZoneListener;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
@ -51,9 +56,13 @@ public class ReceiverCoordinator
|
||||
HeadphoneJackListener.class,
|
||||
//NfcReceiver.class,
|
||||
NoiseListener.class,
|
||||
//NotificationListener.class,
|
||||
PhoneStatusListener.class,
|
||||
ProcessListener.class,
|
||||
TimeZoneListener.class
|
||||
MediaPlayerListener.class,
|
||||
ScreenStateReceiver.class,
|
||||
TimeZoneListener.class,
|
||||
TetheringReceiver.class
|
||||
};
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
@ -62,6 +71,7 @@ public class ReceiverCoordinator
|
||||
DateTimeListener.class,
|
||||
BatteryReceiver.class,
|
||||
BluetoothReceiver.class,
|
||||
BroadcastListener.class,
|
||||
ConnectivityReceiver.class,
|
||||
DeviceOrientationListener.class,
|
||||
HeadphoneJackListener.class,
|
||||
@ -69,7 +79,9 @@ public class ReceiverCoordinator
|
||||
NoiseListener.class,
|
||||
PhoneStatusListener.class,
|
||||
ProcessListener.class,
|
||||
TimeZoneListener.class
|
||||
ScreenStateReceiver.class,
|
||||
TimeZoneListener.class,
|
||||
TetheringReceiver.class
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -132,12 +144,6 @@ public class ReceiverCoordinator
|
||||
Miscellaneous.logEvent("w", "Error in new model", Log.getStackTraceString(e), 3);
|
||||
}
|
||||
|
||||
// if(Settings.useAccelerometerForPositioning && !Miscellaneous.isAndroidEmulator())
|
||||
// {
|
||||
// accelerometerHandler = new AccelerometerHandler();
|
||||
// mySensorActivity = new SensorActivity(this);
|
||||
// }
|
||||
|
||||
// startPhoneStateListener
|
||||
PhoneStatusListener.startPhoneStatusListener(AutomationService.getInstance()); // also used to mute anouncements during calls
|
||||
|
||||
@ -163,13 +169,23 @@ public class ReceiverCoordinator
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.noiseLevel))
|
||||
NoiseListener.startNoiseListener(AutomationService.getInstance());
|
||||
|
||||
// startNoiseListener
|
||||
// startBroadcastListener
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.broadcastReceived))
|
||||
BroadcastListener.getInstance().startListener(AutomationService.getInstance());
|
||||
|
||||
// startProcessListener
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.process_started_stopped))
|
||||
ProcessListener.startProcessListener(AutomationService.getInstance());
|
||||
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.deviceOrientation))
|
||||
DeviceOrientationListener.getInstance().startListener(AutomationService.getInstance());
|
||||
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.tethering))
|
||||
TetheringReceiver.getInstance().startListener(AutomationService.getInstance());
|
||||
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.subSystemState))
|
||||
SubSystemStateReceiver.getInstance().startListener(AutomationService.getInstance());
|
||||
|
||||
try
|
||||
{
|
||||
Class testClass = Class.forName(ActivityManageRule.activityDetectionClassPath);
|
||||
@ -182,13 +198,17 @@ public class ReceiverCoordinator
|
||||
// Nothing to do, just not starting this one.
|
||||
}
|
||||
|
||||
//startBluetoothReceiver
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.bluetoothConnection))
|
||||
BluetoothReceiver.startBluetoothReceiver();
|
||||
|
||||
//startHeadsetJackListener
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.headsetPlugged))
|
||||
HeadphoneJackListener.getInstance().startListener(AutomationService.getInstance());
|
||||
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.musicPlaying))
|
||||
MediaPlayerListener.getInstance().startListener(AutomationService.getInstance());
|
||||
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.screenState))
|
||||
ScreenStateReceiver.startScreenStateReceiver(AutomationService.getInstance());
|
||||
}
|
||||
|
||||
public static void stopAllReceivers()
|
||||
@ -202,15 +222,19 @@ public class ReceiverCoordinator
|
||||
TimeZoneListener.stopTimeZoneListener();
|
||||
DateTimeListener.stopAlarmListener(AutomationService.getInstance());
|
||||
NoiseListener.stopNoiseListener();
|
||||
BroadcastListener.getInstance().stopListener(AutomationService.getInstance());
|
||||
ProcessListener.stopProcessListener(AutomationService.getInstance());
|
||||
MediaPlayerListener.getInstance().stopListener(AutomationService.getInstance());
|
||||
DeviceOrientationListener.getInstance().stopListener(AutomationService.getInstance());
|
||||
TetheringReceiver.getInstance().stopListener(AutomationService.getInstance());
|
||||
SubSystemStateReceiver.getInstance().stopListener(AutomationService.getInstance());
|
||||
|
||||
try
|
||||
{
|
||||
Class testClass = Class.forName(ActivityManageRule.activityDetectionClassPath);
|
||||
Miscellaneous.runMethodReflective("ActivityDetectionReceiver", "stopActivityDetectionReceiver", null);
|
||||
}
|
||||
catch(ClassNotFoundException e)
|
||||
catch(Exception e)
|
||||
{
|
||||
// Nothing to do, just not stopping this one.
|
||||
}
|
||||
@ -241,7 +265,7 @@ public class ReceiverCoordinator
|
||||
|
||||
// timeFrame -> too inexpensive to shutdown
|
||||
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.charging) | Rule.isAnyRuleUsing(Trigger.Trigger_Enum.usb_host_connection) | Rule.isAnyRuleUsing(Trigger.Trigger_Enum.batteryLevel))
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.charging) || Rule.isAnyRuleUsing(Trigger.Trigger_Enum.usb_host_connection) || Rule.isAnyRuleUsing(Trigger.Trigger_Enum.batteryLevel))
|
||||
{
|
||||
if(BatteryReceiver.haveAllPermission())
|
||||
BatteryReceiver.startBatteryReceiver(AutomationService.getInstance());
|
||||
@ -261,6 +285,17 @@ public class ReceiverCoordinator
|
||||
NoiseListener.stopNoiseListener();
|
||||
}
|
||||
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.broadcastReceived))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "LocationProvider", "Starting BroadcastReceiver because used in a new/changed rule.", 4);
|
||||
BroadcastListener.getInstance().startListener(AutomationService.getInstance());
|
||||
}
|
||||
else
|
||||
{
|
||||
Miscellaneous.logEvent("i", "LocationProvider", "Shutting down BroadcastReceiver because not used in any rule.", 4);
|
||||
BroadcastListener.getInstance().stopListener(AutomationService.getInstance());
|
||||
}
|
||||
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.process_started_stopped))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "LocationProvider", "Starting ProcessListener because used in a new/changed rule.", 4);
|
||||
@ -273,7 +308,29 @@ public class ReceiverCoordinator
|
||||
ProcessListener.stopProcessListener(AutomationService.getInstance());
|
||||
}
|
||||
|
||||
if(!BuildConfig.FLAVOR.equalsIgnoreCase("fdroidFlavor"))
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.screenState))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "LocationProvider", "Starting ScreenStateListener because used in a new/changed rule.", 4);
|
||||
ScreenStateReceiver.startScreenStateReceiver(AutomationService.getInstance());
|
||||
}
|
||||
else
|
||||
{
|
||||
Miscellaneous.logEvent("i", "LocationProvider", "Shutting down ScreenStateListener because not used in any rule.", 4);
|
||||
ScreenStateReceiver.stopScreenStateReceiver();
|
||||
}
|
||||
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.musicPlaying))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "LocationProvider", "Starting MediaPlayerListener because used in a new/changed rule.", 4);
|
||||
MediaPlayerListener.getInstance().startListener(AutomationService.getInstance());
|
||||
}
|
||||
else
|
||||
{
|
||||
Miscellaneous.logEvent("i", "LocationProvider", "Shutting down MediaPlayerListener because not used in any rule.", 4);
|
||||
MediaPlayerListener.getInstance().stopListener(AutomationService.getInstance());
|
||||
}
|
||||
|
||||
if(!BuildConfig.FLAVOR.equalsIgnoreCase(AutomationService.flavor_name_fdroid))
|
||||
{
|
||||
if (Rule.isAnyRuleUsing(Trigger.Trigger_Enum.activityDetection))
|
||||
{
|
||||
@ -370,6 +427,42 @@ public class ReceiverCoordinator
|
||||
}
|
||||
}
|
||||
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.tethering))
|
||||
{
|
||||
if(!TetheringReceiver.getInstance().isListenerRunning())
|
||||
{
|
||||
Miscellaneous.logEvent("i", "TetheringReceiver", "Starting TetheringReceiver because used in a new/changed rule.", 4);
|
||||
// if(DevicePositionListener.getInstance().haveAllPermission())
|
||||
TetheringReceiver.getInstance().startListener(AutomationService.getInstance());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(TetheringReceiver.getInstance().isListenerRunning())
|
||||
{
|
||||
Miscellaneous.logEvent("i", "TetheringReceiver", "Shutting down TetheringReceiver because not used in any rule.", 4);
|
||||
TetheringReceiver.getInstance().stopListener(AutomationService.getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import java.util.Set;
|
||||
public class Settings implements SharedPreferences
|
||||
{
|
||||
public static final int rulesThatHaveBeenRanHistorySize = 10;
|
||||
public final static int lockSoundChangesInterval = 15;
|
||||
public static final int lockSoundChangesInterval = 15;
|
||||
public static final int newsPollEveryXDays = 3;
|
||||
public static final int newsDisplayForXDays = 3;
|
||||
public static final int updateCheckFrequencyDays = 7;
|
||||
@ -20,6 +20,7 @@ public class Settings implements SharedPreferences
|
||||
public static final String zipFileName = "automation.zip";
|
||||
|
||||
public static final String constNewsOptInDone ="newsOptInDone";
|
||||
public static final String constNotificationChannelCleanupApk118 ="notificationChannelCleanupApk118";
|
||||
|
||||
public static long minimumDistanceChangeForGpsUpdate;
|
||||
public static long minimumDistanceChangeForNetworkUpdate;
|
||||
@ -64,7 +65,10 @@ public class Settings implements SharedPreferences
|
||||
public static int tabsPlacement;
|
||||
public static boolean executeRulesAndProfilesWithSingleClick;
|
||||
public static boolean displayNewsOnMainScreen;
|
||||
public static boolean showToasts;
|
||||
public static boolean automaticUpdateCheck;
|
||||
public static long musicCheckFrequency;
|
||||
public static String displayLanguage;
|
||||
|
||||
public static boolean lockSoundChanges;
|
||||
public static boolean noticeAndroid9MicrophoneShown;
|
||||
@ -75,57 +79,67 @@ public class Settings implements SharedPreferences
|
||||
public static ArrayList<String> whatHasBeenDone;
|
||||
|
||||
/*
|
||||
Generic settings valid for all installations and not changable
|
||||
Not saved permanently.
|
||||
*/
|
||||
public static boolean deviceStartDone = true; // by default assume device has not just been started
|
||||
public static boolean serviceStartDone = false;
|
||||
|
||||
/*
|
||||
Generic settings valid for all installations and not changeable
|
||||
*/
|
||||
public static final String dateFormat = "E dd.MM.yyyy HH:mm:ss:ssss";
|
||||
|
||||
protected static final int default_positioningEngine = 0;
|
||||
protected static final long default_minimumDistanceChangeForGpsUpdate = 100;
|
||||
protected static final long default_minimumDistanceChangeForNetworkUpdate = 500; // in Meters
|
||||
protected static final long default_satisfactoryAccuracyGps = 50;
|
||||
protected static final long default_satisfactoryAccuracyNetwork = 1000;
|
||||
protected static final int default_gpsTimeout = 300; // seconds
|
||||
protected static final long default_minimumTimeBetweenUpdate = 30000; // in Milliseconds
|
||||
protected static final boolean default_startServiceAtSystemBoot = false;
|
||||
protected static final boolean default_writeLogFile = false;
|
||||
protected static final long default_logLevel = 2;
|
||||
protected static final int default_logFileMaxSize = 10;
|
||||
protected static final boolean default_useTextToSpeechOnNormal = false;
|
||||
protected static final boolean default_useTextToSpeechOnVibrate = false;
|
||||
protected static final boolean default_useTextToSpeechOnSilent = false;
|
||||
protected static final boolean default_muteTextToSpeechDuringCalls = true;
|
||||
protected static final boolean default_useWifiForPositioning = true;
|
||||
protected static final boolean default_useAccelerometerForPositioning = true;
|
||||
protected static final long default_useAccelerometerAfterIdleTime = 5;
|
||||
protected static final long default_accelerometerMovementThreshold = 2;
|
||||
protected static final long default_speedMaximumTimeBetweenLocations = 4;
|
||||
protected static final long default_timeBetweenNoiseLevelMeasurements = 60;
|
||||
protected static final long default_lengthOfNoiseLevelMeasurements = 5;
|
||||
protected static final long default_referenceValueForNoiseLevelMeasurements = 20;
|
||||
protected static final boolean default_hasServiceBeenRunning = false;
|
||||
protected static final boolean default_startServiceAfterAppUpdate = true;
|
||||
protected static final boolean default_startNewThreadForRuleActivation = true;
|
||||
protected static final boolean default_showIconWhenServiceIsRunning = true;
|
||||
protected static final boolean default_httpAcceptAllCertificates = false;
|
||||
protected static final int default_httpAttempts = 3;
|
||||
protected static final int default_httpAttemptsTimeout = 60;
|
||||
protected static final int default_httpAttemptGap = 2;
|
||||
protected static final PointOfInterest default_lastActivePoi = null;
|
||||
protected static final boolean default_rememberLastActivePoi = true;
|
||||
protected static final int default_locationRingBufferSize=3;
|
||||
protected static final long default_timeBetweenProcessMonitorings = 60;
|
||||
protected static final long default_acceptDevicePositionSignalEveryX_MilliSeconds = 1000;
|
||||
protected static final int default_activityDetectionFrequency = 60;
|
||||
protected static final int default_activityDetectionRequiredProbability = 75;
|
||||
protected static final boolean default_privacyLocationing = false;
|
||||
protected static final int default_startScreen = 0;
|
||||
protected static final int default_tabsPlacement = 0;
|
||||
protected static final boolean default_executeRulesAndProfilesWithSingleClick = false;
|
||||
protected static final boolean default_displayNewsOnMainScreen = false;
|
||||
protected static final boolean default_automaticUpdateCheck = false;
|
||||
protected static final boolean default_lockSoundChanges = false;
|
||||
protected static final long default_lastNewsPolltime = -1;
|
||||
protected static final long default_lastUpdateCheck = -1;
|
||||
public static final int default_positioningEngine = 0;
|
||||
public static final long default_minimumDistanceChangeForGpsUpdate = 100;
|
||||
public static final long default_minimumDistanceChangeForNetworkUpdate = 500; // in Meters
|
||||
public static final long default_satisfactoryAccuracyGps = 50;
|
||||
public static final long default_satisfactoryAccuracyNetwork = 1000;
|
||||
public static final int default_gpsTimeout = 300; // seconds
|
||||
public static final long default_minimumTimeBetweenUpdate = 30000; // in Milliseconds
|
||||
public static final boolean default_startServiceAtSystemBoot = false;
|
||||
public static final boolean default_writeLogFile = false;
|
||||
public static final long default_logLevel = 2;
|
||||
public static final int default_logFileMaxSize = 10;
|
||||
public static final boolean default_useTextToSpeechOnNormal = false;
|
||||
public static final boolean default_useTextToSpeechOnVibrate = false;
|
||||
public static final boolean default_useTextToSpeechOnSilent = false;
|
||||
public static final boolean default_muteTextToSpeechDuringCalls = true;
|
||||
public static final boolean default_useWifiForPositioning = true;
|
||||
public static final boolean default_useAccelerometerForPositioning = true;
|
||||
public static final long default_useAccelerometerAfterIdleTime = 5;
|
||||
public static final long default_accelerometerMovementThreshold = 2;
|
||||
public static final long default_speedMaximumTimeBetweenLocations = 4;
|
||||
public static final long default_timeBetweenNoiseLevelMeasurements = 60;
|
||||
public static final long default_lengthOfNoiseLevelMeasurements = 5;
|
||||
public static final long default_referenceValueForNoiseLevelMeasurements = 20;
|
||||
public static final boolean default_hasServiceBeenRunning = false;
|
||||
public static final boolean default_startServiceAfterAppUpdate = true;
|
||||
public static final boolean default_startNewThreadForRuleActivation = true;
|
||||
public static final boolean default_showIconWhenServiceIsRunning = true;
|
||||
public static final boolean default_httpAcceptAllCertificates = false;
|
||||
public static final int default_httpAttempts = 3;
|
||||
public static final int default_httpAttemptsTimeout = 60;
|
||||
public static final int default_httpAttemptGap = 2;
|
||||
public static final PointOfInterest default_lastActivePoi = null;
|
||||
public static final boolean default_rememberLastActivePoi = true;
|
||||
public static final int default_locationRingBufferSize=3;
|
||||
public static final long default_timeBetweenProcessMonitorings = 60;
|
||||
public static final long default_acceptDevicePositionSignalEveryX_MilliSeconds = 1000;
|
||||
public static final int default_activityDetectionFrequency = 60;
|
||||
public static final int default_activityDetectionRequiredProbability = 75;
|
||||
public static final boolean default_privacyLocationing = false;
|
||||
public static final int default_startScreen = 0;
|
||||
public static final int default_tabsPlacement = 0;
|
||||
public static final boolean default_executeRulesAndProfilesWithSingleClick = 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_lockSoundChanges = false;
|
||||
public static final long default_lastNewsPolltime = -1;
|
||||
public static final long default_lastUpdateCheck = -1;
|
||||
public static final long default_musicCheckFrequency = 2500;
|
||||
public static final String default_displayLanguage = "systemDefaultLanguage";
|
||||
|
||||
@Override
|
||||
public boolean contains(String arg0)
|
||||
@ -260,9 +274,16 @@ public class Settings implements SharedPreferences
|
||||
startScreen = Integer.parseInt(prefs.getString("startScreen", String.valueOf(default_startScreen)));
|
||||
tabsPlacement = Integer.parseInt(prefs.getString("tabsPlacement", String.valueOf(default_tabsPlacement)));
|
||||
|
||||
musicCheckFrequency = Long.parseLong(prefs.getString("musicCheckFrequency", String.valueOf(default_musicCheckFrequency)));
|
||||
displayLanguage = prefs.getString("displayLanguage", default_displayLanguage);
|
||||
|
||||
if(Settings.musicCheckFrequency == 0)
|
||||
Settings.musicCheckFrequency = Settings.default_musicCheckFrequency;
|
||||
|
||||
executeRulesAndProfilesWithSingleClick = prefs.getBoolean("executeRulesAndProfilesWithSingleClick", default_executeRulesAndProfilesWithSingleClick);
|
||||
automaticUpdateCheck = prefs.getBoolean("automaticUpdateCheck", default_automaticUpdateCheck);
|
||||
displayNewsOnMainScreen = prefs.getBoolean("displayNewsOnMainScreen", default_displayNewsOnMainScreen);
|
||||
showToasts = prefs.getBoolean("showToasts", default_showToasts);
|
||||
|
||||
lockSoundChanges = prefs.getBoolean("lockSoundChanges", default_lockSoundChanges);
|
||||
noticeAndroid9MicrophoneShown = prefs.getBoolean("noticeAndroid9MicrophoneShown", false);
|
||||
@ -326,154 +347,160 @@ public class Settings implements SharedPreferences
|
||||
|
||||
Editor editor = prefs.edit();
|
||||
|
||||
if(!prefs.contains("startServiceAtSystemBoot") | force)
|
||||
if(!prefs.contains("startServiceAtSystemBoot") || force)
|
||||
editor.putBoolean("startServiceAtSystemBoot", default_startServiceAtSystemBoot);
|
||||
|
||||
if(!prefs.contains("writeLogFile") | force)
|
||||
if(!prefs.contains("writeLogFile") || force)
|
||||
editor.putBoolean("writeLogFile", default_writeLogFile);
|
||||
|
||||
// if(!prefs.contains("useTextToSpeech") | force)
|
||||
// editor.putBoolean("useTextToSpeech", default_useTextToSpeech);
|
||||
|
||||
if(!prefs.contains("useTextToSpeechOnNormal") | force)
|
||||
if(!prefs.contains("useTextToSpeechOnNormal") || force)
|
||||
editor.putBoolean("useTextToSpeechOnNormal", default_useTextToSpeechOnNormal);
|
||||
|
||||
if(!prefs.contains("useTextToSpeechOnVibrate") | force)
|
||||
if(!prefs.contains("useTextToSpeechOnVibrate") || force)
|
||||
editor.putBoolean("useTextToSpeechOnVibrate", default_useTextToSpeechOnVibrate);
|
||||
|
||||
if(!prefs.contains("useTextToSpeechOnSilent") | force)
|
||||
if(!prefs.contains("useTextToSpeechOnSilent") || force)
|
||||
editor.putBoolean("useTextToSpeechOnSilent", default_useTextToSpeechOnSilent);
|
||||
|
||||
if(!prefs.contains("muteTextToSpeechDuringCalls") | force)
|
||||
if(!prefs.contains("muteTextToSpeechDuringCalls") || force)
|
||||
editor.putBoolean("muteTextToSpeechDuringCalls", default_muteTextToSpeechDuringCalls);
|
||||
|
||||
if(!prefs.contains("positioningEngine") | force)
|
||||
if(!prefs.contains("positioningEngine") || force)
|
||||
editor.putString("positioningEngine", String.valueOf(default_positioningEngine));
|
||||
|
||||
if(!prefs.contains("useWifiForPositioning") | force)
|
||||
if(!prefs.contains("useWifiForPositioning") || force)
|
||||
editor.putBoolean("useWifiForPositioning", default_useWifiForPositioning);
|
||||
|
||||
if(!prefs.contains("hasServiceBeenRunning") | force)
|
||||
if(!prefs.contains("hasServiceBeenRunning") || force)
|
||||
editor.putBoolean("hasServiceBeenRunning", default_hasServiceBeenRunning);
|
||||
|
||||
if(!prefs.contains("startServiceAfterAppUpdate") | force)
|
||||
if(!prefs.contains("startServiceAfterAppUpdate") || force)
|
||||
editor.putBoolean("startServiceAfterAppUpdate", default_startServiceAfterAppUpdate);
|
||||
|
||||
if(!prefs.contains("startNewThreadForRuleActivation") | force)
|
||||
if(!prefs.contains("startNewThreadForRuleActivation") || force)
|
||||
editor.putBoolean("startNewThreadForRuleActivation", default_startNewThreadForRuleActivation);
|
||||
|
||||
if(!prefs.contains("showIconWhenServiceIsRunning") | force)
|
||||
if(!prefs.contains("showIconWhenServiceIsRunning") || force)
|
||||
editor.putBoolean("showIconWhenServiceIsRunning", default_showIconWhenServiceIsRunning);
|
||||
|
||||
if(!prefs.contains("useAccelerometerForPositioning") | force)
|
||||
if(!prefs.contains("useAccelerometerForPositioning") || force)
|
||||
editor.putBoolean("useAccelerometerForPositioning", default_useAccelerometerForPositioning);
|
||||
|
||||
if(!prefs.contains("useAccelerometerAfterIdleTime") | force)
|
||||
if(!prefs.contains("useAccelerometerAfterIdleTime") || force)
|
||||
editor.putString("useAccelerometerAfterIdleTime", String.valueOf(default_useAccelerometerAfterIdleTime));
|
||||
|
||||
if(!prefs.contains("accelerometerMovementThreshold") | force)
|
||||
if(!prefs.contains("accelerometerMovementThreshold") || force)
|
||||
editor.putString("accelerometerMovementThreshold", String.valueOf(default_accelerometerMovementThreshold));
|
||||
|
||||
if(!prefs.contains("speedMaximumTimeBetweenLocations") | force)
|
||||
if(!prefs.contains("speedMaximumTimeBetweenLocations") || force)
|
||||
editor.putString("speedMaximumTimeBetweenLocations", String.valueOf(default_speedMaximumTimeBetweenLocations));
|
||||
|
||||
if(!prefs.contains("MINIMUM_DISTANCE_CHANGE_FOR_GPS_UPDATE") | force)
|
||||
if(!prefs.contains("MINIMUM_DISTANCE_CHANGE_FOR_GPS_UPDATE") || force)
|
||||
editor.putString("MINIMUM_DISTANCE_CHANGE_FOR_GPS_UPDATE", String.valueOf(default_minimumDistanceChangeForGpsUpdate));
|
||||
|
||||
if(!prefs.contains("MINIMUM_DISTANCE_CHANGE_FOR_NETWORK_UPDATE") | force)
|
||||
if(!prefs.contains("MINIMUM_DISTANCE_CHANGE_FOR_NETWORK_UPDATE") || force)
|
||||
editor.putString("MINIMUM_DISTANCE_CHANGE_FOR_NETWORK_UPDATE", String.valueOf(default_minimumDistanceChangeForNetworkUpdate));
|
||||
|
||||
if(!prefs.contains("SATISFACTORY_ACCURACY_GPS") | force)
|
||||
if(!prefs.contains("SATISFACTORY_ACCURACY_GPS") || force)
|
||||
editor.putString("SATISFACTORY_ACCURACY_GPS", String.valueOf(default_satisfactoryAccuracyGps));
|
||||
|
||||
if(!prefs.contains("SATISFACTORY_ACCURACY_NETWORK") | force)
|
||||
if(!prefs.contains("SATISFACTORY_ACCURACY_NETWORK") || force)
|
||||
editor.putString("SATISFACTORY_ACCURACY_NETWORK", String.valueOf(default_satisfactoryAccuracyNetwork));
|
||||
|
||||
if(!prefs.contains("gpsTimeout") | force)
|
||||
if(!prefs.contains("gpsTimeout") || force)
|
||||
editor.putString("gpsTimeout", String.valueOf(default_gpsTimeout));
|
||||
|
||||
if(!prefs.contains("MINIMUM_TIME_BETWEEN_UPDATE") | force)
|
||||
if(!prefs.contains("MINIMUM_TIME_BETWEEN_UPDATE") || force)
|
||||
editor.putString("MINIMUM_TIME_BETWEEN_UPDATE", String.valueOf(default_minimumTimeBetweenUpdate));
|
||||
|
||||
if(!prefs.contains("timeBetweenNoiseLevelMeasurements") | force)
|
||||
if(!prefs.contains("timeBetweenNoiseLevelMeasurements") || force)
|
||||
editor.putString("timeBetweenNoiseLevelMeasurements", String.valueOf(default_timeBetweenNoiseLevelMeasurements));
|
||||
|
||||
if(!prefs.contains("lengthOfNoiseLevelMeasurements") | force)
|
||||
if(!prefs.contains("lengthOfNoiseLevelMeasurements") || force)
|
||||
editor.putString("lengthOfNoiseLevelMeasurements", String.valueOf(default_lengthOfNoiseLevelMeasurements));
|
||||
|
||||
if(!prefs.contains("referenceValueForNoiseLevelMeasurements") | force)
|
||||
if(!prefs.contains("referenceValueForNoiseLevelMeasurements") || force)
|
||||
editor.putString("referenceValueForNoiseLevelMeasurements", String.valueOf(default_referenceValueForNoiseLevelMeasurements));
|
||||
|
||||
if(!prefs.contains("logLevel") | force)
|
||||
if(!prefs.contains("logLevel") || force)
|
||||
editor.putString("logLevel", String.valueOf(default_logLevel));
|
||||
|
||||
if(!prefs.contains("logFileMaxSize") | force)
|
||||
if(!prefs.contains("logFileMaxSize") || force)
|
||||
editor.putString("logFileMaxSize", String.valueOf(default_logFileMaxSize));
|
||||
|
||||
if(!prefs.contains("httpAcceptAllCertificates") | force)
|
||||
if(!prefs.contains("httpAcceptAllCertificates") || force)
|
||||
editor.putBoolean("httpAcceptAllCertificates", default_httpAcceptAllCertificates);
|
||||
|
||||
if(!prefs.contains("httpAttempts") | force)
|
||||
if(!prefs.contains("httpAttempts") || force)
|
||||
editor.putString("httpAttempts", String.valueOf(default_httpAttempts));
|
||||
|
||||
if(!prefs.contains("httpAttemptsTimeout") | force)
|
||||
if(!prefs.contains("httpAttemptsTimeout") || force)
|
||||
editor.putString("httpAttemptsTimeout", String.valueOf(default_httpAttemptsTimeout));
|
||||
|
||||
if(!prefs.contains("httpAttemptGap") | force)
|
||||
if(!prefs.contains("httpAttemptGap") || force)
|
||||
editor.putString("httpAttemptGap", String.valueOf(default_httpAttemptGap));
|
||||
|
||||
if(!prefs.contains("lastActivePoi") | force)
|
||||
if(!prefs.contains("lastActivePoi") || force)
|
||||
editor.putString("lastActivePoi", "null");
|
||||
|
||||
if(!prefs.contains("rememberLastActivePoi") | force)
|
||||
if(!prefs.contains("rememberLastActivePoi") || force)
|
||||
editor.putBoolean("rememberLastActivePoi", default_rememberLastActivePoi);
|
||||
|
||||
if(!prefs.contains("locationRingBufferSize") | force)
|
||||
if(!prefs.contains("locationRingBufferSize") || force)
|
||||
editor.putString("locationRingBufferSize", String.valueOf(default_locationRingBufferSize));
|
||||
|
||||
if(!prefs.contains("timeBetweenProcessMonitorings") | force)
|
||||
if(!prefs.contains("timeBetweenProcessMonitorings") || force)
|
||||
editor.putString("timeBetweenProcessMonitorings", String.valueOf(default_timeBetweenProcessMonitorings));
|
||||
|
||||
if(!prefs.contains("acceptDevicePositionSignalEveryX_MilliSeconds") | force)
|
||||
if(!prefs.contains("acceptDevicePositionSignalEveryX_MilliSeconds") || force)
|
||||
editor.putString("acceptDevicePositionSignalEveryX_MilliSeconds", String.valueOf(default_acceptDevicePositionSignalEveryX_MilliSeconds));
|
||||
|
||||
if(!prefs.contains("activityDetectionFrequency") | force)
|
||||
if(!prefs.contains("activityDetectionFrequency") || force)
|
||||
editor.putString("activityDetectionFrequency", String.valueOf(default_activityDetectionFrequency));
|
||||
|
||||
if(!prefs.contains("activityDetectionRequiredProbability") | force)
|
||||
if(!prefs.contains("activityDetectionRequiredProbability") || force)
|
||||
editor.putString("activityDetectionRequiredProbability", String.valueOf(default_activityDetectionRequiredProbability));
|
||||
|
||||
if(!prefs.contains("privacyLocationing") | force)
|
||||
if(!prefs.contains("privacyLocationing") || force)
|
||||
editor.putBoolean("privacyLocationing", default_privacyLocationing);
|
||||
|
||||
if(!prefs.contains("startScreen") | force)
|
||||
if(!prefs.contains("startScreen") || force)
|
||||
editor.putString("startScreen", String.valueOf(default_startScreen));
|
||||
|
||||
if(!prefs.contains("tabsPlacement") | force)
|
||||
if(!prefs.contains("tabsPlacement") || force)
|
||||
editor.putString("tabsPlacement", String.valueOf(default_tabsPlacement));
|
||||
|
||||
if(!prefs.contains("executeRulesAndProfilesWithSingleClick") | force)
|
||||
if(!prefs.contains("executeRulesAndProfilesWithSingleClick") || force)
|
||||
editor.putBoolean("executeRulesAndProfilesWithSingleClick", default_executeRulesAndProfilesWithSingleClick);
|
||||
|
||||
if(!prefs.contains("automaticUpdateCheck") | force)
|
||||
if(!prefs.contains("automaticUpdateCheck") || force)
|
||||
editor.putBoolean("automaticUpdateCheck", default_automaticUpdateCheck);
|
||||
|
||||
if(!prefs.contains("displayNewsOnMainScreen") | force)
|
||||
if(!prefs.contains("displayNewsOnMainScreen") || force)
|
||||
editor.putBoolean("displayNewsOnMainScreen", default_displayNewsOnMainScreen);
|
||||
|
||||
if(!prefs.contains("lockSoundChanges") | force)
|
||||
if(!prefs.contains("showToasts") || force)
|
||||
editor.putBoolean("showToasts", default_showToasts);
|
||||
|
||||
if(!prefs.contains("musicCheckFrequency") || force)
|
||||
editor.putLong("musicCheckFrequency", default_musicCheckFrequency);
|
||||
|
||||
if(!prefs.contains("displayLanguage") || force)
|
||||
editor.putString("displayLanguage", default_displayLanguage);
|
||||
|
||||
if(!prefs.contains("lockSoundChanges") || force)
|
||||
editor.putBoolean("lockSoundChanges", default_lockSoundChanges);
|
||||
|
||||
if(!prefs.contains("noticeAndroid9MicrophoneShown") | force)
|
||||
if(!prefs.contains("noticeAndroid9MicrophoneShown") || force)
|
||||
editor.putBoolean("noticeAndroid9MicrophoneShown", false);
|
||||
|
||||
if(!prefs.contains("lastNewsPolltime") | force)
|
||||
if(!prefs.contains("lastNewsPolltime") || force)
|
||||
editor.putLong("lastNewsPolltime", default_lastNewsPolltime);
|
||||
|
||||
if(!prefs.contains("lastUpdateCheck") | force)
|
||||
if(!prefs.contains("lastUpdateCheck") || force)
|
||||
editor.putLong("lastUpdateCheck", default_lastUpdateCheck);
|
||||
|
||||
if(!prefs.contains("whatHasBeenDone") | force)
|
||||
if(!prefs.contains("whatHasBeenDone") || force)
|
||||
editor.putString("whatHasBeenDone", "");
|
||||
|
||||
editor.commit();
|
||||
@ -541,6 +568,13 @@ public class Settings implements SharedPreferences
|
||||
editor.putBoolean("executeRulesAndProfilesWithSingleClick", executeRulesAndProfilesWithSingleClick);
|
||||
editor.putBoolean("automaticUpdateCheck", automaticUpdateCheck);
|
||||
editor.putBoolean("displayNewsOnMainScreen", displayNewsOnMainScreen);
|
||||
editor.putBoolean("showToasts", showToasts);
|
||||
|
||||
if(Settings.musicCheckFrequency == 0)
|
||||
Settings.musicCheckFrequency = Settings.default_musicCheckFrequency;
|
||||
editor.putString("musicCheckFrequency", String.valueOf(musicCheckFrequency));
|
||||
|
||||
editor.putString("displayLanguage", displayLanguage);
|
||||
|
||||
editor.putBoolean("lockSoundChanges", lockSoundChanges);
|
||||
editor.putBoolean("noticeAndroid9MicrophoneShown", noticeAndroid9MicrophoneShown);
|
||||
@ -588,5 +622,4 @@ public class Settings implements SharedPreferences
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -6,8 +6,8 @@ import java.util.ArrayList;
|
||||
public class TimeFrame
|
||||
{
|
||||
// Defines a timeframe
|
||||
protected Time triggerTimeStart;
|
||||
protected Time triggerTimeStop;
|
||||
protected TimeObject triggerTimeStart;
|
||||
protected TimeObject triggerTimeStop;
|
||||
protected long repetition;
|
||||
|
||||
protected final static String separator = "/";
|
||||
@ -34,20 +34,20 @@ public class TimeFrame
|
||||
}
|
||||
}
|
||||
|
||||
public Time getTriggerTimeStart()
|
||||
public TimeObject getTriggerTimeStart()
|
||||
{
|
||||
return triggerTimeStart;
|
||||
}
|
||||
public void setTriggerTimeStart(Time triggerTimeStart)
|
||||
public void setTriggerTimeStart(TimeObject triggerTimeStart)
|
||||
{
|
||||
this.triggerTimeStart = triggerTimeStart;
|
||||
}
|
||||
|
||||
public Time getTriggerTimeStop()
|
||||
public TimeObject getTriggerTimeStop()
|
||||
{
|
||||
return triggerTimeStop;
|
||||
}
|
||||
public void setTriggerTimeStop(Time triggerTimeStop)
|
||||
public void setTriggerTimeStop(TimeObject triggerTimeStop)
|
||||
{
|
||||
this.triggerTimeStop = triggerTimeStop;
|
||||
}
|
||||
@ -62,7 +62,7 @@ public class TimeFrame
|
||||
this.repetition = repetition;
|
||||
}
|
||||
|
||||
public TimeFrame (Time timeStart, Time timeEnd, ArrayList<Integer> dayList2, long repetition)
|
||||
public TimeFrame (TimeObject timeStart, TimeObject timeEnd, ArrayList<Integer> dayList2, long repetition)
|
||||
{
|
||||
this.setTriggerTimeStart(timeStart);
|
||||
this.setTriggerTimeStop(timeEnd);
|
||||
@ -73,13 +73,36 @@ public class TimeFrame
|
||||
public TimeFrame (String fileContent)
|
||||
{
|
||||
String[] dateArray = fileContent.split(separator); // example: timestart/timestop/days[int]/repetition
|
||||
this.setTriggerTimeStart(Time.valueOf(dateArray[0]));
|
||||
this.setTriggerTimeStop(Time.valueOf(dateArray[1]));
|
||||
this.setTriggerTimeStart(TimeObject.valueOf(dateArray[0]));
|
||||
this.setTriggerTimeStop(TimeObject.valueOf(dateArray[1]));
|
||||
this.setDayListFromString(dateArray[2]);
|
||||
if(dateArray.length > 3) // may not exist in old config files
|
||||
this.setRepetition(Long.parseLong(dateArray[3]));
|
||||
}
|
||||
|
||||
public String toTriggerParameter2String()
|
||||
{
|
||||
StringBuilder response = new StringBuilder();
|
||||
response.append(this.getTriggerTimeStart().getHours() + ":" + this.getTriggerTimeStart().getMinutes() + ":0");
|
||||
response.append(separator);
|
||||
response.append(this.getTriggerTimeStop().getHours() + ":" + this.getTriggerTimeStop().getMinutes() + ":0");
|
||||
response.append(separator);
|
||||
|
||||
StringBuilder days = new StringBuilder();
|
||||
|
||||
for(int day : dayList)
|
||||
days.append(String.valueOf(day));
|
||||
|
||||
response.append(days.toString());
|
||||
|
||||
if(this.repetition > 0)
|
||||
{
|
||||
response.append(separator + this.getRepetition());
|
||||
}
|
||||
|
||||
return response.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
78
app/src/main/java/com/jens/automation2/TimeObject.java
Normal file
78
app/src/main/java/com/jens/automation2/TimeObject.java
Normal file
@ -0,0 +1,78 @@
|
||||
package com.jens.automation2;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.sql.Time;
|
||||
|
||||
public class TimeObject
|
||||
{
|
||||
int hours, minutes, seconds;
|
||||
|
||||
public TimeObject()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int getHours()
|
||||
{
|
||||
return hours;
|
||||
}
|
||||
|
||||
public void setHours(int hours)
|
||||
{
|
||||
this.hours = hours;
|
||||
}
|
||||
|
||||
public int getMinutes()
|
||||
{
|
||||
return minutes;
|
||||
}
|
||||
|
||||
public void setMinutes(int minutes)
|
||||
{
|
||||
this.minutes = minutes;
|
||||
}
|
||||
|
||||
public int getSeconds()
|
||||
{
|
||||
return seconds;
|
||||
}
|
||||
|
||||
public void setSeconds(int seconds)
|
||||
{
|
||||
this.seconds = seconds;
|
||||
}
|
||||
|
||||
public TimeObject(int hours, int minutes, int seconds)
|
||||
{
|
||||
this.hours = hours;
|
||||
this.minutes = minutes;
|
||||
this.seconds = seconds;
|
||||
}
|
||||
|
||||
public static TimeObject valueOf(String input)
|
||||
{
|
||||
TimeObject ro = null;
|
||||
|
||||
if(input.contains(":"))
|
||||
{
|
||||
String[] parts = input.split(":");
|
||||
if(parts.length == 2)
|
||||
ro = new TimeObject(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), 0);
|
||||
else if(parts.length == 3)
|
||||
ro = new TimeObject(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), Integer.parseInt(parts[2]));
|
||||
else
|
||||
Miscellaneous.logEvent("w", "TimeObject", "Invalid length for time. Input: " + input, 4);
|
||||
}
|
||||
|
||||
return ro;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
Time time = Time.valueOf(this.getHours() + ":" + this.getMinutes() + ":" + this.getSeconds());
|
||||
return time.toString();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -160,9 +160,9 @@ public class XmlFileInterface
|
||||
serializer.text(String.valueOf(Profile.getProfileCollection().get(i).getChangeIncomingCallsRingtone()));
|
||||
serializer.endTag(null, "changeIncomingCallsRingtone");//
|
||||
serializer.startTag(null, "incomingCallsRingtone");
|
||||
File incomingFile = Profile.getProfileCollection().get(i).getIncomingCallsRingtone();
|
||||
String incomingFile = Profile.getProfileCollection().get(i).getIncomingCallsRingtone();
|
||||
if(incomingFile != null)
|
||||
serializer.text(String.valueOf(Profile.getProfileCollection().get(i).getIncomingCallsRingtone().getPath()));
|
||||
serializer.text(String.valueOf(Profile.getProfileCollection().get(i).getIncomingCallsRingtone()));
|
||||
else
|
||||
serializer.text("null");
|
||||
serializer.endTag(null, "incomingCallsRingtone");
|
||||
@ -178,9 +178,9 @@ public class XmlFileInterface
|
||||
serializer.text(String.valueOf(Profile.getProfileCollection().get(i).getChangeNotificationRingtone()));
|
||||
serializer.endTag(null, "changeNotificationRingtone");//
|
||||
serializer.startTag(null, "notificationRingtone");
|
||||
File notificationFile = Profile.getProfileCollection().get(i).getNotificationRingtone();
|
||||
String notificationFile = Profile.getProfileCollection().get(i).getNotificationRingtone();
|
||||
if(notificationFile != null)
|
||||
serializer.text(String.valueOf(Profile.getProfileCollection().get(i).getNotificationRingtone().getPath()));
|
||||
serializer.text(String.valueOf(Profile.getProfileCollection().get(i).getNotificationRingtone()));
|
||||
else
|
||||
serializer.text("null");
|
||||
serializer.endTag(null, "notificationRingtone");
|
||||
@ -254,8 +254,6 @@ public class XmlFileInterface
|
||||
else
|
||||
serializer.text("null");
|
||||
}
|
||||
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.timeFrame)
|
||||
serializer.text(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTimeFrame().toString());
|
||||
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.speed)
|
||||
serializer.text(String.valueOf(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getSpeed()));
|
||||
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.noiseLevel)
|
||||
@ -263,11 +261,9 @@ public class XmlFileInterface
|
||||
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.wifiConnection)
|
||||
serializer.text(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerParameter2());
|
||||
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.process_started_stopped)
|
||||
serializer.text(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getProcessName());
|
||||
serializer.text(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerParameter2());
|
||||
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.batteryLevel)
|
||||
serializer.text(String.valueOf(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getBatteryLevel()));
|
||||
// else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.phoneCall)
|
||||
// serializer.text(String.valueOf(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getPhoneDirection()) + "," + String.valueOf(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getPhoneNumber()));
|
||||
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.nfcTag)
|
||||
serializer.text(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getNfcTagId());
|
||||
else if(Rule.getRuleCollection().get(i).getTriggerSet().get(j).getTriggerType() == Trigger_Enum.activityDetection)
|
||||
@ -635,7 +631,7 @@ public class XmlFileInterface
|
||||
{
|
||||
String path = readTag(parser, "incomingCallsRingtone");
|
||||
if(!path.equals("null"))
|
||||
newProfile.setIncomingCallsRingtone(new File(path));
|
||||
newProfile.setIncomingCallsRingtone(path);
|
||||
else
|
||||
newProfile.setIncomingCallsRingtone(null);
|
||||
}
|
||||
@ -647,7 +643,7 @@ public class XmlFileInterface
|
||||
{
|
||||
String path = readTag(parser, "notificationRingtone");
|
||||
if(!path.equals("null"))
|
||||
newProfile.setNotificationRingtone(new File(path));
|
||||
newProfile.setNotificationRingtone(path);
|
||||
else
|
||||
newProfile.setNotificationRingtone(null);
|
||||
}
|
||||
@ -840,7 +836,6 @@ public class XmlFileInterface
|
||||
|
||||
private static Trigger readTrigger(XmlPullParser parser) throws IOException, XmlPullParserException
|
||||
{
|
||||
|
||||
/* FILE EXAMPE:
|
||||
* *****************
|
||||
* <Automation>
|
||||
@ -943,8 +938,16 @@ public class XmlFileInterface
|
||||
}
|
||||
else if(newTrigger.getTriggerType() == Trigger_Enum.process_started_stopped)
|
||||
{
|
||||
newTrigger.setProcessName(triggerParameter2);
|
||||
newTrigger.setTriggerParameter2(triggerParameter2);
|
||||
|
||||
if(triggerParameter2.contains(triggerParameter2Split))
|
||||
{
|
||||
String[] parts = triggerParameter2.split(triggerParameter2Split);
|
||||
newTrigger.setProcessName(parts[1]);
|
||||
}
|
||||
else
|
||||
newTrigger.setProcessName(triggerParameter2);
|
||||
|
||||
}
|
||||
else if(newTrigger.getTriggerType() == Trigger_Enum.phoneCall)
|
||||
{
|
||||
@ -1154,12 +1157,17 @@ public class XmlFileInterface
|
||||
newAction.setAction(Action_Enum.disableScreenRotation);
|
||||
else if(actionNameString.equals("disableScreenRotation"))
|
||||
newAction.setAction(Action_Enum.disableScreenRotation);
|
||||
else if(actionNameString.equals("playMusic"))
|
||||
{
|
||||
newAction.setAction(Action_Enum.controlMediaPlayback);
|
||||
newAction.setParameter2("1");
|
||||
}
|
||||
else if(actionNameString.equals("wakeupDevice"))
|
||||
{
|
||||
newAction.setAction(Action_Enum.turnScreenOnOrOff);
|
||||
newAction.setParameter1(true);
|
||||
}
|
||||
// *** deprecated
|
||||
// *** :deprecated
|
||||
|
||||
else
|
||||
newAction.setAction(Action_Enum.valueOf(actionNameString));
|
||||
@ -1273,14 +1281,14 @@ public class XmlFileInterface
|
||||
{
|
||||
String newTag;
|
||||
|
||||
if(tag.contains(Action.intentPairSeperator)) // already has new format
|
||||
if(tag.contains(Action.intentPairSeparator)) // already has new format
|
||||
newTag = tag;
|
||||
else
|
||||
newTag = tag.replace("/", Action.intentPairSeperator);
|
||||
newTag = tag.replace("/", Action.intentPairSeparator);
|
||||
|
||||
String[] newTagPieces = newTag.split(";");
|
||||
|
||||
if(newTagPieces.length < 2 || (!newTagPieces[0].contains(Actions.dummyPackageString) && newTagPieces[1].contains(Action.intentPairSeperator)))
|
||||
if(newTagPieces.length < 2 || (!newTagPieces[0].contains(Actions.dummyPackageString) && newTagPieces[1].contains(Action.intentPairSeparator)))
|
||||
{
|
||||
newTag = Actions.dummyPackageString + ";" + newTag;
|
||||
newTagPieces = newTag.split(";");
|
||||
@ -1290,7 +1298,7 @@ public class XmlFileInterface
|
||||
newTag += ";" + ActivityManageActionStartActivity.startByActivityString;
|
||||
else if(newTagPieces.length >= 3)
|
||||
{
|
||||
if(newTagPieces[2].contains(Action.intentPairSeperator))
|
||||
if(newTagPieces[2].contains(Action.intentPairSeparator))
|
||||
newTag = newTagPieces[0] + ";" + newTagPieces[1] + ";" + ActivityManageActionStartActivity.startByActivityString + ";" + newTagPieces[2];
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import android.location.LocationManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.jens.automation2.ActivityMainScreen;
|
||||
@ -162,7 +161,7 @@ public class LocationProvider
|
||||
(
|
||||
(locationList.get(i).getProvider().equals(LocationManager.GPS_PROVIDER) && locationList.get(i).getAccuracy() > Settings.satisfactoryAccuracyGps)
|
||||
||
|
||||
(locationList.get(i).getProvider().equals(LocationManager.NETWORK_PROVIDER) && locationList.get(i).getAccuracy() > Settings.satisfactoryAccuracyNetwork)
|
||||
(locationList.get(i).getProvider().equals(LocationManager.NETWORK_PROVIDER) && locationList.get(i).getAccuracy() > Settings.satisfactoryAccuracyNetwork)
|
||||
)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Speed", "Not using 2 most recent locations for speed calculation because at least one does not have a satisfactory accuracy: " + locationList.get(i).toString(), 4);
|
||||
@ -189,7 +188,7 @@ public class LocationProvider
|
||||
/*
|
||||
Due to strange factors the time difference might be 0 resulting in mathematical error.
|
||||
*/
|
||||
if (Double.isInfinite(currentSpeed) | Double.isNaN(currentSpeed))
|
||||
if (Double.isInfinite(currentSpeed) || Double.isNaN(currentSpeed))
|
||||
Miscellaneous.logEvent("i", "Speed", "Error while calculating speed.", 4);
|
||||
else
|
||||
{
|
||||
@ -232,12 +231,6 @@ public class LocationProvider
|
||||
|
||||
public void startLocationService()
|
||||
{
|
||||
// if(Settings.useAccelerometerForPositioning && !Miscellaneous.isAndroidEmulator())
|
||||
// {
|
||||
// accelerometerHandler = new AccelerometerHandler();
|
||||
// mySensorActivity = new SensorActivity(this);
|
||||
// }
|
||||
|
||||
// startPhoneStateListener
|
||||
PhoneStatusListener.startPhoneStatusListener(parentService); // also used to mute anouncements during calls
|
||||
|
||||
@ -246,10 +239,8 @@ public class LocationProvider
|
||||
|
||||
if(Settings.positioningEngine == 0)
|
||||
{
|
||||
if(Rule.isAnyRuleUsing(Trigger_Enum.pointOfInterest) | Rule.isAnyRuleUsing(Trigger_Enum.speed))
|
||||
if(Rule.isAnyRuleUsing(Trigger_Enum.pointOfInterest) || Rule.isAnyRuleUsing(Trigger_Enum.speed))
|
||||
{
|
||||
// TelephonyManager telephonyManager = (TelephonyManager) AutomationService.getInstance().getSystemService(Context.TELEPHONY_SERVICE);
|
||||
|
||||
// startCellLocationChangedReceiver
|
||||
if (CellLocationChangedReceiver.isCellLocationChangedReceiverPossible())
|
||||
{
|
||||
@ -432,7 +423,7 @@ public class LocationProvider
|
||||
}
|
||||
|
||||
// *********** RULE CHANGES ***********
|
||||
if(!CellLocationChangedReceiver.isCellLocationListenerActive() && (Rule.isAnyRuleUsing(Trigger_Enum.pointOfInterest) | Rule.isAnyRuleUsing(Trigger_Enum.speed)))
|
||||
if(!CellLocationChangedReceiver.isCellLocationListenerActive() && (Rule.isAnyRuleUsing(Trigger_Enum.pointOfInterest) || Rule.isAnyRuleUsing(Trigger_Enum.speed)))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "LocationProvider", "Starting NoiseListener CellLocationChangedReceiver because used in a new/changed rule.", 4);
|
||||
if(CellLocationChangedReceiver.haveAllPermission())
|
||||
@ -493,7 +484,6 @@ public class LocationProvider
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void resetSpeedTimer(Calendar timeOfForcedLocationCheck)
|
||||
{
|
||||
if(speedTimerActive)
|
||||
@ -514,7 +504,6 @@ public class LocationProvider
|
||||
Message msg = new Message();
|
||||
msg.what = 1;
|
||||
speedHandler.sendMessageAtTime(msg, timeOfForcedLocationCheck.getTimeInMillis());
|
||||
// speedHandler.sendMessageDelayed(msg, delayTime);
|
||||
speedTimerActive = true;
|
||||
}
|
||||
else
|
||||
@ -531,7 +520,7 @@ public class LocationProvider
|
||||
if(msg.what == 1)
|
||||
{
|
||||
// time is up, no cell location updates since x minutes, start accelerometer
|
||||
String text = "Timer triggered. Based on the last location and speed we may be at a POI. Forcing location update in case CellLocationChangedReceiver didn\'t fire.";
|
||||
Miscellaneous.logEvent("i", "LocationProvider", "Timer triggered. Based on the last location and speed we may be at a POI. Forcing location update in case CellLocationChangedReceiver didn\'t fire.", 5);
|
||||
|
||||
Location currentLocation = CellLocationChangedReceiver.getInstance().getLocation("coarse");
|
||||
AutomationService.getInstance().getLocationProvider().setCurrentLocation(currentLocation, false);
|
||||
|
@ -26,7 +26,7 @@ public class WifiBroadcastReceiver extends BroadcastReceiver
|
||||
public static Boolean wasConnected = false;
|
||||
protected static String lastWifiSsid = "";
|
||||
public static boolean lastConnectedState = false;
|
||||
protected static boolean mayCellLocationChangedReceiverBeActivatedFromWifiPointOfWifi = true;
|
||||
protected static boolean mayCellLocationChangedReceiverBeActivatedFromWifiPointOfView = true;
|
||||
protected static WifiBroadcastReceiver wifiBrInstance;
|
||||
protected static IntentFilter wifiListenerIntentFilter;
|
||||
protected static boolean wifiListenerActive=false;
|
||||
@ -40,8 +40,9 @@ public class WifiBroadcastReceiver extends BroadcastReceiver
|
||||
{
|
||||
if(newWifiSsid.startsWith("\"") && newWifiSsid.endsWith("\""))
|
||||
newWifiSsid = newWifiSsid.substring(1, newWifiSsid.length()-1);
|
||||
|
||||
WifiBroadcastReceiver.lastWifiSsid = newWifiSsid;
|
||||
|
||||
if(newWifiSsid.length() > 0)
|
||||
WifiBroadcastReceiver.lastWifiSsid = newWifiSsid;
|
||||
}
|
||||
|
||||
public static boolean isWifiListenerActive()
|
||||
@ -51,7 +52,7 @@ public class WifiBroadcastReceiver extends BroadcastReceiver
|
||||
|
||||
public static boolean mayCellLocationReceiverBeActivated()
|
||||
{
|
||||
return mayCellLocationChangedReceiverBeActivatedFromWifiPointOfWifi;
|
||||
return mayCellLocationChangedReceiverBeActivatedFromWifiPointOfView;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,18 +63,12 @@ public class WifiBroadcastReceiver extends BroadcastReceiver
|
||||
// int state = -1;
|
||||
NetworkInfo myWifi = null;
|
||||
|
||||
// if(intent.getAction().equals(WifiManager.RSSI_CHANGED_ACTION)) //gefeuert bei Verbindung
|
||||
// {
|
||||
// Miscellaneous.logEvent("i", "WifiReceiver", "RSSI_CHANGED_ACTION: " + String.valueOf(intent.getIntExtra(WifiManager.RSSI_CHANGED_ACTION, -1)));
|
||||
// }
|
||||
// else
|
||||
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);
|
||||
// Miscellaneous.logEvent("i", "WifiReceiver", "NETWORK_STATE_CHANGED_ACTION: " + String.valueOf(state));
|
||||
myWifi = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
|
||||
}
|
||||
|
||||
|
||||
WifiManager myWifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
|
||||
// ConnectivityManager connManager = (ConnectivityManager)context.getSystemService(context.CONNECTIVITY_SERVICE);
|
||||
@ -94,8 +89,14 @@ public class WifiBroadcastReceiver extends BroadcastReceiver
|
||||
if(Settings.useWifiForPositioning && PointOfInterest.reachedPoiWithActivateWifiRule()) // Poi has wifi
|
||||
{
|
||||
Miscellaneous.logEvent("i", "WifiReceiver", context.getResources().getString(R.string.poiHasWifiStoppingCellLocationListener), 2);
|
||||
mayCellLocationChangedReceiverBeActivatedFromWifiPointOfWifi = false;
|
||||
mayCellLocationChangedReceiverBeActivatedFromWifiPointOfView = false;
|
||||
CellLocationChangedReceiver.stopCellLocationChangedReceiver();
|
||||
|
||||
/*
|
||||
TODO: Every time the screen is turned on, we receiver a "wifi has been connected"-event.
|
||||
This is technically wrong and not really any changed to when the screen was off. It has
|
||||
to be filtered.
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -109,7 +110,7 @@ public class WifiBroadcastReceiver extends BroadcastReceiver
|
||||
{
|
||||
wasConnected = true;
|
||||
Miscellaneous.logEvent("i", "WifiReceiver", "WifiReceiver just activated. Wifi already connected. Stopping CellLocationReceiver", 3);
|
||||
mayCellLocationChangedReceiverBeActivatedFromWifiPointOfWifi = false;
|
||||
mayCellLocationChangedReceiverBeActivatedFromWifiPointOfView = false;
|
||||
CellLocationChangedReceiver.stopCellLocationChangedReceiver();
|
||||
SensorActivity.stopAccelerometerTimer();
|
||||
String ssid = myWifiManager.getConnectionInfo().getSSID();
|
||||
@ -125,7 +126,7 @@ public class WifiBroadcastReceiver extends BroadcastReceiver
|
||||
{
|
||||
wasConnected = false;
|
||||
Miscellaneous.logEvent("i", "WifiReceiver", String.format(context.getResources().getString(R.string.disconnectedFromWifi), getLastWifiSsid()) + " Switching to CellLocationChangedReceiver.", 3);
|
||||
mayCellLocationChangedReceiverBeActivatedFromWifiPointOfWifi = true;
|
||||
mayCellLocationChangedReceiverBeActivatedFromWifiPointOfView = true;
|
||||
CellLocationChangedReceiver.startCellLocationChangedReceiver();
|
||||
lastConnectedState = false;
|
||||
findRules(AutomationService.getInstance());
|
||||
|
@ -19,14 +19,13 @@ import java.util.ArrayList;
|
||||
|
||||
public class BatteryReceiver extends BroadcastReceiver implements AutomationListenerInterface
|
||||
{
|
||||
private static int batteryLevel = -1; // initialize with a better value than this
|
||||
public static AutomationService automationServiceRef = null;
|
||||
private static boolean usbHostConnected = false;
|
||||
|
||||
private static boolean batteryReceiverActive = false;
|
||||
private static IntentFilter batteryIntentFilter = null;
|
||||
private static Intent batteryStatus = null;
|
||||
private static BroadcastReceiver batteryInfoReceiverInstance = null;
|
||||
static int batteryLevel = -1; // initialize with a better value than this
|
||||
static boolean usbHostConnected = false;
|
||||
static boolean batteryReceiverActive = false;
|
||||
static IntentFilter batteryIntentFilter = null;
|
||||
static Intent batteryStatus = null;
|
||||
static BroadcastReceiver batteryInfoReceiverInstance = null;
|
||||
|
||||
public static void startBatteryReceiver(final AutomationService automationServiceRef)
|
||||
{
|
||||
@ -90,7 +89,7 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
||||
@Override
|
||||
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)
|
||||
return;
|
||||
@ -99,54 +98,49 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
||||
|
||||
if(intent.getAction().equals(Intent.ACTION_BATTERY_LOW))
|
||||
{
|
||||
Log.i("Battery", "Low battery event");
|
||||
Miscellaneous.logEvent("i", "Battery", "Low battery event", 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
// Miscellaneous.logEvent("i", "BatteryReceiver", "Received battery event.");
|
||||
// if(intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED))
|
||||
// {
|
||||
batteryLevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
|
||||
// int scale = -1;
|
||||
// int voltage = -1;
|
||||
// int temp = -1;
|
||||
// scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
|
||||
// temp = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, -1);
|
||||
// voltage = intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, -1);
|
||||
Log.i("Battery", "Level: " + String.valueOf(batteryLevel));
|
||||
this.actionBatteryLevel(context);
|
||||
|
||||
int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
|
||||
int statusPlugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
|
||||
// Miscellaneous.logEvent("i", "BatteryReceiver", "Status: " + String.valueOf(statusPlugged));
|
||||
|
||||
switch(statusPlugged)
|
||||
{
|
||||
case BatteryManager.BATTERY_PLUGGED_AC:
|
||||
// Toast.makeText(context, "Regular charging", Toast.LENGTH_LONG).show();
|
||||
// Miscellaneous.logEvent("i", "BatteryReceiver", "Regular charging.");
|
||||
this.actionCharging(context);
|
||||
break;
|
||||
case BatteryManager.BATTERY_PLUGGED_USB:
|
||||
this.actionUsbConnected(context);
|
||||
break;
|
||||
}
|
||||
|
||||
switch(status)
|
||||
{
|
||||
// case BatteryManager.BATTERY_STATUS_CHARGING:
|
||||
// break;
|
||||
case BatteryManager.BATTERY_STATUS_FULL:
|
||||
// Toast.makeText(context, "Regular charging full", Toast.LENGTH_LONG).show();
|
||||
// Miscellaneous.logEvent("i", "BatteryReceiver", "Device has been fully charged.");
|
||||
this.actionCharging(context);
|
||||
break;
|
||||
case BatteryManager.BATTERY_STATUS_DISCHARGING:
|
||||
this.actionDischarging(context);
|
||||
break;
|
||||
}
|
||||
batteryLevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
|
||||
// int scale = -1;
|
||||
// int voltage = -1;
|
||||
// int temp = -1;
|
||||
// scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
|
||||
// temp = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, -1);
|
||||
// voltage = intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, -1);
|
||||
Log.i("Battery", "Level: " + String.valueOf(batteryLevel));
|
||||
this.actionBatteryLevel(context);
|
||||
|
||||
int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
|
||||
int statusPlugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
|
||||
Miscellaneous.logEvent("i", "BatteryReceiver", "Status: " + String.valueOf(statusPlugged), 5);
|
||||
|
||||
switch(statusPlugged)
|
||||
{
|
||||
case BatteryManager.BATTERY_PLUGGED_AC:
|
||||
// Toast.makeText(context, "Regular charging", Toast.LENGTH_LONG).show();
|
||||
Miscellaneous.logEvent("i", "BatteryReceiver", "Regular charging.", 5);
|
||||
this.actionCharging(context);
|
||||
break;
|
||||
case BatteryManager.BATTERY_PLUGGED_USB:
|
||||
this.actionUsbConnected(context);
|
||||
break;
|
||||
}
|
||||
|
||||
switch(status)
|
||||
{
|
||||
case BatteryManager.BATTERY_STATUS_CHARGING:
|
||||
case BatteryManager.BATTERY_STATUS_FULL:
|
||||
Miscellaneous.logEvent("i", "BatteryReceiver", "Device has been fully charged.", 5);
|
||||
this.actionCharging(context);
|
||||
break;
|
||||
case BatteryManager.BATTERY_STATUS_DISCHARGING:
|
||||
this.actionDischarging(context);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
@ -264,11 +258,13 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startListener(AutomationService automationService)
|
||||
{
|
||||
BatteryReceiver.startBatteryReceiver(automationService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopListener(AutomationService automationService)
|
||||
{
|
||||
@ -292,4 +288,4 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
||||
// actually monitores several
|
||||
return new Trigger_Enum[] { Trigger_Enum.batteryLevel, Trigger_Enum.charging, Trigger_Enum.usb_host_connection };
|
||||
}
|
||||
}
|
||||
}
|
@ -300,4 +300,16 @@ public class BluetoothReceiver extends BroadcastReceiver implements AutomationLi
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,168 @@
|
||||
package com.jens.automation2.receivers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.jens.automation2.ActivityPermissions;
|
||||
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.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
public class BroadcastListener extends android.content.BroadcastReceiver implements AutomationListenerInterface
|
||||
{
|
||||
ArrayList<EventOccurrence> broadcastsCollection = new ArrayList<>();
|
||||
public static AutomationService automationServiceRef = null;
|
||||
private static boolean broadcastReceiverActive = false;
|
||||
private static BroadcastListener broadcastReceiverInstance = null;
|
||||
private static IntentFilter broadcastIntentFilter = null;
|
||||
private static Intent broadcastStatus = null;
|
||||
|
||||
public static BroadcastListener getInstance()
|
||||
{
|
||||
if(broadcastReceiverInstance == null)
|
||||
broadcastReceiverInstance = new BroadcastListener();
|
||||
|
||||
return broadcastReceiverInstance;
|
||||
}
|
||||
|
||||
public static class EventOccurrence
|
||||
{
|
||||
Calendar time;
|
||||
String event;
|
||||
|
||||
public EventOccurrence(Calendar time, String event)
|
||||
{
|
||||
this.time = time;
|
||||
this.event = event;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
broadcastsCollection.add(new EventOccurrence(Calendar.getInstance(), intent.getAction()));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.broadcastReceived);
|
||||
for(int i=0; i<ruleCandidates.size(); i++)
|
||||
{
|
||||
if(ruleCandidates.get(i).getsGreenLight(context))
|
||||
ruleCandidates.get(i).activate(automationServiceRef, false);
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<EventOccurrence> getBroadcastsCollection()
|
||||
{
|
||||
return broadcastsCollection;
|
||||
}
|
||||
|
||||
public boolean hasBroadcastOccurred(String event)
|
||||
{
|
||||
for(EventOccurrence eo : broadcastsCollection)
|
||||
{
|
||||
if(eo.event.equalsIgnoreCase(event))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasBroadcastOccurredSince(String event, Calendar timeLimit)
|
||||
{
|
||||
for(EventOccurrence eo : broadcastsCollection)
|
||||
{
|
||||
if(eo.event.equalsIgnoreCase(event) && (timeLimit == null || eo.time.getTimeInMillis() > timeLimit.getTimeInMillis()))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startListener(AutomationService automationService)
|
||||
{
|
||||
if(!broadcastReceiverActive)
|
||||
{
|
||||
BroadcastListener.automationServiceRef = automationService;
|
||||
|
||||
if(broadcastReceiverInstance == null)
|
||||
broadcastReceiverInstance = new BroadcastListener();
|
||||
|
||||
if(broadcastIntentFilter == null)
|
||||
{
|
||||
broadcastIntentFilter = new IntentFilter();
|
||||
|
||||
List<String> actionList = new ArrayList<>();
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.broadcastReceived);
|
||||
for(int i=0; i<ruleCandidates.size(); i++)
|
||||
{
|
||||
for(Trigger t : ruleCandidates.get(i).getTriggerSet())
|
||||
{
|
||||
if(t.getTriggerType().equals(Trigger.Trigger_Enum.broadcastReceived))
|
||||
{
|
||||
ActivityPermissions.addToArrayListUnique(t.getTriggerParameter2(), actionList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(String s : actionList)
|
||||
broadcastIntentFilter.addAction(s);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
broadcastStatus = automationServiceRef.registerReceiver(broadcastReceiverInstance, broadcastIntentFilter);
|
||||
broadcastReceiverActive = true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
/*
|
||||
We might be confronted with permission issues here.
|
||||
*/
|
||||
Miscellaneous.logEvent("e", "BroadcastListener", Log.getStackTraceString(e), 1);
|
||||
broadcastReceiverActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopListener(AutomationService automationService)
|
||||
{
|
||||
if(broadcastReceiverActive)
|
||||
{
|
||||
if(broadcastReceiverInstance != null)
|
||||
{
|
||||
automationServiceRef.unregisterReceiver(broadcastReceiverInstance);
|
||||
broadcastReceiverInstance = null;
|
||||
}
|
||||
|
||||
broadcastReceiverActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isListenerRunning()
|
||||
{
|
||||
return broadcastReceiverActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Trigger.Trigger_Enum[] getMonitoredTrigger()
|
||||
{
|
||||
return new Trigger.Trigger_Enum[] { Trigger.Trigger_Enum.broadcastReceived };
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ import com.jens.automation2.AutomationService;
|
||||
import com.jens.automation2.Miscellaneous;
|
||||
import com.jens.automation2.Rule;
|
||||
import com.jens.automation2.TimeFrame;
|
||||
import com.jens.automation2.TimeObject;
|
||||
import com.jens.automation2.Trigger;
|
||||
import com.jens.automation2.Trigger.Trigger_Enum;
|
||||
|
||||
@ -27,12 +28,10 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
|
||||
{
|
||||
private static AutomationService automationServiceRef;
|
||||
private static AlarmManager centralAlarmManagerInstance;
|
||||
// private static Intent alarmIntent;
|
||||
// private static PendingIntent alarmPendingIntent;
|
||||
private static boolean alarmListenerActive=false;
|
||||
private static ArrayList<ScheduleElement> alarmCandidates = new ArrayList<>();
|
||||
|
||||
private static ArrayList<Integer> requestCodeList = new ArrayList<Integer>();
|
||||
static PendingIntent alarmPendingIntent = null;
|
||||
|
||||
public static void startAlarmListener(final AutomationService automationServiceRef)
|
||||
{
|
||||
@ -52,13 +51,9 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "AlarmListener", "Alarm received", 2);
|
||||
Date now = new Date();
|
||||
String timeString = String.valueOf(now.getHours()) + ":" + String.valueOf(now.getMinutes()) + ":" + String.valueOf(now.getSeconds());
|
||||
Time passTime = Time.valueOf(timeString);
|
||||
|
||||
ArrayList<Rule> allRulesWithNowInTimeFrame = Rule.findRuleCandidates(Trigger_Enum.timeFrame);
|
||||
// ArrayList<Rule> allRulesWithNowInTimeFrame = Rule.findRuleCandidatesByTime(passTime);
|
||||
for(int i=0; i<allRulesWithNowInTimeFrame.size(); i++)
|
||||
for(int i=0; i < allRulesWithNowInTimeFrame.size(); i++)
|
||||
{
|
||||
if(allRulesWithNowInTimeFrame.get(i).getsGreenLight(context))
|
||||
allRulesWithNowInTimeFrame.get(i).activate(automationServiceRef, false);
|
||||
@ -77,23 +72,7 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
|
||||
|
||||
clearAlarms();
|
||||
|
||||
int i=0;
|
||||
|
||||
// // get a Calendar object with current time
|
||||
// Calendar cal = Calendar.getInstance();
|
||||
// // add 5 minutes to the calendar object
|
||||
// cal.add(Calendar.SECOND, 10);
|
||||
// String calSetWorkingCopyString2 = null;
|
||||
// SimpleDateFormat sdf2 = new SimpleDateFormat("E dd.MM.yyyy HH:mm");
|
||||
// if (cal != null)
|
||||
// {
|
||||
// calSetWorkingCopyString2 = sdf2.format(cal.getTime());
|
||||
// }
|
||||
// Miscellaneous.logEvent("i", "AlarmManager", "Setting repeating alarm because of hardcoded test: beginning at " + calSetWorkingCopyString2);
|
||||
// Intent alarmIntent2 = new Intent(automationServiceRef, AlarmListener.class);
|
||||
// PendingIntent alarmPendingIntent2 = PendingIntent.getBroadcast(automationServiceRef, 0, alarmIntent2, 0);
|
||||
// centralAlarmManagerInstance.setInexactRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 5000, alarmPendingIntent2);
|
||||
// requestCodeList.add(0);
|
||||
int i=0;
|
||||
|
||||
ArrayList<Rule> allRulesWithTimeFrames = new ArrayList<Rule>();
|
||||
allRulesWithTimeFrames = Rule.findRuleCandidates(Trigger_Enum.timeFrame);
|
||||
@ -118,7 +97,7 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
|
||||
TimeFrame tf = new TimeFrame(oneTrigger.getTriggerParameter2());
|
||||
|
||||
Calendar calSet;
|
||||
Time setTime;
|
||||
TimeObject setTime;
|
||||
|
||||
if(oneTrigger.getTriggerParameter())
|
||||
setTime = tf.getTriggerTimeStart();
|
||||
@ -161,7 +140,7 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
|
||||
}
|
||||
|
||||
i++;
|
||||
i=(int)System.currentTimeMillis();
|
||||
i = (int)System.currentTimeMillis();
|
||||
sdf.format(calSetWorkingCopy.getTime());
|
||||
String.valueOf(i);
|
||||
|
||||
@ -264,11 +243,10 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
|
||||
}
|
||||
|
||||
Intent alarmIntent = new Intent(automationServiceRef, DateTimeListener.class);
|
||||
PendingIntent alarmPendingIntent = PendingIntent.getBroadcast(automationServiceRef, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
alarmPendingIntent = PendingIntent.getBroadcast(automationServiceRef, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
centralAlarmManagerInstance.set(AlarmManager.RTC_WAKEUP, scheduleCandidate.time.getTimeInMillis(), alarmPendingIntent);
|
||||
|
||||
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("E dd.MM.yyyy HH:mm");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("E dd.MM.yyyy HH:mm:ss");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(scheduleCandidate.time.getTimeInMillis());
|
||||
Miscellaneous.logEvent("i", "AlarmManager", "Chose " + sdf.format(calendar.getTime()) + " as next scheduled alarm.", 4);
|
||||
@ -280,7 +258,8 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
|
||||
for(int requestCode : requestCodeList)
|
||||
{
|
||||
Intent alarmIntent = new Intent(automationServiceRef, DateTimeListener.class);
|
||||
PendingIntent alarmPendingIntent = PendingIntent.getBroadcast(automationServiceRef, requestCode, alarmIntent, 0);
|
||||
if(alarmPendingIntent == null)
|
||||
alarmPendingIntent = PendingIntent.getBroadcast(automationServiceRef, requestCode, alarmIntent, 0);
|
||||
// Miscellaneous.logEvent("i", "AlarmManager", "Clearing alarm with request code: " + String.valueOf(requestCode));
|
||||
centralAlarmManagerInstance.cancel(alarmPendingIntent);
|
||||
}
|
||||
@ -316,7 +295,7 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
|
||||
{
|
||||
Miscellaneous.logEvent("i", "AlarmListener", "Stopping alarm listener.", 4);
|
||||
clearAlarms();
|
||||
// centralAlarmManagerInstance.cancel(alarmPendingIntent);
|
||||
centralAlarmManagerInstance.cancel(alarmPendingIntent);
|
||||
alarmListenerActive = false;
|
||||
}
|
||||
else
|
||||
@ -387,7 +366,7 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
|
||||
public static Calendar getNextRepeatedExecutionAfter(Trigger trigger, Calendar now)
|
||||
{
|
||||
Calendar calSet;
|
||||
Time setTime;
|
||||
TimeObject setTime;
|
||||
TimeFrame tf = new TimeFrame(trigger.getTriggerParameter2());
|
||||
|
||||
if(tf.getRepetition() > 0)
|
||||
@ -403,8 +382,6 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
|
||||
calSet.set(Calendar.SECOND, 0);
|
||||
calSet.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
// if(this.applies(null))
|
||||
// {
|
||||
// If the starting time is a day ahead remove 1 day.
|
||||
if(calSet.getTimeInMillis() > now.getTimeInMillis())
|
||||
calSet.add(Calendar.DAY_OF_MONTH, -1);
|
||||
@ -419,11 +396,8 @@ public class DateTimeListener extends BroadcastReceiver implements AutomationLis
|
||||
* Das war mal aktiviert. Allerdings: Die ganze Funktion liefert zurück, wenn die Regel NOCH nicht
|
||||
* zutrifft, aber wir z.B. gleich den zeitlichen Bereich betreten.
|
||||
*/
|
||||
// if(trigger.checkDateTime(calSchedule.getTime(), false))
|
||||
// {
|
||||
|
||||
return calSchedule;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
else
|
||||
Miscellaneous.logEvent("i", "DateTimeListener", "Trigger " + trigger.toString() + " is not executed repeatedly.", 5);
|
||||
|
@ -34,17 +34,18 @@ public class DeviceOrientationListener implements SensorEventListener, Automatio
|
||||
static int sensorValueCounter = 0;
|
||||
|
||||
// Gravity rotational data
|
||||
private float gravity[];
|
||||
float gravity[];
|
||||
// Magnetic rotational data
|
||||
private float magnetic[]; //for magnetic rotational data
|
||||
private float accels[] = new float[3];
|
||||
private float mags[] = new float[3];
|
||||
private float[] values = new float[3];
|
||||
float magnetic[]; //for magnetic rotational data
|
||||
float accels[] = new float[3];
|
||||
float mags[] = new float[3];
|
||||
float[] values = new float[3];
|
||||
boolean hasMagneticSensor=false;
|
||||
|
||||
// azimuth, pitch and roll
|
||||
private float azimuth;
|
||||
private float pitch;
|
||||
private float roll;
|
||||
float azimuth;
|
||||
float pitch;
|
||||
float roll;
|
||||
|
||||
boolean applies = false;
|
||||
boolean flipped = false;
|
||||
@ -91,7 +92,7 @@ public class DeviceOrientationListener implements SensorEventListener, Automatio
|
||||
isRunning = true;
|
||||
|
||||
sManager.registerListener(this, sManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
|
||||
sManager.registerListener(this, sManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD), SensorManager.SENSOR_DELAY_NORMAL);
|
||||
hasMagneticSensor = sManager.registerListener(this, sManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD), SensorManager.SENSOR_DELAY_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,6 +130,9 @@ public class DeviceOrientationListener implements SensorEventListener, Automatio
|
||||
break;
|
||||
}
|
||||
|
||||
if (!hasMagneticSensor)
|
||||
mags=new float[]{1f,1f,1f};
|
||||
|
||||
if (mags != null && accels != null)
|
||||
{
|
||||
gravity = new float[9];
|
||||
|
@ -76,7 +76,6 @@ public class HeadphoneJackListener extends BroadcastReceiver implements Automati
|
||||
}
|
||||
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.headsetPlugged);
|
||||
// ArrayList<Rule> ruleCandidates = Rule.findRuleCandidatesByHeadphoneJack(isHeadsetConnected());
|
||||
for(int i=0; i<ruleCandidates.size(); i++)
|
||||
{
|
||||
if(ruleCandidates.get(i).getsGreenLight(context))
|
||||
@ -104,7 +103,6 @@ public class HeadphoneJackListener extends BroadcastReceiver implements Automati
|
||||
{
|
||||
Miscellaneous.logEvent("i", "HeadsetJackListener", "Starting HeadsetJackListener", 4);
|
||||
headphoneJackListenerActive = true;
|
||||
// getInstance().startHeadphoneJackListener(AutomationService.getInstance(), headphoneJackListenerIntentFilter);
|
||||
automationService.registerReceiver(this, headphoneJackListenerIntentFilter);
|
||||
}
|
||||
}
|
||||
@ -122,7 +120,6 @@ public class HeadphoneJackListener extends BroadcastReceiver implements Automati
|
||||
if(headphoneJackListenerActive)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "HeadsetJackListener", "Stopping HeadsetJackListener", 4);
|
||||
// getInstance().stopHeadphoneJackListener(AutomationService.getInstance());
|
||||
automationService.unregisterReceiver(this);
|
||||
headphoneJackListenerActive = false;
|
||||
}
|
||||
@ -150,5 +147,4 @@ public class HeadphoneJackListener extends BroadcastReceiver implements Automati
|
||||
{
|
||||
return new Trigger_Enum[] { Trigger_Enum.headsetPlugged };
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package com.jens.automation2.receivers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.AudioManager;
|
||||
|
||||
import com.jens.automation2.AutomationService;
|
||||
import com.jens.automation2.Miscellaneous;
|
||||
import com.jens.automation2.Rule;
|
||||
import com.jens.automation2.Settings;
|
||||
import com.jens.automation2.Trigger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class MediaPlayerListener implements AutomationListenerInterface
|
||||
{
|
||||
static MediaPlayerListener instance = null;
|
||||
static AudioManager mAudioManager = null;
|
||||
static boolean listenerActive = false;
|
||||
Timer timer = null;
|
||||
TimerTask task = null;
|
||||
|
||||
public static boolean isAudioPlaying(Context context)
|
||||
{
|
||||
if(mAudioManager == null)
|
||||
mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||
|
||||
return mAudioManager.isMusicActive();
|
||||
}
|
||||
|
||||
public static MediaPlayerListener getInstance()
|
||||
{
|
||||
if(instance == null)
|
||||
instance = new MediaPlayerListener();
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startListener(AutomationService automationService)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "MediaPlayerListener", "Starting listener.",5);
|
||||
|
||||
if(!listenerActive)
|
||||
{
|
||||
if(timer == null)
|
||||
{
|
||||
timer = new Timer();
|
||||
}
|
||||
else
|
||||
{
|
||||
task.cancel();
|
||||
timer.purge();
|
||||
}
|
||||
|
||||
task = new TimerTask()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
synchronized(this)
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.musicPlaying);
|
||||
for (int i = 0; i < ruleCandidates.size(); i++)
|
||||
{
|
||||
if (ruleCandidates.get(i).getsGreenLight(AutomationService.getInstance()))
|
||||
ruleCandidates.get(i).activate(AutomationService.getInstance(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
timer.scheduleAtFixedRate(task, 0, Settings.musicCheckFrequency);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopListener(AutomationService automationService)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "MediaPlayerListener", "Stopping listener.",5);
|
||||
|
||||
if(listenerActive)
|
||||
{
|
||||
if (timer != null)
|
||||
{
|
||||
timer.cancel();
|
||||
timer.purge();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isListenerRunning()
|
||||
{
|
||||
return listenerActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Trigger.Trigger_Enum[] getMonitoredTrigger()
|
||||
{
|
||||
return new Trigger.Trigger_Enum[] { Trigger.Trigger_Enum.musicPlaying };
|
||||
}
|
||||
}
|
@ -216,23 +216,26 @@ public class NfcReceiver
|
||||
}
|
||||
|
||||
NdefMessage ndefMessage = ndef.getCachedNdefMessage();
|
||||
|
||||
NdefRecord[] records = ndefMessage.getRecords();
|
||||
for (NdefRecord ndefRecord : records)
|
||||
{
|
||||
if (ndefRecord.getTnf() == NdefRecord.TNF_WELL_KNOWN && Arrays.equals(ndefRecord.getType(), NdefRecord.RTD_TEXT))
|
||||
{
|
||||
try
|
||||
{
|
||||
return readText(ndefRecord);
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
Miscellaneous.logEvent("w", "NFC", "Unsupported Encoding: " + Log.getStackTraceString(e), 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(ndefMessage != null)
|
||||
{
|
||||
NdefRecord[] records = ndefMessage.getRecords();
|
||||
for (NdefRecord ndefRecord : records)
|
||||
{
|
||||
if (ndefRecord.getTnf() == NdefRecord.TNF_WELL_KNOWN && Arrays.equals(ndefRecord.getType(), NdefRecord.RTD_TEXT))
|
||||
{
|
||||
try
|
||||
{
|
||||
return readText(ndefRecord);
|
||||
}
|
||||
catch (UnsupportedEncodingException e)
|
||||
{
|
||||
Miscellaneous.logEvent("w", "NFC", "Unsupported Encoding: " + Log.getStackTraceString(e), 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,14 @@
|
||||
package com.jens.automation2.receivers;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Notification;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
@ -19,9 +24,10 @@ import java.util.Calendar;
|
||||
|
||||
@SuppressLint("OverrideAbstract")
|
||||
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
public class NotificationListener extends NotificationListenerService
|
||||
public class NotificationListener extends NotificationListenerService// implements AutomationListenerInterface
|
||||
{
|
||||
static Calendar lastResponseToNotification = null;
|
||||
static boolean listenerRunning = false;
|
||||
static NotificationListener instance;
|
||||
static SimpleNotification lastNotification = null;
|
||||
|
||||
@ -37,6 +43,8 @@ public class NotificationListener extends NotificationListenerService
|
||||
// a bitmap to be used instead of the small icon when showing the notification payload
|
||||
public static final String EXTRA_LARGE_ICON = "android.largeIcon";
|
||||
|
||||
protected static IntentFilter notificationReceiverIntentFilter = null;
|
||||
|
||||
public static SimpleNotification getLastNotification()
|
||||
{
|
||||
return lastNotification;
|
||||
@ -78,16 +86,12 @@ public class NotificationListener extends NotificationListenerService
|
||||
{
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT)
|
||||
{
|
||||
String app = sbn.getPackageName();
|
||||
String title = sbn.getNotification().extras.getString(EXTRA_TITLE);
|
||||
String text = sbn.getNotification().extras.getString(EXTRA_TEXT);
|
||||
lastNotification = convertNotificationToSimpleNotification(created, sbn);
|
||||
|
||||
lastNotification = new SimpleNotification();
|
||||
lastNotification.publishTime = Miscellaneous.calendarFromLong(sbn.getPostTime());
|
||||
lastNotification.created = created;
|
||||
lastNotification.app = app;
|
||||
lastNotification.title = title;
|
||||
lastNotification.text = text;
|
||||
if(created)
|
||||
Miscellaneous.logEvent("i", "New notification", lastNotification.toString(), 5);
|
||||
else
|
||||
Miscellaneous.logEvent("i", "Notification removed", lastNotification.toString(), 5);
|
||||
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.notification);
|
||||
for (int i = 0; i < ruleCandidates.size(); i++)
|
||||
@ -100,6 +104,50 @@ public class NotificationListener extends NotificationListenerService
|
||||
return false;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
|
||||
public static SimpleNotification convertNotificationToSimpleNotification(boolean created, StatusBarNotification input)
|
||||
{
|
||||
String app = input.getPackageName();
|
||||
String title = "";
|
||||
String text = "";
|
||||
|
||||
Bundle extras = input.getNotification().extras;
|
||||
|
||||
try
|
||||
{
|
||||
if (extras.containsKey(EXTRA_TITLE))
|
||||
title = extras.getString(EXTRA_TITLE).toString();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
// https://www.b4x.com/android/forum/threads/solved-reading-statusbarnotifications-extras.64416/
|
||||
// Some notifications have an empty title, like KDE connect
|
||||
if(extras.containsKey(EXTRA_TITLE) && extras.get(EXTRA_TITLE) != null)
|
||||
title = extras.get(EXTRA_TITLE).toString();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (extras.containsKey(EXTRA_TEXT))
|
||||
text = extras.getString(EXTRA_TEXT).toString();
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
// in stacked notifications the "surrounding" element has no text, only a title
|
||||
if (extras.containsKey(EXTRA_TEXT) && extras.get(EXTRA_TEXT) != null)
|
||||
text = extras.get(EXTRA_TEXT).toString();
|
||||
}
|
||||
|
||||
SimpleNotification returnNotification = new SimpleNotification();
|
||||
returnNotification.publishTime = Miscellaneous.calendarFromLong(input.getPostTime());
|
||||
returnNotification.created = created;
|
||||
returnNotification.app = app;
|
||||
returnNotification.title = title;
|
||||
returnNotification.text = text;
|
||||
|
||||
return returnNotification;
|
||||
}
|
||||
|
||||
public static class SimpleNotification
|
||||
{
|
||||
boolean created;
|
||||
@ -155,6 +203,18 @@ public class NotificationListener extends NotificationListenerService
|
||||
{
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "SimpleNotification{" +
|
||||
"created=" + created +
|
||||
", publishTime=" + publishTime +
|
||||
", app='" + app + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", text='" + text + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -168,4 +228,44 @@ public class NotificationListener extends NotificationListenerService
|
||||
{
|
||||
super.onListenerDisconnected();
|
||||
}
|
||||
|
||||
public void dismissNotification(StatusBarNotification sbn)
|
||||
{
|
||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
|
||||
cancelNotification(sbn.getPackageName(), sbn.getTag(), sbn.getId());
|
||||
else
|
||||
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.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.os.Build;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.TelephonyCallback;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.jens.automation2.ActivityPermissions;
|
||||
import com.jens.automation2.AutomationService;
|
||||
import com.jens.automation2.Miscellaneous;
|
||||
@ -22,8 +27,7 @@ import java.util.ArrayList;
|
||||
|
||||
public class PhoneStatusListener implements AutomationListenerInterface
|
||||
{
|
||||
// protected static int currentStateIncoming = -1;
|
||||
// protected static int currentStateOutgoing = -1;
|
||||
static int problematicAndroidLevel = 29;
|
||||
protected static String lastPhoneNumber="";
|
||||
protected static int lastPhoneDirection = -1; //0=incoming, 1=outgoing
|
||||
protected static int currentState = -1;
|
||||
@ -72,7 +76,76 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
||||
return currentState;
|
||||
}
|
||||
|
||||
public static class IncomingCallsReceiver extends PhoneStateListener
|
||||
public static interface IncomingCallsReceiver
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected static void workWithIncomingCallData(int state, String incomingNumber)
|
||||
{
|
||||
if(lastPhoneDirection == 2 && currentState != TelephonyManager.CALL_STATE_IDLE)
|
||||
{
|
||||
// This status update is actually for an outgoing call
|
||||
setCurrentState(state);
|
||||
|
||||
if(incomingNumber != null && incomingNumber.length() > 0) // check for null in case call comes in with suppressed number.
|
||||
setLastPhoneNumber(incomingNumber);
|
||||
|
||||
switch(state)
|
||||
{
|
||||
case TelephonyManager.CALL_STATE_IDLE:
|
||||
Miscellaneous.logEvent("i", "Call state", "New call state: CALL_STATE_IDLE", 4);
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_OFFHOOK:
|
||||
Miscellaneous.logEvent("i", "Call state", "New call state: CALL_STATE_OFFHOOK", 4);
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_RINGING:
|
||||
Miscellaneous.logEvent("i", "Call state", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.outgoingCallTo), incomingNumber), 4);
|
||||
break;
|
||||
}
|
||||
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.phoneCall);
|
||||
for(int i=0; i<ruleCandidates.size(); i++)
|
||||
{
|
||||
AutomationService asInstance = AutomationService.getInstance();
|
||||
if(asInstance != null)
|
||||
if(ruleCandidates.get(i).getsGreenLight(asInstance))
|
||||
ruleCandidates.get(i).activate(asInstance, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setCurrentState(state);
|
||||
setLastPhoneDirection(1);
|
||||
|
||||
if (incomingNumber != null && incomingNumber.length() > 0) // check for null in case call comes in with suppressed number.
|
||||
setLastPhoneNumber(incomingNumber);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case TelephonyManager.CALL_STATE_IDLE:
|
||||
Miscellaneous.logEvent("i", "Call state", "New call state: CALL_STATE_IDLE", 4);
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_OFFHOOK:
|
||||
Miscellaneous.logEvent("i", "Call state", "New call state: CALL_STATE_OFFHOOK", 4);
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_RINGING:
|
||||
Miscellaneous.logEvent("i", "Call state", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.incomingCallFrom), incomingNumber), 4);
|
||||
break;
|
||||
}
|
||||
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.phoneCall);
|
||||
for (int i = 0; i < ruleCandidates.size(); i++)
|
||||
{
|
||||
AutomationService asInstance = AutomationService.getInstance();
|
||||
if (asInstance != null)
|
||||
if (ruleCandidates.get(i).getsGreenLight(asInstance))
|
||||
ruleCandidates.get(i).activate(asInstance, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class IncomingCallsReceiverOld extends PhoneStateListener implements IncomingCallsReceiver
|
||||
{
|
||||
@Override
|
||||
public void onCallStateChanged(int state, String incomingNumber)
|
||||
@ -88,67 +161,42 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
||||
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)
|
||||
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))
|
||||
{
|
||||
// This status update is actually for an outgoing call
|
||||
setCurrentState(state);
|
||||
String stateStr = intent.getExtras().getString(TelephonyManager.EXTRA_STATE);
|
||||
int state = 99;
|
||||
|
||||
if(incomingNumber != null && incomingNumber.length() > 0) // check for null in case call comes in with suppressed number.
|
||||
setLastPhoneNumber(incomingNumber);
|
||||
|
||||
switch(state)
|
||||
switch(stateStr)
|
||||
{
|
||||
case TelephonyManager.CALL_STATE_IDLE:
|
||||
Miscellaneous.logEvent("i", "Call state", "New call state: CALL_STATE_IDLE", 4);
|
||||
case "RINGING":
|
||||
state = TelephonyManager.CALL_STATE_RINGING;
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_OFFHOOK:
|
||||
Miscellaneous.logEvent("i", "Call state", "New call state: CALL_STATE_OFFHOOK", 4);
|
||||
case "IDLE":
|
||||
state = TelephonyManager.CALL_STATE_IDLE;
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_RINGING:
|
||||
Miscellaneous.logEvent("i", "Call state", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.outgoingCallTo), incomingNumber), 4);
|
||||
case "OFFHOOK":
|
||||
state = TelephonyManager.CALL_STATE_OFFHOOK;
|
||||
break;
|
||||
}
|
||||
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.phoneCall);
|
||||
for(int i=0; i<ruleCandidates.size(); i++)
|
||||
{
|
||||
AutomationService asInstance = AutomationService.getInstance();
|
||||
if(asInstance != null)
|
||||
if(ruleCandidates.get(i).getsGreenLight(asInstance))
|
||||
ruleCandidates.get(i).activate(asInstance, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// state != TelephonyManager.CALL_STATE_IDLE &&
|
||||
|
||||
setCurrentState(state);
|
||||
setLastPhoneDirection(1);
|
||||
|
||||
if (incomingNumber != null && incomingNumber.length() > 0) // check for null in case call comes in with suppressed number.
|
||||
setLastPhoneNumber(incomingNumber);
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case TelephonyManager.CALL_STATE_IDLE:
|
||||
Miscellaneous.logEvent("i", "Call state", "New call state: CALL_STATE_IDLE", 4);
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_OFFHOOK:
|
||||
Miscellaneous.logEvent("i", "Call state", "New call state: CALL_STATE_OFFHOOK", 4);
|
||||
break;
|
||||
case TelephonyManager.CALL_STATE_RINGING:
|
||||
Miscellaneous.logEvent("i", "Call state", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.incomingCallFrom), incomingNumber), 4);
|
||||
break;
|
||||
}
|
||||
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.phoneCall);
|
||||
for (int i = 0; i < ruleCandidates.size(); i++)
|
||||
{
|
||||
AutomationService asInstance = AutomationService.getInstance();
|
||||
if (asInstance != null)
|
||||
if (ruleCandidates.get(i).getsGreenLight(asInstance))
|
||||
ruleCandidates.get(i).activate(asInstance, false);
|
||||
}
|
||||
String number = intent.getExtras().getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
|
||||
Log.i("test", "test");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -175,12 +223,12 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
||||
Miscellaneous.logEvent("i", "Call state", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.outgoingCallTo), getLastPhoneNumber()), 4);
|
||||
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.phoneCall);
|
||||
for(int i=0; i<ruleCandidates.size(); i++)
|
||||
for(int i = 0; i < ruleCandidates.size(); i++)
|
||||
{
|
||||
AutomationService asInstance = AutomationService.getInstance();
|
||||
if(asInstance != null)
|
||||
if(ruleCandidates.get(i).getsGreenLight(asInstance))
|
||||
ruleCandidates.get(i).activate(asInstance, false);
|
||||
ruleCandidates.get(i).activate(asInstance, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -205,7 +253,12 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
||||
}
|
||||
|
||||
if(incomingCallsReceiverInstance == null)
|
||||
incomingCallsReceiverInstance = new IncomingCallsReceiver();
|
||||
{
|
||||
// if(Build.VERSION.SDK_INT >= 31)
|
||||
// incomingCallsReceiverInstance = new IncomingCallsReceiverNew();
|
||||
// else
|
||||
incomingCallsReceiverInstance = new IncomingCallsReceiverOld();
|
||||
}
|
||||
|
||||
if(outgoingCallsReceiverInstance == null)
|
||||
outgoingCallsReceiverInstance = new OutgoingCallsReceiver();
|
||||
@ -215,8 +268,17 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
||||
if(!incomingCallsReceiverActive)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "PhoneStatusListener", "Starting PhoneStatusListener->incomingCallsReceiver", 4);
|
||||
TelephonyManager tm = (TelephonyManager)automationService.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
tm.listen(incomingCallsReceiverInstance, PhoneStateListener.LISTEN_CALL_STATE);
|
||||
// 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);
|
||||
tm.listen((IncomingCallsReceiverOld)incomingCallsReceiverInstance, PhoneStateListener.LISTEN_CALL_STATE);
|
||||
// }
|
||||
incomingCallsReceiverActive = true;
|
||||
}
|
||||
|
||||
@ -240,8 +302,15 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
||||
if(incomingCallsReceiverActive)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "PhoneStatusListener", "Stopping phoneStatusListener", 4);
|
||||
TelephonyManager tm = (TelephonyManager)automationService.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
tm.listen(incomingCallsReceiverInstance, PhoneStateListener.LISTEN_NONE);
|
||||
// if(Build.VERSION.SDK_INT >= 31)
|
||||
// {
|
||||
// automationService.unregisterReceiver((IncomingCallsReceiverNew)incomingCallsReceiverInstance);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
TelephonyManager tm = (TelephonyManager) automationService.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
tm.listen((IncomingCallsReceiverOld)incomingCallsReceiverInstance, PhoneStateListener.LISTEN_NONE);
|
||||
// }
|
||||
incomingCallsReceiverActive = false;
|
||||
}
|
||||
|
||||
@ -289,4 +358,4 @@ public class PhoneStatusListener implements AutomationListenerInterface
|
||||
{
|
||||
return new Trigger_Enum[] { Trigger_Enum.phoneCall };
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.jens.automation2.receivers;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.ActivityManager.RunningAppProcessInfo;
|
||||
import android.app.ActivityManager.RunningServiceInfo;
|
||||
@ -8,6 +9,7 @@ import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import com.jens.automation2.Action;
|
||||
import com.jens.automation2.ActivityPermissions;
|
||||
import com.jens.automation2.AutomationService;
|
||||
import com.jens.automation2.Miscellaneous;
|
||||
@ -208,12 +210,12 @@ public class ProcessListener implements AutomationListenerInterface
|
||||
workHandler.sendMessage(answer);
|
||||
|
||||
//activate rule(s)
|
||||
/*ArrayList<Rule> ruleCandidates = Rule.findRuleCandidatesByProcess();
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.process_started_stopped);
|
||||
for(int i=0; i<ruleCandidates.size(); i++)
|
||||
{
|
||||
if(ruleCandidates.get(i).applies(automationService))
|
||||
ruleCandidates.get(i).activate(automationService);
|
||||
}*/
|
||||
if(ruleCandidates.get(i).getsGreenLight(automationService))
|
||||
ruleCandidates.get(i).activate(automationService, false);
|
||||
}
|
||||
|
||||
isMonitoringActive = false;
|
||||
|
||||
@ -231,6 +233,7 @@ public class ProcessListener implements AutomationListenerInterface
|
||||
|
||||
final ActivityManager activityManager = (ActivityManager)automationService.getSystemService(Context.ACTIVITY_SERVICE);
|
||||
final List<RunningTaskInfo> services = activityManager.getRunningTasks(Integer.MAX_VALUE);
|
||||
final List<RunningAppProcessInfo> apps = activityManager.getRunningAppProcesses();
|
||||
|
||||
ArrayList<String> runningAppsListReference;
|
||||
if(lastWritten == 1)
|
||||
@ -246,32 +249,23 @@ public class ProcessListener implements AutomationListenerInterface
|
||||
|
||||
runningAppsListReference.clear();
|
||||
|
||||
for (int i = 0; i < services.size(); i++)
|
||||
/*for (int i = 0; i < services.size(); i++)
|
||||
{
|
||||
if(!runningAppsListReference.contains(services.get(i).baseActivity.getClassName()))
|
||||
{
|
||||
// you may broadcast a new application launch here.
|
||||
runningAppsListReference.add(services.get(i).baseActivity.getClassName());
|
||||
}
|
||||
}
|
||||
}*/
|
||||
for (int i = 0; i < apps.size(); i++)
|
||||
{
|
||||
if(!runningAppsListReference.contains(apps.get(i).processName))
|
||||
{
|
||||
// you may broadcast a new application launch here.
|
||||
runningAppsListReference.add(apps.get(i).processName);
|
||||
}
|
||||
}
|
||||
|
||||
// for(String runningApp : runningAppsListReference)
|
||||
// {
|
||||
// Miscellaneous.logEvent("i", "Running app", runningApp, 5);
|
||||
// }
|
||||
|
||||
// List<RunningAppProcessInfo> procInfos = activityManager.getRunningAppProcesses();
|
||||
// for(int i = 0; i < procInfos.size(); i++)
|
||||
// {
|
||||
// ArrayList<String> runningPkgs = new ArrayList<String>(Arrays.asList(procInfos.get(i).pkgList));
|
||||
//
|
||||
// Collection diff = subtractSets(runningPkgs, stalkList);
|
||||
//
|
||||
// if(diff != null)
|
||||
// {
|
||||
// stalkList.removeAll(diff);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Set marker to the one to be written next.
|
||||
if(lastWritten == 1)
|
||||
@ -351,7 +345,7 @@ public class ProcessListener implements AutomationListenerInterface
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkifThisIsActive(RunningAppProcessInfo target)
|
||||
private boolean checkIfThisIsActive(RunningAppProcessInfo target)
|
||||
{
|
||||
boolean result = false;
|
||||
RunningTaskInfo info;
|
||||
@ -397,7 +391,6 @@ public class ProcessListener implements AutomationListenerInterface
|
||||
|
||||
Message message = new Message();
|
||||
message.arg1 = 1;
|
||||
// schedulingHandler.sendMessageDelayed(message, Settings.timeBetweenNoiseLevelMeasurements * 1000);
|
||||
schedulingHandler.sendMessageDelayed(message, 10000);
|
||||
}
|
||||
else
|
||||
@ -444,7 +437,7 @@ public class ProcessListener implements AutomationListenerInterface
|
||||
|
||||
public static boolean haveAllPermission()
|
||||
{
|
||||
return ActivityPermissions.havePermission("android.permission.GET_TASKS", Miscellaneous.getAnyContext());
|
||||
return ActivityPermissions.havePermission(Manifest.permission.GET_TASKS, Miscellaneous.getAnyContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -458,6 +451,4 @@ public class ProcessListener implements AutomationListenerInterface
|
||||
{
|
||||
return new Trigger_Enum[] { Trigger_Enum.process_started_stopped };
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,274 @@
|
||||
package com.jens.automation2.receivers;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.jens.automation2.Actions;
|
||||
import com.jens.automation2.ActivityPermissions;
|
||||
import com.jens.automation2.AutomationService;
|
||||
import com.jens.automation2.Miscellaneous;
|
||||
import com.jens.automation2.Rule;
|
||||
import com.jens.automation2.Trigger.Trigger_Enum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class ScreenStateReceiver extends BroadcastReceiver implements AutomationListenerInterface
|
||||
{
|
||||
static int screenPowerState = -1; // initialize with a better value than this
|
||||
static int screenLockState = -1; // initialize with a better value than this
|
||||
public static AutomationService automationServiceRef = null;
|
||||
|
||||
private static boolean screenStateReceiverActive = false;
|
||||
private static IntentFilter screenStateIntentFilter = null;
|
||||
private static Intent screenStatusIntent = null;
|
||||
private static BroadcastReceiver screenStateReceiverInstance = null;
|
||||
|
||||
public final static String broadcastScreenLockedWithoutSecurity = "automation.system.screen_locked_without_security";
|
||||
public final static String broadcastScreenLockedWithSecurity = "automation.system.screen_locked_with_security";
|
||||
|
||||
public final static int SCREEN_STATE_OFF = 0;
|
||||
public final static int SCREEN_STATE_ON = 1;
|
||||
public final static int SCREEN_STATE_UNLOCKED = 2;
|
||||
public final static int SCREEN_STATE_LOCKED_WITHOUT_SECURITY = 3;
|
||||
public final static int SCREEN_STATE_LOCKED_WITH_SECURITY = 4;
|
||||
|
||||
public static BroadcastReceiver getScreenStateReceiverInstance()
|
||||
{
|
||||
if (screenStateReceiverInstance == null)
|
||||
screenStateReceiverInstance = new ScreenStateReceiver();
|
||||
|
||||
return screenStateReceiverInstance;
|
||||
}
|
||||
|
||||
public static void startScreenStateReceiver(final AutomationService automationServiceRef)
|
||||
{
|
||||
if (!screenStateReceiverActive)
|
||||
{
|
||||
ScreenStateReceiver.automationServiceRef = automationServiceRef;
|
||||
|
||||
if (screenStateReceiverInstance == null)
|
||||
screenStateReceiverInstance = new ScreenStateReceiver();
|
||||
|
||||
if (screenStateIntentFilter == null)
|
||||
{
|
||||
screenStateIntentFilter = new IntentFilter();
|
||||
screenStateIntentFilter.addAction(Intent.ACTION_SCREEN_OFF);
|
||||
screenStateIntentFilter.addAction(Intent.ACTION_SCREEN_ON);
|
||||
screenStateIntentFilter.addAction(Intent.ACTION_USER_PRESENT); // also fired when device is unlocked
|
||||
screenStateIntentFilter.addAction(broadcastScreenLockedWithoutSecurity);
|
||||
screenStateIntentFilter.addAction(broadcastScreenLockedWithSecurity);
|
||||
// Intent.ACTION_USER_UNLOCKED
|
||||
}
|
||||
|
||||
screenStatusIntent = automationServiceRef.registerReceiver(screenStateReceiverInstance, screenStateIntentFilter);
|
||||
|
||||
screenStateReceiverActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopScreenStateReceiver()
|
||||
{
|
||||
if (screenStateReceiverActive)
|
||||
{
|
||||
if (screenStateReceiverInstance != null)
|
||||
{
|
||||
automationServiceRef.unregisterReceiver(screenStateReceiverInstance);
|
||||
screenStateReceiverInstance = null;
|
||||
}
|
||||
|
||||
screenStateReceiverActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isScreenStateReceiverActive()
|
||||
{
|
||||
return screenStateReceiverActive;
|
||||
}
|
||||
|
||||
public static int getScreenPowerState()
|
||||
{
|
||||
return screenPowerState;
|
||||
}
|
||||
|
||||
public static int getScreenLockState()
|
||||
{
|
||||
return screenLockState;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP_MR1)
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
if (intent == null)
|
||||
return;
|
||||
if (context == null)
|
||||
return;
|
||||
|
||||
Miscellaneous.logEvent("e", "ScreenStateReceiver", "Received: " + intent.getAction(), 3);
|
||||
|
||||
try
|
||||
{
|
||||
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF))
|
||||
{
|
||||
ScreenStateReceiver.screenPowerState = SCREEN_STATE_OFF;
|
||||
|
||||
KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
|
||||
|
||||
// PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
// Miscellaneous.logEvent("i", "ScreenStateReceiver", "Method 2: " + String.valueOf(pm.isInteractive() && pm.isScreenOn() && keyguardManager.isKeyguardLocked() && keyguardManager.isDeviceLocked()), 4);
|
||||
// if (pm.isInteractive() && pm.isScreenOn() && keyguardManager.isKeyguardLocked() && keyguardManager.isDeviceLocked())
|
||||
// Miscellaneous.logEvent("i", "ScreenStateReceiver", "pm.isInteractive(): " + String.valueOf(pm.isInteractive()), 4);
|
||||
// Miscellaneous.logEvent("i", "ScreenStateReceiver", "pm.isScreenOn(): " + String.valueOf(pm.isScreenOn()), 4);
|
||||
Miscellaneous.logEvent("i", "ScreenStateReceiver", "keyguardManager.isKeyguardLocked(): " + String.valueOf(keyguardManager.isKeyguardLocked()), 4);
|
||||
Miscellaneous.logEvent("i", "ScreenStateReceiver", "keyguardManager.isDeviceLocked(): " + String.valueOf(keyguardManager.isDeviceLocked()), 4);
|
||||
|
||||
if(keyguardManager.isKeyguardLocked() && !keyguardManager.isDeviceLocked())
|
||||
{
|
||||
Actions.sendBroadcast(Miscellaneous.getAnyContext(), broadcastScreenLockedWithoutSecurity);
|
||||
}
|
||||
else if(keyguardManager.isDeviceLocked())
|
||||
{
|
||||
Actions.sendBroadcast(Miscellaneous.getAnyContext(), broadcastScreenLockedWithSecurity);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Lock may be activated delayed, not at power button press
|
||||
ScreenLockMonitor mon = new ScreenLockMonitor();
|
||||
mon.startMonitor();
|
||||
}
|
||||
}
|
||||
else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON))
|
||||
{
|
||||
ScreenStateReceiver.screenPowerState = SCREEN_STATE_ON;
|
||||
}
|
||||
else if (intent.getAction().equals(Intent.ACTION_USER_PRESENT))
|
||||
{
|
||||
ScreenStateReceiver.screenLockState = SCREEN_STATE_UNLOCKED;
|
||||
}
|
||||
else if (intent.getAction().equals(broadcastScreenLockedWithoutSecurity))
|
||||
{
|
||||
ScreenStateReceiver.screenLockState = SCREEN_STATE_LOCKED_WITHOUT_SECURITY;
|
||||
}
|
||||
else if (intent.getAction().equals(broadcastScreenLockedWithSecurity))
|
||||
{
|
||||
ScreenStateReceiver.screenLockState = SCREEN_STATE_LOCKED_WITH_SECURITY;
|
||||
}
|
||||
else
|
||||
{
|
||||
Miscellaneous.logEvent("e", "ScreenStateReceiver", "Unknown state received: " + intent.getAction(), 3);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "ScreenStateReceiver", "Error receiving screen state: " + e.getMessage(), 3);
|
||||
}
|
||||
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.screenState);
|
||||
for (int i = 0; i < ruleCandidates.size(); i++)
|
||||
{
|
||||
if (ruleCandidates.get(i).getsGreenLight(context))
|
||||
ruleCandidates.get(i).activate(automationServiceRef, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startListener(AutomationService automationService)
|
||||
{
|
||||
ScreenStateReceiver.startScreenStateReceiver(automationService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopListener(AutomationService automationService)
|
||||
{
|
||||
ScreenStateReceiver.stopScreenStateReceiver();
|
||||
}
|
||||
|
||||
public static boolean haveAllPermission()
|
||||
{
|
||||
return ActivityPermissions.havePermission(Manifest.permission.READ_PHONE_STATE, Miscellaneous.getAnyContext()) &&
|
||||
ActivityPermissions.havePermission(Manifest.permission.BATTERY_STATS, Miscellaneous.getAnyContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isListenerRunning()
|
||||
{
|
||||
return ScreenStateReceiver.isScreenStateReceiverActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Trigger_Enum[] getMonitoredTrigger()
|
||||
{
|
||||
return new Trigger_Enum[]{Trigger_Enum.screenState};
|
||||
}
|
||||
|
||||
class ScreenLockMonitor
|
||||
{
|
||||
long runs = 0;
|
||||
final long maxRuns = 20;
|
||||
final long interval = 1000;
|
||||
|
||||
Timer timer = new Timer();
|
||||
|
||||
TimerTask task = new TimerTask()
|
||||
{
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP_MR1)
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
KeyguardManager keyguardManager = (KeyguardManager) Miscellaneous.getAnyContext().getSystemService(Context.KEYGUARD_SERVICE);
|
||||
|
||||
Miscellaneous.logEvent("i", "ScreenStateReceiver", "keyguardManager.isKeyguardLocked(): " + String.valueOf(keyguardManager.isKeyguardLocked()), 4);
|
||||
Miscellaneous.logEvent("i", "ScreenStateReceiver", "keyguardManager.isDeviceLocked(): " + String.valueOf(keyguardManager.isDeviceLocked()), 4);
|
||||
|
||||
if(keyguardManager.isKeyguardLocked() && !keyguardManager.isDeviceLocked())
|
||||
{
|
||||
Actions.sendBroadcast(Miscellaneous.getAnyContext(), broadcastScreenLockedWithoutSecurity);
|
||||
timer.purge();
|
||||
timer.cancel();
|
||||
}
|
||||
else if(keyguardManager.isDeviceLocked())
|
||||
{
|
||||
Actions.sendBroadcast(Miscellaneous.getAnyContext(), broadcastScreenLockedWithSecurity);
|
||||
timer.purge();
|
||||
timer.cancel();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (runs++ > maxRuns)
|
||||
{
|
||||
Miscellaneous.logEvent("w", "ScreenStateReceiver->ScreenLockMonitor", "Lock never came.", 4);
|
||||
timer.purge();
|
||||
timer.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void startMonitor()
|
||||
{
|
||||
ContentResolver mResolver = Miscellaneous.getAnyContext().getContentResolver();
|
||||
long lockscreen_timeout = 0;
|
||||
|
||||
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1)
|
||||
lockscreen_timeout = Settings.System.getInt(mResolver, "lock_screen_lock_after_timeout", 0);
|
||||
else
|
||||
lockscreen_timeout = Settings.Secure.getInt(mResolver, "lock_screen_lock_after_timeout", 0);
|
||||
|
||||
if(lockscreen_timeout > 0)
|
||||
timer.schedule(task, lockscreen_timeout);
|
||||
else
|
||||
timer.scheduleAtFixedRate(task, 0, interval);
|
||||
}
|
||||
}
|
||||
}
|
@ -11,13 +11,14 @@ import com.jens.automation2.Settings;
|
||||
|
||||
public class StartupIntentReceiver extends BroadcastReceiver
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent)
|
||||
{
|
||||
Settings.readFromPersistentStorage(context);
|
||||
|
||||
Miscellaneous.logEvent("i", "Boot event", "Received event: " + intent.getAction(), 5);
|
||||
Miscellaneous.startupContext = context;
|
||||
|
||||
// Miscellaneous.logEvent("i", "Boot event", "Received event: " + intent.getAction(), 5);
|
||||
|
||||
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};
|
||||
}
|
||||
}
|
@ -0,0 +1,205 @@
|
||||
package com.jens.automation2.receivers;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.jens.automation2.ActivityManageTriggerTethering;
|
||||
import com.jens.automation2.AutomationService;
|
||||
import com.jens.automation2.Miscellaneous;
|
||||
import com.jens.automation2.Rule;
|
||||
import com.jens.automation2.Trigger;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
public class TetheringReceiver extends android.content.BroadcastReceiver implements AutomationListenerInterface
|
||||
{
|
||||
public static AutomationService automationServiceRef = null;
|
||||
private static boolean receiverActive = false;
|
||||
private static TetheringReceiver receiverInstance = null;
|
||||
private static IntentFilter intentFilter = null;
|
||||
|
||||
private static List<String> lastTetheringTypes = null;
|
||||
private static boolean tetheringActive = false;
|
||||
|
||||
public static List<String> getLastTetheringTypes()
|
||||
{
|
||||
return lastTetheringTypes;
|
||||
}
|
||||
|
||||
public static TetheringReceiver getInstance()
|
||||
{
|
||||
if(receiverInstance == null)
|
||||
receiverInstance = new TetheringReceiver();
|
||||
|
||||
return receiverInstance;
|
||||
}
|
||||
|
||||
public static boolean isTetheringActive()
|
||||
{
|
||||
return tetheringActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
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())
|
||||
{
|
||||
// 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);
|
||||
|
||||
if (key.equals(searchArray) && ob instanceof ArrayList)
|
||||
{
|
||||
if (((ArrayList<String>) ob).size() > 0)
|
||||
{
|
||||
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
|
||||
tetheringActive = false;
|
||||
}
|
||||
|
||||
// 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);
|
||||
for(int i=0; i<ruleCandidates.size(); i++)
|
||||
{
|
||||
if(ruleCandidates.get(i).getsGreenLight(context))
|
||||
ruleCandidates.get(i).activate(automationServiceRef, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startListener(AutomationService automationService)
|
||||
{
|
||||
if(!receiverActive)
|
||||
{
|
||||
TetheringReceiver.automationServiceRef = automationService;
|
||||
|
||||
if(receiverInstance == null)
|
||||
receiverInstance = new TetheringReceiver();
|
||||
|
||||
if(intentFilter == null)
|
||||
{
|
||||
intentFilter = new IntentFilter();
|
||||
intentFilter.addAction("android.net.conn.TETHER_STATE_CHANGED");
|
||||
// intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
automationServiceRef.registerReceiver(receiverInstance, intentFilter);
|
||||
receiverActive = true;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
/*
|
||||
We might be confronted with permission issues here.
|
||||
*/
|
||||
Miscellaneous.logEvent("e", "TetheringReceiver", Log.getStackTraceString(e), 1);
|
||||
receiverActive = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopListener(AutomationService automationService)
|
||||
{
|
||||
if(receiverActive)
|
||||
{
|
||||
if(receiverInstance != null)
|
||||
{
|
||||
automationServiceRef.unregisterReceiver(receiverInstance);
|
||||
receiverInstance = null;
|
||||
}
|
||||
|
||||
receiverActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isListenerRunning()
|
||||
{
|
||||
return receiverActive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Trigger.Trigger_Enum[] getMonitoredTrigger()
|
||||
{
|
||||
return new Trigger.Trigger_Enum[] { Trigger.Trigger_Enum.tethering};
|
||||
}
|
||||
}
|
@ -14,14 +14,13 @@ import com.jens.automation2.Trigger.Trigger_Enum;
|
||||
public class TimeZoneListener extends BroadcastReceiver implements AutomationListenerInterface
|
||||
{
|
||||
private static TimeZoneListener timeZoneListenerInstance = null;
|
||||
protected static boolean timeZoneListenerActive = false;
|
||||
protected static boolean timezoneListenerActive = false;
|
||||
protected static AutomationService automationServiceRef = null;
|
||||
protected static IntentFilter timeZoneListenerIntentFilter = null;
|
||||
|
||||
protected static IntentFilter timezoneListenerIntentFilter = null;
|
||||
|
||||
public static boolean isTimeZoneListenerActive()
|
||||
public static boolean isTimezoneListenerActive()
|
||||
{
|
||||
return timeZoneListenerActive;
|
||||
return timezoneListenerActive;
|
||||
}
|
||||
|
||||
public static void startTimeZoneListener(AutomationService automationService)
|
||||
@ -33,19 +32,19 @@ public class TimeZoneListener extends BroadcastReceiver implements AutomationLis
|
||||
|
||||
try
|
||||
{
|
||||
if(!timeZoneListenerActive && Rule.isAnyRuleUsing(Trigger_Enum.timeFrame))
|
||||
if(!timezoneListenerActive && Rule.isAnyRuleUsing(Trigger_Enum.timeFrame))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "TimeZoneListener", "Starting TimeZoneListener", 4);
|
||||
timeZoneListenerActive = true;
|
||||
timezoneListenerActive = true;
|
||||
|
||||
if(timeZoneListenerIntentFilter == null)
|
||||
if(timezoneListenerIntentFilter == null)
|
||||
{
|
||||
timeZoneListenerIntentFilter = new IntentFilter();
|
||||
timeZoneListenerIntentFilter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
||||
timeZoneListenerIntentFilter.addAction(Intent.ACTION_TIME_CHANGED);
|
||||
timezoneListenerIntentFilter = new IntentFilter();
|
||||
timezoneListenerIntentFilter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
||||
timezoneListenerIntentFilter.addAction(Intent.ACTION_TIME_CHANGED);
|
||||
}
|
||||
|
||||
automationService.registerReceiver(timeZoneListenerInstance, timeZoneListenerIntentFilter);
|
||||
automationService.registerReceiver(timeZoneListenerInstance, timezoneListenerIntentFilter);
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
@ -57,11 +56,11 @@ public class TimeZoneListener extends BroadcastReceiver implements AutomationLis
|
||||
{
|
||||
try
|
||||
{
|
||||
if(timeZoneListenerActive)
|
||||
if(timezoneListenerActive)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "TimeZoneListener", "Stopping TimeZoneListener", 4);
|
||||
automationServiceRef.unregisterReceiver(timeZoneListenerInstance);
|
||||
timeZoneListenerActive = false;
|
||||
timezoneListenerActive = false;
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
@ -81,7 +80,7 @@ public class TimeZoneListener extends BroadcastReceiver implements AutomationLis
|
||||
}
|
||||
else if(action.equals(Intent.ACTION_TIME_CHANGED))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "TimeZoneListener", "Device time changed. Reloading alarms.", 4);
|
||||
Miscellaneous.logEvent("i", "TimeZoneListener", "Device time changed. Reloading alarms.", 3);
|
||||
DateTimeListener.reloadAlarms();
|
||||
}
|
||||
}
|
||||
@ -104,7 +103,7 @@ public class TimeZoneListener extends BroadcastReceiver implements AutomationLis
|
||||
@Override
|
||||
public boolean isListenerRunning()
|
||||
{
|
||||
return TimeZoneListener.isTimeZoneListenerActive();
|
||||
return TimeZoneListener.isTimezoneListenerActive();
|
||||
}
|
||||
@Override
|
||||
public Trigger_Enum[] getMonitoredTrigger()
|
||||
|
BIN
app/src/main/res/drawable-hdpi/clipboard.png
Normal file
BIN
app/src/main/res/drawable-hdpi/clipboard.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
BIN
app/src/main/res/drawable-hdpi/coffee.png
Normal file
BIN
app/src/main/res/drawable-hdpi/coffee.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
BIN
app/src/main/res/drawable-hdpi/megaphone.png
Normal file
BIN
app/src/main/res/drawable-hdpi/megaphone.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/main/res/drawable-hdpi/script.png
Normal file
BIN
app/src/main/res/drawable-hdpi/script.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 679 B |
BIN
app/src/main/res/drawable-hdpi/subsystemstate.png
Normal file
BIN
app/src/main/res/drawable-hdpi/subsystemstate.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
10
app/src/main/res/drawable/info.xml
Normal file
10
app/src/main/res/drawable/info.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z"/>
|
||||
</vector>
|
@ -16,14 +16,14 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
|
||||
android:text="@string/settings"
|
||||
android:text="@string/controlCenter"
|
||||
android:layout_marginBottom="@dimen/default_margin"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bMoreSettings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/moreSettings" />
|
||||
android:text="@string/settings" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
@ -83,12 +83,38 @@
|
||||
android:layout_margin="@dimen/default_margin"
|
||||
android:background="#aa000000" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bShareConfigAndLog"
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/emailPretext" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/chkShareConfigAndLog"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="@string/shareConfigAndLogFilesWithDev" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSendEmailToDev"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/sendEmailToDev" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/logsExplanation" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_span="2"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="@dimen/default_margin"
|
||||
android:background="#aa000000" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvFileStoreLocation"
|
||||
android:layout_marginVertical="@dimen/default_margin"
|
@ -37,6 +37,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/generalText" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
@ -151,7 +152,7 @@
|
||||
android:orientation="vertical"
|
||||
android:layout_margin="10dp" >
|
||||
<TextView
|
||||
android:id="@+id/tvTimeFrameHelpText"
|
||||
android:id="@+id/tvLastRule"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/helpTextTimeFrame" />
|
@ -0,0 +1,242 @@
|
||||
<?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/closeNotifications"
|
||||
android:textSize="25dp"
|
||||
android:layout_marginBottom="@dimen/default_margin" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/notificationCloseActionExplanation" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:shrinkColumns="1"
|
||||
android:stretchColumns="1">
|
||||
|
||||
<TableRow
|
||||
android:layout_marginBottom="@dimen/activity_vertical_margin">
|
||||
|
||||
<TextView
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/application" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_marginHorizontal="@dimen/default_margin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/etActivityOrActionPath"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/anyApp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSelectApp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/selectApplication" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_marginVertical="@dimen/default_margin"
|
||||
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
|
||||
android:layout_marginBottom="@dimen/activity_vertical_margin">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/title" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinnerTitleDirection"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etNotificationTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_marginVertical="@dimen/default_margin"
|
||||
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
|
||||
android:layout_marginBottom="@dimen/activity_vertical_margin">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/text" />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinnerTextDirection"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etNotificationText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</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>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSaveActionCloseNotification"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/save" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -0,0 +1,78 @@
|
||||
<?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:layout_span="2"
|
||||
android:textSize="25dp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/actionMediaControl" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/actionMediaControlNotice" />
|
||||
|
||||
<RadioGroup
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaPlayPause"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/playPause" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaPlay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/play" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaPause"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/pause" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaStop"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/stop" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaPrevious"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/previous" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbMediaNext"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/next" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSaveControlMediaAction"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/save" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -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,90 @@
|
||||
<?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/createNotification"
|
||||
android:textSize="25dp"
|
||||
android:layout_marginBottom="@dimen/default_margin" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:shrinkColumns="1"
|
||||
android:stretchColumns="1">
|
||||
|
||||
<TableRow
|
||||
android:layout_marginBottom="@dimen/activity_vertical_margin">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="@dimen/default_margin"
|
||||
android:text="@string/title" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etNotificationTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_marginBottom="@dimen/activity_vertical_margin">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/text" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etNotificationText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_marginVertical="@dimen/default_margin"
|
||||
android:background="#aa000000" />
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLegend"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dip"
|
||||
android:text="@string/urlLegend" />
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSaveActionNotification"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
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>
|
@ -0,0 +1,117 @@
|
||||
<?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="match_parent"
|
||||
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/runExecutable" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/runExecutableExplanation" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:stretchColumns="1"
|
||||
android:shrinkColumns="1">
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/runAsRoot" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/chkRunExecAsRoot"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
</CheckBox>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/path" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etRunExecutablePath"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:inputType="textUri" >
|
||||
|
||||
</EditText>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/default_margin"
|
||||
android:text="@string/parameters" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etRunExecutableParameters"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:inputType="text" >
|
||||
|
||||
</EditText>
|
||||
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bChooseExecutable"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/chooseExecutable" />
|
||||
|
||||
<ScrollView
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLegend"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dip"
|
||||
android:text="@string/urlLegend" />
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSaveActionRunExec"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/save" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -0,0 +1,160 @@
|
||||
<?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:layout_span="2"
|
||||
android:textSize="25dp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/sendBroadcast" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/broadcastExplanation" />
|
||||
|
||||
<TextView
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Broadcast:" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etBroadcastToSend"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bBroadcastSendShowSuggestions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="@dimen/default_margin"
|
||||
android:text="@string/broadcastsShowSuggestions" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:stretchColumns="1"
|
||||
android:shrinkColumns="1" >
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<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/addParameters" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_span="2"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/intentDataComment" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/parameterType" />
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/spinnerParameterType"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvCurrentNfcIdValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/parameterName" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etParameterName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/parameterValue" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etParameterValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bAddIntentPair"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/addIntentValue" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="10dp"
|
||||
android:background="#aa000000" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/lvIntentPairs"
|
||||
android:visibility="gone"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="115dp"
|
||||
android:layout_marginBottom="@dimen/default_margin" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSaveSendBroadcast"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/save" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -41,6 +41,32 @@
|
||||
<requestFocus />
|
||||
</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
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@ -67,6 +93,23 @@
|
||||
android:layout_height="wrap_content"
|
||||
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
|
||||
android:id="@+id/bSaveSendTextMessage"
|
||||
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>
|
@ -2,13 +2,22 @@
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_margin="10dp" >
|
||||
android:layout_margin="@dimen/default_margin" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
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/actionSpeakText" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvRuleTitle"
|
||||
android:layout_width="wrap_content"
|
||||
@ -40,7 +49,7 @@
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSaveTriggerUrl"
|
||||
android:id="@+id/bSaveSpeakText"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -129,6 +129,12 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/startAppBySendBroadcast" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbStartAppByService"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/startAppByStartService" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
</TableRow>
|
||||
|
@ -110,7 +110,7 @@
|
||||
</ScrollView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSaveTriggerUrl"
|
||||
android:id="@+id/bSaveSpeakText"
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
100
app/src/main/res/layout/activity_manage_action_wakelock.xml
Normal file
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>
|
100
app/src/main/res/layout/activity_manage_action_wifi.xml
Normal file
100
app/src/main/res/layout/activity_manage_action_wifi.xml
Normal file
@ -0,0 +1,100 @@
|
||||
<?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/actionSetWifi"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvWifiExplanation1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/wifiExplanation1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvWifiExplanation2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:text="@string/wifiExplanation2" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:stretchColumns="1"
|
||||
android:shrinkColumns="1" >
|
||||
|
||||
<TableRow>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/runAsRoot" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/chkWifiRunAsRoot"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/runAsRoot" />
|
||||
|
||||
</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/state" />
|
||||
|
||||
<RadioGroup
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbActionWifiOn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="@string/on" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbActionWifiOff"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/off" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bActionWifiSave"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:text="@string/save" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user