diff --git a/app/build.gradle b/app/build.gradle
index 1110d21..51737df 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -60,6 +60,7 @@ android {
}
dependencies {
+ implementation 'org.jetbrains:annotations:15.0'
googlePlayFlavorImplementation 'com.google.firebase:firebase-appindexing:20.0.0'
googlePlayFlavorImplementation 'com.google.android.gms:play-services-location:18.0.0'
diff --git a/app/src/apkFlavor/AndroidManifest.xml b/app/src/apkFlavor/AndroidManifest.xml
index 5f733da..761f790 100644
--- a/app/src/apkFlavor/AndroidManifest.xml
+++ b/app/src/apkFlavor/AndroidManifest.xml
@@ -150,7 +150,7 @@
-
+
diff --git a/app/src/fdroidFlavor/AndroidManifest.xml b/app/src/fdroidFlavor/AndroidManifest.xml
index 9ee8098..599b381 100644
--- a/app/src/fdroidFlavor/AndroidManifest.xml
+++ b/app/src/fdroidFlavor/AndroidManifest.xml
@@ -148,7 +148,7 @@
-
+
diff --git a/app/src/googlePlayFlavor/AndroidManifest.xml b/app/src/googlePlayFlavor/AndroidManifest.xml
index 9ce871d..0ad5f67 100644
--- a/app/src/googlePlayFlavor/AndroidManifest.xml
+++ b/app/src/googlePlayFlavor/AndroidManifest.xml
@@ -142,7 +142,7 @@
-
+
diff --git a/app/src/main/java/com/jens/automation2/ActivityMaintenance.java b/app/src/main/java/com/jens/automation2/ActivityControlCenter.java
similarity index 77%
rename from app/src/main/java/com/jens/automation2/ActivityMaintenance.java
rename to app/src/main/java/com/jens/automation2/ActivityControlCenter.java
index 9cc335c..d0bf29d 100644
--- a/app/src/main/java/com/jens/automation2/ActivityMaintenance.java
+++ b/app/src/main/java/com/jens/automation2/ActivityControlCenter.java
@@ -10,6 +10,7 @@ import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
+import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.Toast;
@@ -21,7 +22,7 @@ import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.util.ArrayList;
-public class ActivityMaintenance extends Activity
+public class ActivityControlCenter extends Activity
{
final static int requestCodeImport = 1001;
final static int requestCodeExport = 1002;
@@ -30,13 +31,14 @@ public class ActivityMaintenance extends Activity
final static String prefsFileName = "com.jens.automation2_preferences.xml";
TextView tvFileStoreLocation, tvAppVersion;
- Button bVolumeTest, bMoreSettings, bSettingsSetToDefault, bShareConfigAndLog, bImportConfiguration, bExportConfiguration;
+ Button bVolumeTest, bMoreSettings, bSettingsSetToDefault, bSendEmailToDev, bImportConfiguration, bExportConfiguration;
+ CheckBox chkShareConfigAndLog;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_maintenance);
+ setContentView(R.layout.activity_control_center);
bVolumeTest = (Button) findViewById(R.id.bVolumeTest);
bVolumeTest.setOnClickListener(new View.OnClickListener()
@@ -44,18 +46,25 @@ public class ActivityMaintenance extends Activity
@Override
public void onClick(View v)
{
- Intent intent = new Intent(ActivityMaintenance.this, ActivityVolumeTest.class);
+ Intent intent = new Intent(ActivityControlCenter.this, ActivityVolumeTest.class);
startActivity(intent);
}
});
- bShareConfigAndLog = (Button) findViewById(R.id.bShareConfigAndLog);
- bShareConfigAndLog.setOnClickListener(new View.OnClickListener()
+ chkShareConfigAndLog = (CheckBox)findViewById(R.id.chkShareConfigAndLog);
+ bSendEmailToDev = (Button) findViewById(R.id.bSendEmailToDev);
+ bSendEmailToDev.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
- getShareConfigAndLogDialogue(ActivityMaintenance.this).show();
+ if(chkShareConfigAndLog.isChecked())
+ getShareConfigAndLogDialogue(ActivityControlCenter.this).show();
+ else
+ {
+ String subject = "Automation";
+ Miscellaneous.sendEmail(ActivityControlCenter.this, "android-development@gmx.de", "Automation logs", getSystemInfo(), null);
+ }
}
});
@@ -65,17 +74,17 @@ public class ActivityMaintenance extends Activity
@Override
public void onClick(View v)
{
- getDefaultSettingsDialog(ActivityMaintenance.this).show();
+ getDefaultSettingsDialog(ActivityControlCenter.this).show();
}
});
- Button bMoreSettings = (Button) findViewById(R.id.bMoreSettings);
+ bMoreSettings = (Button) findViewById(R.id.bMoreSettings);
bMoreSettings.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
- Intent myIntent = new Intent(ActivityMaintenance.this, ActivitySettings.class);
+ Intent myIntent = new Intent(ActivityControlCenter.this, ActivitySettings.class);
startActivityForResult(myIntent, requestCodeMoreSettings);
}
});
@@ -123,7 +132,7 @@ public class ActivityMaintenance extends Activity
if (AutomationService.isMyServiceRunning(this))
AutomationService.getInstance().serviceInterface(AutomationService.serviceCommands.reloadSettings);
- if (AutomationService.isMyServiceRunning(ActivityMaintenance.this))
+ if (AutomationService.isMyServiceRunning(ActivityControlCenter.this))
Toast.makeText(this, getResources().getString(R.string.settingsWillTakeTime), Toast.LENGTH_LONG).show();
break;
@@ -170,7 +179,7 @@ public class ActivityMaintenance extends Activity
if (Miscellaneous.copyDocumentFileToFile(file, dstRules))
filesImported++;
else
- Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.rulesImportError), Toast.LENGTH_LONG).show();
+ Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.rulesImportError), Toast.LENGTH_LONG).show();
}
}
else if (file.getName().equals(prefsFileName))
@@ -183,7 +192,7 @@ public class ActivityMaintenance extends Activity
if (Miscellaneous.copyDocumentFileToFile(file, dstPrefs))
filesImported++;
else
- Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.prefsImportError), Toast.LENGTH_LONG).show();
+ Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.prefsImportError), Toast.LENGTH_LONG).show();
}
}
}
@@ -191,12 +200,12 @@ public class ActivityMaintenance extends Activity
if(applicableFilesFound > 0)
{
if(filesImported == 0)
- Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.noFilesImported), Toast.LENGTH_LONG).show();
+ Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.noFilesImported), Toast.LENGTH_LONG).show();
else if(filesImported < applicableFilesFound)
- Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.notAllFilesImported), Toast.LENGTH_LONG).show();
+ Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.notAllFilesImported), Toast.LENGTH_LONG).show();
else if (filesImported == applicableFilesFound)
{
- Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.configurationImportedSuccessfully), Toast.LENGTH_LONG).show();
+ Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.configurationImportedSuccessfully), Toast.LENGTH_LONG).show();
try
{
@@ -208,19 +217,19 @@ public class ActivityMaintenance extends Activity
catch (Exception e)
{
Miscellaneous.logEvent("e", "Reading import", "Rules re-read failed: " + Log.getStackTraceString(e), 1);
- Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.errorReadingPoisAndRulesFromFile), Toast.LENGTH_LONG).show();
+ Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.errorReadingPoisAndRulesFromFile), Toast.LENGTH_LONG).show();
}
- Settings.readFromPersistentStorage(ActivityMaintenance.this);
+ Settings.readFromPersistentStorage(ActivityControlCenter.this);
}
else
- Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.noFilesImported), Toast.LENGTH_LONG).show();
+ Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.noFilesImported), Toast.LENGTH_LONG).show();
}
else
- Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.noApplicableFilesFoundInDirectory), Toast.LENGTH_LONG).show();
+ Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.noApplicableFilesFoundInDirectory), Toast.LENGTH_LONG).show();
}
else
- Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.noApplicableFilesFoundInDirectory), Toast.LENGTH_LONG).show();
+ Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.noApplicableFilesFoundInDirectory), Toast.LENGTH_LONG).show();
}
void exportFiles(Uri uriTree)
@@ -252,12 +261,12 @@ public class ActivityMaintenance extends Activity
if(dstRules.canWrite() && dstPrefs.canWrite())
{
if(Miscellaneous.copyFileToDocumentFile(srcRules, dstRules) && Miscellaneous.copyFileToDocumentFile(srcPrefs, dstPrefs))
- Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.configurationExportedSuccessfully), Toast.LENGTH_LONG).show();
+ Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.configurationExportedSuccessfully), Toast.LENGTH_LONG).show();
else
- Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.ConfigurationExportError), Toast.LENGTH_LONG).show();
+ Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.ConfigurationExportError), Toast.LENGTH_LONG).show();
}
else
- Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.ConfigurationExportError), Toast.LENGTH_LONG).show();
+ Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.ConfigurationExportError), Toast.LENGTH_LONG).show();
}
private static AlertDialog getDefaultSettingsDialog(final Context context)
@@ -296,32 +305,33 @@ public class ActivityMaintenance extends Activity
srcFilesList.add(Miscellaneous.getWriteableFolder() + "/../shared_prefs/" + prefsFileName);
String logFilePath = Miscellaneous.getWriteableFolder() + "/" + Miscellaneous.logFileName;
- if((new File(logFilePath)).exists())
+ if ((new File(logFilePath)).exists())
srcFilesList.add(logFilePath);
String logFilePathArchive = Miscellaneous.getWriteableFolder() + "/" + Miscellaneous.logFileName + "-old";
- if((new File(logFilePathArchive)).exists())
+ if ((new File(logFilePathArchive)).exists())
srcFilesList.add(logFilePathArchive);
String[] srcFiles = srcFilesList.toArray(new String[srcFilesList.size()]);
- if(dstZipFile.exists())
+ if (dstZipFile.exists())
dstZipFile.delete();
Miscellaneous.zip(srcFiles, dstZipFile.getAbsolutePath());
- /*
- Without root the zip file in the cache directory is not directly accessible.
- But have to route it through this content provider crap.
- */
+ /*
+ Without root the zip file in the cache directory is not directly accessible.
+ But have to route it through this content provider crap.
+ */
String subject = "Automation logs";
Uri uri = Uri.parse("content://com.jens.automation2/" + Settings.zipFileName);
- Miscellaneous.sendEmail(ActivityMaintenance.this, "android-development@gmx.de", "Automation logs", getSystemInfo(), uri);
+ Miscellaneous.sendEmail(ActivityControlCenter.this, "android-development@gmx.de", "Automation logs", getSystemInfo(), uri);
}
});
+
alertDialogBuilder.setNegativeButton(context.getResources().getString(R.string.no), null);
AlertDialog alertDialog = alertDialogBuilder.create();
@@ -367,7 +377,7 @@ public class ActivityMaintenance extends Activity
{
// if you reach this place, it means there is no any file
// explorer app installed on your device
- Toast.makeText(ActivityMaintenance.this, getResources().getString(R.string.noFileManageInstalled), Toast.LENGTH_LONG).show();
+ Toast.makeText(ActivityControlCenter.this, getResources().getString(R.string.noFileManageInstalled), Toast.LENGTH_LONG).show();
}
}
diff --git a/app/src/main/java/com/jens/automation2/ActivityMainScreen.java b/app/src/main/java/com/jens/automation2/ActivityMainScreen.java
index b74f6aa..56e5559 100644
--- a/app/src/main/java/com/jens/automation2/ActivityMainScreen.java
+++ b/app/src/main/java/com/jens/automation2/ActivityMainScreen.java
@@ -35,18 +35,17 @@ import java.util.Calendar;
@SuppressLint("NewApi")
public class ActivityMainScreen extends ActivityGeneric
{
- private static boolean guiChangeInProgress = false;
+ static boolean guiChangeInProgress = false;
+ static ActivityMainScreen activityMainScreenInstance = null;
+ static boolean updateNoteDisplayed = false;
+ static boolean uiUpdateRunning = false;
- private static ActivityMainScreen activityMainScreenInstance = null;
- private ToggleButton toggleService, tbLockSound;
- private Button bShowHelp, bPrivacy, bSettingsErase, bAddSoundLockTIme, bDonate;
- private TextView tvActivePoi, tvClosestPoi, tvLastRule, tvMainScreenNotePermissions, tvMainScreenNoteFeaturesFromOtherFlavor, tvMainScreenNoteLocationImpossibleBlameGoogle, tvMainScreenNoteNews, tvlockSoundDuration;
- private static boolean updateNoteDisplayed = false;
+ ToggleButton toggleService, tbLockSound;
+ Button bShowHelp, bPrivacy, bAddSoundLockTIme, bDonate, bControlCenter;
+ TextView tvActivePoi, tvClosestPoi, tvLastRule, tvMainScreenNotePermissions, tvMainScreenNoteFeaturesFromOtherFlavor, tvMainScreenNoteLocationImpossibleBlameGoogle, tvMainScreenNoteNews, tvLockSoundDuration;
- private ListView lvRuleHistory;
- private ArrayAdapter ruleHistoryListViewAdapter;
-
- private static boolean uiUpdateRunning = false;
+ ListView lvRuleHistory;
+ ArrayAdapter ruleHistoryListViewAdapter;
@Override
public void onCreate(Bundle savedInstanceState)
@@ -74,7 +73,7 @@ public class ActivityMainScreen extends ActivityGeneric
tvMainScreenNoteFeaturesFromOtherFlavor = (TextView) findViewById(R.id.tvMainScreenNoteFeaturesFromOtherFlavor);
tvMainScreenNoteLocationImpossibleBlameGoogle = (TextView) findViewById(R.id.tvMainScreenNoteLocationImpossibleBlameGoogle);
tvMainScreenNoteNews = (TextView) findViewById(R.id.tvMainScreenNoteNews);
- tvlockSoundDuration = (TextView)findViewById(R.id.tvlockSoundDuration);
+ tvLockSoundDuration = (TextView)findViewById(R.id.tvlockSoundDuration);
tbLockSound = (ToggleButton) findViewById(R.id.tbLockSound);
toggleService = (ToggleButton) findViewById(R.id.tbArmMastListener);
@@ -94,7 +93,8 @@ public class ActivityMainScreen extends ActivityGeneric
if (toggleService.isChecked())
{
startAutomationService(getBaseContext(), false);
- } else
+ }
+ else
{
stopAutomationService();
}
@@ -142,13 +142,13 @@ public class ActivityMainScreen extends ActivityGeneric
}
});
- Button bSettings = (Button) findViewById(R.id.bSettings);
- bSettings.setOnClickListener(new OnClickListener()
+ bControlCenter = (Button) findViewById(R.id.bControlCenter);
+ bControlCenter.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
- Intent myIntent = new Intent(ActivityMainScreen.this, ActivityMaintenance.class);
+ Intent myIntent = new Intent(ActivityMainScreen.this, ActivityControlCenter.class);
startActivity(myIntent);
}
});
@@ -390,21 +390,21 @@ public class ActivityMainScreen extends ActivityGeneric
long millis = end.getTimeInMillis() - now.getTimeInMillis();
long minutes = millis/1000/60;
if(minutes < 60)
- activityMainScreenInstance.tvlockSoundDuration.setText(String.valueOf(minutes + " min..."));
+ activityMainScreenInstance.tvLockSoundDuration.setText(String.valueOf(minutes + " min..."));
else
{
double hours = (double)minutes / 60.0;
- activityMainScreenInstance.tvlockSoundDuration.setText(String.valueOf(Math.round(hours * 100.0) / 100.0) + " h...");
+ activityMainScreenInstance.tvLockSoundDuration.setText(String.valueOf(Math.round(hours * 100.0) / 100.0) + " h...");
}
}
else
- activityMainScreenInstance.tvlockSoundDuration.setText(String.valueOf(""));
+ activityMainScreenInstance.tvLockSoundDuration.setText(String.valueOf(""));
}
else
{
activityMainScreenInstance.tbLockSound.setChecked(false);
activityMainScreenInstance.tbLockSound.setEnabled(false);
- activityMainScreenInstance.tvlockSoundDuration.setText("");
+ activityMainScreenInstance.tvLockSoundDuration.setText("");
}
Settings.writeSettings(activityMainScreenInstance);
// uiUpdateRunning = false;
diff --git a/app/src/main/java/com/jens/automation2/ActivityManageActionBrightnessSetting.java b/app/src/main/java/com/jens/automation2/ActivityManageActionBrightnessSetting.java
index e24b52c..b4a4796 100644
--- a/app/src/main/java/com/jens/automation2/ActivityManageActionBrightnessSetting.java
+++ b/app/src/main/java/com/jens/automation2/ActivityManageActionBrightnessSetting.java
@@ -10,7 +10,7 @@ import android.widget.CompoundButton;
import android.widget.SeekBar;
import android.widget.TextView;
-import androidx.annotation.Nullable;
+import org.jetbrains.annotations.Nullable;
public class ActivityManageActionBrightnessSetting extends Activity
{
diff --git a/app/src/main/java/com/jens/automation2/AutomationService.java b/app/src/main/java/com/jens/automation2/AutomationService.java
index c1c505f..401b90c 100644
--- a/app/src/main/java/com/jens/automation2/AutomationService.java
+++ b/app/src/main/java/com/jens/automation2/AutomationService.java
@@ -197,7 +197,7 @@ public class AutomationService extends Service implements OnInitListener
if (checkStartupRequirements(this, startAtBoot))
{
Miscellaneous.logEvent("i", "Service", this.getResources().getString(R.string.logServiceStarting) + " VERSION_CODE: " + BuildConfig.VERSION_CODE + ", VERSION_NAME: " + BuildConfig.VERSION_NAME + ", flavor: " + BuildConfig.FLAVOR, 1);
- Miscellaneous.logEvent("i", "Service", ActivityMaintenance.getSystemInfo(), 1);
+ Miscellaneous.logEvent("i", "Service", ActivityControlCenter.getSystemInfo(), 1);
startUpRoutine();
diff --git a/app/src/main/java/com/jens/automation2/Trigger.java b/app/src/main/java/com/jens/automation2/Trigger.java
index 0b7a6d7..507c95d 100644
--- a/app/src/main/java/com/jens/automation2/Trigger.java
+++ b/app/src/main/java/com/jens/automation2/Trigger.java
@@ -999,7 +999,7 @@ public class Trigger
*/
public enum Trigger_Enum {
- pointOfInterest, timeFrame, charging, batteryLevel, usb_host_connection, speed, noiseLevel, wifiConnection, process_started_stopped, airplaneMode, roaming, nfcTag, activityDetection, bluetoothConnection, headsetPlugged, notification, deviceOrientation, profileActive, phoneCall; //phoneCall always needs to be at the very end because of Google's shitty so called privacy
+ pointOfInterest, timeFrame, charging, batteryLevel, usb_host_connection, speed, noiseLevel, wifiConnection, process_started_stopped, airplaneMode, roaming, nfcTag, activityDetection, bluetoothConnection, headsetPlugged, notification, deviceOrientation, profileActive, screenState, phoneCall; //phoneCall always needs to be at the very end because of Google's shitty so called privacy
public String getFullName(Context context)
{
diff --git a/app/src/main/java/com/jens/automation2/receivers/ScreenStatusReceiver.java b/app/src/main/java/com/jens/automation2/receivers/ScreenStatusReceiver.java
new file mode 100644
index 0000000..a0b2496
--- /dev/null
+++ b/app/src/main/java/com/jens/automation2/receivers/ScreenStatusReceiver.java
@@ -0,0 +1,292 @@
+package com.jens.automation2.receivers;
+
+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 android.widget.Toast;
+
+import com.jens.automation2.ActivityPermissions;
+import com.jens.automation2.AutomationService;
+import com.jens.automation2.Miscellaneous;
+import com.jens.automation2.Rule;
+import com.jens.automation2.Trigger.Trigger_Enum;
+
+import java.util.ArrayList;
+
+public class ScreenStatusReceiver extends BroadcastReceiver implements AutomationListenerInterface
+{
+ static int batteryLevel = -1; // initialize with a better value than this
+ public static AutomationService automationServiceRef = null;
+ private static boolean usbHostConnected = false;
+
+ private static boolean screenStateReceiverActive = false;
+ private static IntentFilter screenStateIntentFilter = null;
+ private static Intent screenStatusIntent = null;
+ private static BroadcastReceiver screenStateReceiverInstance = null;
+
+ public static void startScreenStateReceiver(final AutomationService automationServiceRef)
+ {
+ if(!screenStateReceiverActive)
+ {
+ ScreenStatusReceiver.automationServiceRef = automationServiceRef;
+
+ if(screenStateReceiverInstance == null)
+ screenStateReceiverInstance = new ScreenStatusReceiver();
+
+ if(screenStateIntentFilter == null)
+ {
+ screenStateIntentFilter = new IntentFilter();
+ screenStateIntentFilter.addAction(Intent.ACTION_SCREEN_OFF);
+ screenStateIntentFilter.addAction(Intent.ACTION_SCREEN_ON);
+ }
+
+ screenStatusIntent = automationServiceRef.registerReceiver(screenStateReceiverInstance, screenStateIntentFilter);
+
+ screenStateReceiverActive = true;
+ }
+ }
+ public static void stopScreenStateReceiver()
+ {
+ if(screenStateReceiverActive)
+ {
+ if(screenStateReceiverInstance != null)
+ {
+ automationServiceRef.unregisterReceiver(screenStateReceiverInstance);
+ screenStateReceiverInstance = null;
+ }
+
+ screenStateReceiverActive = false;
+ }
+ }
+
+ public static boolean isScreenStateReceiverActive()
+ {
+ return screenStateReceiverActive;
+ }
+
+ public static boolean isUsbHostConnected()
+ {
+ return usbHostConnected;
+ }
+
+ public static int getBatteryLevel()
+ {
+ return batteryLevel;
+ }
+
+ private static int currentChargingState = 0; //0=unknown, 1=no, 2=yes
+
+ public static int getCurrentChargingState()
+ {
+ return currentChargingState;
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent)
+ {
+// Log.i("Battery", "Some battery event");
+
+ if (intent == null)
+ return;
+ if (context == null)
+ return;
+
+ if(intent.getAction().equals(Intent.ACTION_BATTERY_LOW))
+ {
+ Log.i("Battery", "Low battery event");
+ }
+ else
+ {
+ try
+ {
+ // Miscellaneous.logEvent("i", "BatteryReceiver", "Received battery event.");
+ // if(intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED))
+ // {
+ batteryLevel = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
+ // int scale = -1;
+ // int voltage = -1;
+ // int temp = -1;
+ // scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
+ // temp = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, -1);
+ // voltage = intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, -1);
+ 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);
+ // Miscellaneous.logEvent("i", "BatteryReceiver", "Status: " + String.valueOf(statusPlugged));
+
+ switch(statusPlugged)
+ {
+ case BatteryManager.BATTERY_PLUGGED_AC:
+ // Toast.makeText(context, "Regular charging", Toast.LENGTH_LONG).show();
+ // Miscellaneous.logEvent("i", "BatteryReceiver", "Regular charging.");
+ this.actionCharging(context);
+ break;
+ case BatteryManager.BATTERY_PLUGGED_USB:
+ this.actionUsbConnected(context);
+ break;
+ }
+
+ switch(status)
+ {
+ // case BatteryManager.BATTERY_STATUS_CHARGING:
+ // break;
+ case BatteryManager.BATTERY_STATUS_FULL:
+ // Toast.makeText(context, "Regular charging full", Toast.LENGTH_LONG).show();
+ // Miscellaneous.logEvent("i", "BatteryReceiver", "Device has been fully charged.");
+ this.actionCharging(context);
+ break;
+ case BatteryManager.BATTERY_STATUS_DISCHARGING:
+ this.actionDischarging(context);
+ break;
+ }
+ }
+ catch(Exception e)
+ {
+ Miscellaneous.logEvent("e", "BatteryReceiver", "Error receiving battery status: " + e.getMessage(), 3);
+ }
+ }
+ }
+
+ public static int isDeviceCharging(Context context)
+ {
+ switch(currentChargingState)
+ {
+ case 0:
+ Miscellaneous.logEvent("w", "ChargingInfo", "Status of device charging was requested. Information isn't available, yet.", 4);
+ break;
+ case 1:
+ Miscellaneous.logEvent("i", "ChargingInfo", "Status of device charging was requested. Device is discharging.", 3);
+ break;
+ case BatteryManager.BATTERY_STATUS_CHARGING:
+ Miscellaneous.logEvent("i", "ChargingInfo", "Status of device charging was requested. Device is charging.", 3);
+ break;
+ }
+
+ return currentChargingState;
+ }
+
+ private void actionCharging(Context context)
+ {
+ 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.
+ {
+ Miscellaneous.logEvent("i", "BatteryReceiver", "Battery is charging or full.", 3);
+ currentChargingState = BatteryManager.BATTERY_STATUS_CHARGING;
+ //activate rule(s)
+ ArrayList ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.charging);
+// ArrayList ruleCandidates = Rule.findRuleCandidatesByCharging(true);
+ for(int i=0; i ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.batteryLevel);
+ for(int i=0; i ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.charging);
+// ArrayList ruleCandidates = Rule.findRuleCandidatesByCharging(false);
+ for(int i=0; i ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.usb_host_connection);
+// ArrayList ruleCandidates = Rule.findRuleCandidatesByUsbHost(true);
+ for(Rule oneRule : ruleCandidates)
+ {
+ if(oneRule.getsGreenLight(context))
+ oneRule.activate(automationServiceRef, false);
+ }
+
+ this.actionCharging(context);
+ }
+ }
+
+ private void actionUsbDisconnected(Context context)
+ {
+ // Event usbDisConnected
+
+ if(usbHostConnected)
+ {
+ usbHostConnected = false;
+ Miscellaneous.logEvent("i", "BatteryReceiver", "Disconnected from computer.", 3);
+ Toast.makeText(context, "Disconnected from computer.", Toast.LENGTH_LONG).show();
+
+ ArrayList ruleCandidates = Rule.findRuleCandidates(Trigger_Enum.usb_host_connection);
+// ArrayList ruleCandidates = Rule.findRuleCandidatesByUsbHost(false);
+ for(Rule oneRule : ruleCandidates)
+ {
+ if(oneRule.getsGreenLight(context))
+ oneRule.activate(automationServiceRef, false);
+ }
+ }
+ }
+ @Override
+ public void startListener(AutomationService automationService)
+ {
+ ScreenStatusReceiver.startScreenStateReceiver(automationService);
+ }
+ @Override
+ public void stopListener(AutomationService automationService)
+ {
+ ScreenStatusReceiver.stopScreenStateReceiver();
+ }
+
+ public static boolean haveAllPermission()
+ {
+ return ActivityPermissions.havePermission(Manifest.permission.READ_PHONE_STATE, Miscellaneous.getAnyContext()) &&
+ ActivityPermissions.havePermission(Manifest.permission.BATTERY_STATS, Miscellaneous.getAnyContext());
+ }
+
+ @Override
+ public boolean isListenerRunning()
+ {
+ return ScreenStatusReceiver.isScreenStateReceiverActive();
+ }
+ @Override
+ public Trigger_Enum[] getMonitoredTrigger()
+ {
+ return new Trigger_Enum[] { Trigger_Enum.screenState };
+ }
+}
diff --git a/app/src/main/res/layout/activity_maintenance.xml b/app/src/main/res/layout/activity_control_center.xml
similarity index 85%
rename from app/src/main/res/layout/activity_maintenance.xml
rename to app/src/main/res/layout/activity_control_center.xml
index a2bed37..49aaa0e 100644
--- a/app/src/main/res/layout/activity_maintenance.xml
+++ b/app/src/main/res/layout/activity_control_center.xml
@@ -16,14 +16,14 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Headline"
- android:text="@string/settings"
+ android:text="@string/controlCenter"
android:layout_marginBottom="@dimen/default_margin"/>
+ android:text="@string/settings" />
+
+
+ android:text="@string/sendEmailToDev" />
+
+
+ android:text="@string/controlCenter" />
-
+
+
+
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 37d8af2..e68e32c 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -532,7 +532,7 @@
Datei existiert nicht.Kein Dateimanager installiert.Wenn diese Einstellung aktiv ist, wird der Ton immer abgespielt. Wenn die Einstellung inaktiv ist, wird der Ton nur dann abgespielt, wenn das Telefon weder auf stumm noch auf Vibration steht, d.h. Klingeltöne aktiv sind. Allerdings hat es keinen Einfluß auf die Medien-Lautstärke. D.h., wenn diese stumm ist, werden Sie so oder so nichts zu hören bekommen.
- Konfigurations- und Logdatei mit Entwickler teilen (via email).
+ Konfigurations- und Logdateien anhängenDies wird eine neue Email öffnen mit Konfigurations- und Logdateien als Zip-Anhang. Sie wird nicht automatisch versendet. D.h. Sie können so z.B. auch den Adressaten zu sich selbst ändern.Dieser Auslöser reagiert auf Benachrichtigungen anderer Anwendung im Benachrichtigungsbereich von Android (oder wenn diese geschlossen werden). Sie können eine bestimmte Anwendung festlegen, von die Nachricht stammen muß. Wenn nicht, zählt jede Benachrichtigung. Sie können auch Zeichenketten für Titel oder Nachrichteninhalt festlegen, die enthalten sein müssen. Die Groß-/Kleinschreibung wird hierbei nicht berücksichtigt.Parameter hinzufügen
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index 9c35551..ec91a2e 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -363,7 +363,7 @@
Rotación del monitor todavia esta desactivado.Se puede usar la lista de wifis conocidos para determinar los sitios en los cuales estuvo. Por eso el permiso de localización es necesario para cargar la lista de wifis. Si quiere elegir uno de la lista tiene que conceder el permiso. En caso contrario todavia puede introducir un nombre wifi manualmente.Controlar conexiones de la app Wireguard
- Enviar configuración y procotolo al desarollador (vía email).
+ Adjuntar configuración y procotolo.Necesita permiso root para esta función. Después encienda la función \"ejecutar regla manualmente\" para presentar el permiso superuser dialogo. Es necesario elegir \"siempre permitir root para esta app\". En caso contrario la regla no puede funcionar en segundo plano.Todas las condiciones están \"Y\"-conectadas. La regla solo va a aplicarse cuando todas las condiciones se aplican. Si quiere \"O\", cree otra regla.Segundos entre dos ensayos de nivel de ruido
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index bead928..fd6f61a 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -456,7 +456,7 @@
Impostazioni predefinite ripristinate.Alcune impostazioni non saranno applicate prima che alcune impostazioni contestuali cambino o che il servizio venga riavviato.Questo creerà una email con la tua configurazione e i file di log allegati come file zip. Non sarà inviata automaticamente, dovrai premere \"invia\". Puoi anche cambiare il destinatario con te stesso, per esempio.
- Condividere i file di configurazione e di registro con lo sviluppatore (via e-mail).
+ Agganciare i file di configurazione e di registroMostra AiutoMostra iconaMostra una icona quando il servizio è attivo (nasconderla funziona solo in versioni inferiori ad Android 7). Se hai una versione superiore, vai alle impostazioni di sistema, quindi all\'automazione, quindi alle notifiche e disabilita la \"Service notification\".
diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml
index 6ad4387..78b2bd5 100644
--- a/app/src/main/res/values-nl/strings.xml
+++ b/app/src/main/res/values-nl/strings.xml
@@ -530,7 +530,7 @@
Selecteer geluidsbestandBestand bestaat niet.Geen bestandsmanager geïnstalleerd.
- Deel config en log bestanden met ontwikkelaar (via email).
+ Config en log vastmakenDit zal een nieuwe email starten met uw configuratie en log bestanden als zip bestand bijgevoegd. Het zal niet automatisch verzonden worden, je moet nog steeds op "verzenden" drukken. U kunt ook de ontvanger veranderen in bijvoorbeeld uzelf.Hier heeft u 2 algemene opties:. Je kunt een programma starten door een activiteit te selecteren. Stel je dit voor als het voorselecteren van een specifiek scherm/venster van een applicatie. Onthoud dat dit niet altijd zal werken. Dit komt omdat de vensters van een toepassing met elkaar kunnen interageren, bv. parameters doorgeven. Bij het botweg starten van een specifiek scherm heeft die interactie niet plaatsgevonden en kan het venster direct sluiten (waardoor het nooit echt getoond wordt). Probeer het desondanks! Je kunt een activiteitspad handmatig invoeren, maar het is aan te bevelen om de knop "Kiezen" te gebruiken. Als u besluit het pad handmatig in te voeren, voer dan in het bovenste veld de pakketnaam van de toepassing in en in het onderste veld het volledige pad van de activiteit.. Selectie door actie In tegenstelling tot het selecteren van een specifiek venster kunt u een programma ook door een actie starten. Dit is hetzelfde als roepen "Ik zou graag xyz willen" en als er een programma is geïnstalleerd dat u daarbij kan helpen, wordt het gestart. Een goed voorbeeld zou kunnen zijn start browser - je kunt er zelfs meerdere geïnstalleerd hebben (een is meestal de standaard). U moet dit handmatig invoeren, PackageName is hier optioneel. Houd in gedachten dat er geen variabelen zullen worden opgelost. Als je bijvoorbeeld de camera wilt starten met "MediaStore.ACTION_IMAGE_CAPTURE" zal dat niet werken. U moet een kijkje nemen in de Android documentatie en in plaats daarvan de werkelijke waarde van deze variabele gebruiken, die in dit voorbeeld zou zijn: "android.media.action.IMAGE_CAPTURE"Er is een fout opgetreden bij het uitvoeren van een regel.
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 57dcade..c32ad34 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -631,7 +631,7 @@
Select sound fileFile does not exist.No file manager installed.
- Share config and log files with developer (via email).
+ Attach config and log files.This will start a new email with your config and log files attached as zip file. It will not be sent automatically, you still need to hit \"send\". You can also change the recipient to yourself for example.Here you have 2 general options:\n\n1. You can start a program by selecting an activity. Imagine this like preselecting a specific screen/window of an application. Keep in mind this may not always work. This is because the windows of an app might interact with each other, e.g. pass on parameters. When bluntly starting a specific screen that interaction has not happened and the window might close instantly (therefore it\'s never really shown). Try it nevertheless! You can enter an activity path manually, but it\'s recommended to use the \"Select\" button. If you decide to enter it manually enter the app\'s package name in the upper field and the full path of the activity in the lower one.\n\n2. Selection by action In contrast to selecting a specific window you can also start a program by an action. This is like shouting out \"I\'d would like xyz\" and if there\'s an app installed that can help you with that it will be started. A good example would be start browser - you might even have multiple installed (one is usually the default one). You need to enter this manually, PackageName is optional here. Keep in mind no variables will be resolved. If you want to start the camera for example using \"MediaStore.ACTION_IMAGE_CAPTURE\" will not work. You have to take a look at the Android documentation and use this variable\'s actual value instead which in this example would be \"android.media.action.IMAGE_CAPTURE\".There was an error running a rule.
@@ -765,4 +765,7 @@
Comparisons are done case-INsensitiveThe settings you can adjust here, can cause that you don\'t notice certain things from your phone anymore. They may even silence your wakeup alarm. So whatever you do - it is recommended you test it.if
+ Email is my preferred method of contact to report bugs, ask questions or make proposals. Go to control center to learn more.
+ Control center
+ Send email to developer
\ No newline at end of file