wifi trigger needs location permission
This commit is contained in:
parent
d07c1a05e4
commit
19fd2d098b
@ -396,7 +396,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ public class Rule implements Comparable<Rule>
|
|||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import android.widget.Button;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -42,6 +43,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;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState)
|
protected void onCreate(@Nullable Bundle savedInstanceState)
|
||||||
@ -55,11 +57,19 @@ public class ActivityManageTriggerWifi extends Activity
|
|||||||
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);
|
||||||
|
tvWifiTriggerNameLocationNotice = (TextView)findViewById(R.id.tvWifiTriggerNameLocationNotice);
|
||||||
|
|
||||||
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);
|
||||||
spinnerWifiList.setEnabled(false); // bug in Android; this only works when done in code, not in xml
|
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"))
|
if (getIntent().hasExtra("edit"))
|
||||||
{
|
{
|
||||||
boolean connected = getIntent().getBooleanExtra("wifiState", false);
|
boolean connected = getIntent().getBooleanExtra("wifiState", false);
|
||||||
|
@ -509,6 +509,12 @@ public class ActivityPermissions extends Activity
|
|||||||
case wifiConnection:
|
case wifiConnection:
|
||||||
addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions);
|
||||||
addToArrayListUnique(Manifest.permission.ACCESS_WIFI_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;
|
break;
|
||||||
case notification:
|
case notification:
|
||||||
addToArrayListUnique(Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.BIND_NOTIFICATION_LISTENER_SERVICE, requiredPermissions);
|
||||||
|
@ -1911,4 +1911,9 @@ public class Miscellaneous extends Service
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getTargetSDK(Context context)
|
||||||
|
{
|
||||||
|
return context.getApplicationContext().getApplicationInfo().targetSdkVersion;
|
||||||
|
}
|
||||||
}
|
}
|
@ -63,7 +63,7 @@ public class WifiBroadcastReceiver extends BroadcastReceiver
|
|||||||
// int state = -1;
|
// int state = -1;
|
||||||
NetworkInfo myWifi = null;
|
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);
|
// state = intent.getIntExtra(WifiManager.NETWORK_STATE_CHANGED_ACTION, -1);
|
||||||
// Miscellaneous.logEvent("i", "WifiReceiver", "NETWORK_STATE_CHANGED_ACTION: " + String.valueOf(state));
|
// Miscellaneous.logEvent("i", "WifiReceiver", "NETWORK_STATE_CHANGED_ACTION: " + String.valueOf(state));
|
||||||
|
@ -47,6 +47,19 @@
|
|||||||
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvWifiTriggerNameLocationNotice"
|
||||||
|
android:layout_span="2"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:textColor="@color/red"
|
||||||
|
android:text="@string/locationRequiredToDetermineWifiName"
|
||||||
|
android:layout_marginVertical="@dimen/default_margin"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</TableRow>
|
||||||
|
|
||||||
<TableRow>
|
<TableRow>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -841,4 +841,5 @@
|
|||||||
<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>
|
<string name="mayUseRegularExpressions">You may also enter a regular expression here.</string>
|
||||||
|
<string name="locationRequiredToDetermineWifiName">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.</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue
Block a user