diff --git a/app/src/main/java/com/jens/automation2/Action.java b/app/src/main/java/com/jens/automation2/Action.java
index e50735c..9f1d688 100644
--- a/app/src/main/java/com/jens/automation2/Action.java
+++ b/app/src/main/java/com/jens/automation2/Action.java
@@ -1,6 +1,7 @@
package com.jens.automation2;
import android.content.Context;
+import android.content.Intent;
import android.os.AsyncTask;
import android.os.Build;
import android.util.Log;
@@ -8,10 +9,8 @@ import android.widget.Toast;
import org.apache.commons.lang3.StringUtils;
-import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Locale;
import java.util.Map;
@@ -61,7 +60,8 @@ public class Action
sendTextMessage,
takeScreenshot,
setSystemSetting,
- sendEmail;
+ sendEmail,
+ stopService;
public String getFullName(Context context)
{
@@ -137,6 +137,8 @@ public class Action
return context.getResources().getString(R.string.setSystemSettingCapital);
case sendEmail:
return context.getResources().getString(R.string.sendEmail);
+ case stopService:
+ return context.getResources().getString(R.string.stopService);
default:
return "Unknown";
}
@@ -326,6 +328,9 @@ public class Action
break;
}
break;
+ case stopService:
+ returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.stopService));
+ break;
default:
returnString.append(action.toString());
}
@@ -649,6 +654,9 @@ public class Action
case sendEmail:
Actions.sendEmailFromAction(this);
break;
+ case stopService:
+ Intent myServiceIntent = new Intent(Miscellaneous.getAnyContext(), AutomationService.class);
+ Miscellaneous.getAnyContext().stopService(myServiceIntent);
default:
Miscellaneous.logEvent("w", "Action", context.getResources().getString(R.string.unknownActionSpecified), 3);
break;
diff --git a/app/src/main/java/com/jens/automation2/ActivityManageRule.java b/app/src/main/java/com/jens/automation2/ActivityManageRule.java
index fa19852..beedf6f 100644
--- a/app/src/main/java/com/jens/automation2/ActivityManageRule.java
+++ b/app/src/main/java/com/jens/automation2/ActivityManageRule.java
@@ -2380,6 +2380,8 @@ public class ActivityManageRule extends Activity
}
else if(types[i].toString().equals(Action_Enum.setSystemSetting.toString()))
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
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);
startActivityForResult(intent, requestCodeActionSendEmailAdd);
}
+ else if(actionTypes[which].toString().equals(Action_Enum.stopService.toString()))
+ {
+ newAction.setAction(Action_Enum.stopService);
+ ruleToEdit.getActionSet().add(newAction);
+ refreshActionList();
+ }
}
});
diff --git a/app/src/main/java/com/jens/automation2/Miscellaneous.java b/app/src/main/java/com/jens/automation2/Miscellaneous.java
index 3a32330..309b966 100644
--- a/app/src/main/java/com/jens/automation2/Miscellaneous.java
+++ b/app/src/main/java/com/jens/automation2/Miscellaneous.java
@@ -2078,7 +2078,7 @@ public class Miscellaneous extends Service
}
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)
{
- 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_SUBJECT, subject);
if (fileAttachment != null)
- {
emailIntent.putExtra(Intent.EXTRA_STREAM, fileAttachment);
- }
+
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message);
context.startActivity(Intent.createChooser(emailIntent, "Sending email..."));
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index aae990d..dce0ea6 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1001,4 +1001,5 @@
Subject
Enter all values.
Remember to configure an SMTP server in settings.
+ Stop service
\ No newline at end of file
diff --git a/fastlane/metadata/android/en-US/changelogs/150.txt b/fastlane/metadata/android/en-US/changelogs/150.txt
index ace8a76..f02408e 100644
--- a/fastlane/metadata/android/en-US/changelogs/150.txt
+++ b/fastlane/metadata/android/en-US/changelogs/150.txt
@@ -1,5 +1,6 @@
* Added: Triggers and actions can now be cloned
* Added: URL checker for triggerUrl 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 service in Google Play version
\ No newline at end of file