diff --git a/app/src/apkFlavor/java/com/jens/automation2/Rule.java b/app/src/apkFlavor/java/com/jens/automation2/Rule.java index a04976cd..842c4c6c 100644 --- a/app/src/apkFlavor/java/com/jens/automation2/Rule.java +++ b/app/src/apkFlavor/java/com/jens/automation2/Rule.java @@ -396,7 +396,7 @@ public class Rule implements Comparable return true; } - Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3); + Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 4); return false; } diff --git a/app/src/fdroidFlavor/java/com/jens/automation2/Rule.java b/app/src/fdroidFlavor/java/com/jens/automation2/Rule.java index fd6b6c71..faffcdfe 100644 --- a/app/src/fdroidFlavor/java/com/jens/automation2/Rule.java +++ b/app/src/fdroidFlavor/java/com/jens/automation2/Rule.java @@ -393,7 +393,7 @@ public class Rule implements Comparable return true; } - Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3); + Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 4); return false; } diff --git a/app/src/googlePlayFlavor/java/com/jens/automation2/Rule.java b/app/src/googlePlayFlavor/java/com/jens/automation2/Rule.java index b4306bcd..e433e507 100644 --- a/app/src/googlePlayFlavor/java/com/jens/automation2/Rule.java +++ b/app/src/googlePlayFlavor/java/com/jens/automation2/Rule.java @@ -396,7 +396,7 @@ public class Rule implements Comparable return true; } - Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 3); + Miscellaneous.logEvent("i", String.format(context.getResources().getString(R.string.ruleCheckOf), this.getName()), String.format(context.getResources().getString(R.string.ruleIsDeactivatedCantApply), this.getName()), 4); return false; } diff --git a/app/src/main/java/com/jens/automation2/ActivityManageTriggerWifi.java b/app/src/main/java/com/jens/automation2/ActivityManageTriggerWifi.java index 99e17f1e..5a1abe9e 100644 --- a/app/src/main/java/com/jens/automation2/ActivityManageTriggerWifi.java +++ b/app/src/main/java/com/jens/automation2/ActivityManageTriggerWifi.java @@ -20,6 +20,7 @@ import android.widget.Button; import android.widget.EditText; import android.widget.RadioButton; import android.widget.Spinner; +import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; @@ -42,6 +43,7 @@ public class ActivityManageTriggerWifi extends Activity List wifiList = new ArrayList<>(); ArrayAdapter wifiSpinnerAdapter; private final static int requestCodeLocationPermission = 124; + TextView tvWifiTriggerNameLocationNotice; @Override protected void onCreate(@Nullable Bundle savedInstanceState) @@ -55,11 +57,19 @@ public class ActivityManageTriggerWifi extends Activity spinnerWifiList = (Spinner) findViewById(R.id.spinnerWifiList); bTriggerWifiSave = (Button) findViewById(R.id.bTriggerWifiSave); bLoadWifiList = (Button) findViewById(R.id.bLoadWifiList); + tvWifiTriggerNameLocationNotice = (TextView)findViewById(R.id.tvWifiTriggerNameLocationNotice); wifiSpinnerAdapter = new ArrayAdapter(this, R.layout.text_view_for_poi_listview_mediumtextsize, wifiList); spinnerWifiList.setAdapter(wifiSpinnerAdapter); spinnerWifiList.setEnabled(false); // bug in Android; this only works when done in code, not in xml + if( + Miscellaneous.getTargetSDK(Miscellaneous.getAnyContext()) >= 29 + && + !ActivityPermissions.isPermissionDeclaratedInManifest(Miscellaneous.getAnyContext(), Manifest.permission.ACCESS_BACKGROUND_LOCATION) + ) + tvWifiTriggerNameLocationNotice.setVisibility(View.VISIBLE); + if (getIntent().hasExtra("edit")) { boolean connected = getIntent().getBooleanExtra("wifiState", false); diff --git a/app/src/main/java/com/jens/automation2/ActivityPermissions.java b/app/src/main/java/com/jens/automation2/ActivityPermissions.java index 34d04caf..915e802a 100644 --- a/app/src/main/java/com/jens/automation2/ActivityPermissions.java +++ b/app/src/main/java/com/jens/automation2/ActivityPermissions.java @@ -509,6 +509,12 @@ public class ActivityPermissions extends Activity case wifiConnection: addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions); addToArrayListUnique(Manifest.permission.ACCESS_WIFI_STATE, requiredPermissions); + if( + Miscellaneous.getTargetSDK(Miscellaneous.getAnyContext()) >= 29 + && + isPermissionDeclaratedInManifest(Miscellaneous.getAnyContext(), Manifest.permission.ACCESS_BACKGROUND_LOCATION) + ) + addToArrayListUnique(Manifest.permission.ACCESS_BACKGROUND_LOCATION, requiredPermissions); break; case notification: addToArrayListUnique(Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE, requiredPermissions); diff --git a/app/src/main/java/com/jens/automation2/Miscellaneous.java b/app/src/main/java/com/jens/automation2/Miscellaneous.java index 6ebc28f2..3a0f9310 100644 --- a/app/src/main/java/com/jens/automation2/Miscellaneous.java +++ b/app/src/main/java/com/jens/automation2/Miscellaneous.java @@ -1911,4 +1911,9 @@ public class Miscellaneous extends Service return null; } + + public static int getTargetSDK(Context context) + { + return context.getApplicationContext().getApplicationInfo().targetSdkVersion; + } } \ No newline at end of file diff --git a/app/src/main/java/com/jens/automation2/location/WifiBroadcastReceiver.java b/app/src/main/java/com/jens/automation2/location/WifiBroadcastReceiver.java index 79e93d9c..2ecfa13e 100644 --- a/app/src/main/java/com/jens/automation2/location/WifiBroadcastReceiver.java +++ b/app/src/main/java/com/jens/automation2/location/WifiBroadcastReceiver.java @@ -63,7 +63,7 @@ public class WifiBroadcastReceiver extends BroadcastReceiver // int state = -1; NetworkInfo myWifi = null; - if(intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) //gefeuert bei Trennung + if(intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) // fired upon disconnection { // state = intent.getIntExtra(WifiManager.NETWORK_STATE_CHANGED_ACTION, -1); // Miscellaneous.logEvent("i", "WifiReceiver", "NETWORK_STATE_CHANGED_ACTION: " + String.valueOf(state)); diff --git a/app/src/main/res/layout/activity_manage_trigger_wifi.xml b/app/src/main/res/layout/activity_manage_trigger_wifi.xml index c21adcfb..aad445ce 100644 --- a/app/src/main/res/layout/activity_manage_trigger_wifi.xml +++ b/app/src/main/res/layout/activity_manage_trigger_wifi.xml @@ -47,6 +47,19 @@ + + + + + Specify timeout Activate will keep the screen on while deactivate will let it turn off. For keeping it on you can either enter a duration after which it may turn off again or you can keep it on indefinitely. In the latter case you would need to create another keep-awake action (in this or another rule) in which you select deactivate. You may also enter a regular expression here. + To get the wifi SSID, the app requires location permissions. Because the Google version cannot get that, you can only use this trigger if you do not specify an SSID. So it can only be used to detect if wifi is connected or not. \ No newline at end of file