From 135f4594be4dc5af17cacedd60fcfda5bfbbe17b Mon Sep 17 00:00:00 2001 From: Jens Date: Sun, 2 Oct 2022 23:26:27 +0200 Subject: [PATCH] call phone --- app/src/apkFlavor/AndroidManifest.xml | 3 +-- app/src/main/java/com/jens/automation2/Action.java | 2 +- app/src/main/java/com/jens/automation2/Actions.java | 3 ++- ...ll.java => ActivityManageActionMakePhoneCall.java} | 4 ++-- .../java/com/jens/automation2/ActivityManageRule.java | 11 +++++++---- .../com/jens/automation2/ActivityPermissions.java | 5 +++++ .../layout/activity_manage_action_make_phone_call.xml | 3 ++- app/src/main/res/values-de/strings.xml | 3 ++- app/src/main/res/values-es/strings.xml | 3 ++- app/src/main/res/values-fr/strings.xml | 3 ++- app/src/main/res/values-it/strings.xml | 3 ++- app/src/main/res/values-nl/strings.xml | 3 ++- app/src/main/res/values-ru/strings.xml | 3 ++- app/src/main/res/values/strings.xml | 3 ++- 14 files changed, 34 insertions(+), 18 deletions(-) rename app/src/main/java/com/jens/automation2/{ActivityManageMakePhoneCall.java => ActivityManageActionMakePhoneCall.java} (89%) diff --git a/app/src/apkFlavor/AndroidManifest.xml b/app/src/apkFlavor/AndroidManifest.xml index 008fbc4c..0f26db0c 100644 --- a/app/src/apkFlavor/AndroidManifest.xml +++ b/app/src/apkFlavor/AndroidManifest.xml @@ -68,7 +68,6 @@ - @@ -173,7 +172,7 @@ - + diff --git a/app/src/main/java/com/jens/automation2/Action.java b/app/src/main/java/com/jens/automation2/Action.java index d8449b52..d6e6fb14 100644 --- a/app/src/main/java/com/jens/automation2/Action.java +++ b/app/src/main/java/com/jens/automation2/Action.java @@ -281,7 +281,7 @@ public class Action 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()) + ")"); + returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.makePhoneCall)); break; default: returnString.append(action.toString()); diff --git a/app/src/main/java/com/jens/automation2/Actions.java b/app/src/main/java/com/jens/automation2/Actions.java index 3cc69ff7..4a4f3125 100644 --- a/app/src/main/java/com/jens/automation2/Actions.java +++ b/app/src/main/java/com/jens/automation2/Actions.java @@ -2190,7 +2190,8 @@ public class Actions { 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); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.addFlags(Intent.FLAG_FROM_BACKGROUND); 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/ActivityManageActionMakePhoneCall.java similarity index 89% rename from app/src/main/java/com/jens/automation2/ActivityManageMakePhoneCall.java rename to app/src/main/java/com/jens/automation2/ActivityManageActionMakePhoneCall.java index 53141f21..864255a3 100644 --- a/app/src/main/java/com/jens/automation2/ActivityManageMakePhoneCall.java +++ b/app/src/main/java/com/jens/automation2/ActivityManageActionMakePhoneCall.java @@ -12,7 +12,7 @@ import androidx.annotation.Nullable; import org.apache.commons.lang3.StringUtils; -public class ActivityManageMakePhoneCall extends Activity +public class ActivityManageActionMakePhoneCall extends Activity { EditText etTargetPhoneNumber; Button bActionMakePhoneCallSave; @@ -47,7 +47,7 @@ public class ActivityManageMakePhoneCall extends Activity finish(); } else - Toast.makeText(ActivityManageMakePhoneCall.this, getResources().getText(R.string.enterPhoneNumber), Toast.LENGTH_SHORT).show(); + Toast.makeText(ActivityManageActionMakePhoneCall.this, getResources().getText(R.string.enterPhoneNumber), Toast.LENGTH_SHORT).show(); } }); } diff --git a/app/src/main/java/com/jens/automation2/ActivityManageRule.java b/app/src/main/java/com/jens/automation2/ActivityManageRule.java index 8d026805..383388dd 100644 --- a/app/src/main/java/com/jens/automation2/ActivityManageRule.java +++ b/app/src/main/java/com/jens/automation2/ActivityManageRule.java @@ -419,7 +419,7 @@ public class ActivityManageRule extends Activity startActivityForResult(activityEditRunExecutableIntent, requestCodeActionRunExecutableEdit); break; case makePhoneCall: - Intent activityEditMakePhoneCallIntent = new Intent(ActivityManageRule.this, ActivityManageMakePhoneCall.class); + Intent activityEditMakePhoneCallIntent = new Intent(ActivityManageRule.this, ActivityManageActionMakePhoneCall.class); activityEditMakePhoneCallIntent.putExtra(intentNameActionParameter1, a.getParameter1()); activityEditMakePhoneCallIntent.putExtra(intentNameActionParameter2, a.getParameter2()); startActivityForResult(activityEditMakePhoneCallIntent, requestCodeActionMakePhoneCallEdit); @@ -1063,7 +1063,7 @@ public class ActivityManageRule extends Activity AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setTitle(myContext.getResources().getString(R.string.phoneNumber)); - alertDialog.setMessage(myContext.getResources().getString(R.string.enterPhoneNumber)); + alertDialog.setMessage(myContext.getResources().getString(R.string.enterPhoneNumberBlankForAny)); // Set an EditText view to get user input final EditText input = new EditText(this); @@ -2006,7 +2006,10 @@ public class ActivityManageRule extends Activity 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)); + { + if(ActivityPermissions.isPermissionDeclaratedInManifest(ActivityManageRule.this, Manifest.permission.CALL_PHONE)) + 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)) @@ -2182,7 +2185,7 @@ public class ActivityManageRule extends Activity else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.makePhoneCall.toString())) { newAction.setAction(Action_Enum.makePhoneCall); - Intent intent = new Intent(ActivityManageRule.this, ActivityManageMakePhoneCall.class); + Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionMakePhoneCall.class); startActivityForResult(intent, requestCodeActionMakePhoneCallAdd); } else if(Action.getActionTypesAsArray()[which].toString().equals(Action_Enum.wakelock.toString())) diff --git a/app/src/main/java/com/jens/automation2/ActivityPermissions.java b/app/src/main/java/com/jens/automation2/ActivityPermissions.java index 17e40464..01f73e99 100644 --- a/app/src/main/java/com/jens/automation2/ActivityPermissions.java +++ b/app/src/main/java/com/jens/automation2/ActivityPermissions.java @@ -681,6 +681,7 @@ public class ActivityPermissions extends Activity break; case makePhoneCall: addToArrayListUnique(Manifest.permission.CALL_PHONE, requiredPermissions); +// addToArrayListUnique(Manifest.permission.SYSTEM_ALERT_WINDOW, requiredPermissions); break; default: break; @@ -873,6 +874,10 @@ public class ActivityPermissions extends Activity for(String ruleName : getRulesUsing(Action.Action_Enum.sendTextMessage)) usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); break; + case Manifest.permission.CALL_PHONE: + for(String ruleName : getRulesUsing(Action.Action_Enum.makePhoneCall)) + usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName)); + break; case Manifest.permission.FOREGROUND_SERVICE: usingElements.add(getResources().getString(R.string.startAutomationAsService)); 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 index f9a43379..8d2aeadb 100644 --- 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 @@ -45,7 +45,8 @@ + android:layout_height="wrap_content" + android:inputType="phone"/> diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 977049ea..db1cfe7f 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -270,7 +270,8 @@ Telefongespräch mit Telefonnummer - Geben Sie eine Telefonnummer ein. Leer lassen für irgendeine Nummer. + Geben Sie eine Telefonnummer ein. Leer lassen für irgendeine Nummer. + Geben Sie eine Telefonnummer ein. Wählen Sie die\nGesprächsrichtung egal eingehend diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 6f016452..0211c77c 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -254,7 +254,8 @@ Auriculares (tipo: %1$s) desconectados Llamada Número de teléfono - Inserte numero de teléfono. Vacio para algún número. + Inserte numero de teléfono. Vacio para algún número. + Inserte numero de teléfono. Elija llamada\nentrante o saliente Auriculares Elija tipo de auriculares diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 3879f97c..8e11d99d 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -273,7 +273,8 @@ Appel téléphonique avec Numéro de téléphone - Saisissez un numéro de téléphone. Laissez vide pour n\'importe quel numéro. + Saisissez un numéro de téléphone. Laissez vide pour n\'importe quel numéro. + Saisissez un numéro de téléphone. Sélectionnez le type \nd\'appel tout entrant diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 5362239d..78bf0ae7 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -179,7 +179,8 @@ Inserisci un nome. Definisci un nome per la coppia dell\'Intent Inserisci un nome di pacchetto che sia valido. - Inserisci un numero di telefono. Lascia vuoto per accettare qualsiasi numero. + Inserisci un numero di telefono. Lascia vuoto per accettare qualsiasi numero. + Inserisci un numero di telefono. Inserisci una azione valida Inserisci un valore di riferimento valido. Definisci un valore per la coppia dell\'Intent. diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 1f688279..1f5bef9d 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -268,7 +268,8 @@ Telefoongesprek met Telefoonnummer - Voer telefoonnummer in. Laat leeg voor een willekeurig nummer. + Voer telefoonnummer in. Laat leeg voor een willekeurig nummer. + Voer telefoonnummer in. Selecteer gespreksrichting een willekeurig binnenkomend diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 259d82e8..1dc8e121 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -302,7 +302,8 @@ Телефонный звонок с Номер телефона - Введите номер телефона. Оставьте пустым для любого номера телефона. + Введите номер телефона. Оставьте пустым для любого номера телефона. + Введите номер телефона. Выберите вызов\nнаправление Любой входящий diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4726a9cf..56346c05 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -341,7 +341,8 @@ Phone call with Phone number - Enter phone number. Leave empty for any number. + Enter phone number. Leave empty for any number. + Enter phone number. Select call\ndirection any incoming