wifi trigger - enabled regex
This commit is contained in:
parent
eeb4f4a39e
commit
d154a3d64f
@ -26,9 +26,6 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
|
|
||||||
import com.jens.automation2.receivers.BluetoothReceiver;
|
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -41,7 +38,7 @@ public class ActivityManageTriggerWifi extends Activity
|
|||||||
RadioButton rbTriggerWifiConnected, rbTriggerWifiDisconnected;
|
RadioButton rbTriggerWifiConnected, rbTriggerWifiDisconnected;
|
||||||
EditText etTriggerWifiName;
|
EditText etTriggerWifiName;
|
||||||
Spinner spinnerWifiList;
|
Spinner spinnerWifiList;
|
||||||
Button btriggerWifiSave, bLoadWifiList;
|
Button bTriggerWifiSave, bLoadWifiList;
|
||||||
List<String> wifiList = new ArrayList<>();
|
List<String> wifiList = new ArrayList<>();
|
||||||
ArrayAdapter<String> wifiSpinnerAdapter;
|
ArrayAdapter<String> wifiSpinnerAdapter;
|
||||||
private final static int requestCodeLocationPermission = 124;
|
private final static int requestCodeLocationPermission = 124;
|
||||||
@ -56,7 +53,7 @@ public class ActivityManageTriggerWifi extends Activity
|
|||||||
rbTriggerWifiDisconnected = (RadioButton) findViewById(R.id.rbTriggerWifiDisconnected);
|
rbTriggerWifiDisconnected = (RadioButton) findViewById(R.id.rbTriggerWifiDisconnected);
|
||||||
etTriggerWifiName = (EditText) findViewById(R.id.etTriggerWifiName);
|
etTriggerWifiName = (EditText) findViewById(R.id.etTriggerWifiName);
|
||||||
spinnerWifiList = (Spinner) findViewById(R.id.spinnerWifiList);
|
spinnerWifiList = (Spinner) findViewById(R.id.spinnerWifiList);
|
||||||
btriggerWifiSave = (Button) findViewById(R.id.btriggerWifiSave);
|
bTriggerWifiSave = (Button) findViewById(R.id.bTriggerWifiSave);
|
||||||
bLoadWifiList = (Button) findViewById(R.id.bLoadWifiList);
|
bLoadWifiList = (Button) findViewById(R.id.bLoadWifiList);
|
||||||
|
|
||||||
wifiSpinnerAdapter = new ArrayAdapter<String>(this, R.layout.text_view_for_poi_listview_mediumtextsize, wifiList);
|
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);
|
etTriggerWifiName.setText(wifiName);
|
||||||
}
|
}
|
||||||
|
|
||||||
btriggerWifiSave.setOnClickListener(new View.OnClickListener()
|
bTriggerWifiSave.setOnClickListener(new View.OnClickListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.jens.automation2;
|
package com.jens.automation2;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.service.notification.StatusBarNotification;
|
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
|
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);
|
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);
|
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;
|
return false;
|
||||||
|
@ -62,6 +62,16 @@
|
|||||||
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
|
||||||
|
<TextView />
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/mayUseRegularExpressions"/>
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
@ -81,7 +91,7 @@
|
|||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btriggerWifiSave"
|
android:id="@+id/bTriggerWifiSave"
|
||||||
android:layout_marginTop="@dimen/default_margin"
|
android:layout_marginTop="@dimen/default_margin"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -840,4 +840,5 @@
|
|||||||
<string name="keepDeviceAwake">Keep device awake</string>
|
<string name="keepDeviceAwake">Keep device awake</string>
|
||||||
<string name="wakeLockTimeout">Specify timeout</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="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>
|
</resources>
|
@ -1,4 +1,5 @@
|
|||||||
* New action: Keep phone turned on
|
* New action: Keep phone turned on
|
||||||
* New: Regular expressions enabled where comparisons apply (one has to use "equals")
|
* New: Regular expressions enabled where comparisons apply (one has to use "equals")
|
||||||
* Fixed: Changed input type for decimal numbers when adding intent data
|
* 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
|
Loading…
Reference in New Issue
Block a user