wifi trigger - enabled regex

This commit is contained in:
jens 2022-07-12 17:03:32 +02:00
parent eeb4f4a39e
commit d154a3d64f
5 changed files with 20 additions and 9 deletions

View File

@ -26,9 +26,6 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;
import com.jens.automation2.receivers.BluetoothReceiver;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -41,7 +38,7 @@ public class ActivityManageTriggerWifi extends Activity
RadioButton rbTriggerWifiConnected, rbTriggerWifiDisconnected;
EditText etTriggerWifiName;
Spinner spinnerWifiList;
Button btriggerWifiSave, bLoadWifiList;
Button bTriggerWifiSave, bLoadWifiList;
List<String> wifiList = new ArrayList<>();
ArrayAdapter<String> wifiSpinnerAdapter;
private final static int requestCodeLocationPermission = 124;
@ -56,7 +53,7 @@ public class ActivityManageTriggerWifi extends Activity
rbTriggerWifiDisconnected = (RadioButton) findViewById(R.id.rbTriggerWifiDisconnected);
etTriggerWifiName = (EditText) findViewById(R.id.etTriggerWifiName);
spinnerWifiList = (Spinner) findViewById(R.id.spinnerWifiList);
btriggerWifiSave = (Button) findViewById(R.id.btriggerWifiSave);
bTriggerWifiSave = (Button) findViewById(R.id.bTriggerWifiSave);
bLoadWifiList = (Button) findViewById(R.id.bLoadWifiList);
wifiSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, wifiList);
@ -74,7 +71,7 @@ public class ActivityManageTriggerWifi extends Activity
etTriggerWifiName.setText(wifiName);
}
btriggerWifiSave.setOnClickListener(new View.OnClickListener()
bTriggerWifiSave.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)

View File

@ -1,6 +1,7 @@
package com.jens.automation2;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.os.Build;
import android.service.notification.StatusBarNotification;
@ -728,7 +729,8 @@ public class Trigger
if(this.getTriggerParameter2().length() > 0) // only check if any wifi name specified, otherwise any wifi will do
{
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format("Wifi name specified, checking that.", this.getParentRule().getName()), 4);
if(!WifiBroadcastReceiver.getLastWifiSsid().equals(this.getTriggerParameter2()))
if(!WifiBroadcastReceiver.getLastWifiSsid().equals(this.getTriggerParameter2()) && !(Miscellaneous.isRegularExpression(this.getTriggerParameter2()) && WifiBroadcastReceiver.getLastWifiSsid().matches(this.getTriggerParameter2())))
{
Miscellaneous.logEvent("i", Miscellaneous.getAnyContext().getResources().getString(R.string.ruleCheckOf), String.format(String.format(Miscellaneous.getAnyContext().getResources().getString(R.string.ruleDoesntApplyNotTheCorrectSsid), getParentRule().getName(), this.getTriggerParameter2(), WifiBroadcastReceiver.getLastWifiSsid()),this.getParentRule().getName()), 3);
return false;

View File

@ -62,6 +62,16 @@
</TableRow>
<TableRow>
<TextView />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/mayUseRegularExpressions"/>
</TableRow>
<TableRow>
<Button
@ -81,7 +91,7 @@
</TableLayout>
<Button
android:id="@+id/btriggerWifiSave"
android:id="@+id/bTriggerWifiSave"
android:layout_marginTop="@dimen/default_margin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@ -840,4 +840,5 @@
<string name="keepDeviceAwake">Keep device awake</string>
<string name="wakeLockTimeout">Specify timeout</string>
<string name="wakeLockExplanation">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.</string>
<string name="mayUseRegularExpressions">You may also enter a regular expression here.</string>
</resources>

View File

@ -1,4 +1,5 @@
* New action: Keep phone turned on
* New: Regular expressions enabled where comparisons apply (one has to use "equals")
* Fixed: Changed input type for decimal numbers when adding intent data
* Fixed: Battery level trigger not working when using direction falling-below
* Fixed: Battery level trigger not working when using direction falling-below
* New: Wifi trigger can now use Regex for SSID