forked from jens/Automation
WG now works. Many small changes and fixes.
This commit is contained in:
parent
d257c4ccb0
commit
f79efa7739
@ -56,7 +56,8 @@ public class Actions
|
||||
private static String suVersion = null;
|
||||
private static String suVersionInternal = null;
|
||||
private static List<String> suResult = null;
|
||||
final static String smsSeparator = "&sms&";
|
||||
public final static String smsSeparator = "&sms&";
|
||||
public final static String dummyPackageString = "dummyPkg239asd";
|
||||
|
||||
public static final String wireguard_tunnel_up = "com.wireguard.android.action.SET_TUNNEL_UP";
|
||||
public static final String wireguard_tunnel_down = "com.wireguard.android.action.SET_TUNNEL_DOWN";
|
||||
@ -611,23 +612,16 @@ public class Actions
|
||||
|
||||
externalActivityIntent = new Intent();
|
||||
|
||||
if(params.length > 1 && !params[1].contains(Action.intentPairSeperator))
|
||||
{
|
||||
if(!params[0].equals(dummyPackageString))
|
||||
externalActivityIntent.setPackage(params[0]);
|
||||
externalActivityIntent.setAction(params[1]);
|
||||
paramsStartIndex = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
externalActivityIntent.setAction(params[0]);
|
||||
paramsStartIndex = 1;
|
||||
}
|
||||
|
||||
externalActivityIntent.setAction(params[1]);
|
||||
}
|
||||
|
||||
externalActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
// Pack intents
|
||||
for (int i = paramsStartIndex; i < params.length; i++)
|
||||
for (int i = 3; i < params.length; i++)
|
||||
{
|
||||
String[] singleParam = params[i].split(Action.intentPairSeperator);
|
||||
|
||||
@ -708,8 +702,10 @@ public class Actions
|
||||
Miscellaneous.logEvent("w", "StartOtherApp", "Unknown type of parameter " + singleParam[0] + " found. Name " + singleParam[1] + " and value " + singleParam[2], 3);
|
||||
}
|
||||
|
||||
// autoMationServerRef.sendBroadcast(externalActivityIntent);
|
||||
autoMationServerRef.startActivity(externalActivityIntent);
|
||||
if(params[2].equals(ActivityManageActionStartActivity.startByActivityString))
|
||||
autoMationServerRef.startActivity(externalActivityIntent);
|
||||
else
|
||||
autoMationServerRef.sendBroadcast(externalActivityIntent);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
|
@ -10,6 +10,7 @@ import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
@ -38,13 +39,21 @@ import java.util.List;
|
||||
|
||||
public class ActivityManageActionStartActivity extends Activity
|
||||
{
|
||||
/*
|
||||
This page might qualify as a help page: https://stackoverflow.com/questions/55323947/open-url-in-firefox-for-android-using-intent
|
||||
*/
|
||||
|
||||
ListView lvIntentPairs;
|
||||
EditText etParameterName, etParameterValue, etPackageName, etActivityOrActionPath;
|
||||
Button bSelectApp, bAddIntentPair, bSaveActionStartOtherActivity;
|
||||
Button bSelectApp, bAddIntentPair, bSaveActionStartOtherActivity, showStartProgramExamples;
|
||||
Spinner spinnerParameterType;
|
||||
boolean edit = false;
|
||||
ProgressDialog progressDialog = null;
|
||||
RadioButton rbStartAppSelectByActivity, rbStartAppSelectByAction;
|
||||
RadioButton rbStartAppSelectByActivity, rbStartAppSelectByAction, rbStartAppByActivity, rbStartAppByBroadcast;
|
||||
|
||||
final String urlShowExamples = "https://server47.de/automation/examples_startProgram.html";
|
||||
final static String startByActivityString = "0";
|
||||
final static String startByBroadcastString = "1";
|
||||
|
||||
private class CustomPackageInfo extends PackageInfo implements Comparable<CustomPackageInfo>
|
||||
{
|
||||
@ -269,7 +278,8 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
public void onClick(DialogInterface dialog, int which)
|
||||
{
|
||||
ActivityInfo ai = ActivityManageActionStartActivity.getActivityInfoForPackageNameAndActivityName(packageName, activityArray[which]);
|
||||
etActivityOrActionPath.setText(ai.packageName + ";" + ai.name);
|
||||
etPackageName.setText(ai.packageName);
|
||||
etActivityOrActionPath.setText(ai.name);
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
@ -294,6 +304,10 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
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);
|
||||
@ -370,6 +384,16 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
}
|
||||
});
|
||||
|
||||
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
|
||||
@ -458,42 +482,27 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
|
||||
String[] params = resultingAction.getParameter2().split(";");
|
||||
|
||||
rbStartAppByActivity.setChecked(params[2].equals(startByActivityString));
|
||||
rbStartAppByBroadcast.setChecked(params[2].equals(startByBroadcastString));
|
||||
|
||||
int startIndex = -1;
|
||||
|
||||
if(!selectionByAction)
|
||||
{
|
||||
etPackageName.setText(params[0]);
|
||||
if(params.length > 1) // should not occur, have fault tollerance
|
||||
{
|
||||
etActivityOrActionPath.setText(params[1]);
|
||||
|
||||
if (params.length >= 2)
|
||||
startIndex = 2;
|
||||
}
|
||||
etActivityOrActionPath.setText(params[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(params.length > 1) // should not occur, have fault tollerance
|
||||
{
|
||||
if(params[1].contains(Action.intentPairSeperator))
|
||||
{
|
||||
etActivityOrActionPath.setText(params[0]);
|
||||
startIndex = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
etPackageName.setText(params[0]);
|
||||
etActivityOrActionPath.setText(params[1]);
|
||||
startIndex = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
etActivityOrActionPath.setText(params[0]);
|
||||
startIndex = 1;
|
||||
}
|
||||
if(!params[0].contains(Actions.dummyPackageString))
|
||||
etPackageName.setText(params[0]);
|
||||
|
||||
etActivityOrActionPath.setText(params[1]);
|
||||
}
|
||||
|
||||
if (params.length >= 3)
|
||||
startIndex = 3;
|
||||
|
||||
if(startIndex > -1 && params.length > startIndex)
|
||||
{
|
||||
intentPairList.clear();
|
||||
@ -549,18 +558,23 @@ public class ActivityManageActionStartActivity extends Activity
|
||||
|
||||
resultingAction.setAction(Action_Enum.startOtherActivity);
|
||||
|
||||
String parameter2;
|
||||
String parameter2 = "";
|
||||
|
||||
if(rbStartAppSelectByActivity.isChecked())
|
||||
parameter2 = etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString();
|
||||
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();
|
||||
parameter2 += etPackageName.getText().toString() + ";" + etActivityOrActionPath.getText().toString();
|
||||
else
|
||||
parameter2 = etActivityOrActionPath.getText().toString();
|
||||
parameter2 += Actions.dummyPackageString + ";" + etActivityOrActionPath.getText().toString();
|
||||
}
|
||||
|
||||
if(rbStartAppByActivity.isChecked())
|
||||
parameter2 += ";" + startByActivityString;
|
||||
else
|
||||
parameter2 += ";" + startByBroadcastString;
|
||||
|
||||
for(String s : intentPairList)
|
||||
parameter2 += ";" + s;
|
||||
|
||||
|
@ -581,11 +581,11 @@ public class AutomationService extends Service implements OnInitListener
|
||||
if(activePoi == null)
|
||||
{
|
||||
PointOfInterest closestPoi = PointOfInterest.getClosestPOI(instance.getLocationProvider().getCurrentLocation());
|
||||
bodyText = "Active POI: none" + "\n" + "Closest POI: " + 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 = "Active POI: " + activePoi.getName() + lastRuleString;
|
||||
bodyText = AutomationService.getInstance().getResources().getString(R.string.activePoi) + ": " + activePoi.getName() + lastRuleString;
|
||||
}
|
||||
}
|
||||
catch(NullPointerException e)
|
||||
|
@ -1160,10 +1160,30 @@ public class XmlFileInterface
|
||||
}
|
||||
else if(newAction.getAction().equals(Action_Enum.startOtherActivity)) // separator has been changed, convert in old files
|
||||
{
|
||||
String newTag;
|
||||
|
||||
if(tag.contains(Action.intentPairSeperator)) // already has new format
|
||||
newAction.setParameter2(tag);
|
||||
newTag = tag;
|
||||
else
|
||||
newAction.setParameter2(tag.replace("/", Action.intentPairSeperator));
|
||||
newTag = tag.replace("/", Action.intentPairSeperator);
|
||||
|
||||
String[] newTagPieces = newTag.split(";");
|
||||
|
||||
if(newTagPieces.length < 2 || (!newTagPieces[0].contains(Actions.dummyPackageString) && newTagPieces[1].contains(Action.intentPairSeperator)))
|
||||
{
|
||||
newTag = Actions.dummyPackageString + ";" + newTag;
|
||||
newTagPieces = newTag.split(";");
|
||||
}
|
||||
|
||||
if(newTagPieces.length < 3)
|
||||
newTag += ";" + ActivityManageActionStartActivity.startByActivityString;
|
||||
else if(newTagPieces.length >= 3)
|
||||
{
|
||||
if(newTagPieces[2].contains(Action.intentPairSeperator))
|
||||
newTag = newTagPieces[0] + ";" + newTagPieces[1] + ";" + ActivityManageActionStartActivity.startByActivityString + ";" + newTagPieces[2];
|
||||
}
|
||||
|
||||
newAction.setParameter2(newTag);
|
||||
}
|
||||
else
|
||||
newAction.setParameter2(tag);
|
||||
|
@ -1,93 +1,102 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_margin="@dimen/default_margin">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/default_margin" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
|
||||
android:text="@string/settings"
|
||||
android:layout_marginBottom="@dimen/default_margin"/>
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent">
|
||||
|
||||
<Button
|
||||
android:id="@+id/bMoreSettings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/moreSettings" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
|
||||
android:text="@string/settings"
|
||||
android:layout_marginBottom="@dimen/default_margin"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_span="2"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="@dimen/default_margin"
|
||||
android:background="#aa000000" />
|
||||
<Button
|
||||
android:id="@+id/bMoreSettings"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/moreSettings" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/importExportExplanation" />
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_span="2"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="@dimen/default_margin"
|
||||
android:background="#aa000000" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bImportConfiguration"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/importConfiguration" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/importExportExplanation" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bExportConfiguration"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/exportConfiguration" />
|
||||
<Button
|
||||
android:id="@+id/bImportConfiguration"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/importConfiguration" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_span="2"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="@dimen/default_margin"
|
||||
android:background="#aa000000" />
|
||||
<Button
|
||||
android:id="@+id/bExportConfiguration"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/exportConfiguration" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bVolumeTest"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/volumeTest" />
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_span="2"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="@dimen/default_margin"
|
||||
android:background="#aa000000" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_span="2"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="@dimen/default_margin"
|
||||
android:background="#aa000000" />
|
||||
<Button
|
||||
android:id="@+id/bVolumeTest"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/volumeTest" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSettingsSetToDefault"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/defaultSettings" />
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_span="2"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="@dimen/default_margin"
|
||||
android:background="#aa000000" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_span="2"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="@dimen/default_margin"
|
||||
android:background="#aa000000" />
|
||||
<Button
|
||||
android:id="@+id/bSettingsSetToDefault"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/defaultSettings" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bShareConfigAndLog"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/shareConfigAndLogFilesWithDev" />
|
||||
<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"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<Button
|
||||
android:id="@+id/bShareConfigAndLog"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/shareConfigAndLogFilesWithDev" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
<TextView
|
||||
android:id="@+id/tvFileStoreLocation"
|
||||
android:layout_marginVertical="@dimen/default_margin"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
</ScrollView>
|
@ -44,6 +44,18 @@
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/showStartProgramExamples"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:layout_span="2"
|
||||
android:text="@string/openExamplesPage" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
@ -76,6 +88,64 @@
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_span="2"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="10dp"
|
||||
android:background="#aa000000" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/startAppStartType" />
|
||||
|
||||
<RadioGroup
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbStartAppByActivity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="@string/startAppByStartActivity" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/rbStartAppByBroadcast"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/startAppBySendBroadcast" />
|
||||
|
||||
</RadioGroup>
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_span="2"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="10dp"
|
||||
android:background="#aa000000" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
@ -662,4 +662,8 @@
|
||||
<string name="importExportExplanation">When clicking import or export you select the directory from which files are imported or exported to. When exporting existing files might get overwritten.</string>
|
||||
<string name="intentDataComment">If your parameter is of type Uri AND you specify \"IntentData\" as name (lower/upper case is not important), the parameter will not be added as a normal parameter with putExtra(), but will instead be added to the intent with setData().</string>
|
||||
<string name="stringNotAllowed">String %1$s is not allowed.</string>
|
||||
<string name="startAppStartType">Select start type</string>
|
||||
<string name="startAppByStartActivity">by startActivity()</string>
|
||||
<string name="startAppBySendBroadcast">by sendBroadcast()</string>
|
||||
<string name="openExamplesPage">Open webpage with examples</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user