diff --git a/app/src/apkFlavor/AndroidManifest.xml b/app/src/apkFlavor/AndroidManifest.xml
index 714c2b82..008fbc4c 100644
--- a/app/src/apkFlavor/AndroidManifest.xml
+++ b/app/src/apkFlavor/AndroidManifest.xml
@@ -66,6 +66,8 @@
+
+
+
diff --git a/app/src/fdroidFlavor/AndroidManifest.xml b/app/src/fdroidFlavor/AndroidManifest.xml
index 37fd4ca2..51aacdc5 100644
--- a/app/src/fdroidFlavor/AndroidManifest.xml
+++ b/app/src/fdroidFlavor/AndroidManifest.xml
@@ -64,6 +64,7 @@
+
+
diff --git a/app/src/main/java/com/jens/automation2/Action.java b/app/src/main/java/com/jens/automation2/Action.java
index e758ee31..d8449b52 100644
--- a/app/src/main/java/com/jens/automation2/Action.java
+++ b/app/src/main/java/com/jens/automation2/Action.java
@@ -6,8 +6,6 @@ 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;
@@ -54,6 +52,7 @@ public class Action
sendBroadcast,
runExecutable,
wakelock,
+ makePhoneCall,
sendTextMessage;
public String getFullName(Context context)
@@ -130,6 +129,8 @@ public class Action
return context.getResources().getString(R.string.runExecutable);
case wakelock:
return context.getResources().getString(R.string.keepDeviceAwake);
+ case makePhoneCall:
+ return context.getResources().getString(R.string.makePhoneCall);
default:
return "Unknown";
}
@@ -279,6 +280,9 @@ public class Action
case wakelock:
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.keepDeviceAwake) + " (" + String.valueOf(getParameter1()) + ")");
break;
+ case makePhoneCall:
+ returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.makePhoneCall) + " (" + String.valueOf(getParameter2()) + ")");
+ break;
default:
returnString.append(action.toString());
}
@@ -590,6 +594,9 @@ public class Action
else
Actions.wakeLockStop();
break;
+ case makePhoneCall:
+ Actions.makePhoneCall(context, this.getParameter2());
+ break;
default:
Miscellaneous.logEvent("w", "Action", context.getResources().getString(R.string.unknownActionSpecified), 3);
break;
diff --git a/app/src/main/java/com/jens/automation2/Actions.java b/app/src/main/java/com/jens/automation2/Actions.java
index de1db7f4..3cc69ff7 100644
--- a/app/src/main/java/com/jens/automation2/Actions.java
+++ b/app/src/main/java/com/jens/automation2/Actions.java
@@ -10,13 +10,10 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.content.ActivityNotFoundException;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.media.MediaPlayer;
-import android.media.session.MediaController;
-import android.media.session.MediaSessionManager;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.net.wifi.WifiManager;
@@ -26,7 +23,6 @@ import android.os.PowerManager.WakeLock;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.provider.MediaStore;
-import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.telephony.SmsManager;
import android.telephony.SubscriptionManager;
@@ -36,7 +32,6 @@ import android.view.KeyEvent;
import android.widget.Toast;
import androidx.annotation.RequiresApi;
-import androidx.legacy.content.WakefulBroadcastReceiver;
import com.jens.automation2.actions.wifi_router.MyOnStartTetheringCallback;
import com.jens.automation2.actions.wifi_router.MyOreoWifiManager;
@@ -44,7 +39,6 @@ import com.jens.automation2.location.WifiBroadcastReceiver;
import com.jens.automation2.receivers.ConnectivityReceiver;
import com.jens.automation2.receivers.NotificationListener;
-import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.HttpClient;
import org.apache.http.conn.ClientConnectionManager;
@@ -71,7 +65,6 @@ 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;
@@ -2192,4 +2185,12 @@ public class Actions
Miscellaneous.logEvent("i", "WakeLockStart", "Requesting stop.", 4);
wakeLockStopRequested = true;
}
+
+ public static void makePhoneCall(Context context, String phoneNumber)
+ {
+ Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber));
+// intent.setClassName("com.android.phone","com.android.phone.OutgoingCallBroadcaster");
+ intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ context.startActivity(intent);
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/jens/automation2/ActivityManageMakePhoneCall.java b/app/src/main/java/com/jens/automation2/ActivityManageMakePhoneCall.java
new file mode 100644
index 00000000..53141f21
--- /dev/null
+++ b/app/src/main/java/com/jens/automation2/ActivityManageMakePhoneCall.java
@@ -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 ActivityManageMakePhoneCall 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(ActivityManageMakePhoneCall.this, getResources().getText(R.string.enterPhoneNumber), Toast.LENGTH_SHORT).show();
+ }
+ });
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/jens/automation2/ActivityManageRule.java b/app/src/main/java/com/jens/automation2/ActivityManageRule.java
index 931379fb..8d026805 100644
--- a/app/src/main/java/com/jens/automation2/ActivityManageRule.java
+++ b/app/src/main/java/com/jens/automation2/ActivityManageRule.java
@@ -133,6 +133,8 @@ public class ActivityManageRule extends Activity
final static int requestCodeActionWakeLockEdit = 820;
final static int requestCodeTriggerSubSystemStateAdd = 821;
final static int requestCodeTriggerSubSystemStateEdit = 822;
+ final static int requestCodeActionMakePhoneCallAdd = 823;
+ final static int requestCodeActionMakePhoneCallEdit = 824;
public static ActivityManageRule getInstance()
{
@@ -416,6 +418,12 @@ public class ActivityManageRule extends Activity
activityEditRunExecutableIntent.putExtra(intentNameActionParameter2, a.getParameter2());
startActivityForResult(activityEditRunExecutableIntent, requestCodeActionRunExecutableEdit);
break;
+ case makePhoneCall:
+ Intent activityEditMakePhoneCallIntent = new Intent(ActivityManageRule.this, ActivityManageMakePhoneCall.class);
+ activityEditMakePhoneCallIntent.putExtra(intentNameActionParameter1, a.getParameter1());
+ activityEditMakePhoneCallIntent.putExtra(intentNameActionParameter2, a.getParameter2());
+ startActivityForResult(activityEditMakePhoneCallIntent, requestCodeActionMakePhoneCallEdit);
+ break;
case setWifi:
Intent activityEditSetWifiIntent = new Intent(ActivityManageRule.this, ActivityManageActionWifi.class);
activityEditSetWifiIntent.putExtra(intentNameActionParameter1, a.getParameter1());
@@ -1582,6 +1590,17 @@ public class ActivityManageRule extends Activity
this.refreshActionList();
}
}
+ else if(requestCode == requestCodeActionMakePhoneCallAdd)
+ {
+ if(resultCode == RESULT_OK)
+ {
+ newAction.setParentRule(ruleToEdit);
+ newAction.setParameter1(data.getBooleanExtra(intentNameActionParameter1, false));
+ newAction.setParameter2(data.getStringExtra(intentNameActionParameter2));
+ ruleToEdit.getActionSet().add(newAction);
+ this.refreshActionList();
+ }
+ }
else if(requestCode == requestCodeActionWakeLockAdd)
{
if(resultCode == RESULT_OK)
@@ -1692,6 +1711,21 @@ public class ActivityManageRule extends Activity
this.refreshActionList();
}
}
+ else if(requestCode == requestCodeActionMakePhoneCallEdit)
+ {
+ if(resultCode == RESULT_OK)
+ {
+ ruleToEdit.getActionSet().get(editIndex).setParentRule(ruleToEdit);
+
+ if(data.hasExtra(intentNameActionParameter1) && data.hasExtra(intentNameActionParameter2))
+ {
+ ruleToEdit.getActionSet().get(editIndex).setParameter1(data.getBooleanExtra(intentNameActionParameter1, false));
+ ruleToEdit.getActionSet().get(editIndex).setParameter2(data.getStringExtra(intentNameActionParameter2));
+ }
+
+ this.refreshActionList();
+ }
+ }
else if(requestCode == requestCodeActionSetWifiEdit)
{
if(resultCode == RESULT_OK)
@@ -1971,6 +2005,8 @@ public class ActivityManageRule extends Activity
items.add(new Item(typesLong[i].toString(), R.drawable.coffee));
else if(types[i].toString().equals(Action_Enum.runExecutable.toString()))
items.add(new Item(typesLong[i].toString(), R.drawable.script));
+ else if(types[i].toString().equals(Action_Enum.makePhoneCall.toString()))
+ items.add(new Item(typesLong[i].toString(), R.drawable.phone));
else if(types[i].toString().equals(Action_Enum.sendTextMessage.toString()))
{
// if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageSpecificRule.this, "android.permission.SEND_SMS") && !Miscellaneous.isGooglePlayInstalled(ActivityManageSpecificRule.this))
@@ -2143,6 +2179,12 @@ public class ActivityManageRule extends Activity
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionRunExecutable.class);
startActivityForResult(intent, requestCodeActionRunExecutableAdd);
}
+ else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.makePhoneCall.toString()))
+ {
+ newAction.setAction(Action_Enum.makePhoneCall);
+ Intent intent = new Intent(ActivityManageRule.this, ActivityManageMakePhoneCall.class);
+ startActivityForResult(intent, requestCodeActionMakePhoneCallAdd);
+ }
else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.wakelock.toString()))
{
newAction.setAction(Action_Enum.wakelock);
diff --git a/app/src/main/java/com/jens/automation2/ActivityPermissions.java b/app/src/main/java/com/jens/automation2/ActivityPermissions.java
index 915e802a..17e40464 100644
--- a/app/src/main/java/com/jens/automation2/ActivityPermissions.java
+++ b/app/src/main/java/com/jens/automation2/ActivityPermissions.java
@@ -679,6 +679,9 @@ public class ActivityPermissions extends Activity
else
addToArrayListUnique(Manifest.permission.BIND_DEVICE_ADMIN, requiredPermissions);
break;
+ case makePhoneCall:
+ addToArrayListUnique(Manifest.permission.CALL_PHONE, requiredPermissions);
+ break;
default:
break;
}
diff --git a/app/src/main/res/layout/activity_manage_action_make_phone_call.xml b/app/src/main/res/layout/activity_manage_action_make_phone_call.xml
new file mode 100644
index 00000000..f9a43379
--- /dev/null
+++ b/app/src/main/res/layout/activity_manage_action_make_phone_call.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 3ff3add8..b779389c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -851,4 +851,7 @@
Type
Cable
Bluetooth tethering can currently not be detected. Only the other means of connection will activate this trigger.
+ Make phone call
+ Make phone call
+ Here you can enter a phone number that will be called without further prompts. You may use this to make settings like making adjustments to call routing, etc.. Please search for the codes required for this on your own.
\ No newline at end of file