Compare commits

..
2 Commits
Author SHA1 Message Date
jens 56a766d03c registerReceiver option added 2026-08-13 18:58:55 +02:00
jens 5b86d57857 Number check fix 2026-08-09 16:12:16 +02:00
11 changed files with 69 additions and 14 deletions
@@ -106,7 +106,7 @@ public class ActivityManageActionSetSystemSetting extends Activity
selectedDataType.equalsIgnoreCase("Long")
)
{
if(!Miscellaneous.isNumeric(etSettingValue.getText().toString()) || Miscellaneous.isNonDecimalNumber(etSettingValue.getText().toString()))
if(!Miscellaneous.isNumeric(etSettingValue.getText().toString()) || !Miscellaneous.isNumericNonDecimal(etSettingValue.getText().toString()))
{
Toast.makeText(ActivityManageActionSetSystemSetting.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show();
return;
@@ -1154,12 +1154,24 @@ public class Miscellaneous extends Service
return true;
}
public static boolean isNonDecimalNumber(String number)
public static boolean isNumericNonDecimal(String number)
{
if (number == null)
return false;
return !number.contains(String.valueOf(getDecimalSeparator()));
try
{
int temp = Integer.parseInt(number);
}
catch (Exception e)
{
return false;
}
if(number.contains(String.valueOf(getDecimalSeparator())))
return false;
else
return true;
}
public static boolean isNumeric(String str)
@@ -1,5 +1,6 @@
package com.jens.automation2.receivers;
import static android.content.Context.RECEIVER_NOT_EXPORTED;
import static android.os.BatteryManager.*;
import android.os.BatteryManager;
@@ -8,6 +9,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.util.Log;
import com.jens.automation2.ActivityPermissions;
@@ -30,7 +32,7 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
static boolean usbHostConnected = false;
static boolean batteryReceiverActive = false;
static IntentFilter batteryIntentFilter = null;
static Intent batteryStatus = null;
static Intent batteryStatusReceiverIntent = null;
private static int currentChargingState = 0; //0=unknown, 1=no, 2=yes
private static int currentChargingType = 0; //AC, wireless, USB
@@ -52,7 +54,10 @@ public class BatteryReceiver extends BroadcastReceiver implements AutomationList
batteryIntentFilter.addAction(Intent.ACTION_BATTERY_LOW);
}
batteryStatus = automationServiceRef.registerReceiver(batteryInfoReceiverInstance, batteryIntentFilter);
if(Build.VERSION.SDK_INT >= 26)
batteryStatusReceiverIntent = automationServiceRef.registerReceiver(batteryInfoReceiverInstance, batteryIntentFilter, Context.RECEIVER_NOT_EXPORTED);
else
batteryStatusReceiverIntent = automationServiceRef.registerReceiver(batteryInfoReceiverInstance, batteryIntentFilter);
batteryReceiverActive = true;
}
@@ -1,11 +1,14 @@
package com.jens.automation2.receivers;
import static android.content.Context.RECEIVER_EXPORTED;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.util.Log;
import android.widget.Toast;
@@ -57,6 +60,10 @@ public class BluetoothReceiver extends BroadcastReceiver implements AutomationLi
{
Miscellaneous.logEvent("i", "BluetoothReceiver", "Starting BluetoothReceiver", 4);
bluetoothReceiverActive = true;
if(Build.VERSION.SDK_INT >= 26)
AutomationService.getInstance().registerReceiver(bluetoothReceiverInstance, bluetoothReceiverIntentFilter, Context.RECEIVER_EXPORTED);
else
AutomationService.getInstance().registerReceiver(bluetoothReceiverInstance, bluetoothReceiverIntentFilter);
}
}
@@ -57,6 +57,10 @@ public class ConnectivityReceiver extends BroadcastReceiver implements Automatio
{
Miscellaneous.logEvent("i", "Wifi Listener", "Starting connectivityReceiver", 4);
connectivityReceiverActive = true;
if(Build.VERSION.SDK_INT >= 26)
automationServiceRef.registerReceiver(connectivityReceiverInstance, connectivityIntentFilter, Context.RECEIVER_EXPORTED);
else
automationServiceRef.registerReceiver(connectivityReceiverInstance, connectivityIntentFilter);
}
}
@@ -5,6 +5,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.util.Log;
import com.jens.automation2.ActivityPermissions;
@@ -105,6 +106,10 @@ public class HeadphoneJackListener extends BroadcastReceiver implements Automati
{
Miscellaneous.logEvent("i", "HeadsetJackListener", "Starting HeadsetJackListener", 4);
headphoneJackListenerActive = true;
if(Build.VERSION.SDK_INT >= 26)
automationService.registerReceiver(this, headphoneJackListenerIntentFilter, Context.RECEIVER_NOT_EXPORTED);
else
automationService.registerReceiver(this, headphoneJackListenerIntentFilter);
}
}
@@ -285,7 +285,12 @@ public class PhoneStatusListener implements AutomationListenerInterface
if(!outgoingCallsReceiverActive)
{
Miscellaneous.logEvent("i", "PhoneStatusListener", "Starting PhoneStatusListener->outgoingCallsReceiver", 4);
if(Build.VERSION.SDK_INT >= 26)
automationService.registerReceiver(outgoingCallsReceiverInstance, outgoingCallsIntentFilter, Context.RECEIVER_NOT_EXPORTED);
else
automationService.registerReceiver(outgoingCallsReceiverInstance, outgoingCallsIntentFilter);
outgoingCallsReceiverActive = true;
}
}
@@ -1,5 +1,7 @@
package com.jens.automation2.receivers;
import static android.content.Context.RECEIVER_NOT_EXPORTED;
import android.Manifest;
import android.app.KeyguardManager;
import android.content.BroadcastReceiver;
@@ -71,6 +73,9 @@ public class ScreenStateReceiver extends BroadcastReceiver implements Automation
// Intent.ACTION_USER_UNLOCKED
}
if(Build.VERSION.SDK_INT >= 26)
screenStatusIntent = automationServiceRef.registerReceiver(screenStateReceiverInstance, screenStateIntentFilter, Context.RECEIVER_NOT_EXPORTED);
else
screenStatusIntent = automationServiceRef.registerReceiver(screenStateReceiverInstance, screenStateIntentFilter);
screenStateReceiverActive = true;
@@ -6,6 +6,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.wifi.WifiManager;
import android.os.Build;
import com.jens.automation2.AutomationService;
import com.jens.automation2.Miscellaneous;
@@ -116,6 +117,9 @@ public class SubSystemStateReceiver extends BroadcastReceiver implements Automat
subSystemStateIntentFilter.addAction(stateBluetooth);
}
if(Build.VERSION.SDK_INT >= 26)
subSystemStatusIntent = automationServiceRef.registerReceiver(subSystemStateReceiverInstance, subSystemStateIntentFilter, Context.RECEIVER_NOT_EXPORTED);
else
subSystemStatusIntent = automationServiceRef.registerReceiver(subSystemStateReceiverInstance, subSystemStateIntentFilter);
subSystemStateReceiverActive = true;
@@ -162,7 +162,11 @@ public class TetheringReceiver extends android.content.BroadcastReceiver impleme
try
{
if(Build.VERSION.SDK_INT >= 26)
automationServiceRef.registerReceiver(receiverInstance, intentFilter, Context.RECEIVER_NOT_EXPORTED);
else
automationServiceRef.registerReceiver(receiverInstance, intentFilter);
receiverActive = true;
}
catch(Exception e)
@@ -4,6 +4,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import android.util.Log;
import com.jens.automation2.AutomationService;
@@ -44,6 +45,9 @@ public class TimeZoneListener extends BroadcastReceiver implements AutomationLis
timezoneListenerIntentFilter.addAction(Intent.ACTION_TIME_CHANGED);
}
if(Build.VERSION.SDK_INT >= 26)
automationService.registerReceiver(timeZoneListenerInstance, timezoneListenerIntentFilter, Context.RECEIVER_NOT_EXPORTED);
else
automationService.registerReceiver(timeZoneListenerInstance, timezoneListenerIntentFilter);
}
}