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)
|
||||||
|
@ -341,6 +341,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)
|
||||||
{
|
{
|
||||||
|
@ -345,6 +345,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)
|
||||||
{
|
{
|
||||||
|
@ -1094,23 +1094,48 @@ public class Actions
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
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.acquire();
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Thread.sleep(awakeTime);
|
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");
|
||||||
catch (InterruptedException e)
|
wakeLock.acquire();
|
||||||
{
|
|
||||||
Miscellaneous.logEvent("w", context.getResources().getString(R.string.wakeupDevice), "Error keeping device awake: " + Log.getStackTraceString(e), 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
wakeLock.release();
|
try
|
||||||
|
{
|
||||||
|
Thread.sleep(awakeTime);
|
||||||
|
}
|
||||||
|
catch (InterruptedException e)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("w", context.getResources().getString(R.string.wakeupDevice), "Error keeping device awake: " + Log.getStackTraceString(e), 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
public static boolean setAirplaneMode(boolean desiredState, boolean toggleActionIfPossible)
|
public static boolean setAirplaneMode(boolean desiredState, boolean toggleActionIfPossible)
|
||||||
|
@ -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,13 +113,21 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
|||||||
if(getIntent().hasExtra(vectorFieldName))
|
if(getIntent().hasExtra(vectorFieldName))
|
||||||
{
|
{
|
||||||
editMode = true;
|
editMode = true;
|
||||||
String values[] = getIntent().getStringExtra(vectorFieldName).split(Trigger.triggerParameter2Split);
|
try
|
||||||
etDesiredAzimuth.setText(values[0]);
|
{
|
||||||
etDesiredAzimuthTolerance.setText(values[1]);
|
String values[] = getIntent().getStringExtra(vectorFieldName).split(Trigger.triggerParameter2Split);
|
||||||
etDesiredPitch.setText(values[2]);
|
etDesiredAzimuth.setText(values[0]);
|
||||||
etDesiredPitchTolerance.setText(values[3]);
|
etDesiredAzimuthTolerance.setText(values[1]);
|
||||||
etDesiredRoll.setText(values[4]);
|
etDesiredPitch.setText(values[2]);
|
||||||
etDesiredRollTolerance.setText(values[5]);
|
etDesiredPitchTolerance.setText(values[3]);
|
||||||
|
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()
|
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