pull/1/head
jens 12 months ago
parent b88801500f
commit 89ac69fd4b
  1. 17
      .idea/deploymentTargetDropDown.xml
  2. 2
      app/src/apkFlavor/java/com/jens/automation2/Rule.java
  3. 5
      app/src/fdroidFlavor/java/com/jens/automation2/Rule.java
  4. 5
      app/src/googlePlayFlavor/java/com/jens/automation2/Rule.java
  5. 43
      app/src/main/java/com/jens/automation2/Actions.java
  6. 3
      app/src/main/java/com/jens/automation2/ActivityManageRule.java
  7. 25
      app/src/main/java/com/jens/automation2/ActivityManageTriggerDevicePosition.java
  8. 1
      app/src/main/java/com/jens/automation2/PointOfInterest.java
  9. 6
      app/src/main/java/com/jens/automation2/Trigger.java
  10. 1
      app/src/main/res/values/strings.xml

@ -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)

@ -341,6 +341,11 @@ public class Rule implements Comparable<Rule>
return false;
}
public boolean getsGreenLight(Context context)
{
return isRuleActive() && applies(context) && hasNotAppliedSinceLastExecution();
}
public boolean applies(Context context)
{

@ -345,6 +345,11 @@ public class Rule implements Comparable<Rule>
return false;
}
public boolean getsGreenLight(Context context)
{
return isRuleActive() && applies(context) && hasNotAppliedSinceLastExecution();
}
public boolean applies(Context context)
{

@ -1094,23 +1094,48 @@ public class Actions
@Override
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
{
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");
wakeLock.acquire();
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 (InterruptedException e)
catch(Exception e)
{
Miscellaneous.logEvent("w", context.getResources().getString(R.string.wakeupDevice), "Error keeping device awake: " + Log.getStackTraceString(e), 4);
Miscellaneous.logEvent("e", "Wakeup device action", "Error while waking up device: " + Log.getStackTraceString(e), 1);
}
wakeLock.release();
}
}
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)
@SuppressLint("NewApi")
public static boolean setAirplaneMode(boolean desiredState, boolean toggleActionIfPossible)

@ -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,13 +113,21 @@ public class ActivityManageTriggerDevicePosition extends Activity
if(getIntent().hasExtra(vectorFieldName))
{
editMode = true;
String values[] = getIntent().getStringExtra(vectorFieldName).split(Trigger.triggerParameter2Split);
etDesiredAzimuth.setText(values[0]);
etDesiredAzimuthTolerance.setText(values[1]);
etDesiredPitch.setText(values[2]);
etDesiredPitchTolerance.setText(values[3]);
etDesiredRoll.setText(values[4]);
etDesiredRollTolerance.setText(values[5]);
try
{
String values[] = getIntent().getStringExtra(vectorFieldName).split(Trigger.triggerParameter2Split);
etDesiredAzimuth.setText(values[0]);
etDesiredAzimuthTolerance.setText(values[1]);
etDesiredPitch.setText(values[2]);
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()
@ -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…
Cancel
Save