send emails

This commit is contained in:
jens committed 2026-10-18 18:16:10 +02:00
1 parent 0231051138
commit 3fe1c590ca
5 files changed
+24 -7

No files matched your search

@@ -1,6 +1,7 @@
package com.jens.automation2; package com.jens.automation2;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.util.Log; import android.util.Log;
@@ -8,10 +9,8 @@ import android.widget.Toast;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
@@ -61,7 +60,8 @@ public class Action
sendTextMessage, sendTextMessage,
takeScreenshot, takeScreenshot,
setSystemSetting, setSystemSetting,
sendEmail; sendEmail,
stopService;
public String getFullName(Context context) public String getFullName(Context context)
{ {
@@ -137,6 +137,8 @@ public class Action
return context.getResources().getString(R.string.setSystemSettingCapital); return context.getResources().getString(R.string.setSystemSettingCapital);
case sendEmail: case sendEmail:
return context.getResources().getString(R.string.sendEmail); return context.getResources().getString(R.string.sendEmail);
case stopService:
return context.getResources().getString(R.string.stopService);
default: default:
return "Unknown"; return "Unknown";
} }
@@ -326,6 +328,9 @@ public class Action
break; break;
} }
break; break;
case stopService:
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.stopService));
break;
default: default:
returnString.append(action.toString()); returnString.append(action.toString());
} }
@@ -649,6 +654,9 @@ public class Action
case sendEmail: case sendEmail:
Actions.sendEmailFromAction(this); Actions.sendEmailFromAction(this);
break; break;
case stopService:
Intent myServiceIntent = new Intent(Miscellaneous.getAnyContext(), AutomationService.class);
Miscellaneous.getAnyContext().stopService(myServiceIntent);
default: default:
Miscellaneous.logEvent("w", "Action", context.getResources().getString(R.string.unknownActionSpecified), 3); Miscellaneous.logEvent("w", "Action", context.getResources().getString(R.string.unknownActionSpecified), 3);
break; break;
@@ -2380,6 +2380,8 @@ public class ActivityManageRule extends Activity
} }
else if(types[i].toString().equals(Action_Enum.setSystemSetting.toString())) else if(types[i].toString().equals(Action_Enum.setSystemSetting.toString()))
items.add(new Item(typesLong[i].toString(), R.drawable.gears_small)); items.add(new Item(typesLong[i].toString(), R.drawable.gears_small));
else if(types[i].toString().equals(Action_Enum.stopService.toString()))
items.add(new Item(typesLong[i].toString(), R.drawable.stop_service));
else else
items.add(new Item(typesLong[i].toString(), R.drawable.placeholder)); items.add(new Item(typesLong[i].toString(), R.drawable.placeholder));
} }
@@ -2630,6 +2632,12 @@ public class ActivityManageRule extends Activity
Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionSendEmail.class); Intent intent = new Intent(ActivityManageRule.this, ActivityManageActionSendEmail.class);
startActivityForResult(intent, requestCodeActionSendEmailAdd); startActivityForResult(intent, requestCodeActionSendEmailAdd);
} }
else if(actionTypes[which].toString().equals(Action_Enum.stopService.toString()))
{
newAction.setAction(Action_Enum.stopService);
ruleToEdit.getActionSet().add(newAction);
refreshActionList();
}
} }
}); });
@@ -2078,7 +2078,7 @@ public class Miscellaneous extends Service
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); Miscellaneous.logEvent("e", "unzip()", Log.getStackTraceString(e), 1);
} }
} }
@@ -2115,7 +2115,7 @@ public class Miscellaneous extends Service
} }
catch (Exception e) catch (Exception e)
{ {
System.out.println(e); Miscellaneous.logEvent("e", "unzip()", Log.getStackTraceString(e), 1);
} }
} }
@@ -2128,9 +2128,8 @@ public class Miscellaneous extends Service
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{targetAddress}); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{targetAddress});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
if (fileAttachment != null) if (fileAttachment != null)
{
emailIntent.putExtra(Intent.EXTRA_STREAM, fileAttachment); emailIntent.putExtra(Intent.EXTRA_STREAM, fileAttachment);
}
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
context.startActivity(Intent.createChooser(emailIntent, "Sending email...")); context.startActivity(Intent.createChooser(emailIntent, "Sending email..."));
} }
+1
View File
@@ -1001,4 +1001,5 @@
<string name="emailSubject">Subject</string> <string name="emailSubject">Subject</string>
<string name="enterAllValues">Enter all values.</string> <string name="enterAllValues">Enter all values.</string>
<string name="emailConfigurationNotice">Remember to configure an SMTP server in settings.</string> <string name="emailConfigurationNotice">Remember to configure an SMTP server in settings.</string>
<string name="stopService">Stop service</string>
</resources> </resources>
@@ -1,5 +1,6 @@
* Added: Triggers and actions can now be cloned * Added: Triggers and actions can now be cloned
* Added: URL checker for triggerUrl action * Added: URL checker for triggerUrl action
* Added: Send emails as action * Added: Send emails as action
* Added: Stop service as action
* Fixed: Crash when starting to add/edit a triggerURL action while the app or the system are set to the German language * Fixed: Crash when starting to add/edit a triggerURL action while the app or the system are set to the German language
* Fixed: Crash when starting service in Google Play version * Fixed: Crash when starting service in Google Play version