Many small fixes
This commit is contained in:
@@ -514,8 +514,6 @@ public class Rule implements Comparable<Rule>
|
|||||||
protected boolean activateInternally(AutomationService automationService)
|
protected boolean activateInternally(AutomationService automationService)
|
||||||
{
|
{
|
||||||
boolean isActuallyToggleable = isActuallyToggable();
|
boolean isActuallyToggleable = isActuallyToggable();
|
||||||
|
|
||||||
// boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
|
|
||||||
boolean doToggle = ruleToggle && isActuallyToggleable;
|
boolean doToggle = ruleToggle && isActuallyToggleable;
|
||||||
|
|
||||||
String message;
|
String message;
|
||||||
|
|||||||
@@ -487,8 +487,6 @@ public class Rule implements Comparable<Rule>
|
|||||||
protected boolean activateInternally(AutomationService automationService)
|
protected boolean activateInternally(AutomationService automationService)
|
||||||
{
|
{
|
||||||
boolean isActuallyToggleable = isActuallyToggable();
|
boolean isActuallyToggleable = isActuallyToggable();
|
||||||
|
|
||||||
// boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
|
|
||||||
boolean doToggle = ruleToggle && isActuallyToggleable;
|
boolean doToggle = ruleToggle && isActuallyToggleable;
|
||||||
|
|
||||||
String message;
|
String message;
|
||||||
|
|||||||
@@ -514,8 +514,6 @@ public class Rule implements Comparable<Rule>
|
|||||||
protected boolean activateInternally(AutomationService automationService)
|
protected boolean activateInternally(AutomationService automationService)
|
||||||
{
|
{
|
||||||
boolean isActuallyToggleable = isActuallyToggable();
|
boolean isActuallyToggleable = isActuallyToggable();
|
||||||
|
|
||||||
// boolean notLastActive = getLastActivatedRule() == null || !getLastActivatedRule().equals(Rule.this);
|
|
||||||
boolean doToggle = ruleToggle && isActuallyToggleable;
|
boolean doToggle = ruleToggle && isActuallyToggleable;
|
||||||
|
|
||||||
String message;
|
String message;
|
||||||
|
|||||||
@@ -1777,7 +1777,7 @@ public class Actions
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Miscellaneous.logEvent("e", "setData", "Error changing network type: " + Log.getStackTraceString(e), 2);
|
Miscellaneous.logEvent("e", "setData", "Error setting data connection: " + Log.getStackTraceString(e), 2);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,14 +36,14 @@ public class ActivityManageActionWifi extends Activity
|
|||||||
|
|
||||||
Intent input = getIntent();
|
Intent input = getIntent();
|
||||||
if(input.hasExtra(ActivityManageRule.intentNameActionParameter1))
|
if(input.hasExtra(ActivityManageRule.intentNameActionParameter1))
|
||||||
|
{
|
||||||
rbActionWifiOn.setChecked(input.getBooleanExtra(ActivityManageRule.intentNameActionParameter1, true));
|
rbActionWifiOn.setChecked(input.getBooleanExtra(ActivityManageRule.intentNameActionParameter1, true));
|
||||||
|
rbActionWifiOff.setChecked(!input.getBooleanExtra(ActivityManageRule.intentNameActionParameter1, true));
|
||||||
|
}
|
||||||
|
|
||||||
if(input.hasExtra(ActivityManageRule.intentNameActionParameter2))
|
if(input.hasExtra(ActivityManageRule.intentNameActionParameter2))
|
||||||
chkWifiRunAsRoot.setChecked(Boolean.parseBoolean(input.getStringExtra(ActivityManageRule.intentNameActionParameter2)));
|
chkWifiRunAsRoot.setChecked(Boolean.parseBoolean(input.getStringExtra(ActivityManageRule.intentNameActionParameter2)));
|
||||||
|
|
||||||
// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
|
|
||||||
// Miscellaneous.messageBox(getResources().getString(R.string.app_name), getResources().getString(R.string.android10WifiToggleNotice), ActivityManageActionWifi.this).show();
|
|
||||||
|
|
||||||
if(getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.Q)
|
if(getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.Q)
|
||||||
tvWifiExplanation1.setVisibility(View.VISIBLE);
|
tvWifiExplanation1.setVisibility(View.VISIBLE);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -281,6 +281,19 @@ public class ActivityPermissions extends Activity
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getAmountOfRulesWhichLackPermissions(Context context)
|
||||||
|
{
|
||||||
|
int rulesWhichLackPermissions = 0;
|
||||||
|
|
||||||
|
for(Rule r : Rule.getRuleCollection())
|
||||||
|
{
|
||||||
|
if(!ActivityPermissions.havePermissionsForRule(r, context))
|
||||||
|
rulesWhichLackPermissions++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rulesWhichLackPermissions;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean havePermission(String s, Context context)
|
public static boolean havePermission(String s, Context context)
|
||||||
{
|
{
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
||||||
@@ -536,6 +549,8 @@ public class ActivityPermissions extends Activity
|
|||||||
addToArrayListUnique(Manifest.permission.BLUETOOTH_ADMIN, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.BLUETOOTH_ADMIN, requiredPermissions);
|
||||||
addToArrayListUnique(Manifest.permission.BLUETOOTH, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.BLUETOOTH, requiredPermissions);
|
||||||
addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions);
|
addToArrayListUnique(Manifest.permission.ACCESS_NETWORK_STATE, requiredPermissions);
|
||||||
|
if(Build.VERSION.SDK_INT >= 31)
|
||||||
|
addToArrayListUnique(Manifest.permission.BLUETOOTH_CONNECT, requiredPermissions);
|
||||||
break;
|
break;
|
||||||
case charging:
|
case charging:
|
||||||
// addToArrayListUnique(Manifest.permission.READ_PHONE_STATE, requiredPermissions);
|
// addToArrayListUnique(Manifest.permission.READ_PHONE_STATE, requiredPermissions);
|
||||||
@@ -911,12 +926,8 @@ public class ActivityPermissions extends Activity
|
|||||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
break;
|
break;
|
||||||
case Manifest.permission.BLUETOOTH_ADMIN:
|
case Manifest.permission.BLUETOOTH_ADMIN:
|
||||||
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.bluetoothConnection))
|
|
||||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
|
||||||
for(String ruleName : getRulesUsing(Action.Action_Enum.setBluetooth))
|
|
||||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
|
||||||
break;
|
|
||||||
case Manifest.permission.BLUETOOTH:
|
case Manifest.permission.BLUETOOTH:
|
||||||
|
case Manifest.permission.BLUETOOTH_CONNECT:
|
||||||
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.bluetoothConnection))
|
for(String ruleName : getRulesUsing(Trigger.Trigger_Enum.bluetoothConnection))
|
||||||
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
usingElements.add(String.format(getResources().getString(R.string.ruleXrequiresThis), ruleName));
|
||||||
for(String ruleName : getRulesUsing(Action.Action_Enum.setBluetooth))
|
for(String ruleName : getRulesUsing(Action.Action_Enum.setBluetooth))
|
||||||
|
|||||||
@@ -180,6 +180,17 @@ public class AutomationService extends Service implements OnInitListener
|
|||||||
Rule.getRuleCollection().size() == 0
|
Rule.getRuleCollection().size() == 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
if(
|
||||||
|
Rule.getRuleCollection().size() > 0
|
||||||
|
&&
|
||||||
|
Rule.getRuleCollection().size() == ActivityPermissions.getAmountOfRulesWhichLackPermissions(Miscellaneous.getAnyContext())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Miscellaneous.logEvent("w", "AutomationService", "Don't have complete permissions for any defined rule. Not starting service.", 1);
|
||||||
|
Toast.makeText(context, context.getResources().getString(R.string.serviceWontStartPermissions), Toast.LENGTH_LONG).show();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (startAtBoot)
|
if (startAtBoot)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.jens.automation2.ActivityPermissions;
|
import com.jens.automation2.ActivityPermissions;
|
||||||
import com.jens.automation2.AutomationService;
|
import com.jens.automation2.AutomationService;
|
||||||
@@ -149,8 +150,6 @@ public class BluetoothReceiver extends BroadcastReceiver implements AutomationLi
|
|||||||
{
|
{
|
||||||
return lhs.getName().compareTo(rhs.getName());
|
return lhs.getName().compareTo(rhs.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch(NullPointerException e)
|
catch(NullPointerException e)
|
||||||
@@ -159,6 +158,12 @@ public class BluetoothReceiver extends BroadcastReceiver implements AutomationLi
|
|||||||
|
|
||||||
returnArray = new BluetoothDevice[] {};
|
returnArray = new BluetoothDevice[] {};
|
||||||
}
|
}
|
||||||
|
catch(SecurityException se)
|
||||||
|
{
|
||||||
|
Toast.makeText(Miscellaneous.getAnyContext(), Miscellaneous.getAnyContext().getResources().getString(R.string.permissionRequiredBluetooth), Toast.LENGTH_SHORT).show();
|
||||||
|
|
||||||
|
returnArray = new BluetoothDevice[] {};
|
||||||
|
}
|
||||||
|
|
||||||
return returnArray;
|
return returnArray;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<string name="pleaseSpecifiyTrigger">Please specify at least one trigger.</string>
|
<string name="pleaseSpecifiyTrigger">Please specify at least one trigger.</string>
|
||||||
<string name="pleaseSpecifiyAction">Please specify at least one action.</string>
|
<string name="pleaseSpecifiyAction">Please specify at least one action.</string>
|
||||||
<string name="serviceWontStart">No rules defined. Service won\'t start.</string>
|
<string name="serviceWontStart">No rules defined. Service won\'t start.</string>
|
||||||
|
<string name="serviceWontStartPermissions">Don\'t have full permission for any defined rule. Service won\'t start.</string>
|
||||||
<string name="serviceWontStartNoActivatedRules">No activated rules defined. Service won\'t start.</string>
|
<string name="serviceWontStartNoActivatedRules">No activated rules defined. Service won\'t start.</string>
|
||||||
<string name="serviceStarted">Automation Service started.</string>
|
<string name="serviceStarted">Automation Service started.</string>
|
||||||
<string name="version">Version %1$s.</string>
|
<string name="version">Version %1$s.</string>
|
||||||
@@ -970,4 +971,5 @@
|
|||||||
<string name="far">far</string>
|
<string name="far">far</string>
|
||||||
<string name="proximityText">proximity is between \"%1$s\" and \"%2$s\"</string>
|
<string name="proximityText">proximity is between \"%1$s\" and \"%2$s\"</string>
|
||||||
<string name="pleaseWait">Please wait.</string>
|
<string name="pleaseWait">Please wait.</string>
|
||||||
|
<string name="permissionRequiredBluetooth">Bluetooth permission required to edit this rule. Request permissions from the main screen first.</string>
|
||||||
</resources>
|
</resources>
|
||||||
3
fastlane/metadata/android/en-US/changelogs/146.txt
Normal file
3
fastlane/metadata/android/en-US/changelogs/146.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
* Fixed: Set-wifi action wasn't correctly pre-filled-out when editing action.
|
||||||
|
* Fixed: Service startup checks improved when no rules with full permissions were present.
|
||||||
|
* Fixed: Editing bluetooth trigger could crash if permissions weren't given.
|
||||||
Reference in New Issue
Block a user