forked from jens/Automation
make phone call action
This commit is contained in:
parent
a0910e620f
commit
5baa40ed59
@ -66,6 +66,8 @@
|
||||
<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"/>
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.telephony"
|
||||
@ -171,6 +173,7 @@
|
||||
<activity android:name=".ActivityManageTriggerTethering" />
|
||||
<activity android:name=".ActivityManageActionWakeLock" />
|
||||
<activity android:name=".ActivityManageTriggerSubSystemState" />
|
||||
<activity android:name=".ActivityManageMakePhoneCall" />
|
||||
<activity
|
||||
android:name=".ActivityMainTabLayout"
|
||||
android:launchMode="singleTask">
|
||||
|
@ -64,6 +64,7 @@
|
||||
<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"/>
|
||||
<uses-permission android:name="android.permission.CALL_PHONE" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.telephony"
|
||||
@ -169,6 +170,7 @@
|
||||
<activity android:name=".ActivityManageTriggerTethering" />
|
||||
<activity android:name=".ActivityManageActionWakeLock" />
|
||||
<activity android:name=".ActivityManageTriggerSubSystemState" />
|
||||
<activity android:name=".ActivityManageMakePhoneCall" />
|
||||
<activity
|
||||
android:name=".ActivityMainTabLayout"
|
||||
android:launchMode="singleTask">
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -0,0 +1,63 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_margin="@dimen/default_margin" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_span="2"
|
||||
android:textSize="25dp"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginBottom="@dimen/default_margin"
|
||||
android:text="@string/makePhoneCall"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvMakePhoneCallExplanation1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/makePhoneCallExplanation1" />
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:stretchColumns="1"
|
||||
android:shrinkColumns="1" >
|
||||
|
||||
<TableRow
|
||||
android:layout_marginTop="@dimen/default_margin">
|
||||
|
||||
<TextView
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/default_margin"
|
||||
android:text="@string/phoneNumber" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etTargetPhoneNumber"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/bActionMakePhoneCallSave"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:text="@string/save" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
@ -851,4 +851,7 @@
|
||||
<string name="type">Type</string>
|
||||
<string name="cable">Cable</string>
|
||||
<string name="tetheringBluetoothNotPossible">Bluetooth tethering can currently not be detected. Only the other means of connection will activate this trigger.</string>
|
||||
<string name="makePhoneCall">Make phone call</string>
|
||||
<string name="android.permission.CALL_PHONE">Make phone call</string>
|
||||
<string name="makePhoneCallExplanation1">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.</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user