Rework
This commit is contained in:
parent
03c8a1ff60
commit
c1139e1cb8
@ -145,7 +145,7 @@
|
||||
<activity android:name=".ActivityMaintenance" />
|
||||
<activity android:name=".ActivityManageTriggerPhoneCall" />
|
||||
<activity android:name=".ActivityManageActionBrightnessSetting" />
|
||||
<activity android:name=".ActivityManageTriggerDevicePosition" />
|
||||
<activity android:name=".ActivityManageTriggerDeviceOrientation" />
|
||||
<activity android:name=".ActivityHelp" />
|
||||
<activity android:name=".ActivityManageActionVibrate" />
|
||||
<activity
|
||||
|
@ -264,10 +264,10 @@ public class ActivityManageRule extends Activity
|
||||
wifiEditor.putExtra("wifiName", selectedTrigger.getTriggerParameter2());
|
||||
startActivityForResult(wifiEditor, requestCodeTriggerWifiEdit);
|
||||
break;
|
||||
case devicePosition:
|
||||
Intent devicePositionEditor = new Intent(ActivityManageRule.this, ActivityManageTriggerDevicePosition.class);
|
||||
case deviceOrientation:
|
||||
Intent devicePositionEditor = new Intent(ActivityManageRule.this, ActivityManageTriggerDeviceOrientation.class);
|
||||
devicePositionEditor.putExtra(ActivityManageRule.intentNameTriggerParameter1, selectedTrigger.getTriggerParameter());
|
||||
devicePositionEditor.putExtra(ActivityManageTriggerDevicePosition.vectorFieldName, selectedTrigger.getTriggerParameter2());
|
||||
devicePositionEditor.putExtra(ActivityManageTriggerDeviceOrientation.vectorFieldName, selectedTrigger.getTriggerParameter2());
|
||||
startActivityForResult(devicePositionEditor, requestCodeTriggerDevicePositionEdit);
|
||||
break;
|
||||
default:
|
||||
@ -479,7 +479,7 @@ public class ActivityManageRule extends Activity
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.headphone));
|
||||
else if(types[i].toString().equals(Trigger_Enum.notification.toString()))
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.notification));
|
||||
else if(types[i].toString().equals(Trigger_Enum.devicePosition.toString()))
|
||||
else if(types[i].toString().equals(Trigger_Enum.deviceOrientation.toString()))
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.smartphone));
|
||||
else
|
||||
items.add(new Item(typesLong[i].toString(), R.drawable.placeholder));
|
||||
@ -555,10 +555,10 @@ public class ActivityManageRule extends Activity
|
||||
return;
|
||||
// booleanChoices = new String[]{getResources().getString(R.string.started), getResources().getString(R.string.stopped)};
|
||||
}
|
||||
else if(triggerType == Trigger_Enum.devicePosition)
|
||||
else if(triggerType == Trigger_Enum.deviceOrientation)
|
||||
{
|
||||
newTrigger.setTriggerType(Trigger_Enum.devicePosition);
|
||||
Intent devicePositionTriggerEditor = new Intent(myContext, ActivityManageTriggerDevicePosition.class);
|
||||
newTrigger.setTriggerType(Trigger_Enum.deviceOrientation);
|
||||
Intent devicePositionTriggerEditor = new Intent(myContext, ActivityManageTriggerDeviceOrientation.class);
|
||||
startActivityForResult(devicePositionTriggerEditor, requestCodeTriggerDevicePositionAdd);
|
||||
return;
|
||||
// booleanChoices = new String[]{getResources().getString(R.string.started), getResources().getString(R.string.stopped)};
|
||||
@ -1366,7 +1366,7 @@ public class ActivityManageRule extends Activity
|
||||
if(resultCode == RESULT_OK)
|
||||
{
|
||||
// newTrigger.setTriggerParameter(data.getBooleanExtra("wifiState", false));
|
||||
newTrigger.setTriggerParameter2(data.getStringExtra(ActivityManageTriggerDevicePosition.vectorFieldName));
|
||||
newTrigger.setTriggerParameter2(data.getStringExtra(ActivityManageTriggerDeviceOrientation.vectorFieldName));
|
||||
newTrigger.setParentRule(ruleToEdit);
|
||||
ruleToEdit.getTriggerSet().add(newTrigger);
|
||||
this.refreshTriggerList();
|
||||
@ -1377,9 +1377,9 @@ public class ActivityManageRule extends Activity
|
||||
if(resultCode == RESULT_OK)
|
||||
{
|
||||
Trigger editedTrigger = new Trigger();
|
||||
editedTrigger.setTriggerType(Trigger_Enum.devicePosition);
|
||||
editedTrigger.setTriggerType(Trigger_Enum.deviceOrientation);
|
||||
editedTrigger.setTriggerParameter(data.getBooleanExtra(ActivityManageRule.intentNameTriggerParameter1, true));
|
||||
editedTrigger.setTriggerParameter2(data.getStringExtra(ActivityManageTriggerDevicePosition.vectorFieldName));
|
||||
editedTrigger.setTriggerParameter2(data.getStringExtra(ActivityManageTriggerDeviceOrientation.vectorFieldName));
|
||||
editedTrigger.setParentRule(ruleToEdit);
|
||||
ruleToEdit.getTriggerSet().set(editIndex, editedTrigger);
|
||||
this.refreshTriggerList();
|
||||
|
@ -16,11 +16,11 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.jens.automation2.receivers.DevicePositionListener;
|
||||
import com.jens.automation2.receivers.DeviceOrientationListener;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class ActivityManageTriggerDevicePosition extends Activity
|
||||
public class ActivityManageTriggerDeviceOrientation extends Activity
|
||||
{
|
||||
TextView currentAzimuth, currentPitch, currentRoll, tvAppliesAzimuth, tvAppliesPitch, tvAppliesRoll;
|
||||
Button bApplyPositionValues, bSavePositionValues;
|
||||
@ -104,7 +104,7 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_manage_trigger_device_position);
|
||||
setContentView(R.layout.activity_manage_trigger_device_orientation);
|
||||
|
||||
currentAzimuth = (TextView) findViewById(R.id.tvCurrentAzimuth);
|
||||
currentPitch = (TextView) findViewById(R.id.tvCurrentOrientationPitch);
|
||||
@ -149,7 +149,7 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
Toast.makeText(ActivityManageTriggerDevicePosition.this, getResources().getString(R.string.triggerWrong), Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(ActivityManageTriggerDeviceOrientation.this, getResources().getString(R.string.triggerWrong), Toast.LENGTH_SHORT).show();
|
||||
Miscellaneous.logEvent("e", "DevicePositionTrigger", "There\'s something wrong with a device position trigger. Content: " + getIntent().getStringExtra(vectorFieldName) + ", " + Log.getStackTraceString(e), 1);
|
||||
}
|
||||
}
|
||||
@ -177,7 +177,7 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
||||
{
|
||||
if(!checkInputs(true))
|
||||
{
|
||||
Toast.makeText(ActivityManageTriggerDevicePosition.this, getResources().getString(R.string.enterValidNumbersIntoAllFields), Toast.LENGTH_LONG).show();
|
||||
Toast.makeText(ActivityManageTriggerDeviceOrientation.this, getResources().getString(R.string.enterValidNumbersIntoAllFields), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -236,7 +236,7 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
||||
*/
|
||||
if (Math.abs(dat) >= 180 && Math.abs(dpt) >= 180 && Math.abs(drt) >= 180)
|
||||
{
|
||||
Miscellaneous.messageBox(getResources().getString(R.string.warning), getResources().getString(R.string.toleranceOf180OnlyAllowedIn2Fields), ActivityManageTriggerDevicePosition.this).show();
|
||||
Miscellaneous.messageBox(getResources().getString(R.string.warning), getResources().getString(R.string.toleranceOf180OnlyAllowedIn2Fields), ActivityManageTriggerDeviceOrientation.this).show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -251,14 +251,14 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
||||
protected void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
DevicePositionListener.getInstance().startSensorFromConfigActivity(ActivityManageTriggerDevicePosition.this, this);
|
||||
DeviceOrientationListener.getInstance().startSensorFromConfigActivity(ActivityManageTriggerDeviceOrientation.this, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause()
|
||||
{
|
||||
super.onPause();
|
||||
DevicePositionListener.getInstance().stopSensorFromConfigActivity();
|
||||
DeviceOrientationListener.getInstance().stopSensorFromConfigActivity();
|
||||
}
|
||||
|
||||
public class InputFilterMinMax implements InputFilter
|
@ -10,7 +10,7 @@ import com.jens.automation2.receivers.AutomationListenerInterface;
|
||||
import com.jens.automation2.receivers.BatteryReceiver;
|
||||
import com.jens.automation2.receivers.BluetoothReceiver;
|
||||
import com.jens.automation2.receivers.ConnectivityReceiver;
|
||||
import com.jens.automation2.receivers.DevicePositionListener;
|
||||
import com.jens.automation2.receivers.DeviceOrientationListener;
|
||||
import com.jens.automation2.receivers.HeadphoneJackListener;
|
||||
import com.jens.automation2.receivers.NoiseListener;
|
||||
import com.jens.automation2.receivers.PhoneStatusListener;
|
||||
@ -47,7 +47,7 @@ public class ReceiverCoordinator
|
||||
BatteryReceiver.class,
|
||||
BluetoothReceiver.class,
|
||||
ConnectivityReceiver.class,
|
||||
DevicePositionListener.class,
|
||||
DeviceOrientationListener.class,
|
||||
HeadphoneJackListener.class,
|
||||
//NfcReceiver.class,
|
||||
NoiseListener.class,
|
||||
@ -63,7 +63,7 @@ public class ReceiverCoordinator
|
||||
BatteryReceiver.class,
|
||||
BluetoothReceiver.class,
|
||||
ConnectivityReceiver.class,
|
||||
DevicePositionListener.class,
|
||||
DeviceOrientationListener.class,
|
||||
HeadphoneJackListener.class,
|
||||
//NfcReceiver.class,
|
||||
NoiseListener.class,
|
||||
@ -167,8 +167,8 @@ public class ReceiverCoordinator
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.process_started_stopped))
|
||||
ProcessListener.startProcessListener(AutomationService.getInstance());
|
||||
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.devicePosition))
|
||||
DevicePositionListener.getInstance().startListener(AutomationService.getInstance());
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.deviceOrientation))
|
||||
DeviceOrientationListener.getInstance().startListener(AutomationService.getInstance());
|
||||
|
||||
try
|
||||
{
|
||||
@ -220,7 +220,7 @@ public class ReceiverCoordinator
|
||||
|
||||
BluetoothReceiver.stopBluetoothReceiver();
|
||||
HeadphoneJackListener.getInstance().stopListener(AutomationService.getInstance());
|
||||
DevicePositionListener.getInstance().stopListener(AutomationService.getInstance());
|
||||
DeviceOrientationListener.getInstance().stopListener(AutomationService.getInstance());
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
@ -355,21 +355,21 @@ public class ReceiverCoordinator
|
||||
}
|
||||
}
|
||||
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.devicePosition))
|
||||
if(Rule.isAnyRuleUsing(Trigger.Trigger_Enum.deviceOrientation))
|
||||
{
|
||||
if(!DevicePositionListener.getInstance().isListenerRunning())
|
||||
if(!DeviceOrientationListener.getInstance().isListenerRunning())
|
||||
{
|
||||
Miscellaneous.logEvent("i", "DevicePositionListener", "Starting DevicePositionListener because used in a new/changed rule.", 4);
|
||||
// if(DevicePositionListener.getInstance().haveAllPermission())
|
||||
DevicePositionListener.getInstance().startListener(AutomationService.getInstance());
|
||||
DeviceOrientationListener.getInstance().startListener(AutomationService.getInstance());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(DevicePositionListener.getInstance().isListenerRunning())
|
||||
if(DeviceOrientationListener.getInstance().isListenerRunning())
|
||||
{
|
||||
Miscellaneous.logEvent("i", "DevicePositionListener", "Shutting down DevicePositionListener because not used in any rule.", 4);
|
||||
DevicePositionListener.getInstance().stopListener(AutomationService.getInstance());
|
||||
DeviceOrientationListener.getInstance().stopListener(AutomationService.getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class Settings implements SharedPreferences
|
||||
public static boolean rememberLastActivePoi;
|
||||
public static int locationRingBufferSize;
|
||||
public static long timeBetweenProcessMonitorings;
|
||||
public static long acceptDevicePositionSignalEveryX_MilliSeconds;
|
||||
public static long acceptDeviceOrientationSignalEveryX_MilliSeconds;
|
||||
public static int activityDetectionFrequency;
|
||||
public static int activityDetectionRequiredProbability;
|
||||
public static boolean privacyLocationing;
|
||||
@ -238,7 +238,7 @@ public class Settings implements SharedPreferences
|
||||
lengthOfNoiseLevelMeasurements = Long.parseLong(prefs.getString("lengthOfNoiseLevelMeasurements", String.valueOf(default_lengthOfNoiseLevelMeasurements)));
|
||||
referenceValueForNoiseLevelMeasurements = Long.parseLong(prefs.getString("referenceValueForNoiseLevelMeasurements", String.valueOf(default_referenceValueForNoiseLevelMeasurements)));
|
||||
timeBetweenProcessMonitorings = Long.parseLong(prefs.getString("timeBetweenProcessMonitorings", String.valueOf(default_timeBetweenProcessMonitorings)));
|
||||
acceptDevicePositionSignalEveryX_MilliSeconds = Long.parseLong(prefs.getString("acceptDevicePositionSignalEveryX_MilliSeconds", String.valueOf(default_acceptDevicePositionSignalEveryX_MilliSeconds)));
|
||||
acceptDeviceOrientationSignalEveryX_MilliSeconds = Long.parseLong(prefs.getString("acceptDevicePositionSignalEveryX_MilliSeconds", String.valueOf(default_acceptDevicePositionSignalEveryX_MilliSeconds)));
|
||||
|
||||
httpAcceptAllCertificates = prefs.getBoolean("httpAcceptAllCertificates", default_httpAcceptAllCertificates);
|
||||
httpAttempts = Integer.parseInt(prefs.getString("httpAttempts", String.valueOf(default_httpAttempts)));
|
||||
@ -532,7 +532,7 @@ public class Settings implements SharedPreferences
|
||||
editor.putString("httpAttemptGap", String.valueOf(httpAttemptGap));
|
||||
editor.putString("locationRingBufferSize", String.valueOf(locationRingBufferSize));
|
||||
editor.putString("timeBetweenProcessMonitorings", String.valueOf(timeBetweenProcessMonitorings));
|
||||
editor.putString("acceptDevicePositionSignalEveryX_MilliSeconds", String.valueOf(acceptDevicePositionSignalEveryX_MilliSeconds));
|
||||
editor.putString("acceptDevicePositionSignalEveryX_MilliSeconds", String.valueOf(acceptDeviceOrientationSignalEveryX_MilliSeconds));
|
||||
editor.putString("activityDetectionFrequency", String.valueOf(activityDetectionFrequency));
|
||||
editor.putString("activityDetectionRequiredProbability", String.valueOf(activityDetectionRequiredProbability));
|
||||
editor.putBoolean("privacyLocationing", privacyLocationing);
|
||||
|
@ -1,10 +1,7 @@
|
||||
package com.jens.automation2;
|
||||
|
||||
import static android.content.Context.DEVICE_POLICY_SERVICE;
|
||||
|
||||
import android.bluetooth.BluetoothDevice;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
@ -18,7 +15,7 @@ import com.jens.automation2.location.WifiBroadcastReceiver;
|
||||
import com.jens.automation2.receivers.BatteryReceiver;
|
||||
import com.jens.automation2.receivers.BluetoothReceiver;
|
||||
import com.jens.automation2.receivers.ConnectivityReceiver;
|
||||
import com.jens.automation2.receivers.DevicePositionListener;
|
||||
import com.jens.automation2.receivers.DeviceOrientationListener;
|
||||
import com.jens.automation2.receivers.HeadphoneJackListener;
|
||||
import com.jens.automation2.receivers.NfcReceiver;
|
||||
import com.jens.automation2.receivers.NoiseListener;
|
||||
@ -112,8 +109,8 @@ public class Trigger
|
||||
if(!checkNotification())
|
||||
result = false;
|
||||
break;
|
||||
case devicePosition:
|
||||
if(!checkDevicePosition())
|
||||
case deviceOrientation:
|
||||
if(!checkDeviceOrientation())
|
||||
result = false;
|
||||
break;
|
||||
case activityDetection:
|
||||
@ -276,18 +273,18 @@ public class Trigger
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean checkDevicePosition()
|
||||
boolean checkDeviceOrientation()
|
||||
{
|
||||
String devicePositionPieces[] = getTriggerParameter2().split(Trigger.triggerParameter2Split);
|
||||
float desiredAzimuth = Float.parseFloat(devicePositionPieces[0]);
|
||||
float desiredAzimuthTolerance = Float.parseFloat(devicePositionPieces[1]);
|
||||
float desiredPitch = Float.parseFloat(devicePositionPieces[2]);
|
||||
float desiredPitchTolerance = Float.parseFloat(devicePositionPieces[3]);
|
||||
float desiredRoll = Float.parseFloat(devicePositionPieces[4]);
|
||||
float desiredRollTolerance = Float.parseFloat(devicePositionPieces[5]);
|
||||
float currentAzimuth = DevicePositionListener.getInstance().getAzimuth();
|
||||
float currentPitch = DevicePositionListener.getInstance().getPitch();
|
||||
float currentRoll = DevicePositionListener.getInstance().getRoll();
|
||||
String deviceOrientationPieces[] = getTriggerParameter2().split(Trigger.triggerParameter2Split);
|
||||
float desiredAzimuth = Float.parseFloat(deviceOrientationPieces[0]);
|
||||
float desiredAzimuthTolerance = Float.parseFloat(deviceOrientationPieces[1]);
|
||||
float desiredPitch = Float.parseFloat(deviceOrientationPieces[2]);
|
||||
float desiredPitchTolerance = Float.parseFloat(deviceOrientationPieces[3]);
|
||||
float desiredRoll = Float.parseFloat(deviceOrientationPieces[4]);
|
||||
float desiredRollTolerance = Float.parseFloat(deviceOrientationPieces[5]);
|
||||
float currentAzimuth = DeviceOrientationListener.getInstance().getAzimuth();
|
||||
float currentPitch = DeviceOrientationListener.getInstance().getPitch();
|
||||
float currentRoll = DeviceOrientationListener.getInstance().getRoll();
|
||||
|
||||
if(
|
||||
desiredAzimuthTolerance < 180
|
||||
@ -299,7 +296,7 @@ public class Trigger
|
||||
)
|
||||
)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "DevicePosition", "Trigger doesn\'t apply. Azimuth outside of tolerance area.", 5);
|
||||
Miscellaneous.logEvent("i", "DeviceOrientation", "Trigger doesn\'t apply. Azimuth outside of tolerance area.", 5);
|
||||
if(getTriggerParameter())
|
||||
return false;
|
||||
else
|
||||
@ -316,7 +313,7 @@ public class Trigger
|
||||
)
|
||||
)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "DevicePosition", "Trigger doesn\'t apply. Pitch outside of tolerance area.", 5);
|
||||
Miscellaneous.logEvent("i", "DeviceOrientation", "Trigger doesn\'t apply. Pitch outside of tolerance area.", 5);
|
||||
if(getTriggerParameter())
|
||||
return false;
|
||||
else
|
||||
@ -333,7 +330,7 @@ public class Trigger
|
||||
)
|
||||
)
|
||||
{
|
||||
Miscellaneous.logEvent("i", "DevicePosition", "Trigger doesn\'t apply. Roll outside of tolerance area.", 5);
|
||||
Miscellaneous.logEvent("i", "DeviceOrientation", "Trigger doesn\'t apply. Roll outside of tolerance area.", 5);
|
||||
if(getTriggerParameter())
|
||||
return false;
|
||||
else
|
||||
@ -982,7 +979,7 @@ public class Trigger
|
||||
*/
|
||||
|
||||
public enum Trigger_Enum {
|
||||
pointOfInterest, timeFrame, charging, batteryLevel, usb_host_connection, speed, noiseLevel, wifiConnection, process_started_stopped, airplaneMode, roaming, nfcTag, activityDetection, bluetoothConnection, headsetPlugged, notification, devicePosition, phoneCall; //phoneCall always needs to be at the very end because of Google's shitty so called privacy
|
||||
pointOfInterest, timeFrame, charging, batteryLevel, usb_host_connection, speed, noiseLevel, wifiConnection, process_started_stopped, airplaneMode, roaming, nfcTag, activityDetection, bluetoothConnection, headsetPlugged, notification, deviceOrientation, phoneCall; //phoneCall always needs to be at the very end because of Google's shitty so called privacy
|
||||
|
||||
public String getFullName(Context context)
|
||||
{
|
||||
@ -1022,8 +1019,8 @@ public class Trigger
|
||||
return context.getResources().getString(R.string.triggerHeadsetPlugged);
|
||||
case notification:
|
||||
return context.getResources().getString(R.string.notification);
|
||||
case devicePosition:
|
||||
return context.getResources().getString(R.string.devicePosition);
|
||||
case deviceOrientation:
|
||||
return context.getResources().getString(R.string.deviceOrientation);
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
@ -1493,8 +1490,8 @@ public class Trigger
|
||||
setTriggerParameter2("-1" + triggerParameter2Split + directionEquals + triggerParameter2Split + triggerParameter2Split + directionEquals + triggerParameter2Split + triggerParameter2Split);
|
||||
}
|
||||
break;
|
||||
case devicePosition:
|
||||
returnString.append(Miscellaneous.getAnyContext().getString(R.string.deviceIsInCertainPosition));
|
||||
case deviceOrientation:
|
||||
returnString.append(Miscellaneous.getAnyContext().getString(R.string.deviceIsInCertainOrientation));
|
||||
break;
|
||||
default:
|
||||
returnString.append("error");
|
||||
|
@ -891,6 +891,8 @@ public class XmlFileInterface
|
||||
|
||||
if(triggerEventString.equals("process_started_stopped") | triggerEventString.equals("process_running"))
|
||||
newTrigger.setTriggerType(Trigger_Enum.process_started_stopped);
|
||||
if(triggerEventString.equals("devicePosition"))
|
||||
newTrigger.setTriggerType(Trigger_Enum.deviceOrientation);
|
||||
else
|
||||
newTrigger.setTriggerType(Trigger_Enum.valueOf(triggerEventString));
|
||||
}
|
||||
@ -939,7 +941,6 @@ public class XmlFileInterface
|
||||
}
|
||||
else if(newTrigger.getTriggerType() == Trigger_Enum.wifiConnection)
|
||||
{
|
||||
// newTrigger.setWifiName(triggerParameter2);
|
||||
newTrigger.setTriggerParameter2(triggerParameter2);
|
||||
}
|
||||
else if(newTrigger.getTriggerType() == Trigger_Enum.process_started_stopped)
|
||||
|
@ -7,9 +7,8 @@ import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.jens.automation2.ActivityManageTriggerDevicePosition;
|
||||
import com.jens.automation2.ActivityManageTriggerDeviceOrientation;
|
||||
import com.jens.automation2.AutomationService;
|
||||
import com.jens.automation2.Miscellaneous;
|
||||
import com.jens.automation2.Rule;
|
||||
@ -19,15 +18,15 @@ import com.jens.automation2.Trigger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class DevicePositionListener implements SensorEventListener, AutomationListenerInterface
|
||||
public class DeviceOrientationListener implements SensorEventListener, AutomationListenerInterface
|
||||
{
|
||||
// https://developer.android.com/guide/topics/sensors/sensors_position#java
|
||||
|
||||
ActivityManageTriggerDevicePosition activityManageTriggerDevicePositionInstance = null;
|
||||
ActivityManageTriggerDeviceOrientation activityManageTriggerDeviceOrientationInstance = null;
|
||||
|
||||
//the Sensor Manager
|
||||
private SensorManager sManager;
|
||||
static DevicePositionListener instance = null;
|
||||
static DeviceOrientationListener instance = null;
|
||||
boolean isRunning = false;
|
||||
|
||||
Calendar now = null;
|
||||
@ -51,10 +50,10 @@ public class DevicePositionListener implements SensorEventListener, AutomationLi
|
||||
boolean toggable = false;
|
||||
|
||||
|
||||
public static DevicePositionListener getInstance()
|
||||
public static DeviceOrientationListener getInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
instance = new DevicePositionListener();
|
||||
instance = new DeviceOrientationListener();
|
||||
|
||||
return instance;
|
||||
}
|
||||
@ -74,9 +73,9 @@ public class DevicePositionListener implements SensorEventListener, AutomationLi
|
||||
return roll;
|
||||
}
|
||||
|
||||
public void startSensorFromConfigActivity(Context context, ActivityManageTriggerDevicePosition activityManageTriggerDevicePositionInstance)
|
||||
public void startSensorFromConfigActivity(Context context, ActivityManageTriggerDeviceOrientation activityManageTriggerDeviceOrientationInstance)
|
||||
{
|
||||
this.activityManageTriggerDevicePositionInstance = activityManageTriggerDevicePositionInstance;
|
||||
this.activityManageTriggerDeviceOrientationInstance = activityManageTriggerDeviceOrientationInstance;
|
||||
|
||||
if(!isRunning)
|
||||
{
|
||||
@ -97,11 +96,11 @@ public class DevicePositionListener implements SensorEventListener, AutomationLi
|
||||
|
||||
public void stopSensorFromConfigActivity()
|
||||
{
|
||||
activityManageTriggerDevicePositionInstance = null;
|
||||
activityManageTriggerDeviceOrientationInstance = null;
|
||||
|
||||
if(isRunning)
|
||||
{
|
||||
if(!Rule.isAnyRuleUsing(Trigger.Trigger_Enum.devicePosition))
|
||||
if(!Rule.isAnyRuleUsing(Trigger.Trigger_Enum.deviceOrientation))
|
||||
{
|
||||
//unregister the sensor listener
|
||||
sManager.unregisterListener(this);
|
||||
@ -146,16 +145,19 @@ public class DevicePositionListener implements SensorEventListener, AutomationLi
|
||||
}
|
||||
|
||||
//else it will output the Roll, Pitch and Yawn values
|
||||
if(activityManageTriggerDevicePositionInstance != null)
|
||||
activityManageTriggerDevicePositionInstance.updateFields(azimuth, pitch, roll);
|
||||
if(activityManageTriggerDeviceOrientationInstance != null)
|
||||
activityManageTriggerDeviceOrientationInstance.updateFields(azimuth, pitch, roll);
|
||||
|
||||
now = Calendar.getInstance();
|
||||
if(lastTimeSignalArrived == null || now.getTimeInMillis() >= lastTimeSignalArrived.getTimeInMillis() + Settings.acceptDevicePositionSignalEveryX_MilliSeconds)
|
||||
if(lastTimeSignalArrived == null || now.getTimeInMillis() >= lastTimeSignalArrived.getTimeInMillis() + Settings.acceptDeviceOrientationSignalEveryX_MilliSeconds)
|
||||
{
|
||||
lastTimeSignalArrived = now;
|
||||
|
||||
Miscellaneous.logEvent("i", "DeviceOrientation", "Got device orientation update: azimuth: " + String.valueOf(azimuth) + ", pitch: " + String.valueOf(pitch) + ", roll: " + String.valueOf(pitch), 4);
|
||||
|
||||
if (AutomationService.isMyServiceRunning(Miscellaneous.getAnyContext()))
|
||||
{
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.devicePosition);
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.deviceOrientation);
|
||||
for (int i = 0; i < ruleCandidates.size(); i++)
|
||||
{
|
||||
if (ruleCandidates.get(i).getsGreenLight(Miscellaneous.getAnyContext()))
|
||||
@ -188,7 +190,7 @@ public class DevicePositionListener implements SensorEventListener, AutomationLi
|
||||
@Override
|
||||
public void stopListener(AutomationService automationService)
|
||||
{
|
||||
this.activityManageTriggerDevicePositionInstance = null;
|
||||
this.activityManageTriggerDeviceOrientationInstance = null;
|
||||
|
||||
if(isRunning)
|
||||
{
|
||||
@ -207,7 +209,7 @@ public class DevicePositionListener implements SensorEventListener, AutomationLi
|
||||
@Override
|
||||
public Trigger.Trigger_Enum[] getMonitoredTrigger()
|
||||
{
|
||||
return new Trigger.Trigger_Enum[] { Trigger.Trigger_Enum.devicePosition };
|
||||
return new Trigger.Trigger_Enum[] { Trigger.Trigger_Enum.deviceOrientation};
|
||||
}
|
||||
|
||||
/*
|
@ -13,7 +13,7 @@
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/devicePositionExplanation"
|
||||
android:text="@string/deviceOrientationExplanation"
|
||||
android:layout_marginBottom="@dimen/default_margin" />
|
||||
|
||||
<TableLayout
|
||||
@ -97,7 +97,7 @@
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:text="@string/position"
|
||||
android:text="@string/orientation"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
@ -234,7 +234,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/explanationDevicePositionDirection" />
|
||||
android:text="@string/explanationDeviceOrientationDirection" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/bSavePositionValues"
|
@ -264,13 +264,13 @@
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:summary="@string/devicePositionSettings"
|
||||
android:title="@string/devicePositionSettings">
|
||||
android:summary="@string/deviceOrientationSettings"
|
||||
android:title="@string/deviceOrientationSettings">
|
||||
|
||||
<EditTextPreference
|
||||
android:key="acceptDevicePositionSignalEveryX_MilliSeconds"
|
||||
android:summary="@string/devicePositionTimeAcceptIntervalSummary"
|
||||
android:title="@string/devicePositionTimeAcceptIntervalTitle"
|
||||
android:summary="@string/deviceOrientationTimeAcceptIntervalSummary"
|
||||
android:title="@string/deviceOrientationTimeAcceptIntervalTitle"
|
||||
android:inputType="number"></EditTextPreference>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
@ -612,4 +612,24 @@
|
||||
<string name="wifiApi30">Weil Google wieder einen weiteren Teil von Android kaputt gemacht hat, können ab API 30 nur noch jede WLANs angezeigt werden, die sich gegenwärtig in Reichweite befinden, nicht mehr alle, zu denen das Gerät einmal verbunden war.</string>
|
||||
<string name="smsDialogNotice">Wenn Sie in diesem Programm noch keine SMS-senden Aktion benutzt haben, zeigt Android wahrscheinlich beim ersten Ausführen einen Bestätigungsdialog an. Sie müssen das Häkchen bei \"Immer erlauben\" setzen und bestätigen, wenn Sie möchten, daß diese Aktion im Hintergrund ausgeführt werden kann. Es wird daher empfohlen, diese Regel einmalig manuell auszuführen, um diesen Dialog zu provozieren.</string>
|
||||
<string name="silentTriggersDnd">Hinweis: Der Stumm-Modus löst auf neuren Geräten häufig die Funktion \"Nicht stören\" aus. Wenn das auf Ihrem Gerät passiert, wird empfohlen stattdessen den Normalen Modus zu verwenden und alle Lautstärken auf 0 zu reduzieren.</string>
|
||||
<string name="deviceOrientation">Geräteausrichtung</string>
|
||||
<string name="tolerance">Toleranz (0-180)</string>
|
||||
<string name="orientationAzimuth">Azimut:</string>
|
||||
<string name="orientationPitch">Neigung:</string>
|
||||
<string name="enterValidNumbersIntoAllFields">Geben Sie gültige Nummern in allen Feldern ein.</string>
|
||||
<string name="orientationRoll">Rollen:</string>
|
||||
<string name="wouldCurrentlyApply">Würde gerade zutreffen?</string>
|
||||
<string name="deviceIsInCertainOrientation">Das Gerät hat eine bestimmte Ausrichtung</string>
|
||||
<string name="toleranceOf180OnlyAllowedIn2Fields">Eine Toleranz von 180 ist nur für zwei Toleranz-Felder erlaubt, nicht alle drei. Andernfalls würde der Auslöser immer zutreffen.</string>
|
||||
<string name="unknown">unbekannt</string>
|
||||
<string name="orientation">Ausrichtung</string>
|
||||
<string name="turnScreenOnOrOff">Bildschirm ein- oder ausschalten</string>
|
||||
<string name="turnScreenOn">Bildschirm einschalten</string>
|
||||
<string name="turnScreenOff">Bildschirm ausschalten</string>
|
||||
<string name="mustApply">Muß zutreffen</string>
|
||||
<string name="deviceOrientationTimeAcceptIntervalTitle">Signal Häufigkeit</string>
|
||||
<string name="deviceOrientationTimeAcceptIntervalSummary">Neue Signale nur alle x Millisekunden akzeptieren</string>
|
||||
<string name="deviceOrientationSettings">Geräteausrichtungseinstellungen</string>
|
||||
<string name="explanationDeviceOrientationDirection">Wenn das Häkchen gesetzt ist, bedeutet das, daß das Geräte in der angegebenen Ausrichtung sein muß. Wenn es nicht gesetzt ist, führt jede andere Ausrichtung zu einem positiven Ergebnis.</string>
|
||||
<string name="deviceOrientationExplanation">Wenn Sie Ihr Gerät bewegen, werden die Zahlen unten aktualisiert. Was Sie hier sehen können, ist die momentane Ausrichtung Ihres Geräts, gemessen in Grad. Wenn das Gerät in der gewünschten Ausrichtung ist, klicken Sie den \"übernehmen\" Knopf, um die Werte in die \"gewünscht\" Felder zu übertragen.\nWeil es sehr unwahrscheinlich ist, daß Sie diese exakte Ausrichtung jemals wieder erreichen, müssen Sie Toleranzen eingeben. Dies ist der Winkel in Grad, der in jede Richtung noch akzeptiert wird. 15° entsprechen somit einem Gesamtwinkel von 30°, 15 in jede Richtung.\nWenn Ihnen nur eine bestimmte Achse wichtig ist, können Sie eine Toleranz von 180° für die anderen beiden Richtungen angeben.</string>
|
||||
</resources>
|
@ -597,4 +597,9 @@
|
||||
<string name="dnd">No interrumpir</string>
|
||||
<string name="donate">Donar</string>
|
||||
<string name="notice">Nota</string>
|
||||
<string name="deviceOrientation">Orientación</string>
|
||||
<string name="tolerance">Tolerancia</string>
|
||||
<string name="orientationAzimuth">" Acimut:"</string>
|
||||
<string name="turnScreenOff">apagar pantalla</string>
|
||||
<string name="turnScreenOn">encender pantalla</string>
|
||||
</resources>
|
@ -588,4 +588,7 @@
|
||||
<string name="pleaseGiveBgLocation">Nella schermata successiva vai su permessi, poi posizione. Lì seleziona \"Consenti sempre\" per permettere ad Automation di determinare la tua posizione in secondo piano.</string>
|
||||
<string name="tones">Suonerias</string>
|
||||
<string name="dnd">Non disturbare</string>
|
||||
<string name="deviceOrientation">Orientamento</string>
|
||||
<string name="tolerance">Tolleranza</string>
|
||||
<string name="orientationAzimuth">Azimut:</string>
|
||||
</resources>
|
||||
|
@ -713,25 +713,25 @@
|
||||
<string name="donate">Donate</string>
|
||||
<string name="btTetheringNotice">This feature is confirmed to work up until Android 8.0. From some higher version upwards it ceases to work, but due to a lack of physical devices I cannot tell which one that is. On Android 11 it definitely ain\'t working anymore. If you have a version in between please let me know if it\'s working or not.</string>
|
||||
<string name="notice">Notice</string>
|
||||
<string name="devicePosition">Device position (Gyroscope)</string>
|
||||
<string name="tolerance">Tolerance\n(0-180)</string>
|
||||
<string name="deviceOrientation">Device orientation</string>
|
||||
<string name="tolerance">Tolerance (0-180)</string>
|
||||
<string name="orientationAzimuth">Azimuth:</string>
|
||||
<string name="orientationPitch">Pitch:</string>
|
||||
<string name="orientationRoll">Roll:</string>
|
||||
<string name="enterValidNumbersIntoAllFields">Enter valid numbers in all fields.</string>
|
||||
<string name="devicePositionExplanation">When you move your device the below numbers will update. What you can see there, is the current \"position\" of your device measured in degrees. If it is in the desired position, click the apply button to copy the current values to the desired fields.\nBecause reaching this exact position ever again is highly unlikely you must also enter a tolerance. The is amount of degrees to which the position can deviate in either direction. If you only care about one specific axis, specify a tolerance of 180° for the two other ones.</string>
|
||||
<string name="deviceOrientationExplanation">When you move your device the below numbers will update. What you can see there, is the current orientation of your device measured in degrees. If it is in the desired orientation, click the apply button to copy the current values to the desired fields.\nBecause reaching this exact orientation ever again is highly unlikely you must also enter a tolerance. The is amount of degrees to which the orientation can deviate in either direction. 15° will result in a total angle of 30°, 15° in every direction.\nIf you only care about one specific axis, specify a tolerance of 180° for the two other ones.</string>
|
||||
<string name="wouldCurrentlyApply">Would currently apply?</string>
|
||||
<string name="deviceIsInCertainPosition">the device is in a certain position</string>
|
||||
<string name="deviceIsInCertainOrientation">the device is in a certain orientation</string>
|
||||
<string name="toleranceOf180OnlyAllowedIn2Fields">A tolerance of 180 is allowed for 2 tolerance fields only, not all 3. Otherwise the trigger would ALWAYS apply.</string>
|
||||
<string name="unknown">unknown</string>
|
||||
<string name="position">Position</string>
|
||||
<string name="triggerWrong">" There's something wrong with this trigger. It could not be loaded correctly."</string>
|
||||
<string name="orientation">Orientation</string>
|
||||
<string name="triggerWrong">There\'s something wrong with this trigger. It could not be loaded correctly.</string>
|
||||
<string name="turnScreenOnOrOff">Turn screen on or off</string>
|
||||
<string name="turnScreenOn">turn screen on</string>
|
||||
<string name="turnScreenOff">turn screen off</string>
|
||||
<string name="mustApply">Must apply</string>
|
||||
<string name="explanationDevicePositionDirection">If the checkbox is checked that means the device has to be in the position you specify. If it\'s not checked, any position that does NOT match your criteria will do.</string>
|
||||
<string name="devicePositionTimeAcceptIntervalTitle">Signal frequency</string>
|
||||
<string name="devicePositionTimeAcceptIntervalSummary">Accept new movement signals every x milliseconds</string>
|
||||
<string name="devicePositionSettings">Device positioning settings</string>
|
||||
<string name="explanationDeviceOrientationDirection">If the checkbox is checked that means the device has to be in the orientation you specify. If it\'s not checked, any orientation that does NOT match your criteria will do.</string>
|
||||
<string name="deviceOrientationTimeAcceptIntervalTitle">Signal frequency</string>
|
||||
<string name="deviceOrientationTimeAcceptIntervalSummary">Accept new movement signals every x milliseconds</string>
|
||||
<string name="deviceOrientationSettings">Device orientation settings</string>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user