forked from jens/Automation
Compare commits
50 Commits
master
...
developmen
Author | SHA1 | Date |
---|---|---|
|
2361c758c9 | |
|
f738e02b72 | |
|
f5a3636222 | |
|
bb1b3b0149 | |
|
b35208b7aa | |
|
b3ad72cc50 | |
|
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 | |
|
965bf55811 | |
|
13fd4c2aae | |
|
195a60cfe0 | |
|
76563eb89b | |
|
7733d57435 | |
|
481e4d1896 | |
|
5af59e1754 | |
|
619f348a28 | |
|
9bf353ea3a | |
|
af90b566c8 | |
|
0e51c577d5 |
|
@ -11,8 +11,8 @@ android {
|
|||
compileSdkVersion 31
|
||||
buildToolsVersion '29.0.2'
|
||||
useLibrary 'org.apache.http.legacy'
|
||||
versionCode 119
|
||||
versionName "1.7.5"
|
||||
versionCode 120
|
||||
versionName "1.7.6"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ android {
|
|||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
|
||||
flavorDimensions "version"
|
||||
|
||||
productFlavors
|
||||
|
@ -57,6 +56,7 @@ android {
|
|||
abortOnError false
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
namespace 'com.jens.automation2'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
|
@ -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"
|
||||
|
@ -159,12 +158,17 @@
|
|||
<activity android:name=".ActivityManageTriggerTimeFrame" />
|
||||
<activity android:name=".ActivityControlCenter" />
|
||||
<activity android:name=".ActivityManageTriggerPhoneCall" />
|
||||
<activity android:name=".ActivityManageTriggerBroadcast" />
|
||||
<activity android:name=".ActivityManageActionBrightnessSetting" />
|
||||
<activity android:name=".ActivityManageActionCreateNotification" />
|
||||
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
|
||||
<activity android:name=".ActivityHelp" />
|
||||
<activity android:name=".ActivityManageActionVibrate" />
|
||||
<activity android:name=".ActivityManageActionControlMedia" />
|
||||
<activity android:name=".ActivityManageActionSendBroadcast" />
|
||||
<activity android:name=".ActivityManageActionRunExecutable" />
|
||||
<activity android:name=".ActivityManageActionWifi" />
|
||||
<activity android:name=".ActivityManageTriggerTethering" />
|
||||
<activity
|
||||
android:name=".ActivityMainTabLayout"
|
||||
android:launchMode="singleTask">
|
||||
|
|
|
@ -12,6 +12,7 @@ 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;
|
||||
|
@ -348,6 +349,10 @@ public class Rule implements Comparable<Rule>
|
|||
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;
|
||||
|
@ -386,7 +391,8 @@ 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
@ -157,12 +156,17 @@
|
|||
<activity android:name=".ActivityManageTriggerTimeFrame" />
|
||||
<activity android:name=".ActivityControlCenter" />
|
||||
<activity android:name=".ActivityManageTriggerPhoneCall" />
|
||||
<activity android:name=".ActivityManageTriggerBroadcast" />
|
||||
<activity android:name=".ActivityManageActionBrightnessSetting" />
|
||||
<activity android:name=".ActivityManageActionCreateNotification" />
|
||||
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
|
||||
<activity android:name=".ActivityHelp" />
|
||||
<activity android:name=".ActivityManageActionVibrate" />
|
||||
<activity android:name=".ActivityManageActionControlMedia" />
|
||||
<activity android:name=".ActivityManageActionSendBroadcast" />
|
||||
<activity android:name=".ActivityManageActionRunExecutable" />
|
||||
<activity android:name=".ActivityManageActionWifi" />
|
||||
<activity android:name=".ActivityManageTriggerTethering" />
|
||||
<activity
|
||||
android:name=".ActivityMainTabLayout"
|
||||
android:launchMode="singleTask">
|
||||
|
|
|
@ -10,6 +10,7 @@ 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;
|
||||
|
@ -345,6 +346,10 @@ public class Rule implements Comparable<Rule>
|
|||
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;
|
||||
|
@ -383,7 +388,8 @@ 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,7 +64,6 @@
|
|||
<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"/>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
@ -145,12 +143,17 @@
|
|||
<activity android:name=".ActivityManageTriggerTimeFrame" />
|
||||
<activity android:name=".ActivityControlCenter" />
|
||||
<activity android:name=".ActivityManageTriggerPhoneCall" />
|
||||
<activity android:name=".ActivityManageTriggerBroadcast" />
|
||||
<activity android:name=".ActivityManageActionBrightnessSetting" />
|
||||
<activity android:name=".ActivityManageActionCreateNotification" />
|
||||
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
|
||||
<activity android:name=".ActivityHelp" />
|
||||
<activity android:name=".ActivityManageActionVibrate" />
|
||||
<activity android:name=".ActivityManageActionControlMedia" />
|
||||
<activity android:name=".ActivityManageActionSendBroadcast" />
|
||||
<activity android:name=".ActivityManageActionRunExecutable" />
|
||||
<activity android:name=".ActivityManageActionWifi" />
|
||||
<activity android:name=".ActivityManageTriggerTethering" />
|
||||
<activity
|
||||
android:name=".ActivityMainTabLayout"
|
||||
android:launchMode="singleTask">
|
||||
|
|
|
@ -12,6 +12,7 @@ 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;
|
||||
|
@ -348,6 +349,10 @@ public class Rule implements Comparable<Rule>
|
|||
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;
|
||||
|
@ -386,7 +391,8 @@ 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +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">
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ import android.os.Build;
|
|||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
|
||||
|
@ -21,108 +23,115 @@ public class Action
|
|||
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,
|
||||
controlMediaPlayback,
|
||||
setScreenBrightness,
|
||||
playSound,
|
||||
vibrate,
|
||||
createNotification,
|
||||
closeNotification,
|
||||
sendTextMessage;
|
||||
|
||||
public String getFullName(Context context)
|
||||
{
|
||||
switch(this)
|
||||
{
|
||||
case setWifi:
|
||||
return context.getResources().getString(R.string.actionSetWifi);
|
||||
case setBluetooth:
|
||||
return context.getResources().getString(R.string.actionSetBluetooth);
|
||||
case setWifiTethering:
|
||||
return context.getResources().getString(R.string.actionSetWifiTethering);
|
||||
case setBluetoothTethering:
|
||||
return context.getResources().getString(R.string.actionSetBluetoothTethering);
|
||||
case setUsbTethering:
|
||||
return context.getResources().getString(R.string.actionSetUsbTethering);
|
||||
case setDisplayRotation:
|
||||
return context.getResources().getString(R.string.actionSetDisplayRotation);
|
||||
case turnWifiOn:
|
||||
return context.getResources().getString(R.string.actionTurnWifiOn);
|
||||
case turnWifiOff:
|
||||
return context.getResources().getString(R.string.actionTurnWifiOff);
|
||||
case turnBluetoothOn:
|
||||
return context.getResources().getString(R.string.actionTurnBluetoothOn);
|
||||
case turnBluetoothOff:
|
||||
return context.getResources().getString(R.string.actionTurnBluetoothOff);
|
||||
case triggerUrl:
|
||||
return context.getResources().getString(R.string.actionTriggerUrl);
|
||||
case changeSoundProfile:
|
||||
return context.getResources().getString(R.string.actionChangeSoundProfile);
|
||||
case turnUsbTetheringOn:
|
||||
return context.getResources().getString(R.string.actionTurnUsbTetheringOn);
|
||||
case turnUsbTetheringOff:
|
||||
return context.getResources().getString(R.string.actionTurnUsbTetheringOff);
|
||||
case turnWifiTetheringOn:
|
||||
return context.getResources().getString(R.string.actionTurnWifiTetheringOn);
|
||||
case turnWifiTetheringOff:
|
||||
return context.getResources().getString(R.string.actionTurnWifiTetheringOff);
|
||||
case enableScreenRotation:
|
||||
return context.getResources().getString(R.string.actionEnableScreenRotation);
|
||||
case disableScreenRotation:
|
||||
return context.getResources().getString(R.string.actionDisableScreenRotation);
|
||||
case startOtherActivity:
|
||||
return context.getResources().getString(R.string.startOtherActivity);
|
||||
case waitBeforeNextAction:
|
||||
return context.getResources().getString(R.string.waitBeforeNextAction);
|
||||
case turnScreenOnOrOff:
|
||||
return context.getResources().getString(R.string.turnScreenOnOrOff);
|
||||
case vibrate:
|
||||
return context.getResources().getString(R.string.vibrate);
|
||||
case setAirplaneMode:
|
||||
return context.getResources().getString(R.string.airplaneMode);
|
||||
case setDataConnection:
|
||||
return context.getResources().getString(R.string.actionDataConnection);
|
||||
case speakText:
|
||||
return context.getResources().getString(R.string.actionSpeakText);
|
||||
case playMusic:
|
||||
return context.getResources().getString(R.string.actionPlayMusic);
|
||||
case controlMediaPlayback:
|
||||
return context.getResources().getString(R.string.actionMediaControl);
|
||||
case playSound:
|
||||
return context.getResources().getString(R.string.playSound);
|
||||
case sendTextMessage:
|
||||
return context.getResources().getString(R.string.sendTextMessage);
|
||||
case setScreenBrightness:
|
||||
return context.getResources().getString(R.string.setScreenBrightness);
|
||||
case createNotification:
|
||||
return context.getResources().getString(R.string.createNotification);
|
||||
case closeNotification:
|
||||
return context.getResources().getString(R.string.closeNotifications);
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
};
|
||||
public enum Action_Enum
|
||||
{
|
||||
setWifi,
|
||||
setBluetooth,
|
||||
setUsbTethering,
|
||||
setWifiTethering,
|
||||
setBluetoothTethering,
|
||||
setDisplayRotation,
|
||||
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,
|
||||
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);
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private Action_Enum action;
|
||||
private boolean parameter1 = false;
|
||||
|
@ -258,6 +267,12 @@ public class Action
|
|||
case closeNotification:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.closeNotifications));
|
||||
break;
|
||||
case sendBroadcast:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.sendBroadcast));
|
||||
break;
|
||||
case runExecutable:
|
||||
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.runExecutable));
|
||||
break;
|
||||
default:
|
||||
returnString.append(action.toString());
|
||||
}
|
||||
|
@ -315,7 +330,15 @@ public class Action
|
|||
|
||||
if (parts.length > 4 && !StringUtils.isBlank(parts[4]))
|
||||
returnString.append(", " + Miscellaneous.getAnyContext().getResources().getString(R.string.ifString) + " " + Miscellaneous.getAnyContext().getResources().getString(R.string.text) + " " + Trigger.getMatchString(parts[3]) + " " + parts[4]);
|
||||
|
||||
}
|
||||
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))
|
||||
{
|
||||
|
@ -430,7 +453,7 @@ public class Action
|
|||
|
||||
return (String[])actionTypesList.toArray(new String[actionTypesList.size()]);
|
||||
}
|
||||
|
||||
|
||||
public void run(Context context, boolean toggleActionIfPossible)
|
||||
{
|
||||
try
|
||||
|
@ -533,6 +556,16 @@ public class Action
|
|||
else
|
||||
Miscellaneous.logEvent("w", "Close notification", "Close notification was requested, but OS version is too low: " + String.valueOf(Build.VERSION.SDK_INT), 2);
|
||||
break;
|
||||
case sendBroadcast:
|
||||
Actions.sendBroadcast(context, this.getParameter2());
|
||||
break;
|
||||
case runExecutable:
|
||||
String[] execParts = this.getParameter2().split(Action.actionParameter2Split);
|
||||
if(execParts.length == 1)
|
||||
Actions.runExecutable(context, this.getParameter1(), execParts[0], null);
|
||||
else if(execParts.length == 2)
|
||||
Actions.runExecutable(context, this.getParameter1(), execParts[0], execParts[1]);
|
||||
break;
|
||||
default:
|
||||
Miscellaneous.logEvent("w", "Action", context.getResources().getString(R.string.unknownActionSpecified), 3);
|
||||
break;
|
||||
|
@ -636,7 +669,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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,12 @@ import org.apache.http.conn.ssl.SSLSocketFactory;
|
|||
import org.apache.http.conn.util.InetAddressUtils;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
@ -62,8 +67,11 @@ import java.net.NetworkInterface;
|
|||
import java.security.KeyStore;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
||||
|
@ -185,7 +193,24 @@ public class Actions
|
|||
}
|
||||
}
|
||||
|
||||
public static class WifiStuff
|
||||
public static void sendBroadcast(Context context, String action)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "sendBroadcast", "Sending broadcast with action " + action, 5);
|
||||
Intent broadcastIntent = new Intent();
|
||||
|
||||
if(action.contains(Action.actionParameter2Split))
|
||||
{
|
||||
String[] parts = action.split(Action.actionParameter2Split);
|
||||
broadcastIntent.setAction(parts[0]);
|
||||
add params
|
||||
}
|
||||
else
|
||||
broadcastIntent.setAction(action);
|
||||
|
||||
context.sendBroadcast(broadcastIntent);
|
||||
}
|
||||
|
||||
public static class WifiStuff
|
||||
{
|
||||
public static Boolean setWifi(Context context, Boolean desiredState, boolean toggleActionIfPossible)
|
||||
{
|
||||
|
@ -1899,4 +1924,187 @@ public class Actions
|
|||
return android.provider.Settings.Global.getInt(context.getContentResolver(), android.provider.Settings.Global.AIRPLANE_MODE_ON, 0) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean runExecutable(Context context, boolean runAsRoot, String path, String parameters)
|
||||
{
|
||||
if(runAsRoot)
|
||||
{
|
||||
if(!StringUtils.isEmpty(parameters))
|
||||
return executeCommandViaSu(new String[] { path + " " + parameters });
|
||||
else
|
||||
return executeCommandViaSu(new String[] { path });
|
||||
}
|
||||
else
|
||||
{
|
||||
Object[] result;
|
||||
|
||||
File executable = new File(path);
|
||||
File workingDir = new File(executable.getParent());
|
||||
|
||||
if(!StringUtils.isEmpty(parameters))
|
||||
result = runExternalApplication(path, 0, workingDir, parameters);
|
||||
else
|
||||
result = runExternalApplication(path, 0, workingDir, null);
|
||||
|
||||
boolean execResult = (boolean) result[0];
|
||||
|
||||
return execResult;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param commandToExecute
|
||||
* @param timeout
|
||||
* @param params
|
||||
* @return Returns an array: 0=exit code, 1=cmdline output
|
||||
*/
|
||||
public static Object[] runExternalApplication(String commandToExecute, long timeout, File workingDirectory, String params)
|
||||
{
|
||||
/*
|
||||
* Classes stolen from https://github.com/stleary/JSON-java
|
||||
*/
|
||||
|
||||
String fullCommand;
|
||||
|
||||
if(!StringUtils.isEmpty(params))
|
||||
fullCommand = commandToExecute + " " + params;
|
||||
else
|
||||
fullCommand = commandToExecute;
|
||||
|
||||
Miscellaneous.logEvent("i", "Running executable", "Running external application " + fullCommand, 4);
|
||||
|
||||
Object[] returnObject = new Object[2];
|
||||
|
||||
StringBuilder output = new StringBuilder();
|
||||
String line = null;
|
||||
OutputStream stdin = null;
|
||||
InputStream stderr = null;
|
||||
InputStream stdout = null;
|
||||
|
||||
try
|
||||
{
|
||||
Process process = null;
|
||||
|
||||
if(workingDirectory != null)
|
||||
process = Runtime.getRuntime().exec(fullCommand, null, workingDirectory);
|
||||
else
|
||||
process = Runtime.getRuntime().exec(fullCommand);
|
||||
stdin = process.getOutputStream ();
|
||||
stderr = process.getErrorStream ();
|
||||
stdout = process.getInputStream ();
|
||||
|
||||
// "write" the parms into stdin
|
||||
/*line = "param1" + "\n";
|
||||
stdin.write(line.getBytes() );
|
||||
stdin.flush();
|
||||
|
||||
line = "param2" + "\n";
|
||||
stdin.write(line.getBytes() );
|
||||
stdin.flush();
|
||||
|
||||
line = "param3" + "\n";
|
||||
stdin.write(line.getBytes() );
|
||||
stdin.flush();*/
|
||||
|
||||
stdin.close();
|
||||
|
||||
// clean up if any output in stdout
|
||||
BufferedReader brCleanUp = new BufferedReader (new InputStreamReader (stdout));
|
||||
while ((line = brCleanUp.readLine ()) != null)
|
||||
{
|
||||
Miscellaneous.logEvent ("i", "Running executable", "[Stdout] " + line, 4);
|
||||
output.append(line);
|
||||
}
|
||||
brCleanUp.close();
|
||||
|
||||
// clean up if any output in stderr
|
||||
brCleanUp = new BufferedReader (new InputStreamReader(stderr));
|
||||
while ((line = brCleanUp.readLine ()) != null)
|
||||
{
|
||||
Miscellaneous.logEvent ("i", "Running executable", "[Stderr] " + line, 4);
|
||||
output.append(line);
|
||||
}
|
||||
brCleanUp.close();
|
||||
|
||||
try
|
||||
{
|
||||
// Wait for the process to exit, we want the return code
|
||||
if(timeout > 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(!process.waitFor(timeout, TimeUnit.MILLISECONDS))
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Running executable", "Timeout of " + String.valueOf(timeout) + " ms reached. Killing check attempt.", 3);
|
||||
process.destroyForcibly();
|
||||
}
|
||||
}
|
||||
catch(NoSuchMethodError e)
|
||||
{
|
||||
process.waitFor();
|
||||
}
|
||||
}
|
||||
else
|
||||
process.waitFor();
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "Running executable", "Waiting for process failed: " + Log.getStackTraceString(e), 4);
|
||||
Miscellaneous.logEvent("i", "Running executable", Log.getStackTraceString(e), 1);
|
||||
}
|
||||
|
||||
if(process.exitValue() == 0)
|
||||
Miscellaneous.logEvent("i", "Running executable", "ReturnCode: " + String.valueOf(process.exitValue()), 4);
|
||||
else
|
||||
Miscellaneous.logEvent("i", "Running executable", "External execution (RC=" + String.valueOf(process.exitValue()) + ") returned error: " + output.toString(), 3);
|
||||
|
||||
returnObject[0] = process.exitValue();
|
||||
returnObject[1] = output.toString();
|
||||
|
||||
return returnObject;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "Running executable", Log.getStackTraceString(e), 1);
|
||||
}
|
||||
|
||||
Miscellaneous.logEvent("i", "Running executable", "Error running external application.", 1);
|
||||
|
||||
// if(slotMap != null)
|
||||
// for(String key : slotMap.keySet())
|
||||
// System.clearProperty(key);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean isTetheringActive1(Context context)
|
||||
{
|
||||
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"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Miscellaneous.logEvent("e", "isTetheringActive()", Log.getStackTraceString(e), 3);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -353,11 +353,15 @@ public class ActivityControlCenter extends Activity
|
|||
systemInfoText.append("Device details" + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("OS version: " + System.getProperty("os.version") + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("API Level: " + android.os.Build.VERSION.SDK + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Target SDK: " + Miscellaneous.getAnyContext().getApplicationInfo().targetSdkVersion + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Device: " + android.os.Build.DEVICE + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Model: " + android.os.Build.MODEL + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Product: " + android.os.Build.PRODUCT + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Rooted: " + String.valueOf(Miscellaneous.isPhoneRooted()) + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Country: " + Miscellaneous.getUserCountry(Miscellaneous.getAnyContext()) + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("OS language: " + Locale.getDefault().getDisplayName());
|
||||
systemInfoText.append("OS language: " + Locale.getDefault().getDisplayName() + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Logfile written: " + String.valueOf(Settings.writeLogFile) + Miscellaneous.lineSeparator);
|
||||
systemInfoText.append("Log level: " + String.valueOf(Settings.logLevel));
|
||||
|
||||
/*
|
||||
I've checked the Locale methods on my Android 4.1.2 device, and the results:
|
||||
|
|
|
@ -77,10 +77,9 @@ public class ActivityMainScreen extends ActivityGeneric
|
|||
tvLockSoundDuration = (TextView)findViewById(R.id.tvlockSoundDuration);
|
||||
tbLockSound = (ToggleButton) findViewById(R.id.tbLockSound);
|
||||
toggleService = (ToggleButton) findViewById(R.id.tbArmMastListener);
|
||||
|
||||
bDonate = (Button)findViewById(R.id.bDonate);
|
||||
|
||||
if(!BuildConfig.FLAVOR.equalsIgnoreCase("googlePlayFlavor"))
|
||||
if(!BuildConfig.FLAVOR.equalsIgnoreCase(AutomationService.flavor_name_googleplay))
|
||||
bDonate.setVisibility(View.VISIBLE);
|
||||
|
||||
toggleService.setChecked(AutomationService.isMyServiceRunning(this));
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.jens.automation2;
|
||||
|
||||
import static com.jens.automation2.Trigger.triggerParameter2Split;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
|
@ -18,8 +16,6 @@ import android.view.View;
|
|||
import android.view.View.OnClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
@ -49,7 +45,6 @@ public class ActivityManageActionCloseNotification extends Activity
|
|||
TextView tvSelectedApplication;
|
||||
|
||||
private static List<PackageInfo> pInfos = null;
|
||||
public static Trigger resultingTrigger;
|
||||
|
||||
private static String[] directions;
|
||||
|
||||
|
@ -271,6 +266,7 @@ public class ActivityManageActionCloseNotification 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)
|
||||
|
|
|
@ -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,256 @@
|
|||
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;
|
||||