diff --git a/app/src/apkFlavor/AndroidManifest.xml b/app/src/apkFlavor/AndroidManifest.xml
index 6f843ef..41dd23a 100644
--- a/app/src/apkFlavor/AndroidManifest.xml
+++ b/app/src/apkFlavor/AndroidManifest.xml
@@ -266,6 +266,10 @@
+
+
diff --git a/app/src/fdroidFlavor/AndroidManifest.xml b/app/src/fdroidFlavor/AndroidManifest.xml
index af39e62..e02e028 100644
--- a/app/src/fdroidFlavor/AndroidManifest.xml
+++ b/app/src/fdroidFlavor/AndroidManifest.xml
@@ -251,6 +251,10 @@
+
+
diff --git a/app/src/googlePlayFlavor/AndroidManifest.xml b/app/src/googlePlayFlavor/AndroidManifest.xml
index 1c67849..cbc088a 100644
--- a/app/src/googlePlayFlavor/AndroidManifest.xml
+++ b/app/src/googlePlayFlavor/AndroidManifest.xml
@@ -250,6 +250,10 @@
+
+
diff --git a/app/src/main/java/com/jens/automation2/Action.java b/app/src/main/java/com/jens/automation2/Action.java
index 2c3c359..da60524 100644
--- a/app/src/main/java/com/jens/automation2/Action.java
+++ b/app/src/main/java/com/jens/automation2/Action.java
@@ -640,6 +640,9 @@ public class Action
case copyToClipboard:
Actions.copyToClipboard(context, Miscellaneous.replaceVariablesInText(this.getParameter2(), context));
break;
+ case takeScreenshot:
+ Actions.takeScreenshot();
+ break;
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 b012e1a..b5c6205 100644
--- a/app/src/main/java/com/jens/automation2/ActivityManageRule.java
+++ b/app/src/main/java/com/jens/automation2/ActivityManageRule.java
@@ -2127,7 +2127,7 @@ public class ActivityManageRule extends Activity
else if(types[i].toString().equals(Action_Enum.copyToClipboard.toString()))
items.add(new Item(typesLong[i].toString(), R.drawable.clipboard));
else if(types[i].toString().equals(Action_Enum.takeScreenshot.toString()))
- items.add(new Item(typesLong[i].toString(), R.drawable.clipboard));
+ items.add(new Item(typesLong[i].toString(), R.drawable.copier));
else
items.add(new Item(typesLong[i].toString(), R.drawable.placeholder));
}
diff --git a/app/src/main/java/com/jens/automation2/ActivityPermissions.java b/app/src/main/java/com/jens/automation2/ActivityPermissions.java
index 43a9c2d..87b4716 100644
--- a/app/src/main/java/com/jens/automation2/ActivityPermissions.java
+++ b/app/src/main/java/com/jens/automation2/ActivityPermissions.java
@@ -333,31 +333,33 @@ public class ActivityPermissions extends Activity
{
int accessibilityEnabled = 0;
- final String service = mContext.getPackageName() + "/com.mytest.accessibility.MyAccessibilityService";
+ final String service = mContext.getPackageName() + "/" + BuildConfig.APPLICATION_ID + ".MyAccessibilityService";
boolean accessibilityFound = false;
try
{
accessibilityEnabled = Settings.Secure.getInt(mContext.getApplicationContext().getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED);
- Log.v(TAG, "accessibilityEnabled = " + accessibilityEnabled);
+// Log.v(TAG, "accessibilityEnabled = " + accessibilityEnabled);
}
catch (Settings.SettingNotFoundException e)
{
- Log.e(TAG, "Error finding setting, default accessibility to not found: " + e.getMessage());
+// Log.e(TAG, "Error finding setting, default accessibility to not found: " + e.getMessage());
}
TextUtils.SimpleStringSplitter mStringColonSplitter = new TextUtils.SimpleStringSplitter(':');
- if (accessibilityEnabled == 1) {
- String settingValue = Settings.Secure.getString(mContext
- .getApplicationContext().getContentResolver(),
- Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
- if (settingValue != null) {
+ if (accessibilityEnabled == 1)
+ {
+ String settingValue = Settings.Secure.getString(mContext.getApplicationContext().getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
+ if (settingValue != null)
+ {
TextUtils.SimpleStringSplitter splitter = mStringColonSplitter;
splitter.setString(settingValue);
- while (splitter.hasNext()) {
- String accessabilityService = splitter.next();
+ while (splitter.hasNext())
+ {
+ String accessibilityService = splitter.next();
- if (accessabilityService.equalsIgnoreCase(service)) {
+ if (accessibilityService.equalsIgnoreCase(service))
+ {
return true;
}
}
@@ -1026,7 +1028,9 @@ public class ActivityPermissions extends Activity
usingElements.add(getResources().getString(R.string.queryAllPackages));
break;
case Manifest.permission.BIND_ACCESSIBILITY_SERVICE:
- usingElements.add(getResources().getString(R.string.bindAccessibilityService));
+ for(String ruleName : getRulesUsing(Action.Action_Enum.takeScreenshot))
+ usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
+ break;
}
return usingElements;
@@ -1035,6 +1039,15 @@ public class ActivityPermissions extends Activity
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
+ /*
+ All of the following permissions need to be "manually" activated by the user in some
+ buried system menu.
+ In my opinion by mistake the function will be called when the user has just landed
+ on one of those screens, not when he exits it again. To compensate for that onResume()
+ is overridden. This enables the permission screen to automatically close after all
+ required permissions have been granted.
+ */
+
super.onActivityResult(requestCode, resultCode, data);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
@@ -1665,4 +1678,19 @@ public class ActivityPermissions extends Activity
return false;
}
}
+
+ @Override
+ protected void onResume()
+ {
+ super.onResume();
+
+ for(String p : getRequiredPermissions(false))
+ {
+ if(!havePermission(p, this))
+ return;
+ }
+
+ // have all
+ setHaveAllPermissions();
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/com/jens/automation2/MyAccessibilityService.java b/app/src/main/java/com/jens/automation2/MyAccessibilityService.java
index 922c91f..79edbd1 100644
--- a/app/src/main/java/com/jens/automation2/MyAccessibilityService.java
+++ b/app/src/main/java/com/jens/automation2/MyAccessibilityService.java
@@ -1,8 +1,14 @@
package com.jens.automation2;
import android.accessibilityservice.AccessibilityService;
+import android.os.Build;
+import android.util.Log;
+import android.view.Display;
import android.view.accessibility.AccessibilityEvent;
+import androidx.annotation.NonNull;
+import androidx.annotation.RequiresApi;
+
public class MyAccessibilityService extends AccessibilityService
{
static MyAccessibilityService instance;
@@ -10,7 +16,9 @@ public class MyAccessibilityService extends AccessibilityService
public static MyAccessibilityService getInstance()
{
if(instance == null)
+ {
instance = new MyAccessibilityService();
+ }
return instance;
}
@@ -26,4 +34,18 @@ public class MyAccessibilityService extends AccessibilityService
{
}
+
+ @Override
+ public void onCreate()
+ {
+ super.onCreate();
+ instance = this;
+ }
+
+ @Override
+ protected void onServiceConnected()
+ {
+ super.onServiceConnected();
+ Miscellaneous.logEvent("i", "Accessibility service", "Service started.", 4);
+ }
}
\ No newline at end of file
diff --git a/app/src/main/res/drawable-hdpi/copier.png b/app/src/main/res/drawable-hdpi/copier.png
new file mode 100644
index 0000000..81257cb
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/copier.png differ
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index bfaa942..7651fe9 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -893,6 +893,8 @@
GET
POST
Take screenshot
+ Bind to accessibility service
Bind to accessibility service
After clicking OK you\'ll be sent to a system dialog. Please select Automation there and allow "Allow accessibility API".
+ Required for certains actions.
\ No newline at end of file
diff --git a/app/src/main/res/xml/config_accessibility_service.xml b/app/src/main/res/xml/config_accessibility_service.xml
new file mode 100644
index 0000000..b1f0a7e
--- /dev/null
+++ b/app/src/main/res/xml/config_accessibility_service.xml
@@ -0,0 +1,12 @@
+
+
\ No newline at end of file
diff --git a/fastlane/metadata/android/en-US/changelogs/138.txt b/fastlane/metadata/android/en-US/changelogs/138.txt
index 7c8e11a..1ccda42 100644
--- a/fastlane/metadata/android/en-US/changelogs/138.txt
+++ b/fastlane/metadata/android/en-US/changelogs/138.txt
@@ -1,3 +1,4 @@
* Fixed: Overlay permission for start other program action only required if startByActivity() is selected
* Fixed: Broadcast receiver trigger would not trigger anything, but crash
-* Added: One can now choose between GET and POST when using triggerURL action
\ No newline at end of file
+* Added: One can now choose between GET and POST when using triggerURL action
+* Added: new action -> take screenshot
\ No newline at end of file