diff --git a/app/src/apkFlavor/AndroidManifest.xml b/app/src/apkFlavor/AndroidManifest.xml
index 026b670..19aaf80 100644
--- a/app/src/apkFlavor/AndroidManifest.xml
+++ b/app/src/apkFlavor/AndroidManifest.xml
@@ -185,6 +185,7 @@
+
+
+
diff --git a/app/src/googlePlayFlavor/AndroidManifest.xml b/app/src/googlePlayFlavor/AndroidManifest.xml
index 098200f..019dfc5 100644
--- a/app/src/googlePlayFlavor/AndroidManifest.xml
+++ b/app/src/googlePlayFlavor/AndroidManifest.xml
@@ -167,6 +167,8 @@
+
+
0)
returnString.append(": " + parameter2.replace(Action.actionParameter2Split, "; "));
@@ -651,7 +663,7 @@ public class Action
Actions.takeScreenshot();
break;
case setLocationService:
- Actions.setLocationService(this.getParameter1(), AutomationService.getInstance());
+ Actions.setLocationService(Integer.parseInt(this.getParameter2()), AutomationService.getInstance());
break;
default:
Miscellaneous.logEvent("w", "Action", context.getResources().getString(R.string.unknownActionSpecified), 3);
diff --git a/app/src/main/java/com/jens/automation2/Actions.java b/app/src/main/java/com/jens/automation2/Actions.java
index 3499707..d9bae56 100644
--- a/app/src/main/java/com/jens/automation2/Actions.java
+++ b/app/src/main/java/com/jens/automation2/Actions.java
@@ -2360,17 +2360,17 @@ public class Actions
}
}
- public static void setLocationService(boolean desiredState, Context context)
+ public static void setLocationService(int desiredState, Context context)
{
- if(desiredState)
- {
- android.provider.Settings.Secure.putString(context.getContentResolver(), android.provider.Settings.Secure.LOCATION_MODE, new Integer(android.provider.Settings.Secure.LOCATION_MODE_HIGH_ACCURACY).toString());
- }
- else
- {
- android.provider.Settings.Secure.putString(context.getContentResolver(), android.provider.Settings.Secure.LOCATION_MODE, new Integer(android.provider.Settings.Secure.LOCATION_MODE_OFF).toString());
- }
- android.provider.Settings.Secure.LOCATION_MODE_
+// if(desiredState)
+// {
+// android.provider.Settings.Secure.putString(context.getContentResolver(), android.provider.Settings.Secure.LOCATION_MODE, new Integer(android.provider.Settings.Secure.LOCATION_MODE_HIGH_ACCURACY).toString());
+// }
+// else
+// {
+// android.provider.Settings.Secure.putString(context.getContentResolver(), android.provider.Settings.Secure.LOCATION_MODE, new Integer(android.provider.Settings.Secure.LOCATION_MODE_OFF).toString());
+// }
+ android.provider.Settings.Secure.putString(context.getContentResolver(), android.provider.Settings.Secure.LOCATION_MODE, String.valueOf(desiredState));
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/jens/automation2/ActivityManageActionLocationService.java b/app/src/main/java/com/jens/automation2/ActivityManageActionLocationService.java
index 65d0ac7..1105ce8 100644
--- a/app/src/main/java/com/jens/automation2/ActivityManageActionLocationService.java
+++ b/app/src/main/java/com/jens/automation2/ActivityManageActionLocationService.java
@@ -2,22 +2,18 @@ package com.jens.automation2;
import android.app.Activity;
import android.content.Intent;
-import android.os.Build;
import android.os.Bundle;
+import android.provider.Settings;
import android.view.View;
import android.widget.Button;
-import android.widget.CheckBox;
import android.widget.RadioButton;
-import android.widget.TextView;
import androidx.annotation.Nullable;
public class ActivityManageActionLocationService extends Activity
{
- CheckBox chkWifiRunAsRoot;
- RadioButton rbActionWifiOn, rbActionWifiOff;
- Button bActionWifiSave;
- TextView tvWifiExplanation1, tvWifiExplanation2;
+ RadioButton rbActionLocationServiceOff, rbActionLocationServiceSensorsOnly, rbActionLocationServiceBatterySaving, rbActionLocationServiceHighAccuracy;
+ Button bActionSetLocationServiceSave;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState)
@@ -26,36 +22,51 @@ public class ActivityManageActionLocationService extends Activity
Miscellaneous.setDisplayLanguage(this);
setContentView(R.layout.activity_manage_action_location_service);
- chkWifiRunAsRoot = (CheckBox)findViewById(R.id.chkWifiRunAsRoot);
- rbActionWifiOn = (RadioButton) findViewById(R.id.rbActionWifiOn);
- rbActionWifiOff = (RadioButton)findViewById(R.id.rbActionWifiOff);
- bActionWifiSave = (Button) findViewById(R.id.bActionWifiSave);
- tvWifiExplanation1 = (TextView)findViewById(R.id.tvWifiExplanation1);
- tvWifiExplanation2 = (TextView)findViewById(R.id.tvWifiExplanation2);
+ rbActionLocationServiceOff = (RadioButton) findViewById(R.id.rbActionLocationServiceOff);
+ rbActionLocationServiceSensorsOnly = (RadioButton)findViewById(R.id.rbActionLocationServiceSensorsOnly);
+ rbActionLocationServiceBatterySaving = (RadioButton)findViewById(R.id.rbActionLocationServiceBatterySaving);
+ rbActionLocationServiceHighAccuracy = (RadioButton)findViewById(R.id.rbActionLocationServiceHighAccuracy);
+ bActionSetLocationServiceSave = (Button) findViewById(R.id.bActionSetLocationServiceSave);
Intent input = getIntent();
- if(input.hasExtra(ActivityManageRule.intentNameActionParameter1))
- rbActionWifiOn.setChecked(input.getBooleanExtra(ActivityManageRule.intentNameActionParameter1, true));
if(input.hasExtra(ActivityManageRule.intentNameActionParameter2))
- chkWifiRunAsRoot.setChecked(Boolean.parseBoolean(input.getStringExtra(ActivityManageRule.intentNameActionParameter2)));
+ {
+ String[] params = input.getStringExtra(ActivityManageRule.intentNameActionParameter2).split(Action.actionParameter2Split);
+ int desiredState = Integer.parseInt(params[0]);
-// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
-// Miscellaneous.messageBox(getResources().getString(R.string.app_name), getResources().getString(R.string.android10WifiToggleNotice), ActivityManageActionWifi.this).show();
+ switch(desiredState)
+ {
+ case Settings.Secure.LOCATION_MODE_OFF:
+ rbActionLocationServiceOff.setChecked(true);
+ break;
+ case Settings.Secure.LOCATION_MODE_SENSORS_ONLY:
+ rbActionLocationServiceSensorsOnly.setChecked(true);
+ break;
+ case Settings.Secure.LOCATION_MODE_BATTERY_SAVING:
+ rbActionLocationServiceBatterySaving.setChecked(true);
+ break;
+ case Settings.Secure.LOCATION_MODE_HIGH_ACCURACY:
+ rbActionLocationServiceHighAccuracy.setChecked(true);
+ break;
+ }
+ }
- if(getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.Q)
- tvWifiExplanation1.setVisibility(View.VISIBLE);
- else
- tvWifiExplanation1.setVisibility(View.GONE);
-
- bActionWifiSave.setOnClickListener(new View.OnClickListener()
+ bActionSetLocationServiceSave.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
Intent response = new Intent();
- response.putExtra(ActivityManageRule.intentNameActionParameter1, rbActionWifiOn.isChecked());
- response.putExtra(ActivityManageRule.intentNameActionParameter2, String.valueOf(chkWifiRunAsRoot.isChecked()));
+ if(rbActionLocationServiceOff.isChecked())
+ response.putExtra(ActivityManageRule.intentNameActionParameter2, String.valueOf(Settings.Secure.LOCATION_MODE_OFF));
+ else if(rbActionLocationServiceSensorsOnly.isChecked())
+ response.putExtra(ActivityManageRule.intentNameActionParameter2, String.valueOf(Settings.Secure.LOCATION_MODE_SENSORS_ONLY));
+ else if(rbActionLocationServiceBatterySaving.isChecked())
+ response.putExtra(ActivityManageRule.intentNameActionParameter2, String.valueOf(Settings.Secure.LOCATION_MODE_BATTERY_SAVING));
+ else
+ response.putExtra(ActivityManageRule.intentNameActionParameter2, String.valueOf(Settings.Secure.LOCATION_MODE_HIGH_ACCURACY));
+
setResult(RESULT_OK, response);
finish();
}
diff --git a/app/src/main/java/com/jens/automation2/ActivityManageRule.java b/app/src/main/java/com/jens/automation2/ActivityManageRule.java
index f8d5b78..f07971a 100644
--- a/app/src/main/java/com/jens/automation2/ActivityManageRule.java
+++ b/app/src/main/java/com/jens/automation2/ActivityManageRule.java
@@ -482,8 +482,8 @@ public class ActivityManageRule extends Activity
break;
case setLocationService:
Intent actionSetLocationServiceIntent = new Intent(context, ActivityManageActionLocationService.class);
- actionSetLocationServiceIntent.putExtra(intentNameActionParameter1, a.getParameter1());
-// actionSetLocationServiceIntent.putExtra(intentNameActionParameter2, a.getParameter2());
+// actionSetLocationServiceIntent.putExtra(intentNameActionParameter1, a.getParameter1());
+ actionSetLocationServiceIntent.putExtra(intentNameActionParameter2, a.getParameter2());
startActivityForResult(actionSetLocationServiceIntent, requestCodeActionSetLocationServiceEdit);
break;
default:
@@ -2063,8 +2063,8 @@ public class ActivityManageRule extends Activity
if(resultCode == RESULT_OK)
{
newAction.setParentRule(ruleToEdit);
- newAction.setParameter1(data.getBooleanExtra(intentNameActionParameter1, false));
-// newAction.setParameter2(data.getStringExtra(intentNameActionParameter2));
+// newAction.setParameter1(data.getBooleanExtra(intentNameActionParameter1, false));
+ newAction.setParameter2(data.getStringExtra(intentNameActionParameter2));
ruleToEdit.getActionSet().add(newAction);
this.refreshActionList();
}
@@ -2074,12 +2074,12 @@ public class ActivityManageRule extends Activity
if(resultCode == RESULT_OK)
{
ruleToEdit.getActionSet().get(editIndex).setParentRule(ruleToEdit);
- ruleToEdit.getActionSet().get(editIndex).setParameter1(data.getBooleanExtra(intentNameActionParameter1, false));
+// ruleToEdit.getActionSet().get(editIndex).setParameter1(data.getBooleanExtra(intentNameActionParameter1, false));
-// if(data.hasExtra(intentNameActionParameter2))
-// {
-// ruleToEdit.getActionSet().get(editIndex).setParameter2(data.getStringExtra(intentNameActionParameter2));
-// }
+ if(data.hasExtra(intentNameActionParameter2))
+ {
+ ruleToEdit.getActionSet().get(editIndex).setParameter2(data.getStringExtra(intentNameActionParameter2));
+ }
this.refreshActionList();
}
@@ -2162,6 +2162,8 @@ public class ActivityManageRule extends Activity
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.copier));
+ else if(types[i].toString().equals(Action_Enum.setLocationService.toString()))
+ items.add(new Item(typesLong[i].toString(), R.drawable.compass_small));
else
items.add(new Item(typesLong[i].toString(), R.drawable.placeholder));
}
diff --git a/app/src/main/res/layout/activity_manage_action_location_servicei.xml b/app/src/main/res/layout/activity_manage_action_location_service.xml
similarity index 98%
rename from app/src/main/res/layout/activity_manage_action_location_servicei.xml
rename to app/src/main/res/layout/activity_manage_action_location_service.xml
index c31ec51..cf60f37 100644
--- a/app/src/main/res/layout/activity_manage_action_location_servicei.xml
+++ b/app/src/main/res/layout/activity_manage_action_location_service.xml
@@ -89,7 +89,7 @@