18 Commits

Author SHA1 Message Date
98b49036a7 Merge remote-tracking branch 'origin/development-stable' into development
# Conflicts:
#	app/src/main/res/values-de/strings.xml
#	app/src/main/res/values-es/strings.xml
#	app/src/main/res/values-it/strings.xml
#	app/src/main/res/values-nl/strings.xml
#	app/src/main/res/values/strings.xml
2022-05-21 14:08:19 +02:00
a7c4cc0965 app picker removed from play store version 2022-05-21 14:06:09 +02:00
5d67452486 Merge remote-tracking branch 'origin/development-stable' into development
# Conflicts:
#	app/src/main/res/values-de/strings.xml
#	app/src/main/res/values-es/strings.xml
#	app/src/main/res/values-it/strings.xml
#	app/src/main/res/values-nl/strings.xml
#	app/src/main/res/values/strings.xml
2022-05-21 13:37:50 +02:00
7e12a0f3e5 full day time window 2022-05-21 13:34:44 +02:00
5786c1bfd4 full day time window 2022-05-21 02:33:56 +02:00
cf500c740e new release prep 2022-05-15 01:54:56 +02:00
41efa7c11b Merge remote-tracking branch 'origin/development-stable' into development
# Conflicts:
#	app/src/main/res/values-de/strings.xml
#	app/src/main/res/values-es/strings.xml
#	app/src/main/res/values-it/strings.xml
#	app/src/main/res/values-nl/strings.xml
#	app/src/main/res/values/strings.xml
#	build.gradle
#	fastlane/metadata/android/en-US/changelogs/119.txt
2022-05-15 01:54:32 +02:00
965bf55811 Merge remote-tracking branch 'origin/development-stable' into development 2022-03-05 20:59:33 +01:00
13fd4c2aae magnetometer 2022-03-05 02:00:16 +01:00
195a60cfe0 magnetometer 2022-03-03 17:32:06 +01:00
76563eb89b Merge remote-tracking branch 'origin/development-stable' into development 2022-02-28 13:46:42 +01:00
7733d57435 gradle 2022-02-26 13:02:07 +01:00
481e4d1896 screen state string 2022-02-23 18:09:21 +01:00
5af59e1754 Merge remote-tracking branch 'origin/development-stable' into development
# Conflicts:
#	app/src/main/java/com/jens/automation2/Trigger.java
2022-02-22 22:21:39 +01:00
619f348a28 Merge remote-tracking branch 'origin/development-stable' into development 2022-02-20 18:57:38 +01:00
9bf353ea3a logging 2022-02-12 20:04:19 +01:00
af90b566c8 new triggers: service or device starts 2022-02-07 20:09:45 +01:00
0e51c577d5 new triggers: service or device starts 2022-02-06 20:12:11 +01:00
19 changed files with 322 additions and 154 deletions

View File

@@ -386,7 +386,8 @@ public class Rule implements Comparable<Rule>
if (!oneTrigger.applies(null, context)) if (!oneTrigger.applies(null, context))
return false; return false;
} }
Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format("Rule %1$s generally applies currently. Checking if it's really due, yet will be done separately.", this.getName()), 3);
return true; return true;
} }

View File

@@ -65,7 +65,6 @@
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/> <uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
<uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/> <uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/> <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>
<application <application
android:allowBackup="true" android:allowBackup="true"

View File

@@ -21,108 +21,109 @@ public class Action
public static final String intentPairSeparator = "intPairSplit"; public static final String intentPairSeparator = "intPairSplit";
public static final String vibrateSeparator = ","; public static final String vibrateSeparator = ",";
public enum Action_Enum { public enum Action_Enum
setWifi, {
setBluetooth, setWifi,
setUsbTethering, setBluetooth,
setWifiTethering, setUsbTethering,
setBluetoothTethering, setWifiTethering,
setDisplayRotation, setBluetoothTethering,
turnWifiOn,turnWifiOff, setDisplayRotation,
turnBluetoothOn,turnBluetoothOff, turnWifiOn,turnWifiOff,
triggerUrl, turnBluetoothOn,turnBluetoothOff,
changeSoundProfile, triggerUrl,
turnUsbTetheringOn,turnUsbTetheringOff, changeSoundProfile,
turnWifiTetheringOn,turnWifiTetheringOff, turnUsbTetheringOn,turnUsbTetheringOff,
enableScreenRotation,disableScreenRotation, turnWifiTetheringOn,turnWifiTetheringOff,
startOtherActivity, enableScreenRotation,disableScreenRotation,
waitBeforeNextAction, startOtherActivity,
turnScreenOnOrOff, waitBeforeNextAction,
setAirplaneMode, turnScreenOnOrOff,
setDataConnection, setAirplaneMode,
speakText, setDataConnection,
playMusic, speakText,
controlMediaPlayback, playMusic,
setScreenBrightness, controlMediaPlayback,
playSound, setScreenBrightness,
vibrate, playSound,
createNotification, vibrate,
closeNotification, createNotification,
sendTextMessage; closeNotification,
sendTextMessage;
public String getFullName(Context context)
{ public String getFullName(Context context)
switch(this) {
{ switch(this)
case setWifi: {
return context.getResources().getString(R.string.actionSetWifi); case setWifi:
case setBluetooth: return context.getResources().getString(R.string.actionSetWifi);
return context.getResources().getString(R.string.actionSetBluetooth); case setBluetooth:
case setWifiTethering: return context.getResources().getString(R.string.actionSetBluetooth);
return context.getResources().getString(R.string.actionSetWifiTethering); case setWifiTethering:
case setBluetoothTethering: return context.getResources().getString(R.string.actionSetWifiTethering);
return context.getResources().getString(R.string.actionSetBluetoothTethering); case setBluetoothTethering:
case setUsbTethering: return context.getResources().getString(R.string.actionSetBluetoothTethering);
return context.getResources().getString(R.string.actionSetUsbTethering); case setUsbTethering:
case setDisplayRotation: return context.getResources().getString(R.string.actionSetUsbTethering);
return context.getResources().getString(R.string.actionSetDisplayRotation); case setDisplayRotation:
case turnWifiOn: return context.getResources().getString(R.string.actionSetDisplayRotation);
return context.getResources().getString(R.string.actionTurnWifiOn); case turnWifiOn:
case turnWifiOff: return context.getResources().getString(R.string.actionTurnWifiOn);
return context.getResources().getString(R.string.actionTurnWifiOff); case turnWifiOff:
case turnBluetoothOn: return context.getResources().getString(R.string.actionTurnWifiOff);
return context.getResources().getString(R.string.actionTurnBluetoothOn); case turnBluetoothOn:
case turnBluetoothOff: return context.getResources().getString(R.string.actionTurnBluetoothOn);
return context.getResources().getString(R.string.actionTurnBluetoothOff); case turnBluetoothOff:
case triggerUrl: return context.getResources().getString(R.string.actionTurnBluetoothOff);
return context.getResources().getString(R.string.actionTriggerUrl); case triggerUrl:
case changeSoundProfile: return context.getResources().getString(R.string.actionTriggerUrl);
return context.getResources().getString(R.string.actionChangeSoundProfile); case changeSoundProfile:
case turnUsbTetheringOn: return context.getResources().getString(R.string.actionChangeSoundProfile);
return context.getResources().getString(R.string.actionTurnUsbTetheringOn); case turnUsbTetheringOn:
case turnUsbTetheringOff: return context.getResources().getString(R.string.actionTurnUsbTetheringOn);
return context.getResources().getString(R.string.actionTurnUsbTetheringOff); case turnUsbTetheringOff:
case turnWifiTetheringOn: return context.getResources().getString(R.string.actionTurnUsbTetheringOff);
return context.getResources().getString(R.string.actionTurnWifiTetheringOn); case turnWifiTetheringOn:
case turnWifiTetheringOff: return context.getResources().getString(R.string.actionTurnWifiTetheringOn);
return context.getResources().getString(R.string.actionTurnWifiTetheringOff); case turnWifiTetheringOff:
case enableScreenRotation: return context.getResources().getString(R.string.actionTurnWifiTetheringOff);
return context.getResources().getString(R.string.actionEnableScreenRotation); case enableScreenRotation:
case disableScreenRotation: return context.getResources().getString(R.string.actionEnableScreenRotation);
return context.getResources().getString(R.string.actionDisableScreenRotation); case disableScreenRotation:
case startOtherActivity: return context.getResources().getString(R.string.actionDisableScreenRotation);
return context.getResources().getString(R.string.startOtherActivity); case startOtherActivity:
case waitBeforeNextAction: return context.getResources().getString(R.string.startOtherActivity);
return context.getResources().getString(R.string.waitBeforeNextAction); case waitBeforeNextAction:
case turnScreenOnOrOff: return context.getResources().getString(R.string.waitBeforeNextAction);
return context.getResources().getString(R.string.turnScreenOnOrOff); case turnScreenOnOrOff:
case vibrate: return context.getResources().getString(R.string.turnScreenOnOrOff);
return context.getResources().getString(R.string.vibrate); case vibrate:
case setAirplaneMode: return context.getResources().getString(R.string.vibrate);
return context.getResources().getString(R.string.airplaneMode); case setAirplaneMode:
case setDataConnection: return context.getResources().getString(R.string.airplaneMode);
return context.getResources().getString(R.string.actionDataConnection); case setDataConnection:
case speakText: return context.getResources().getString(R.string.actionDataConnection);
return context.getResources().getString(R.string.actionSpeakText); case speakText:
case playMusic: return context.getResources().getString(R.string.actionSpeakText);
return context.getResources().getString(R.string.actionPlayMusic); case playMusic:
case controlMediaPlayback: return context.getResources().getString(R.string.actionPlayMusic);
return context.getResources().getString(R.string.actionMediaControl); case controlMediaPlayback:
case playSound: return context.getResources().getString(R.string.actionMediaControl);
return context.getResources().getString(R.string.playSound); case playSound:
case sendTextMessage: return context.getResources().getString(R.string.playSound);
return context.getResources().getString(R.string.sendTextMessage); case sendTextMessage:
case setScreenBrightness: return context.getResources().getString(R.string.sendTextMessage);
return context.getResources().getString(R.string.setScreenBrightness); case setScreenBrightness:
case createNotification: return context.getResources().getString(R.string.setScreenBrightness);
return context.getResources().getString(R.string.createNotification); case createNotification:
case closeNotification: return context.getResources().getString(R.string.createNotification);
return context.getResources().getString(R.string.closeNotifications); case closeNotification:
default: return context.getResources().getString(R.string.closeNotifications);
return "Unknown"; default:
} return "Unknown";
} }
}; }
};
private Action_Enum action; private Action_Enum action;
private boolean parameter1 = false; private boolean parameter1 = false;

View File

@@ -380,7 +380,13 @@ public class ActivityManageActionStartActivity extends Activity
int targetSdkVersion = getApplicationContext().getApplicationInfo().targetSdkVersion; int targetSdkVersion = getApplicationContext().getApplicationInfo().targetSdkVersion;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && targetSdkVersion >= 30 && !ActivityPermissions.havePermission(Manifest.permission.QUERY_ALL_PACKAGES, ActivityManageActionStartActivity.this))// && shouldShowRequestPermissionRationale(Manifest.permission.QUERY_ALL_PACKAGES)) if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && targetSdkVersion >= 30 && !ActivityPermissions.havePermission(Manifest.permission.QUERY_ALL_PACKAGES, ActivityManageActionStartActivity.this))// && shouldShowRequestPermissionRationale(Manifest.permission.QUERY_ALL_PACKAGES))
{ {
requestPermissions(new String[] {Manifest.permission.QUERY_ALL_PACKAGES}, requestCodeForRequestQueryAllPackagesPermission); if(BuildConfig.FLAVOR.equals("googlePlayFlavor"))
{
// This ain't possible anymore.
Miscellaneous.messageBox(getResources().getString(R.string.info), getResources().getString(R.string.featureNotInGooglePlayVersion) + Miscellaneous.lineSeparator + Miscellaneous.lineSeparator + getResources().getString(R.string.startActivityInsertManually), ActivityManageActionStartActivity.this).show();
}
else
requestPermissions(new String[] {Manifest.permission.QUERY_ALL_PACKAGES}, requestCodeForRequestQueryAllPackagesPermission);
} }
else else
getAppList(); getAppList();

View File

@@ -531,6 +531,10 @@ public class ActivityManageRule extends Activity
items.add(new Item(typesLong[i].toString(), R.drawable.sound)); items.add(new Item(typesLong[i].toString(), R.drawable.sound));
else if(types[i].toString().equals(Trigger_Enum.screenState.toString())) else if(types[i].toString().equals(Trigger_Enum.screenState.toString()))
items.add(new Item(typesLong[i].toString(), R.drawable.smartphone)); items.add(new Item(typesLong[i].toString(), R.drawable.smartphone));
else if(types[i].toString().equals(Trigger_Enum.deviceStarts.toString()))
items.add(new Item(typesLong[i].toString(), R.drawable.alarm));
else if(types[i].toString().equals(Trigger_Enum.serviceStarts.toString()))
items.add(new Item(typesLong[i].toString(), R.drawable.alarm));
else else
items.add(new Item(typesLong[i].toString(), R.drawable.placeholder)); items.add(new Item(typesLong[i].toString(), R.drawable.placeholder));
} }
@@ -595,7 +599,7 @@ public class ActivityManageRule extends Activity
booleanChoices = new String[]{getResources().getString(R.string.started), getResources().getString(R.string.stopped)}; booleanChoices = new String[]{getResources().getString(R.string.started), getResources().getString(R.string.stopped)};
else if(triggerType == Trigger_Enum.usb_host_connection) else if(triggerType == Trigger_Enum.usb_host_connection)
booleanChoices = new String[]{getResources().getString(R.string.connected), getResources().getString(R.string.disconnected)}; booleanChoices = new String[]{getResources().getString(R.string.connected), getResources().getString(R.string.disconnected)};
else if(triggerType == Trigger_Enum.speed | triggerType == Trigger_Enum.noiseLevel | triggerType == Trigger_Enum.batteryLevel) else if(triggerType == Trigger_Enum.speed || triggerType == Trigger_Enum.noiseLevel || triggerType == Trigger_Enum.batteryLevel)
booleanChoices = new String[]{getResources().getString(R.string.exceeds), getResources().getString(R.string.dropsBelow)}; booleanChoices = new String[]{getResources().getString(R.string.exceeds), getResources().getString(R.string.dropsBelow)};
else if(triggerType == Trigger_Enum.wifiConnection) else if(triggerType == Trigger_Enum.wifiConnection)
{ {
@@ -700,6 +704,20 @@ public class ActivityManageRule extends Activity
getTriggerScreenStateDialog().show(); getTriggerScreenStateDialog().show();
return; return;
} }
else if(triggerType == Trigger_Enum.deviceStarts)
{
newTrigger.setTriggerType(Trigger_Enum.deviceStarts);
ruleToEdit.getTriggerSet().add(newTrigger);
refreshTriggerList();
return;
}
else if(triggerType == Trigger_Enum.serviceStarts)
{
newTrigger.setTriggerType(Trigger_Enum.serviceStarts);
ruleToEdit.getTriggerSet().add(newTrigger);
refreshTriggerList();
return;
}
else if(triggerType == Trigger_Enum.headsetPlugged) else if(triggerType == Trigger_Enum.headsetPlugged)
booleanChoices = new String[]{getResources().getString(R.string.connected), getResources().getString(R.string.disconnected)}; booleanChoices = new String[]{getResources().getString(R.string.connected), getResources().getString(R.string.disconnected)};

View File

@@ -10,13 +10,13 @@ import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.EditText; import android.widget.EditText;
import android.widget.RadioButton; import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.TimePicker; import android.widget.TimePicker;
import android.widget.Toast; import android.widget.Toast;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.sql.Time; import java.sql.Time;
import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
@@ -27,6 +27,7 @@ public class ActivityManageTriggerTimeFrame extends Activity
CheckBox checkMonday, checkTuesday, checkWednesday, checkThursday, checkFriday, checkSaturday, checkSunday, chkRepeat; CheckBox checkMonday, checkTuesday, checkWednesday, checkThursday, checkFriday, checkSaturday, checkSunday, chkRepeat;
RadioButton radioTimeFrameEntering, radioTimeFrameLeaving; RadioButton radioTimeFrameEntering, radioTimeFrameLeaving;
EditText etRepeatEvery; EditText etRepeatEvery;
TextView tvDaysHint;
static Trigger editedTimeFrameTrigger = null; static Trigger editedTimeFrameTrigger = null;
@@ -53,6 +54,7 @@ public class ActivityManageTriggerTimeFrame extends Activity
radioTimeFrameLeaving = (RadioButton)findViewById(R.id.radioTimeFrameLeaving); radioTimeFrameLeaving = (RadioButton)findViewById(R.id.radioTimeFrameLeaving);
chkRepeat = (CheckBox)findViewById(R.id.chkRepeat); chkRepeat = (CheckBox)findViewById(R.id.chkRepeat);
etRepeatEvery = (EditText)findViewById(R.id.etRepeatEvery); etRepeatEvery = (EditText)findViewById(R.id.etRepeatEvery);
tvDaysHint = (TextView)findViewById(R.id.tvDaysHint);
bSaveTimeFrame.setOnClickListener(new OnClickListener() bSaveTimeFrame.setOnClickListener(new OnClickListener()
{ {
@@ -181,6 +183,31 @@ public class ActivityManageTriggerTimeFrame extends Activity
editedTimeFrameTrigger.setTimeFrame(new TimeFrame(editedTimeFrameTrigger.getTriggerParameter2())); editedTimeFrameTrigger.setTimeFrame(new TimeFrame(editedTimeFrameTrigger.getTriggerParameter2()));
loadVariableIntoGui(); loadVariableIntoGui();
} }
TimePicker.OnTimeChangedListener pickerListener = new TimePicker.OnTimeChangedListener()
{
@Override
public void onTimeChanged(TimePicker timePicker, int i, int i1)
{
if(
startPicker.getCurrentHour() > stopPicker.getCurrentHour()
||
(
startPicker.getCurrentHour() == stopPicker.getCurrentHour()
&&
startPicker.getCurrentMinute() >= stopPicker.getCurrentMinute()
)
)
tvDaysHint.setText(getResources().getString(R.string.timeFrameDaysHint));
else
tvDaysHint.setText("");
}
};
startPicker.setOnTimeChangedListener(pickerListener);
stopPicker.setOnTimeChangedListener(pickerListener);
// Perform check once
pickerListener.onTimeChanged(null, 0, 0);
} }
private void loadVariableIntoGui() private void loadVariableIntoGui()

View File

@@ -33,6 +33,7 @@ import com.jens.automation2.receivers.PackageReplacedReceiver;
import com.jens.automation2.receivers.PhoneStatusListener; import com.jens.automation2.receivers.PhoneStatusListener;
import java.util.Calendar; import java.util.Calendar;
import java.util.Set;
@SuppressLint("NewApi") @SuppressLint("NewApi")
public class AutomationService extends Service implements OnInitListener public class AutomationService extends Service implements OnInitListener
@@ -193,6 +194,9 @@ public class AutomationService extends Service implements OnInitListener
{ {
Bundle b = intent.getExtras(); Bundle b = intent.getExtras();
startAtBoot = b.getBoolean("startAtBoot", false); startAtBoot = b.getBoolean("startAtBoot", false);
if(startAtBoot)
Settings.deviceStartDone = false;
} }
if (checkStartupRequirements(this, startAtBoot)) if (checkStartupRequirements(this, startAtBoot))
@@ -212,12 +216,9 @@ public class AutomationService extends Service implements OnInitListener
ActivityMainScreen.updateMainScreen(); ActivityMainScreen.updateMainScreen();
this.isRunning = true; this.isRunning = true;
Miscellaneous.logEvent("i", "Service", this.getResources().getString(R.string.serviceStarted) + " VERSION_CODE: " + BuildConfig.VERSION_CODE + ", VERSION_NAME: " + BuildConfig.VERSION_NAME + ", flavor: " + BuildConfig.FLAVOR, 1); Miscellaneous.logEvent("i", "Service", this.getResources().getString(R.string.serviceStarted) + " VERSION_CODE: " + BuildConfig.VERSION_CODE + ", VERSION_NAME: " + BuildConfig.VERSION_NAME + ", flavor: " + BuildConfig.FLAVOR, 1);
Toast.makeText(this, this.getResources().getString(R.string.serviceStarted), Toast.LENGTH_LONG).show(); Toast.makeText(this, this.getResources().getString(R.string.serviceStarted), Toast.LENGTH_LONG).show();
// ********** Test area **********
// Miscellaneous.logEvent("i", "setNetworkType", "bin hier.", 3);
// Actions.setData(true);
// ********** Test area **********
/* /*
On normal phones the app is supposed to automatically restart in case of any problems. On normal phones the app is supposed to automatically restart in case of any problems.
@@ -318,6 +319,8 @@ public class AutomationService extends Service implements OnInitListener
private void startUpRoutine() private void startUpRoutine()
{ {
Settings.serviceStartDone = false;
checkForTtsEngine(); checkForTtsEngine();
checkForPermissions(); checkForPermissions();
checkForRestrictedFeatures(); checkForRestrictedFeatures();
@@ -336,6 +339,9 @@ public class AutomationService extends Service implements OnInitListener
if(r.getsGreenLight(AutomationService.this)) if(r.getsGreenLight(AutomationService.this))
r.activate(AutomationService.this, false); r.activate(AutomationService.this, false);
} }
Settings.serviceStartDone = true;
Settings.deviceStartDone = true;
} }
protected void startLocationProvider() protected void startLocationProvider()

View File

@@ -215,7 +215,7 @@ public class ReceiverCoordinator
Class testClass = Class.forName(ActivityManageRule.activityDetectionClassPath); Class testClass = Class.forName(ActivityManageRule.activityDetectionClassPath);
Miscellaneous.runMethodReflective("ActivityDetectionReceiver", "stopActivityDetectionReceiver", null); Miscellaneous.runMethodReflective("ActivityDetectionReceiver", "stopActivityDetectionReceiver", null);
} }
catch(ClassNotFoundException e) catch(Exception e)
{ {
// Nothing to do, just not stopping this one. // Nothing to do, just not stopping this one.
} }

View File

@@ -12,7 +12,7 @@ import java.util.Set;
public class Settings implements SharedPreferences public class Settings implements SharedPreferences
{ {
public static final int rulesThatHaveBeenRanHistorySize = 10; public static final int rulesThatHaveBeenRanHistorySize = 10;
public final static int lockSoundChangesInterval = 15; public static final int lockSoundChangesInterval = 15;
public static final int newsPollEveryXDays = 3; public static final int newsPollEveryXDays = 3;
public static final int newsDisplayForXDays = 3; public static final int newsDisplayForXDays = 3;
public static final int updateCheckFrequencyDays = 7; public static final int updateCheckFrequencyDays = 7;
@@ -77,7 +77,13 @@ public class Settings implements SharedPreferences
public static ArrayList<String> whatHasBeenDone; public static ArrayList<String> whatHasBeenDone;
/* /*
Generic settings valid for all installations and not changable Not saved permanently.
*/
public static boolean deviceStartDone = true; // by default assume device has not just been started
public static boolean serviceStartDone = false;
/*
Generic settings valid for all installations and not changeable
*/ */
public static final String dateFormat = "E dd.MM.yyyy HH:mm:ss:ssss"; public static final String dateFormat = "E dd.MM.yyyy HH:mm:ss:ssss";
@@ -600,5 +606,4 @@ public class Settings implements SharedPreferences
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
} }

View File

@@ -3,7 +3,7 @@ package com.jens.automation2;
import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice;
import android.content.Context; import android.content.Context;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.SystemClock;
import android.service.notification.StatusBarNotification; import android.service.notification.StatusBarNotification;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import android.util.Log; import android.util.Log;
@@ -25,10 +25,6 @@ import com.jens.automation2.receivers.PhoneStatusListener;
import com.jens.automation2.receivers.ProcessListener; import com.jens.automation2.receivers.ProcessListener;
import com.jens.automation2.receivers.ScreenStateReceiver; import com.jens.automation2.receivers.ScreenStateReceiver;
import static com.jens.automation2.Trigger.triggerParameter2Split;
import static com.jens.automation2.receivers.NotificationListener.EXTRA_TEXT;
import static com.jens.automation2.receivers.NotificationListener.EXTRA_TITLE;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.sql.Time; import java.sql.Time;
@@ -38,8 +34,31 @@ import java.util.Date;
public class Trigger public class Trigger
{ {
public enum Trigger_Enum { public enum Trigger_Enum
pointOfInterest, timeFrame, charging, batteryLevel, usb_host_connection, speed, noiseLevel, wifiConnection, process_started_stopped, airplaneMode, roaming, nfcTag, activityDetection, bluetoothConnection, headsetPlugged, notification, deviceOrientation, profileActive, screenState, musicPlaying, phoneCall; //phoneCall always needs to be at the very end because of Google's shitty so called privacy {
pointOfInterest,
timeFrame,
charging,
batteryLevel,
usb_host_connection,
speed,
noiseLevel,
wifiConnection,
process_started_stopped,
airplaneMode,
roaming,
nfcTag,
activityDetection,
bluetoothConnection,
headsetPlugged,
notification,
deviceOrientation,
profileActive,
screenState,
musicPlaying,
deviceStarts,
serviceStarts,
phoneCall; //phoneCall always needs to be at the very end because of Google's shitty so called privacy
public String getFullName(Context context) public String getFullName(Context context)
{ {
@@ -87,6 +106,10 @@ public class Trigger
return context.getResources().getString(R.string.musicPlaying); return context.getResources().getString(R.string.musicPlaying);
case screenState: case screenState:
return context.getResources().getString(R.string.screenState); return context.getResources().getString(R.string.screenState);
case deviceStarts:
return context.getResources().getString(R.string.deviceStarts);
case serviceStarts:
return context.getResources().getString(R.string.serviceStarts);
default: default:
return "Unknown"; return "Unknown";
} }
@@ -190,6 +213,14 @@ public class Trigger
if(!checkScreenState()) if(!checkScreenState())
result = false; result = false;
break; break;
case deviceStarts:
if(!checkDeviceStarts())
result = false;
break;
case serviceStarts:
if(!checkServiceStarts())
result = false;
break;
default: default:
break; break;
} }
@@ -343,6 +374,16 @@ public class Trigger
return triggerParameter == MediaPlayerListener.isAudioPlaying(Miscellaneous.getAnyContext()); return triggerParameter == MediaPlayerListener.isAudioPlaying(Miscellaneous.getAnyContext());
} }
boolean checkDeviceStarts()
{
return checkServiceStarts() && !Settings.deviceStartDone;
}
boolean checkServiceStarts()
{
return !Settings.serviceStartDone;
}
boolean checkProfileActive() boolean checkProfileActive()
{ {
String demandedProfileName = getTriggerParameter2().split(Trigger.triggerParameter2Split)[0]; String demandedProfileName = getTriggerParameter2().split(Trigger.triggerParameter2Split)[0];
@@ -884,20 +925,24 @@ public class Trigger
if( if(
// Regular case, start time is lower than end time // Regular case, start time is lower than end time
( (
Miscellaneous.compareTimes(tf.getTriggerTimeStart(), nowTime) >= 0 Miscellaneous.compareTimes(tf.getTriggerTimeStart(), nowTime) >= 0
&& &&
Miscellaneous.compareTimes(nowTime, tf.getTriggerTimeStop()) > 0 Miscellaneous.compareTimes(nowTime, tf.getTriggerTimeStop()) > 0
)
||
// Other case, start time higher than end time, timeframe goes over midnight
(
Miscellaneous.compareTimes(tf.getTriggerTimeStart(), tf.getTriggerTimeStop()) < 0
&&
(Miscellaneous.compareTimes(tf.getTriggerTimeStart(), nowTime) >= 0
||
Miscellaneous.compareTimes(nowTime, tf.getTriggerTimeStop()) > 0)
)
||
// further case: start and end times are identical, meaning a 24h window
(
Miscellaneous.compareTimes(tf.getTriggerTimeStart(), tf.getTriggerTimeStop()) == 0
) )
|
// Other case, start time higher than end time, timeframe goes over midnight
(
Miscellaneous.compareTimes(tf.getTriggerTimeStart(), tf.getTriggerTimeStop()) < 0
&&
(Miscellaneous.compareTimes(tf.getTriggerTimeStart(), nowTime) >= 0
||
Miscellaneous.compareTimes(nowTime, tf.getTriggerTimeStop()) > 0)
)
) )
{ {
// We are in the timeframe // We are in the timeframe
@@ -1538,7 +1583,7 @@ public class Trigger
state = Miscellaneous.getAnyContext().getString(R.string.off); state = Miscellaneous.getAnyContext().getString(R.string.off);
break; break;
case "1": case "1":
state = Miscellaneous.getAnyContext().getString(R.string.on); state = Miscellaneous.getAnyContext().getString(R.string.on);
break; break;
case "2": case "2":
state = Miscellaneous.getAnyContext().getString(R.string.unlocked); state = Miscellaneous.getAnyContext().getString(R.string.unlocked);
@@ -1546,8 +1591,15 @@ public class Trigger
default: default:
state = Miscellaneous.getAnyContext().getString(R.string.unknown); state = Miscellaneous.getAnyContext().getString(R.string.unknown);
} }
returnString.append(String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.screenIs), state));
returnString.append(String.format(Miscellaneous.getAnyContext().getString(R.string.screenIs), state)); break;
case deviceStarts:
// This type doesn't have an activate/deactivate equivalent
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.deviceHasJustStarted));
break;
case serviceStarts:
// This type doesn't have an activate/deactivate equivalent
returnString.append(Miscellaneous.getAnyContext().getResources().getString(R.string.serviceHasJustStarted));
break; break;
default: default:
returnString.append("error"); returnString.append("error");

View File

@@ -34,17 +34,18 @@ public class DeviceOrientationListener implements SensorEventListener, Automatio
static int sensorValueCounter = 0; static int sensorValueCounter = 0;
// Gravity rotational data // Gravity rotational data
private float gravity[]; float gravity[];
// Magnetic rotational data // Magnetic rotational data
private float magnetic[]; //for magnetic rotational data float magnetic[]; //for magnetic rotational data
private float accels[] = new float[3]; float accels[] = new float[3];
private float mags[] = new float[3]; float mags[] = new float[3];
private float[] values = new float[3]; float[] values = new float[3];
boolean hasMagneticSensor=false;
// azimuth, pitch and roll // azimuth, pitch and roll
private float azimuth; float azimuth;
private float pitch; float pitch;
private float roll; float roll;
boolean applies = false; boolean applies = false;
boolean flipped = false; boolean flipped = false;
@@ -91,7 +92,7 @@ public class DeviceOrientationListener implements SensorEventListener, Automatio
isRunning = true; isRunning = true;
sManager.registerListener(this, sManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL); sManager.registerListener(this, sManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
sManager.registerListener(this, sManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD), SensorManager.SENSOR_DELAY_NORMAL); hasMagneticSensor = sManager.registerListener(this, sManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD), SensorManager.SENSOR_DELAY_NORMAL);
} }
} }
@@ -129,6 +130,9 @@ public class DeviceOrientationListener implements SensorEventListener, Automatio
break; break;
} }
if (!hasMagneticSensor)
mags=new float[]{1f,1f,1f};
if (mags != null && accels != null) if (mags != null && accels != null)
{ {
gravity = new float[9]; gravity = new float[9];

View File

@@ -89,6 +89,11 @@ public class NotificationListener extends NotificationListenerService// implemen
{ {
lastNotification = convertNotificationToSimpleNotification(created, sbn); lastNotification = convertNotificationToSimpleNotification(created, sbn);
if(created)
Miscellaneous.logEvent("i", "New notification", lastNotification.toString(), 5);
else
Miscellaneous.logEvent("i", "Notification removed", lastNotification.toString(), 5);
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.notification); ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger.Trigger_Enum.notification);
for (int i = 0; i < ruleCandidates.size(); i++) for (int i = 0; i < ruleCandidates.size(); i++)
{ {

View File

@@ -71,13 +71,20 @@
android:layout_margin="10dp" android:layout_margin="10dp"
android:background="#aa000000" /> android:background="#aa000000" />
<TextView <TextView
android:id="@+id/tvCurrentNfcIdValue" android:id="@+id/tvCurrentNfcIdValue"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/timeFrameWhichDays" android:text="@string/timeFrameWhichDays"
android:textAppearance="?android:attr/textAppearanceLarge" /> android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/tvDaysHint"
android:layout_marginVertical="@dimen/default_margin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/red" />
<CheckBox <CheckBox
android:id="@+id/checkMonday" android:id="@+id/checkMonday"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@@ -701,4 +701,11 @@
<string name="profileXrequiresThis">Profil \"%1$s\" benötigt dies.</string> <string name="profileXrequiresThis">Profil \"%1$s\" benötigt dies.</string>
<string name="lastProfile">Letztes Profil:</string> <string name="lastProfile">Letztes Profil:</string>
<string name="queryAllPackages">Liste von installierten Anwendungen auslesen</string> <string name="queryAllPackages">Liste von installierten Anwendungen auslesen</string>
<string name="timeFrameDaysHint">Wenn Sie ein Zeitfenster verwenden, das sich über Mitternacht erstreckt, müssen Sie auch den Folgetag auswählen, wenn der Auslöser auch nach Mitternacht noch auslösen soll.</string>
<string name="featureNotInGooglePlayVersion">Diese Funktion ist in der Google Play-Version nicht mehr verfügbar.\n\nHin und wieder schikaniert Google Entwickler. Wenn Sie bestimmte Funktionen weiterhin verwenden möchten, müssen Sie Unterlagen einreichen. Leider besteht eine 99% ige Chance, dass der Papierkram abgelehnt wird. Es ist so ziemlich wie im Asterix-Comic/Film.\n\nIch habe in der Vergangenheit Wochen damit verbracht, mit ihnen über solche Fälle zu streiten, aber ich bekam immer wieder Ablehnungen - entweder von Bots oder von Leuten, die ungefähr so intelligent sind wie Bots. Ich kann mich dann nur entscheiden, ob die App vollständig aus dem Play Store fliegen soll oder die Funktion aus der Play Store Version entfernen.\n\nBitte erwägen Sie, die APK-Version von meiner Website oder die von F-Droid zu verwenden, wenn Sie diese Funktionen benötigen.</string>
<string name="startActivityInsertManually">Diese Einschränkung betrifft nur die Auswahl einer App, nicht den eigentlichen Start. So können Sie den Namen einer Anwendung immer noch manuell eingeben, falls Sie ihn kennen.</string>
<string name="serviceStarts">Dienst startet</string>
<string name="deviceStarts">Gerät startet</string>
<string name="deviceHasJustStarted">Gerät ist gerade gestartet</string>
<string name="serviceHasJustStarted">Dienst ist gerade gestartet</string>
</resources> </resources>

View File

@@ -700,4 +700,11 @@
<string name="profileXrequiresThis">El perfil \"%1$s\" requiere esto.</string> <string name="profileXrequiresThis">El perfil \"%1$s\" requiere esto.</string>
<string name="lastProfile">Último perfil:</string> <string name="lastProfile">Último perfil:</string>
<string name="queryAllPackages">Obtener una lista de las aplicaciones instaladas</string> <string name="queryAllPackages">Obtener una lista de las aplicaciones instaladas</string>
<string name="timeFrameDaysHint">Si utiliza un marco de tiempo que se extiende más allá de la medianoche, también debe seleccionar el día siguiente si desea que la condición se aplique después de la medianoche.</string>
<string name="featureNotInGooglePlayVersion">Esta función ya no está disponible en la versión de Google Play.\n\nTodo de vez en cuando Google intimida a los desarrolladores. Si desea seguir utilizando ciertas funciones, debe presentar documentos. Desafortunadamente, hay un 99% de posibilidades de que el papeleo sea rechazado. Es más o menos como en el cómic/la película de Astérix.\n\nHe pasado semanas discutiendo con ellos sobre casos como ese en el pasado, pero seguí recibiendo rechazos, ya sea por bots o personas que son tan inteligentes como los bots. En el puedo decidir entre que la aplicación se elimine de Play Store por completo o eliminar la función.\n\nPor favor, considere usar la versión APK de mi sitio web o la de F-Droid si necesita esas características.</string>
<string name="startActivityInsertManually">Esta limitación se refiere solo a la selección de una aplicación, no al inicio real. Por lo tanto, aún puede ingresar el nombre de una aplicación manualmente si lo conoce.</string>
<string name="deviceStarts">Dispositivo esta enciendo</string>
<string name="serviceStarts">Servicio esta enciendo</string>
<string name="deviceHasJustStarted">el dispositivo justamente ha encendido</string>
<string name="serviceHasJustStarted">el servicio justamente ha encendido</string>
</resources> </resources>

View File

@@ -701,4 +701,11 @@
<string name="locationNotWorkingOn12">Ottenere la posizione non sembra funzionare su dispositivi Android 12 al momento. Se non funziona per te, mi dispiace. Cercherò di risolvere questo problema non appena conoscerò la causa. Quindi, se cerchio rotante non smette di girare, sai perché.</string> <string name="locationNotWorkingOn12">Ottenere la posizione non sembra funzionare su dispositivi Android 12 al momento. Se non funziona per te, mi dispiace. Cercherò di risolvere questo problema non appena conoscerò la causa. Quindi, se cerchio rotante non smette di girare, sai perché.</string>
<string name="lastProfile">Ultimo profilo:</string> <string name="lastProfile">Ultimo profilo:</string>
<string name="queryAllPackages">Ottenere un elenco delle applicazioni installate</string> <string name="queryAllPackages">Ottenere un elenco delle applicazioni installate</string>
<string name="timeFrameDaysHint">Se si utilizza un intervallo di tempo che si estende oltre la mezzanotte, è necessario selezionare anche il giorno successivo se si desidera che il trigger venga applicato dopo la mezzanotte.</string>
<string name="featureNotInGooglePlayVersion">Questa funzione non è più disponibile nella versione di Google Play.\\n\\nOltre di tanto in tanto Google bullizza gli sviluppatori. Se si desidera continuare a utilizzare determinate funzionalità, è necessario archiviare i documenti. Sfortunatamente c\'è una probabilità del 99% che i documenti vengano rifiutati. È più o meno come nel fumetto / film di Asterix.\\n\\nHo passato settimane a discutere con loro su casi del genere in passato, ma ho continuato a ricevere rifiuti - sia da bot che da persone che sono intelligenti come i bot. Nella sezione Posso decidere se l\'app viene rimossa completamente dal Play Store o rimuovere la funzione.\\nConsigliare l\'utilizzo della versione APK dal mio sito Web o quella di F-Droid se sono necessarie tali funzionalità.</string>
<string name="startActivityInsertManually">Questa limitazione riguarda solo la selezione di un\'app, non l\'avvio effettivo. Quindi puoi comunque inserire manualmente il nome di un\'applicazione se lo conosci.</string>
<string name="deviceStarts">Device starts</string>
<string name="serviceStarts">Avvio del servizio</string>
<string name="deviceHasJustStarted">Il dispositivo è appena stato avviato</string>
<string name="serviceHasJustStarted">il servizio è appena iniziato</string>
</resources> </resources>

View File

@@ -699,4 +699,11 @@
<string name="profileXrequiresThis">Profiel \"%1$s\" vereist dit.</string> <string name="profileXrequiresThis">Profiel \"%1$s\" vereist dit.</string>
<string name="lastProfile">Laatste profiel:</string> <string name="lastProfile">Laatste profiel:</string>
<string name="queryAllPackages">Een lijst met geïnstalleerde toepassingen ophalen</string> <string name="queryAllPackages">Een lijst met geïnstalleerde toepassingen ophalen</string>
<string name="timeFrameDaysHint">Als u een tijdsbestek gebruikt dat zich uitstrekt over middernacht, moet u ook de volgende dag selecteren als u wilt dat de trigger na middernacht van toepassing is.</string>
<string name="featureNotInGooglePlayVersion">Deze functie is niet meer beschikbaar in de Google Play-versie.\\n\\nAlles af en toe pest Google ontwikkelaars. Als u bepaalde functies wilt blijven gebruiken, moet u papierwerk indienen. Helaas is er een kans van 99% dat het papierwerk wordt afgewezen. Het is vrijwel net als in de Asterix-strip / film.\\n\\nIk heb in het verleden wekenlang met hen gediscussieerd over dergelijke gevallen, maar ik bleef afwijzingen krijgen - hetzij door bots of mensen die ongeveer net zo intelligent zijn als bots. In de ik kan kiezen tussen de app die volledig uit de Play Store wordt verwijderd of de functie verwijdert.\\n Overweeg de APK-versie van mijn website of die van F-Droid te gebruiken als je die functies nodig hebt.</string>
<string name="startActivityInsertManually">Deze beperking heeft alleen betrekking op de selectie van een app, niet op de daadwerkelijke start. U kunt dus nog steeds handmatig de naam van een toepassing invoeren als u deze kent.</string>
<string name="deviceHasJustStarted">apparaat is net gestart</string>
<string name="serviceHasJustStarted">service is net begonnen</string>
<string name="serviceStarts">Service start</string>
<string name="deviceStarts">Apparaat start</string>
</resources> </resources>

View File

@@ -797,4 +797,11 @@
<string name="locationNotWorkingOn12">Getting the location does not seem to be working on Android 12 devices currently. If it isn\'t working for you, I\'m sorry. I\'ll try to fix this as soon as I know the cause. So if the donut doesn\'t stop spinning, you know why.</string> <string name="locationNotWorkingOn12">Getting the location does not seem to be working on Android 12 devices currently. If it isn\'t working for you, I\'m sorry. I\'ll try to fix this as soon as I know the cause. So if the donut doesn\'t stop spinning, you know why.</string>
<string name="lastProfile">Last profile:</string> <string name="lastProfile">Last profile:</string>
<string name="queryAllPackages">Get a list of installed applications</string> <string name="queryAllPackages">Get a list of installed applications</string>
<string name="timeFrameDaysHint">If you use a timeframe that stretches over midnight you need to select the following day as well if you want the trigger to apply after midnight.</string>
<string name="featureNotInGooglePlayVersion">This feature is not available in the Google Play version anymore.\n\nEvery now and then Google bullies developers. If you want to keep using certain features you have to file paperwork. Unfortunately there\'s a 99% chance that the paperwork gets rejected. It\'s pretty much like in the Asterix comic/movie.\n\nI\'ve spent weeks arguing with them about cases like that in the past, but I kept getting rejections - either by bots or people who are about as intelligent as bots. In the I can decide between the app being removed from the Play Store entirely or remove the feature.\nPlease consider using the APK version from my website or the one from F-Droid if you need those features.</string>
<string name="startActivityInsertManually">This limitation concerns only the selection of an app, not the actual start. So you can still enter the name of an application manually if you know it.</string>
<string name="deviceStarts">Device starts</string>
<string name="serviceStarts">Service starts</string>
<string name="deviceHasJustStarted">device has just started</string>
<string name="serviceHasJustStarted">service has just started</string>
</resources> </resources>

View File

@@ -0,0 +1,2 @@
* New trigger: device has just started
* New trigger: service has just started