Compare commits
No commits in common. "5ae193847e0273f0661f394bfffff467153b0f4f" and "fa578b175d64c93258eb1bb94059e3d369693921" have entirely different histories.
5ae193847e
...
fa578b175d
@ -348,24 +348,14 @@ public class Rule implements Comparable<Rule>
|
|||||||
|
|
||||||
public boolean getsGreenLight(Context context)
|
public boolean getsGreenLight(Context context)
|
||||||
{
|
{
|
||||||
if(applies(context))
|
return applies(context) && hasNotAppliedSinceLastExecution();
|
||||||
{
|
|
||||||
if(hasNotAppliedSinceLastExecution())
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " has not flipped since its last execution.", 4);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Miscellaneous.logEvent("i", "getsGreenLight()", "Rule " + getName() + " does not apply.", 4);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean applies(Context context)
|
public boolean applies(Context context)
|
||||||
{
|
{
|
||||||
if(AutomationService.getInstance() == null)
|
if(AutomationService.getInstance() == null)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "RuleCheck", "Automation service not running. Rule " + getName() + " cannot apply.", 3);
|
Miscellaneous.logEvent("i", "RuleCheck", "Automation service not running. Rule cannot apply.", 3);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +393,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyActivityNotPresent), getName(), ActivityDetectionReceiver.getDescription(oneTrigger.getActivityDetectionType())), 3);
|
Miscellaneous.logEvent("i", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyActivityNotPresent), ActivityDetectionReceiver.getDescription(oneTrigger.getActivityDetectionType())), 3);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -412,7 +402,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
{
|
{
|
||||||
if (oneDetectedActivity.getType() == oneTrigger.getActivityDetectionType() && oneDetectedActivity.getConfidence() < Settings.activityDetectionRequiredProbability)
|
if (oneDetectedActivity.getType() == oneTrigger.getActivityDetectionType() && oneDetectedActivity.getConfidence() < Settings.activityDetectionRequiredProbability)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyActivityGivenButTooLowProbability), getName(), ActivityDetectionReceiver.getDescription(oneDetectedActivity.getType()), String.valueOf(oneDetectedActivity.getConfidence()), String.valueOf(Settings.activityDetectionRequiredProbability)), 3);
|
Miscellaneous.logEvent("i", String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyActivityGivenButTooLowProbability), ActivityDetectionReceiver.getDescription(oneDetectedActivity.getType()), String.valueOf(oneDetectedActivity.getConfidence()), String.valueOf(Settings.activityDetectionRequiredProbability)), 3);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -544,7 +534,15 @@ public class Rule implements Comparable<Rule>
|
|||||||
public void activate(AutomationService automationService, boolean force)
|
public void activate(AutomationService automationService, boolean force)
|
||||||
{
|
{
|
||||||
ActivateRuleTask task = new ActivateRuleTask();
|
ActivateRuleTask task = new ActivateRuleTask();
|
||||||
|
|
||||||
|
// if(Settings.startNewThreadForRuleActivation)
|
||||||
task.execute(automationService, force);
|
task.execute(automationService, force);
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// task.activateInternally(automationService, force);
|
||||||
|
// AutomationService.updateNotification();
|
||||||
|
// ActivityMainScreen.updateMainScreen();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<Rule> findRuleCandidatesByPoi(PointOfInterest searchPoi, boolean triggerParameter)
|
public static ArrayList<Rule> findRuleCandidatesByPoi(PointOfInterest searchPoi, boolean triggerParameter)
|
||||||
@ -629,7 +627,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
|
|
||||||
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() > oneTrigger.getTimeFrame().getTriggerTimeStop().getTime())
|
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() > oneTrigger.getTimeFrame().getTriggerTimeStop().getTime())
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "Timeframe search", "Rule (" + oneRule.getName() + ") stretches over midnight.", 5);
|
Miscellaneous.logEvent("i", "Timeframe search", "Rule goes over midnight.", 5);
|
||||||
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() <= searchTime.getTime() || searchTime.getTime() <= oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()+20000) //add 20 seconds because of delay
|
if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() <= searchTime.getTime() || searchTime.getTime() <= oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()+20000) //add 20 seconds because of delay
|
||||||
{
|
{
|
||||||
ruleCandidates.add(oneRule);
|
ruleCandidates.add(oneRule);
|
||||||
@ -638,7 +636,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
}
|
}
|
||||||
else if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() <= searchTime.getTime() && searchTime.getTime() <= oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()+20000) //add 20 seconds because of delay
|
else if(oneTrigger.getTimeFrame().getTriggerTimeStart().getTime() <= searchTime.getTime() && searchTime.getTime() <= oneTrigger.getTimeFrame().getTriggerTimeStop().getTime()+20000) //add 20 seconds because of delay
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "RuleSearch", "Rule found (" + oneRule.getName() + ") with TimeFrame with time " + searchTime.toString(), 3);
|
Miscellaneous.logEvent("i", "RuleSearch", "Rule found with TimeFrame with time " + searchTime.toString(), 3);
|
||||||
ruleCandidates.add(oneRule);
|
ruleCandidates.add(oneRule);
|
||||||
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
break innerloop; //if the poi is found we don't need to search the other triggers in the same rule
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import android.os.AsyncTask;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -430,10 +429,7 @@ public class Action
|
|||||||
case turnScreenOnOrOff:
|
case turnScreenOnOrOff:
|
||||||
if(getParameter1())
|
if(getParameter1())
|
||||||
{
|
{
|
||||||
if(StringUtils.isNumeric(this.getParameter2()))
|
|
||||||
Actions.wakeupDevice(Long.parseLong(this.getParameter2()));
|
Actions.wakeupDevice(Long.parseLong(this.getParameter2()));
|
||||||
else
|
|
||||||
Actions.wakeupDevice((long)1000);
|
|
||||||
// wakeupDevice() will create a separate thread. That'll take some time, we wait 100ms.
|
// wakeupDevice() will create a separate thread. That'll take some time, we wait 100ms.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1124,7 +1124,7 @@ public class Actions
|
|||||||
// turn on screen
|
// turn on screen
|
||||||
Miscellaneous.logEvent("i", "Actions", "Turning screen on.", 3);
|
Miscellaneous.logEvent("i", "Actions", "Turning screen on.", 3);
|
||||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
WakeLock wakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, AutomationService.NOTIFICATION_CHANNEL_ID + ":turnOffScreen");
|
WakeLock wakeLock = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag");
|
||||||
wakeLock.acquire();
|
wakeLock.acquire();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1141,9 +1141,6 @@ public class Actions
|
|||||||
getWindow().setAttributes(params);
|
getWindow().setAttributes(params);
|
||||||
|
|
||||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||||
WakeLock wakeLock = pm.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK,AutomationService.NOTIFICATION_CHANNEL_ID + ":turnOffScreen");
|
|
||||||
// WakeLock wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK , AutomationService.NOTIFICATION_CHANNEL_ID + ":turnOffScreen");
|
|
||||||
wakeLock.acquire();
|
|
||||||
WakeLock wakeLock = pm.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "tag");
|
WakeLock wakeLock = pm.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "tag");
|
||||||
// WakeLock wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK , "tag");
|
// WakeLock wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK , "tag");
|
||||||
wakeLock.acquire();*/
|
wakeLock.acquire();*/
|
||||||
|
@ -49,7 +49,6 @@ import java.util.Collections;
|
|||||||
public class ActivityManageRule extends Activity
|
public class ActivityManageRule extends Activity
|
||||||
{
|
{
|
||||||
final static String activityDetectionClassPath = "com.jens.automation2.receivers.ActivityDetectionReceiver";
|
final static String activityDetectionClassPath = "com.jens.automation2.receivers.ActivityDetectionReceiver";
|
||||||
public final static String intentNameTriggerParameter1 = "triggerParameter1";
|
|
||||||
|
|
||||||
public Context context;
|
public Context context;
|
||||||
private Button cmdTriggerAdd, cmdActionAdd, cmdSaveRule;
|
private Button cmdTriggerAdd, cmdActionAdd, cmdSaveRule;
|
||||||
@ -266,7 +265,6 @@ public class ActivityManageRule extends Activity
|
|||||||
break;
|
break;
|
||||||
case devicePosition:
|
case devicePosition:
|
||||||
Intent devicePositionEditor = new Intent(ActivityManageRule.this, ActivityManageTriggerDevicePosition.class);
|
Intent devicePositionEditor = new Intent(ActivityManageRule.this, ActivityManageTriggerDevicePosition.class);
|
||||||
devicePositionEditor.putExtra(ActivityManageRule.intentNameTriggerParameter1, selectedTrigger.getTriggerParameter());
|
|
||||||
devicePositionEditor.putExtra(ActivityManageTriggerDevicePosition.vectorFieldName, selectedTrigger.getTriggerParameter2());
|
devicePositionEditor.putExtra(ActivityManageTriggerDevicePosition.vectorFieldName, selectedTrigger.getTriggerParameter2());
|
||||||
startActivityForResult(devicePositionEditor, requestCodeTriggerDevicePositionEdit);
|
startActivityForResult(devicePositionEditor, requestCodeTriggerDevicePositionEdit);
|
||||||
break;
|
break;
|
||||||
@ -1367,7 +1365,6 @@ public class ActivityManageRule extends Activity
|
|||||||
{
|
{
|
||||||
// newTrigger.setTriggerParameter(data.getBooleanExtra("wifiState", false));
|
// newTrigger.setTriggerParameter(data.getBooleanExtra("wifiState", false));
|
||||||
newTrigger.setTriggerParameter2(data.getStringExtra(ActivityManageTriggerDevicePosition.vectorFieldName));
|
newTrigger.setTriggerParameter2(data.getStringExtra(ActivityManageTriggerDevicePosition.vectorFieldName));
|
||||||
newTrigger.setParentRule(ruleToEdit);
|
|
||||||
ruleToEdit.getTriggerSet().add(newTrigger);
|
ruleToEdit.getTriggerSet().add(newTrigger);
|
||||||
this.refreshTriggerList();
|
this.refreshTriggerList();
|
||||||
}
|
}
|
||||||
@ -1378,9 +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);
|
||||||
editedTrigger.setTriggerParameter(data.getBooleanExtra(ActivityManageRule.intentNameTriggerParameter1, true));
|
|
||||||
editedTrigger.setTriggerParameter2(data.getStringExtra(ActivityManageTriggerDevicePosition.vectorFieldName));
|
editedTrigger.setTriggerParameter2(data.getStringExtra(ActivityManageTriggerDevicePosition.vectorFieldName));
|
||||||
editedTrigger.setParentRule(ruleToEdit);
|
|
||||||
ruleToEdit.getTriggerSet().set(editIndex, editedTrigger);
|
ruleToEdit.getTriggerSet().set(editIndex, editedTrigger);
|
||||||
this.refreshTriggerList();
|
this.refreshTriggerList();
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import android.text.Spanned;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@ -25,7 +24,6 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
|||||||
TextView currentAzimuth, currentPitch, currentRoll, tvAppliesAzimuth, tvAppliesPitch, tvAppliesRoll;
|
TextView currentAzimuth, currentPitch, currentRoll, tvAppliesAzimuth, tvAppliesPitch, tvAppliesRoll;
|
||||||
Button bApplyPositionValues, bSavePositionValues;
|
Button bApplyPositionValues, bSavePositionValues;
|
||||||
EditText etDesiredAzimuth, etDesiredAzimuthTolerance, etDesiredPitch, etDesiredPitchTolerance, etDesiredRoll, etDesiredRollTolerance;
|
EditText etDesiredAzimuth, etDesiredAzimuthTolerance, etDesiredPitch, etDesiredPitchTolerance, etDesiredRoll, etDesiredRollTolerance;
|
||||||
CheckBox chkDevicePositionApplies;
|
|
||||||
|
|
||||||
public static String vectorFieldName = "deviceVector";
|
public static String vectorFieldName = "deviceVector";
|
||||||
|
|
||||||
@ -39,11 +37,11 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
|||||||
currentPitch.setText(Float.toString(pitch));
|
currentPitch.setText(Float.toString(pitch));
|
||||||
currentRoll.setText(Float.toString(roll));
|
currentRoll.setText(Float.toString(roll));
|
||||||
|
|
||||||
try
|
if(checkInputs(false))
|
||||||
{
|
{
|
||||||
desiredAzimuth = Float.parseFloat(etDesiredAzimuth.getText().toString());
|
desiredAzimuth = Float.parseFloat(etDesiredAzimuth.getText().toString());
|
||||||
desiredAzimuthTolerance = Float.parseFloat(etDesiredAzimuthTolerance.getText().toString());
|
desiredAzimuthTolerance = Float.parseFloat(etDesiredAzimuthTolerance.getText().toString());
|
||||||
if (Math.abs(azimuth) <= Math.abs(desiredAzimuth - desiredAzimuthTolerance) || Math.abs(azimuth) <= desiredAzimuth + desiredAzimuthTolerance)
|
if(Math.abs(azimuth) <= Math.abs(desiredAzimuth - desiredAzimuthTolerance) || Math.abs(azimuth) <= desiredAzimuth + desiredAzimuthTolerance)
|
||||||
{
|
{
|
||||||
tvAppliesAzimuth.setText(getResources().getString(R.string.yes));
|
tvAppliesAzimuth.setText(getResources().getString(R.string.yes));
|
||||||
tvAppliesAzimuth.setTextColor(Color.GREEN);
|
tvAppliesAzimuth.setTextColor(Color.GREEN);
|
||||||
@ -53,17 +51,10 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
|||||||
tvAppliesAzimuth.setText(getResources().getString(R.string.no));
|
tvAppliesAzimuth.setText(getResources().getString(R.string.no));
|
||||||
tvAppliesAzimuth.setTextColor(Color.RED);
|
tvAppliesAzimuth.setTextColor(Color.RED);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
tvAppliesAzimuth.setText("");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
desiredPitch = Float.parseFloat(etDesiredPitch.getText().toString());
|
desiredPitch = Float.parseFloat(etDesiredPitch.getText().toString());
|
||||||
desiredPitchTolerance = Float.parseFloat(etDesiredPitchTolerance.getText().toString());
|
desiredPitchTolerance = Float.parseFloat(etDesiredPitchTolerance.getText().toString());
|
||||||
if (Math.abs(pitch) <= Math.abs(desiredPitch - desiredPitchTolerance) || Math.abs(pitch) <= desiredPitch + desiredPitchTolerance)
|
if(Math.abs(pitch) <= Math.abs(desiredPitch - desiredPitchTolerance) || Math.abs(pitch) <= desiredPitch + desiredPitchTolerance)
|
||||||
{
|
{
|
||||||
tvAppliesPitch.setText(getResources().getString(R.string.yes));
|
tvAppliesPitch.setText(getResources().getString(R.string.yes));
|
||||||
tvAppliesPitch.setTextColor(Color.GREEN);
|
tvAppliesPitch.setTextColor(Color.GREEN);
|
||||||
@ -73,17 +64,10 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
|||||||
tvAppliesPitch.setText(getResources().getString(R.string.no));
|
tvAppliesPitch.setText(getResources().getString(R.string.no));
|
||||||
tvAppliesPitch.setTextColor(Color.RED);
|
tvAppliesPitch.setTextColor(Color.RED);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
tvAppliesPitch.setText("");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
desiredRoll = Float.parseFloat(etDesiredRoll.getText().toString());
|
desiredRoll = Float.parseFloat(etDesiredRoll.getText().toString());
|
||||||
desiredRollTolerance = Float.parseFloat(etDesiredRollTolerance.getText().toString());
|
desiredRollTolerance = Float.parseFloat(etDesiredRollTolerance.getText().toString());
|
||||||
if (Math.abs(roll) <= Math.abs(desiredRoll - desiredRollTolerance) || Math.abs(roll) <= desiredRoll + desiredRollTolerance)
|
if(Math.abs(roll) <= Math.abs(desiredRoll - desiredRollTolerance) || Math.abs(roll) <= desiredRoll + desiredRollTolerance)
|
||||||
{
|
{
|
||||||
tvAppliesRoll.setText(getResources().getString(R.string.yes));
|
tvAppliesRoll.setText(getResources().getString(R.string.yes));
|
||||||
tvAppliesRoll.setTextColor(Color.GREEN);
|
tvAppliesRoll.setTextColor(Color.GREEN);
|
||||||
@ -94,10 +78,6 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
|||||||
tvAppliesRoll.setTextColor(Color.RED);
|
tvAppliesRoll.setTextColor(Color.RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
tvAppliesRoll.setText("");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -123,8 +103,6 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
|||||||
etDesiredRoll = (EditText) findViewById(R.id.etDesiredRoll);
|
etDesiredRoll = (EditText) findViewById(R.id.etDesiredRoll);
|
||||||
etDesiredRollTolerance = (EditText) findViewById(R.id.etDesiredRollTolerance);
|
etDesiredRollTolerance = (EditText) findViewById(R.id.etDesiredRollTolerance);
|
||||||
|
|
||||||
chkDevicePositionApplies = (CheckBox)findViewById(R.id.chkDevicePositionApplies);
|
|
||||||
|
|
||||||
// etDesiredAzimuth.setFilters(new InputFilter[]{new InputFilterMinMax(-180, 180)});
|
// etDesiredAzimuth.setFilters(new InputFilter[]{new InputFilterMinMax(-180, 180)});
|
||||||
// etDesiredPitch.setFilters(new InputFilter[]{new InputFilterMinMax(-180, 180)});
|
// etDesiredPitch.setFilters(new InputFilter[]{new InputFilterMinMax(-180, 180)});
|
||||||
// etDesiredRoll.setFilters(new InputFilter[]{new InputFilterMinMax(-180, 180)});
|
// etDesiredRoll.setFilters(new InputFilter[]{new InputFilterMinMax(-180, 180)});
|
||||||
@ -137,8 +115,6 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
|||||||
editMode = true;
|
editMode = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
boolean chkValue = getIntent().getBooleanExtra(ActivityManageRule.intentNameTriggerParameter1, true);
|
|
||||||
chkDevicePositionApplies.setChecked(chkValue);
|
|
||||||
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]);
|
||||||
@ -183,7 +159,6 @@ public class ActivityManageTriggerDevicePosition extends Activity
|
|||||||
{
|
{
|
||||||
// Save
|
// Save
|
||||||
Intent returnData = new Intent();
|
Intent returnData = new Intent();
|
||||||
returnData.putExtra(ActivityManageRule.intentNameTriggerParameter1, chkDevicePositionApplies.isChecked());
|
|
||||||
returnData.putExtra(vectorFieldName,
|
returnData.putExtra(vectorFieldName,
|
||||||
etDesiredAzimuth.getText().toString() + Trigger.triggerParameter2Split +
|
etDesiredAzimuth.getText().toString() + Trigger.triggerParameter2Split +
|
||||||
etDesiredAzimuthTolerance.getText().toString() + Trigger.triggerParameter2Split +
|
etDesiredAzimuthTolerance.getText().toString() + Trigger.triggerParameter2Split +
|
||||||
|
@ -360,7 +360,7 @@ public class ReceiverCoordinator
|
|||||||
if(!DevicePositionListener.getInstance().isListenerRunning())
|
if(!DevicePositionListener.getInstance().isListenerRunning())
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "DevicePositionListener", "Starting DevicePositionListener because used in a new/changed rule.", 4);
|
Miscellaneous.logEvent("i", "DevicePositionListener", "Starting DevicePositionListener because used in a new/changed rule.", 4);
|
||||||
// if(DevicePositionListener.getInstance().haveAllPermission())
|
if(HeadphoneJackListener.getInstance().haveAllPermission())
|
||||||
DevicePositionListener.getInstance().startListener(AutomationService.getInstance());
|
DevicePositionListener.getInstance().startListener(AutomationService.getInstance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,10 +300,7 @@ public class Trigger
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "DevicePosition", "Trigger doesn\'t apply. Azimuth outside of tolerance area.", 5);
|
Miscellaneous.logEvent("i", "DevicePosition", "Trigger doesn\'t apply. Azimuth outside of tolerance area.", 5);
|
||||||
if(getTriggerParameter())
|
|
||||||
return false;
|
return false;
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(
|
if(
|
||||||
@ -317,10 +314,7 @@ public class Trigger
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "DevicePosition", "Trigger doesn\'t apply. Pitch outside of tolerance area.", 5);
|
Miscellaneous.logEvent("i", "DevicePosition", "Trigger doesn\'t apply. Pitch outside of tolerance area.", 5);
|
||||||
if(getTriggerParameter())
|
|
||||||
return false;
|
return false;
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(
|
if(
|
||||||
@ -334,16 +328,10 @@ public class Trigger
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("i", "DevicePosition", "Trigger doesn\'t apply. Roll outside of tolerance area.", 5);
|
Miscellaneous.logEvent("i", "DevicePosition", "Trigger doesn\'t apply. Roll outside of tolerance area.", 5);
|
||||||
if(getTriggerParameter())
|
|
||||||
return false;
|
return false;
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getTriggerParameter())
|
|
||||||
return true;
|
return true;
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean checkHeadsetPlugged()
|
boolean checkHeadsetPlugged()
|
||||||
@ -1395,6 +1383,8 @@ public class Trigger
|
|||||||
break;
|
break;
|
||||||
case bluetoothConnection:
|
case bluetoothConnection:
|
||||||
String device = Miscellaneous.getAnyContext().getResources().getString(R.string.anyDevice);
|
String device = Miscellaneous.getAnyContext().getResources().getString(R.string.anyDevice);
|
||||||
|
// if(this.bluetoothDeviceAddress != null)
|
||||||
|
// {
|
||||||
if(bluetoothDeviceAddress.equals("<any>"))
|
if(bluetoothDeviceAddress.equals("<any>"))
|
||||||
{
|
{
|
||||||
device = Miscellaneous.getAnyContext().getResources().getString(R.string.any);
|
device = Miscellaneous.getAnyContext().getResources().getString(R.string.any);
|
||||||
@ -1411,8 +1401,8 @@ public class Trigger
|
|||||||
}
|
}
|
||||||
catch(NullPointerException e)
|
catch(NullPointerException e)
|
||||||
{
|
{
|
||||||
device = Miscellaneous.getAnyContext().getResources().getString(R.string.invalidDevice) + ": " + this.bluetoothDeviceAddress;
|
device = Miscellaneous.getAnyContext().getResources().getString(R.string.invalidDevice) + ": " + device;
|
||||||
Miscellaneous.logEvent("w", "Trigger", device, 3);
|
Miscellaneous.logEvent("w", "Trigger", Miscellaneous.getAnyContext().getResources().getString(R.string.invalidDevice) + ": " + device, 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1430,6 +1420,7 @@ public class Trigger
|
|||||||
else
|
else
|
||||||
returnString.append(String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.bluetoothDeviceOutOfRange), device));
|
returnString.append(String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.bluetoothDeviceOutOfRange), device));
|
||||||
}
|
}
|
||||||
|
// }
|
||||||
break;
|
break;
|
||||||
case headsetPlugged:
|
case headsetPlugged:
|
||||||
String type;
|
String type;
|
||||||
|
@ -100,7 +100,7 @@ public class DevicePositionListener implements SensorEventListener, AutomationLi
|
|||||||
{
|
{
|
||||||
//unregister the sensor listener
|
//unregister the sensor listener
|
||||||
sManager.unregisterListener(this);
|
sManager.unregisterListener(this);
|
||||||
isRunning = false;
|
isRunning = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,7 +184,7 @@ public class DevicePositionListener implements SensorEventListener, AutomationLi
|
|||||||
{
|
{
|
||||||
//unregister the sensor listener
|
//unregister the sensor listener
|
||||||
sManager.unregisterListener(this);
|
sManager.unregisterListener(this);
|
||||||
isRunning = false;
|
isRunning = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.jens.automation2.receivers;
|
package com.jens.automation2.receivers;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -134,7 +133,7 @@ public class HeadphoneJackListener extends BroadcastReceiver implements Automati
|
|||||||
|
|
||||||
public static boolean haveAllPermission()
|
public static boolean haveAllPermission()
|
||||||
{
|
{
|
||||||
return ActivityPermissions.havePermission(Manifest.permission.READ_PHONE_STATE, Miscellaneous.getAnyContext());
|
return ActivityPermissions.havePermission("android.permission.READ_PHONE_STATE", Miscellaneous.getAnyContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -224,18 +224,6 @@
|
|||||||
|
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
<CheckBox
|
|
||||||
android:id="@+id/chkDevicePositionApplies"
|
|
||||||
android:checked="true"
|
|
||||||
android:text="@string/mustApply"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@string/explanationDevicePositionDirection" />
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/bSavePositionValues"
|
android:id="@+id/bSavePositionValues"
|
||||||
android:text="@string/save"
|
android:text="@string/save"
|
||||||
|
@ -404,8 +404,8 @@
|
|||||||
<string name="detectedActivityWalking">Walking</string>
|
<string name="detectedActivityWalking">Walking</string>
|
||||||
<string name="detectedActivityRunning">Running</string>
|
<string name="detectedActivityRunning">Running</string>
|
||||||
<string name="detectedActivityInvalidStatus">Invalid activity</string>
|
<string name="detectedActivityInvalidStatus">Invalid activity</string>
|
||||||
<string name="ruleDoesntApplyActivityGivenButTooLowProbability" translatable="false">Rule %1$s doesn\'t apply. Detected activity %2$s given, but too low probability (%3$s %%), required %4$s %%.</string>
|
<string name="ruleDoesntApplyActivityGivenButTooLowProbability" translatable="false">Rule doesn\'t apply. Detected activity %1$s given, but too low probability (%2$s %%), required %3$s %%.</string>
|
||||||
<string name="ruleDoesntApplyActivityNotPresent" translatable="false">Rule %1$s doesn\'t apply. Required activity %2$s not present.</string>
|
<string name="ruleDoesntApplyActivityNotPresent" translatable="false">Rule doesn\'t apply. Required activity %1$s not present.</string>
|
||||||
<string name="selectTypeOfActivity">Select type of activity</string>
|
<string name="selectTypeOfActivity">Select type of activity</string>
|
||||||
<string name="triggerOnlyAvailableIfPlayServicesInstalled">This trigger is only available if Google Play Services is installed.</string>
|
<string name="triggerOnlyAvailableIfPlayServicesInstalled">This trigger is only available if Google Play Services is installed.</string>
|
||||||
<string name="activityDetectionFrequencyTitle">Activity detection frequency [sec]</string>
|
<string name="activityDetectionFrequencyTitle">Activity detection frequency [sec]</string>
|
||||||
@ -729,6 +729,4 @@
|
|||||||
<string name="turnScreenOnOrOff">Turn screen on or off</string>
|
<string name="turnScreenOnOrOff">Turn screen on or off</string>
|
||||||
<string name="turnScreenOn">turn screen on</string>
|
<string name="turnScreenOn">turn screen on</string>
|
||||||
<string name="turnScreenOff">turn screen off</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>
|
|
||||||
</resources>
|
</resources>
|
@ -5,7 +5,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:7.0.4'
|
classpath 'com.android.tools.build:gradle:7.0.3'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
Loading…
Reference in New Issue
Block a user