forked from jens/Automation
Rework
This commit is contained in:
parent
b88801500f
commit
89ac69fd4b
17
.idea/deploymentTargetDropDown.xml
generated
17
.idea/deploymentTargetDropDown.xml
generated
@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="deploymentTargetDropDown">
|
|
||||||
<targetSelectedWithDropDown>
|
|
||||||
<Target>
|
|
||||||
<type value="QUICK_BOOT_TARGET" />
|
|
||||||
<deviceKey>
|
|
||||||
<Key>
|
|
||||||
<type value="VIRTUAL_DEVICE_PATH" />
|
|
||||||
<value value="C:\Users\jens\.android\avd\Android_11.avd" />
|
|
||||||
</Key>
|
|
||||||
</deviceKey>
|
|
||||||
</Target>
|
|
||||||
</targetSelectedWithDropDown>
|
|
||||||
<timeTargetWasSelectedWithDropDown value="2021-12-04T01:10:17.133406Z" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -348,7 +348,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
|
|
||||||
public boolean getsGreenLight(Context context)
|
public boolean getsGreenLight(Context context)
|
||||||
{
|
{
|
||||||
return isRuleActive() && applies(context) && (hasNotAppliedSinceLastExecution() || isActuallyToggable());
|
return applies(context) && hasNotAppliedSinceLastExecution();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean applies(Context context)
|
public boolean applies(Context context)
|
||||||
|
@ -342,6 +342,11 @@ public class Rule implements Comparable<Rule>
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getsGreenLight(Context context)
|
||||||
|
{
|
||||||
|
return isRuleActive() && applies(context) && hasNotAppliedSinceLastExecution();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean applies(Context context)
|
public boolean applies(Context context)
|
||||||
{
|
{
|
||||||
if(AutomationService.getInstance() == null)
|
if(AutomationService.getInstance() == null)
|
||||||
|
@ -346,6 +346,11 @@ public class Rule implements Comparable<Rule>
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getsGreenLight(Context context)
|
||||||
|
{
|
||||||
|
return isRuleActive() && applies(context) && hasNotAppliedSinceLastExecution();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean applies(Context context)
|
public boolean applies(Context context)
|
||||||
{
|
{
|
||||||
if(AutomationService.getInstance() == null)
|
if(AutomationService.getInstance() == null)
|
||||||
|
@ -1093,6 +1093,8 @@ public class Actions
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
WakeLock wakeLock = pm.newWakeLock((WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "Automation:Wakelock");
|
WakeLock wakeLock = pm.newWakeLock((WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "Automation:Wakelock");
|
||||||
@ -1109,6 +1111,29 @@ public class Actions
|
|||||||
|
|
||||||
wakeLock.release();
|
wakeLock.release();
|
||||||
}
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("e", "Wakeup device action", "Error while waking up device: " + Log.getStackTraceString(e), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void turnOnScreen()
|
||||||
|
{
|
||||||
|
// turn on screen
|
||||||
|
Log.v("ProximityActivity", "ON!");
|
||||||
|
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
|
WakeLock wakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag");
|
||||||
|
wakeLock.acquire();
|
||||||
|
}
|
||||||
|
|
||||||
|
@TargetApi(21) //Suppress lint error for PROXIMITY_SCREEN_OFF_WAKE_LOCK
|
||||||
|
public void turnOffScreen(){
|
||||||
|
// turn off screen
|
||||||
|
Log.v("ProximityActivity", "OFF!");
|
||||||
|
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
|
WakeLock wakeLock = pm.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "tag");
|
||||||
|
wakeLock.acquire();
|
||||||
}
|
}
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||||
|
@ -1375,8 +1375,7 @@ public class ActivityManageRule extends Activity
|
|||||||
{
|
{
|
||||||
Trigger editedTrigger = new Trigger();
|
Trigger editedTrigger = new Trigger();
|
||||||
editedTrigger.setTriggerType(Trigger_Enum.devicePosition);
|
editedTrigger.setTriggerType(Trigger_Enum.devicePosition);
|
||||||
// newTrigger.setTriggerParameter(data.getBooleanExtra("wifiState", false));
|
editedTrigger.setTriggerParameter2(data.getStringExtra(ActivityManageTriggerDevicePosition.vectorFieldName));
|
||||||
newTrigger.setTriggerParameter2(data.getStringExtra(ActivityManageTriggerDevicePosition.vectorFieldName));
|
|
||||||
ruleToEdit.getTriggerSet().set(editIndex, editedTrigger);
|
ruleToEdit.getTriggerSet().set(editIndex, editedTrigger);
|
||||||
this.refreshTriggerList();
|
this.refreshTriggerList();
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import android.graphics.Color;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.InputFilter;
|
import android.text.InputFilter;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@ -112,6 +113,8 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
|||||||
if(getIntent().hasExtra(vectorFieldName))
|
if(getIntent().hasExtra(vectorFieldName))
|
||||||
{
|
{
|
||||||
editMode = true;
|
editMode = true;
|
||||||
|
try
|
||||||
|
{
|
||||||
String values[] = getIntent().getStringExtra(vectorFieldName).split(Trigger.triggerParameter2Split);
|
String values[] = getIntent().getStringExtra(vectorFieldName).split(Trigger.triggerParameter2Split);
|
||||||
etDesiredAzimuth.setText(values[0]);
|
etDesiredAzimuth.setText(values[0]);
|
||||||
etDesiredAzimuthTolerance.setText(values[1]);
|
etDesiredAzimuthTolerance.setText(values[1]);
|
||||||
@ -120,6 +123,12 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
|||||||
etDesiredRoll.setText(values[4]);
|
etDesiredRoll.setText(values[4]);
|
||||||
etDesiredRollTolerance.setText(values[5]);
|
etDesiredRollTolerance.setText(values[5]);
|
||||||
}
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
Toast.makeText(ActivityManageTriggerDevicePosition.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bApplyPositionValues.setOnClickListener(new View.OnClickListener()
|
bApplyPositionValues.setOnClickListener(new View.OnClickListener()
|
||||||
{
|
{
|
||||||
@ -206,6 +215,8 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -276,6 +276,7 @@ public class PointOfInterest implements Comparable<PointOfInterest>
|
|||||||
ActivityMainScreen.updateMainScreen();
|
ActivityMainScreen.updateMainScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deactivate(AutomationService parentService)
|
public void deactivate(AutomationService parentService)
|
||||||
{
|
{
|
||||||
if(this.isActivated())
|
if(this.isActivated())
|
||||||
|
@ -290,6 +290,8 @@ public class Trigger
|
|||||||
float currentRoll = DevicePositionListener.getInstance().getRoll();
|
float currentRoll = DevicePositionListener.getInstance().getRoll();
|
||||||
|
|
||||||
if(
|
if(
|
||||||
|
desiredAzimuthTolerance < 180
|
||||||
|
&&
|
||||||
!(
|
!(
|
||||||
currentAzimuth <= desiredAzimuth + desiredAzimuthTolerance
|
currentAzimuth <= desiredAzimuth + desiredAzimuthTolerance
|
||||||
&&
|
&&
|
||||||
@ -302,6 +304,8 @@ public class Trigger
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(
|
if(
|
||||||
|
desiredPitchTolerance < 180
|
||||||
|
&&
|
||||||
!(
|
!(
|
||||||
currentPitch <= desiredPitch + desiredPitchTolerance
|
currentPitch <= desiredPitch + desiredPitchTolerance
|
||||||
&&
|
&&
|
||||||
@ -314,6 +318,8 @@ public class Trigger
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(
|
if(
|
||||||
|
desiredRollTolerance < 180
|
||||||
|
&&
|
||||||
!(
|
!(
|
||||||
currentRoll <= desiredRoll + desiredRollTolerance
|
currentRoll <= desiredRoll + desiredRollTolerance
|
||||||
&&
|
&&
|
||||||
|
@ -725,4 +725,5 @@
|
|||||||
<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="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="unknown">unknown</string>
|
||||||
<string name="position">Position</string>
|
<string name="position">Position</string>
|
||||||
|
<string name="triggerWrong">" There's something wrong with this trigger. It could not be loaded correctly."</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue
Block a user