startApp changes

This commit is contained in:
jens 2021-05-11 20:00:50 +02:00
parent 327a992cac
commit e39f0c2497
8 changed files with 106 additions and 13 deletions

View File

@ -15,6 +15,7 @@ import java.util.Locale;
public class Action public class Action
{ {
public static final String actionParameter2Split = "ap2split"; public static final String actionParameter2Split = "ap2split";
public static final String intentPairSeperator = "intPairSplit";
public enum Action_Enum { public enum Action_Enum {
setWifi, setWifi,
@ -237,6 +238,10 @@ public class Action
else else
returnString.append(": " + components[0]); 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)) else if(this.getAction().equals(Action_Enum.sendTextMessage))
{ {
String[] components = parameter2.split(Actions.smsSeparator); String[] components = parameter2.split(Actions.smsSeparator);

View File

@ -611,7 +611,7 @@ public class Actions
externalActivityIntent = new Intent(); externalActivityIntent = new Intent();
if(params.length > 1 && !params[1].contains("/")) if(params.length > 1 && !params[1].contains(Action.intentPairSeperator))
{ {
externalActivityIntent.setPackage(params[0]); externalActivityIntent.setPackage(params[0]);
externalActivityIntent.setAction(params[1]); externalActivityIntent.setAction(params[1]);
@ -629,7 +629,7 @@ public class Actions
// Pack intents // Pack intents
for (int i = paramsStartIndex; i < params.length; i++) for (int i = paramsStartIndex; i < params.length; i++)
{ {
String[] singleParam = params[i].split("/"); String[] singleParam = params[i].split(Action.intentPairSeperator);
/*Class c = Class.forName(singleParam[0]); /*Class c = Class.forName(singleParam[0]);
for(Method m : c.getMethods()) for(Method m : c.getMethods())
@ -686,6 +686,19 @@ public class Actions
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3); Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
externalActivityIntent.putExtra(singleParam[1], Short.parseShort(singleParam[2])); externalActivityIntent.putExtra(singleParam[1], Short.parseShort(singleParam[2]));
} }
else if (singleParam[0].equals("Uri"))
{
if(singleParam[1].equalsIgnoreCase("IntentData"))
{
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with value " + singleParam[2] + " as standard data parameter.", 3);
externalActivityIntent.setData(Uri.parse(singleParam[2]));
}
else
{
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
externalActivityIntent.putExtra(singleParam[1], Uri.parse(singleParam[2]));
}
}
else if (singleParam[0].equals("String")) else if (singleParam[0].equals("String"))
{ {
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3); Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);

View File

@ -73,7 +73,7 @@ public class ActivityManageActionStartActivity extends Activity
private static List<PackageInfo> pInfos = null; private static List<PackageInfo> pInfos = null;
public static Action resultingAction; public static Action resultingAction;
private static final String[] supportedIntentTypes = { "boolean", "byte", "char", "double", "float", "int", "long", "short", "String" }; private static final String[] supportedIntentTypes = { "boolean", "byte", "char", "double", "float", "int", "long", "short", "String", "Uri" };
private ArrayList<String> intentPairList = new ArrayList<String>(); private ArrayList<String> intentPairList = new ArrayList<String>();
ArrayAdapter<String> intentTypeSpinnerAdapter, intentPairAdapter; ArrayAdapter<String> intentTypeSpinnerAdapter, intentPairAdapter;
@ -281,7 +281,7 @@ public class ActivityManageActionStartActivity extends Activity
protected void onCreate(Bundle savedInstanceState) protected void onCreate(Bundle savedInstanceState)
{ {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.action_start_activity); setContentView(R.layout.activity_manage_action_start_activity);
lvIntentPairs = (ListView)findViewById(R.id.lvIntentPairs); lvIntentPairs = (ListView)findViewById(R.id.lvIntentPairs);
etParameterName = (EditText)findViewById(R.id.etParameterName); etParameterName = (EditText)findViewById(R.id.etParameterName);
@ -329,14 +329,34 @@ public class ActivityManageActionStartActivity extends Activity
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterNameForIntentPair), Toast.LENGTH_LONG).show(); Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterNameForIntentPair), Toast.LENGTH_LONG).show();
return; 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) if(etParameterValue.getText().toString().length() == 0)
{ {
Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterValueForIntentPair), Toast.LENGTH_LONG).show(); Toast.makeText(ActivityManageActionStartActivity.this, getResources().getString(R.string.enterValueForIntentPair), Toast.LENGTH_LONG).show();
return; 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()] + "/" + etParameterName.getText().toString() + "/" + etParameterValue.getText().toString(); String param = supportedIntentTypes[spinnerParameterType.getSelectedItemPosition()] + Action.intentPairSeperator + etParameterName.getText().toString() + Action.intentPairSeperator + etParameterValue.getText().toString();
intentPairList.add(param); intentPairList.add(param);
spinnerParameterType.setSelection(0); spinnerParameterType.setSelection(0);
@ -455,7 +475,7 @@ public class ActivityManageActionStartActivity extends Activity
{ {
if(params.length > 1) // should not occur, have fault tollerance if(params.length > 1) // should not occur, have fault tollerance
{ {
if(params[1].contains("/")) if(params[1].contains(Action.intentPairSeperator))
{ {
etActivityOrActionPath.setText(params[0]); etActivityOrActionPath.setText(params[0]);
startIndex = 1; startIndex = 1;

View File

@ -1158,6 +1158,13 @@ public class XmlFileInterface
} }
} }
} }
else if(newAction.getAction().equals(Action_Enum.startOtherActivity)) // separator has been changed, convert in old files
{
if(tag.contains(Action.intentPairSeperator)) // already has new format
newAction.setParameter2(tag);
else
newAction.setParameter2(tag.replace("/", Action.intentPairSeperator));
}
else else
newAction.setParameter2(tag); newAction.setParameter2(tag);
} }

View File

@ -10,7 +10,26 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Headline" android:textAppearance="@style/TextAppearance.AppCompat.Headline"
android:text="@string/settings" /> android:text="@string/settings"
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" />
<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:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/importExportExplanation" />
<Button <Button
android:id="@+id/bImportConfiguration" android:id="@+id/bImportConfiguration"
@ -24,17 +43,25 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/exportConfiguration" /> android:text="@string/exportConfiguration" />
<ImageView
android:layout_width="match_parent"
android:layout_span="2"
android:layout_height="1dp"
android:layout_margin="@dimen/default_margin"
android:background="#aa000000" />
<Button <Button
android:id="@+id/bVolumeTest" android:id="@+id/bVolumeTest"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/volumeTest" /> android:text="@string/volumeTest" />
<Button <ImageView
android:id="@+id/bMoreSettings"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_span="2"
android:text="@string/moreSettings" /> android:layout_height="1dp"
android:layout_margin="@dimen/default_margin"
android:background="#aa000000" />
<Button <Button
android:id="@+id/bSettingsSetToDefault" android:id="@+id/bSettingsSetToDefault"
@ -42,6 +69,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/defaultSettings" /> 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" />
<Button <Button
android:id="@+id/bShareConfigAndLog" android:id="@+id/bShareConfigAndLog"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -139,6 +139,17 @@
</TableRow> </TableRow>
<TableRow>
<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 <TableRow
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
@ -168,7 +179,7 @@
<EditText <EditText
android:id="@+id/etParameterName" android:id="@+id/etParameterName"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" /> android:layout_height="wrap_content" />
</TableRow> </TableRow>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" <TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="20sp"> android:textSize="20sp">

View File

@ -659,4 +659,7 @@
<string name="noApplicableFilesFoundInDirectory">No applicable files could be found in that directory.</string> <string name="noApplicableFilesFoundInDirectory">No applicable files could be found in that directory.</string>
<string name="noFilesImported">No file could be imported.</string> <string name="noFilesImported">No file could be imported.</string>
<string name="notAllFilesImported">Not all applicable files could be imported.</string> <string name="notAllFilesImported">Not all applicable files could be imported.</string>
<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>
</resources> </resources>