Wifi trigger hint
This commit is contained in:
parent
8d10bf05af
commit
02f7b642cf
@ -12,11 +12,15 @@ import android.net.wifi.WifiConfiguration;
|
|||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.KeyEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
@ -43,7 +47,7 @@ public class ActivityManageTriggerWifi extends Activity
|
|||||||
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;
|
||||||
TextView tvWifiTriggerNameLocationNotice;
|
TextView tvWifiTriggerNameLocationNotice, tvWifiTriggerDisconnectionHint;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
@ -59,6 +63,9 @@ public class ActivityManageTriggerWifi extends Activity
|
|||||||
bTriggerWifiSave = (Button) findViewById(R.id.bTriggerWifiSave);
|
bTriggerWifiSave = (Button) findViewById(R.id.bTriggerWifiSave);
|
||||||
bLoadWifiList = (Button) findViewById(R.id.bLoadWifiList);
|
bLoadWifiList = (Button) findViewById(R.id.bLoadWifiList);
|
||||||
tvWifiTriggerNameLocationNotice = (TextView)findViewById(R.id.tvWifiTriggerNameLocationNotice);
|
tvWifiTriggerNameLocationNotice = (TextView)findViewById(R.id.tvWifiTriggerNameLocationNotice);
|
||||||
|
tvWifiTriggerDisconnectionHint = (TextView)findViewById(R.id.tvWifiTriggerDisconnectionHint);
|
||||||
|
|
||||||
|
tvWifiTriggerDisconnectionHint.setVisibility(View.GONE);
|
||||||
|
|
||||||
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);
|
||||||
spinnerWifiList.setAdapter(wifiSpinnerAdapter);
|
spinnerWifiList.setAdapter(wifiSpinnerAdapter);
|
||||||
@ -101,6 +108,11 @@ public class ActivityManageTriggerWifi extends Activity
|
|||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
|
||||||
{
|
{
|
||||||
etTriggerWifiName.setText(wifiList.get(position));
|
etTriggerWifiName.setText(wifiList.get(position));
|
||||||
|
|
||||||
|
if(etTriggerWifiName.getText().toString().length() > 0 && rbTriggerWifiDisconnected.isChecked())
|
||||||
|
tvWifiTriggerDisconnectionHint.setVisibility(View.VISIBLE);
|
||||||
|
else
|
||||||
|
tvWifiTriggerDisconnectionHint.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -118,6 +130,41 @@ public class ActivityManageTriggerWifi extends Activity
|
|||||||
loadWifis();
|
loadWifis();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
rbTriggerWifiDisconnected.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean b)
|
||||||
|
{
|
||||||
|
if(etTriggerWifiName.getText().toString().length() > 0 && b)
|
||||||
|
tvWifiTriggerDisconnectionHint.setVisibility(View.VISIBLE);
|
||||||
|
else
|
||||||
|
tvWifiTriggerDisconnectionHint.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
etTriggerWifiName.addTextChangedListener(new TextWatcher()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2)
|
||||||
|
{
|
||||||
|
if(etTriggerWifiName.getText().toString().length() > 0 && rbTriggerWifiDisconnected.isChecked())
|
||||||
|
tvWifiTriggerDisconnectionHint.setVisibility(View.VISIBLE);
|
||||||
|
else
|
||||||
|
tvWifiTriggerDisconnectionHint.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable editable)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadWifis()
|
public void loadWifis()
|
||||||
|
@ -815,7 +815,10 @@ public class Trigger
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!WifiBroadcastReceiver.getLastWifiSsidReal().equals(this.getTriggerParameter2()) && !(Miscellaneous.isRegularExpression(this.getTriggerParameter2()) && WifiBroadcastReceiver.getLastWifiSsidReal().matches(this.getTriggerParameter2())))
|
if (
|
||||||
|
!Settings.serviceStartDone
|
||||||
|
||
|
||||||
|
(!WifiBroadcastReceiver.getLastWifiSsidReal().equals(this.getTriggerParameter2()) && !(Miscellaneous.isRegularExpression(this.getTriggerParameter2()) && WifiBroadcastReceiver.getLastWifiSsidReal().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.getLastWifiSsidReal()), 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.getLastWifiSsidReal()), this.getParentRule().getName()), 3);
|
||||||
return false;
|
return false;
|
||||||
|
@ -103,6 +103,14 @@
|
|||||||
|
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvWifiTriggerDisconnectionHint"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginVertical="@dimen/default_margin"
|
||||||
|
android:textColor="@color/red"
|
||||||
|
android:text="@string/wifiTriggerDisconnectionHint" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/bTriggerWifiSave"
|
android:id="@+id/bTriggerWifiSave"
|
||||||
android:layout_marginTop="@dimen/default_margin"
|
android:layout_marginTop="@dimen/default_margin"
|
||||||
|
@ -886,4 +886,5 @@
|
|||||||
<string name="overlayPermissionHint">After clicking OK you\'ll be sent to a system dialog. Please select Automation there and allow "Display over other apps".</string>
|
<string name="overlayPermissionHint">After clicking OK you\'ll be sent to a system dialog. Please select Automation there and allow "Display over other apps".</string>
|
||||||
<string name="variablesOnlyForTypes">Variables are only available for parameter types String and URI</string>
|
<string name="variablesOnlyForTypes">Variables are only available for parameter types String and URI</string>
|
||||||
<string name="intentParametersHint">If you want to specify a parameter you also have to click \"Add intent pair\". Otherwise your changes will not be saved.</string>
|
<string name="intentParametersHint">If you want to specify a parameter you also have to click \"Add intent pair\". Otherwise your changes will not be saved.</string>
|
||||||
|
<string name="wifiTriggerDisconnectionHint">This trigger will be valid if you just disconnected from the wifi specified above\n\nOR\n\nwhile the service is still starting and if you\'re not connected to any wifi.</string>
|
||||||
</resources>
|
</resources>
|
@ -1,4 +1,5 @@
|
|||||||
* Fixed: Added overlay permission for start-phone-call action
|
* Fixed: Added overlay permission for start-phone-call action
|
||||||
* Change: Icon changed in Play store version
|
|
||||||
* Fixed: Trigger "battery is charging" would only fire once and not after disconnecting and connecting charger
|
* Fixed: Trigger "battery is charging" would only fire once and not after disconnecting and connecting charger
|
||||||
|
* Fixed: Wifi trigger would not reliably fire upon disconnection
|
||||||
|
* Change: Icon changed in Play store version
|
||||||
* Change: Was forced to raise targetSdk to 32 for Google Play version. If that should break something, consider switching to the F-Droid or APK version.
|
* Change: Was forced to raise targetSdk to 32 for Google Play version. If that should break something, consider switching to the F-Droid or APK version.
|
Loading…
Reference in New Issue
Block a user