Enabled variables as intent parameters

This commit is contained in:
Jens 2023-05-05 23:26:32 +02:00
parent bd2920e6d9
commit a76cafc6e2
3 changed files with 35 additions and 9 deletions

View File

@ -10,8 +10,6 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile; import android.bluetooth.BluetoothProfile;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.media.AudioManager; import android.media.AudioManager;
@ -1166,21 +1164,36 @@ public class Actions
} }
else if (singleParam[0].equals("Uri")) else if (singleParam[0].equals("Uri"))
{ {
if (singleParam[1].equalsIgnoreCase("IntentData")) try
{ {
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with value " + singleParam[2] + " as standard data parameter.", 3); if (singleParam[1].equalsIgnoreCase("IntentData"))
intent.setData(Uri.parse(singleParam[2])); {
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with value " + singleParam[2] + " as standard data parameter.", 3);
intent.setData(Uri.parse(Miscellaneous.replaceVariablesInText(singleParam[2], context)));
}
else
{
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3);
intent.putExtra(singleParam[1], Uri.parse(Miscellaneous.replaceVariablesInText(singleParam[2], context)));
}
} }
else catch (Exception e)
{ {
Miscellaneous.logEvent("i", "StartOtherApp", "Adding parameter of type " + singleParam[0] + " with name " + singleParam[1] + " and value " + singleParam[2], 3); throw new RuntimeException(e);
intent.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);
intent.putExtra(singleParam[1], singleParam[2]); try
{
intent.putExtra(singleParam[1], Miscellaneous.replaceVariablesInText(singleParam[2], context));
}
catch (Exception e)
{
intent.putExtra(singleParam[1], singleParam[2]);
}
} }
else else
Miscellaneous.logEvent("w", "StartOtherApp", "Unknown type of parameter " + singleParam[0] + " found. Name " + singleParam[1] + " and value " + singleParam[2], 3); Miscellaneous.logEvent("w", "StartOtherApp", "Unknown type of parameter " + singleParam[0] + " found. Name " + singleParam[1] + " and value " + singleParam[2], 3);

View File

@ -304,6 +304,18 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/addIntentValue" /> android:text="@string/addIntentValue" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25dp"
android:text="@string/variablesOnlyForTypes" />
<TextView
android:id="@+id/tvLegend"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/urlLegend" />
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"

View File

@ -884,4 +884,5 @@
<string name="textToCopy">Text to copy</string> <string name="textToCopy">Text to copy</string>
<string name="android.permission.SYSTEM_ALERT_WINDOW">Draw over other apps</string> <string name="android.permission.SYSTEM_ALERT_WINDOW">Draw over other apps</string>
<string name="overlayPermissionHint">After clicking OK you\'ll be sent to a system dialog. Please select Automation there and allow "draw over other apps".</string> <string name="overlayPermissionHint">After clicking OK you\'ll be sent to a system dialog. Please select Automation there and allow "draw over other apps".</string>
<string name="variablesOnlyForTypes">Variables are only available for parameter types String and URI</string>
</resources> </resources>