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)
|
||||
{
|
||||
return isRuleActive() && applies(context) && (hasNotAppliedSinceLastExecution() || isActuallyToggable());
|
||||
return applies(context) && hasNotAppliedSinceLastExecution();
|
||||
}
|
||||
|
||||
public boolean applies(Context context)
|
||||
|
@ -342,6 +342,11 @@ public class Rule implements Comparable<Rule>
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getsGreenLight(Context context)
|
||||
{
|
||||
return isRuleActive() && applies(context) && hasNotAppliedSinceLastExecution();
|
||||
}
|
||||
|
||||
public boolean applies(Context context)
|
||||
{
|
||||
if(AutomationService.getInstance() == null)
|
||||
|
@ -346,6 +346,11 @@ public class Rule implements Comparable<Rule>
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getsGreenLight(Context context)
|
||||
{
|
||||
return isRuleActive() && applies(context) && hasNotAppliedSinceLastExecution();
|
||||
}
|
||||
|
||||
public boolean applies(Context context)
|
||||
{
|
||||
if(AutomationService.getInstance() == null)
|
||||
|
@ -1093,6 +1093,8 @@ public class Actions
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
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");
|
||||
@ -1109,6 +1111,29 @@ public class Actions
|
||||
|
||||
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)
|
||||
|
@ -1375,8 +1375,7 @@ public class ActivityManageRule extends Activity
|
||||
{
|
||||
Trigger editedTrigger = new Trigger();
|
||||
editedTrigger.setTriggerType(Trigger_Enum.devicePosition);
|
||||
// newTrigger.setTriggerParameter(data.getBooleanExtra("wifiState", false));
|
||||
newTrigger.setTriggerParameter2(data.getStringExtra(ActivityManageTriggerDevicePosition.vectorFieldName));
|
||||
editedTrigger.setTriggerParameter2(data.getStringExtra(ActivityManageTriggerDevicePosition.vectorFieldName));
|
||||
ruleToEdit.getTriggerSet().set(editIndex, editedTrigger);
|
||||
this.refreshTriggerList();
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputFilter;
|
||||
import android.text.Spanned;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
@ -112,6 +113,8 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
||||
if(getIntent().hasExtra(vectorFieldName))
|
||||
{
|
||||
editMode = true;
|
||||
try
|
||||
{
|
||||
String values[] = getIntent().getStringExtra(vectorFieldName).split(Trigger.triggerParameter2Split);
|
||||
etDesiredAzimuth.setText(values[0]);
|
||||
etDesiredAzimuthTolerance.setText(values[1]);
|
||||
@ -120,6 +123,12 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
||||
etDesiredRoll.setText(values[4]);
|
||||
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()
|
||||
{
|
||||
@ -206,6 +215,8 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -276,6 +276,7 @@ public class PointOfInterest implements Comparable<PointOfInterest>
|
||||
ActivityMainScreen.updateMainScreen();
|
||||
}
|
||||
}
|
||||
|
||||
public void deactivate(AutomationService parentService)
|
||||
{
|
||||
if(this.isActivated())
|
||||
|
@ -290,6 +290,8 @@ public class Trigger
|
||||
float currentRoll = DevicePositionListener.getInstance().getRoll();
|
||||
|
||||
if(
|
||||
desiredAzimuthTolerance < 180
|
||||
&&
|
||||
!(
|
||||
currentAzimuth <= desiredAzimuth + desiredAzimuthTolerance
|
||||
&&
|
||||
@ -302,6 +304,8 @@ public class Trigger
|
||||
}
|
||||
|
||||
if(
|
||||
desiredPitchTolerance < 180
|
||||
&&
|
||||
!(
|
||||
currentPitch <= desiredPitch + desiredPitchTolerance
|
||||
&&
|
||||
@ -314,6 +318,8 @@ public class Trigger
|
||||
}
|
||||
|
||||
if(
|
||||
desiredRollTolerance < 180
|
||||
&&
|
||||
!(
|
||||
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="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>
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user