Compare commits
3 Commits
master
...
developmen
Author | SHA1 | Date | |
---|---|---|---|
b6d7958389 | |||
04d2e4b432 | |||
abd346946a |
@ -11,8 +11,8 @@ android {
|
||||
compileSdkVersion 33
|
||||
buildToolsVersion '29.0.2'
|
||||
useLibrary 'org.apache.http.legacy'
|
||||
versionCode 143
|
||||
versionName "1.8.2"
|
||||
versionCode 144
|
||||
versionName "1.8.3"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
@ -734,7 +734,8 @@ public class Action
|
||||
for(String pair : paramPairs)
|
||||
{
|
||||
String[] pieces = pair.split(Action.actionParameters2SeparatorInner);
|
||||
httpParams.put(pieces[0], pieces[1]);
|
||||
if(pieces.length == 2)
|
||||
httpParams.put(pieces[0], pieces[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,12 +10,7 @@ import android.widget.RadioButton;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.jens.automation2.ActivityManageRule;
|
||||
import com.jens.automation2.Miscellaneous;
|
||||
import com.jens.automation2.R;
|
||||
import com.jens.automation2.Trigger;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import com.jens.automation2.receivers.BatteryReceiver;
|
||||
|
||||
public class ActivityManageTriggerCharging extends Activity
|
||||
{
|
||||
@ -69,13 +64,13 @@ public class ActivityManageTriggerCharging extends Activity
|
||||
String param2 = "";
|
||||
|
||||
if(rbChargingTypeAny.isChecked())
|
||||
param2 = "0";
|
||||
param2 = String.valueOf(BatteryReceiver.batteryChargingTypeAny);
|
||||
else if(rbChargingTypeAc.isChecked())
|
||||
param2 = String.valueOf(BatteryManager.BATTERY_PLUGGED_AC);
|
||||
param2 = String.valueOf(BatteryReceiver.batteryChargingTypeAc);
|
||||
else if(rbChargingTypeUsb.isChecked())
|
||||
param2 = String.valueOf(BatteryManager.BATTERY_PLUGGED_USB);
|
||||
param2 = String.valueOf(BatteryReceiver.batteryChargingTypeUsb);
|
||||
else if(rbChargingTypeWireless.isChecked())
|
||||
param2 = String.valueOf(BatteryManager.BATTERY_PLUGGED_WIRELESS);
|
||||
param2 = String.valueOf(BatteryReceiver.batteryChargingTypeWireless);
|
||||
|
||||
response.putExtra(ActivityManageRule.intentNameTriggerParameter2, param2);
|
||||
|
||||
|
@ -5,6 +5,8 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@ -14,6 +16,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
public class ActivityManageTriggerCheckVariable extends Activity
|
||||
{
|
||||
EditText etVariableKeyTrigger, etVariableValueTrigger;
|
||||
CheckBox chkTriggerVariableDirection;
|
||||
Button bTriggerVariableSave;
|
||||
|
||||
@Override
|
||||
@ -25,6 +28,7 @@ public class ActivityManageTriggerCheckVariable extends Activity
|
||||
|
||||
etVariableKeyTrigger = (EditText) findViewById(R.id.etVariableKeyTrigger);
|
||||
etVariableValueTrigger = (EditText) findViewById(R.id.etVariableValueTrigger);
|
||||
chkTriggerVariableDirection = (CheckBox)findViewById(R.id.chkTriggerVariableDirection);
|
||||
bTriggerVariableSave = (Button) findViewById(R.id.bTriggerVariableSave);
|
||||
|
||||
Intent input = getIntent();
|
||||
@ -36,6 +40,18 @@ public class ActivityManageTriggerCheckVariable extends Activity
|
||||
etVariableValueTrigger.setText(conditions[1]);
|
||||
}
|
||||
|
||||
chkTriggerVariableDirection.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener()
|
||||
{
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked)
|
||||
{
|
||||
if(checked)
|
||||
chkTriggerVariableDirection.setText(getResources().getString(R.string.matches));
|
||||
else
|
||||
chkTriggerVariableDirection.setText(getResources().getString(R.string.doesNotMatch));
|
||||
}
|
||||
});
|
||||
|
||||
bTriggerVariableSave.setOnClickListener(new View.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
|
@ -1220,7 +1220,9 @@ public class Trigger
|
||||
int desiredType;
|
||||
String[] typeParams = getTriggerParameter2().split(triggerParameter2Split, -1);
|
||||
desiredType = Integer.parseInt(typeParams[0]);
|
||||
if(desiredType == BatteryReceiver.getCurrentChargingType())
|
||||
if(desiredType == BatteryReceiver.batteryChargingTypeAny)
|
||||
return true;
|
||||
else if(desiredType == BatteryReceiver.getCurrentChargingType())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.jens.automation2.receivers;
|
||||
|
||||
import static android.os.BatteryManager.*;
|
||||
|
||||
import android.os.BatteryManager;
|
||||
import android.Manifest;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.BatteryManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.jens.automation2.ActivityPermissions;
|
||||
@ -18,6 +20,11 @@ import java.util.ArrayList;
|
||||
|
||||
public class BatteryReceiver extends BroadcastReceiver implements AutomationListenerInterface
|
||||
{
|
||||
public static final int batteryChargingTypeAny = 0;
|
||||
public static final int batteryChargingTypeAc = BatteryManager.BATTERY_PLUGGED_AC;
|
||||
public static final int batteryChargingTypeUsb = BatteryManager.BATTERY_PLUGGED_USB;
|
||||
public static final int batteryChargingTypeWireless = BatteryManager.BATTERY_PLUGGED_WIRELESS;
|
||||
|
||||
public static AutomationService automationServiceRef = null;
|
||||
static int batteryLevel = -1; // initialize with a better value than this
|
||||
static boolean usbHostConnected = false;
|
||||
@ -102,7 +109,7 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
||||
{
|
||||
try
|
||||
{
|
||||
batteryLevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
|
||||
batteryLevel = intent.getIntExtra(EXTRA_LEVEL, -1);
|
||||
// int scale = -1;
|
||||
// int voltage = -1;
|
||||
// int temp = -1;
|
||||
@ -112,36 +119,36 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
||||
Log.i("Battery", "Level: " + String.valueOf(batteryLevel));
|
||||
this.actionBatteryLevel(context);
|
||||
|
||||
int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
|
||||
int statusPlugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
|
||||
int status = intent.getIntExtra(EXTRA_STATUS, -1);
|
||||
int statusPlugged = intent.getIntExtra(EXTRA_PLUGGED, -1);
|
||||
Miscellaneous.logEvent("i", "BatteryReceiver", "Status: " + String.valueOf(statusPlugged), 5);
|
||||
|
||||
switch(statusPlugged)
|
||||
{
|
||||
case BatteryManager.BATTERY_PLUGGED_AC:
|
||||
case BATTERY_PLUGGED_AC:
|
||||
// Toast.makeText(context, "Regular charging", Toast.LENGTH_LONG).show();
|
||||
Miscellaneous.logEvent("i", "BatteryReceiver", "Regular charging.", 5);
|
||||
this.actionCharging(context, statusPlugged);
|
||||
break;
|
||||
case BatteryManager.BATTERY_PLUGGED_WIRELESS:
|
||||
case BATTERY_PLUGGED_WIRELESS:
|
||||
// Toast.makeText(context, "Regular charging", Toast.LENGTH_LONG).show();
|
||||
Miscellaneous.logEvent("i", "BatteryReceiver", "Wireless charging.", 5);
|
||||
this.actionCharging(context, statusPlugged);
|
||||
break;
|
||||
case BatteryManager.BATTERY_PLUGGED_USB:
|
||||
case BATTERY_PLUGGED_USB:
|
||||
this.actionUsbConnected(context);
|
||||
break;
|
||||
}
|
||||
|
||||
switch(status)
|
||||
{
|
||||
case BatteryManager.BATTERY_STATUS_CHARGING:
|
||||
case BatteryManager.BATTERY_STATUS_FULL:
|
||||
case BATTERY_STATUS_CHARGING:
|
||||
case BATTERY_STATUS_FULL:
|
||||
// Miscellaneous.logEvent("i", "BatteryReceiver", "Device has been fully charged.", 5);
|
||||
this.actionCharging(context, statusPlugged);
|
||||
break;
|
||||
case BatteryManager.BATTERY_STATUS_DISCHARGING:
|
||||
case BatteryManager.BATTERY_STATUS_NOT_CHARGING:
|
||||
case BATTERY_STATUS_DISCHARGING:
|
||||
case BATTERY_STATUS_NOT_CHARGING:
|
||||
this.actionDischarging(context);
|
||||
break;
|
||||
}
|
||||
@ -163,7 +170,7 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
||||
case 1:
|
||||
Miscellaneous.logEvent("i", "ChargingInfo", "Device is discharging.", 3);
|
||||
break;
|
||||
case BatteryManager.BATTERY_STATUS_CHARGING:
|
||||
case BATTERY_STATUS_CHARGING:
|
||||
Miscellaneous.logEvent("i", "ChargingInfo", "Device is charging.", 3);
|
||||
break;
|
||||
}
|
||||
@ -178,10 +185,10 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
||||
|
||||
private void actionCharging(Context context, int statusPlugged)
|
||||
{
|
||||
if(currentChargingState != BatteryManager.BATTERY_STATUS_CHARGING) // Avoid flooding the log. This event will occur on a regular basis even though charging state wasn't changed.
|
||||
if(currentChargingState != BATTERY_STATUS_CHARGING) // Avoid flooding the log. This event will occur on a regular basis even though charging state wasn't changed.
|
||||
{
|
||||
Miscellaneous.logEvent("i", "BatteryReceiver", "Battery is charging or full.", 3);
|
||||
currentChargingState = BatteryManager.BATTERY_STATUS_CHARGING;
|
||||
currentChargingState = BATTERY_STATUS_CHARGING;
|
||||
currentChargingType = statusPlugged;
|
||||
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.charging);
|
||||
@ -207,10 +214,10 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
||||
|
||||
private void actionDischarging(Context context)
|
||||
{
|
||||
if(currentChargingState != BatteryManager.BATTERY_STATUS_UNKNOWN) // Avoid flooding the log. This event will occur on a regular basis even though charging state wasn't changed.
|
||||
if(currentChargingState != BATTERY_STATUS_UNKNOWN) // Avoid flooding the log. This event will occur on a regular basis even though charging state wasn't changed.
|
||||
{
|
||||
Miscellaneous.logEvent("i", "BatteryReceiver", "Battery is discharging.", 3);
|
||||
currentChargingState = BatteryManager.BATTERY_STATUS_UNKNOWN;
|
||||
currentChargingState = BATTERY_STATUS_UNKNOWN;
|
||||
//activate rule(s)
|
||||
ArrayList<Rule> ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.charging);
|
||||
// ArrayList<Rule> ruleCandidates = Rule.findRuleCandidatesByCharging(false);
|
||||
@ -243,7 +250,7 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
|
||||
oneRule.activate(automationServiceRef, false);
|
||||
}
|
||||
|
||||
this.actionCharging(context, BatteryManager.BATTERY_PLUGGED_USB);
|
||||
this.actionCharging(context, BATTERY_PLUGGED_USB);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,13 @@
|
||||
|
||||
</TableLayout>
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/chkTriggerVariableDirection"
|
||||
android:layout_marginTop="@dimen/default_margin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/matches" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -949,4 +949,6 @@
|
||||
<string name="helpTextProfiles">A profile is a collection of settings for ringtones, volumes and other audio related settings that you can have applied from rules or apply it manually.\n\nIt is also possible to query for the last activated profile as a trigger. In the normal case it will only query if the profile was the last activated one (regardless if specific audio settings have been changed in the meantime). But you can also have the individual settings compared.</string>
|
||||
<string name="version143StartOtherActivityHint">In version 1.8.2 it was necessary to revise the way actions to start other programs were saved. Compatibility could not be ensured. Please check and edit your start other activity actions to make sure they are still working.</string>
|
||||
<string name="importChooseFolderNotice">In the following dialog do not try to select specific files, but choose the folder in which the Automation backup files reside. If the choose button is disabled, you have found an Android limitation. In that case try moving the files to a subdirectory first.</string>
|
||||
<string name="matches">matches</string>
|
||||
<string name="doesNotMatch">does not match</string>
|
||||
</resources>
|
2
fastlane/metadata/android/en-US/changelogs/144.txt
Normal file
2
fastlane/metadata/android/en-US/changelogs/144.txt
Normal file
@ -0,0 +1,2 @@
|
||||
* Fixed: Crash when triggering a URL without parameter pairs
|
||||
* Fixed: When checking for battery charging type "any" the trigger didn't fire.
|
Loading…
x
Reference in New Issue
Block a user