diff --git a/app/build.gradle b/app/build.gradle
index a60dc6f..36c7675 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -12,7 +12,7 @@ android {
minSdk 26
targetSdk 34
versionCode 1
- versionName "25.531.1"
+ versionName "25.1006.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@@ -44,4 +44,6 @@ dependencies {
implementation libs.google.services
implementation libs.touchImageView
implementation libs.gson
+ implementation libs.lifecycle.process
+ implementation libs.lifecycle.runtime
}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 6255407..24821c6 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,18 +26,6 @@
android:theme="@style/Theme.Haussteuerung"
tools:targetApi="31"
android:usesCleartextTraffic="true">
-
-
-
{
- try {
- InputStream in = null;
- try {
- in = new URL(url).openStream();
- String text = "Verbindung zum Server erfolgreich. Download wird durchgeführt.";
- txt_status.setText(text);
- Log.d("APK", "Verbindung zum Server erfolgreich. Download wird durchgeführt.");
- } catch (IOException e) {
- String text = "Verbindungsfehler.";
- txt_status.setText(text);
- Log.d("APK", "Verbindungsfehler.");
- }
- try {
- Files.copy(in, Paths.get(f1), StandardCopyOption.REPLACE_EXISTING);
- downloadFinished = true;
- button_Install.setBackgroundResource(R.drawable.alarm_false);
- String text = "Download erfolgreich. Zum Installieren drücken!";
- txt_status.setText(text);
- Log.d("APK", "Download und Speichern erfolgreich.");
- } catch (IOException e) {
- String text = "Download fehlgeschlagen.";
- txt_status.setText(text);
- Log.d("APK", "Download fehlgeschlagen.");
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- });
- gfgThread.start();
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/haussteuerung/FragmentHeizkoerper.java b/app/src/main/java/com/haussteuerung/FragmentHeizkoerper.java
index c7a2779..593914c 100644
--- a/app/src/main/java/com/haussteuerung/FragmentHeizkoerper.java
+++ b/app/src/main/java/com/haussteuerung/FragmentHeizkoerper.java
@@ -8,6 +8,7 @@ import android.os.Bundle;
import androidx.appcompat.widget.SwitchCompat;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
+import androidx.lifecycle.ProcessLifecycleOwner;
import android.os.Handler;
import android.util.Log;
@@ -48,6 +49,8 @@ public class FragmentHeizkoerper extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ ProcessLifecycleOwner.get().getLifecycle().addObserver(new AppLifecycleTracker());
+
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_heizkoerper, container, false);
requireActivity().setTitle("Haussteuerung - Heizkörper");
@@ -58,14 +61,13 @@ public class FragmentHeizkoerper extends Fragment {
context = getContext();
-
return view;
}
// Runnable method
final Runnable myRunnable = new Runnable() {
public void run() {
- Log.d("Heizkoerper","OK");
+ Log.d("Heizkoerper", "OK");
tv_temp_Grossraum.setText(istTempHKGrossraum);
setTextColor(tv_temp_Grossraum, istTempHKGrossraum);
@@ -94,57 +96,41 @@ public class FragmentHeizkoerper extends Fragment {
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
final View view = this.getLayoutInflater().inflate(R.layout.layout_numberpicker, null);
builder.setView(view);
- //builder.setTitle();
final NumberPicker picker = view.findViewById(R.id.picker);
- String[] values = {"off","12.0","12.5","13.0","13.5","14.0","14.5","15.0","15.5","16.0","16.5","17.0","17.5","18.0",
- "18.5","19.0","19.5","20.0","20.5","21.0","21.5","22.0","22.5","23.0","23.5","24.0","24.5","25.0",
- "25.5","26.0","26.5","27.0","27.5","28.0","28.5","29.0","29.5","30.0","on"};
+ String[] values = {"off", "12.0", "12.5", "13.0", "13.5", "14.0", "14.5", "15.0", "15.5", "16.0", "16.5", "17.0", "17.5", "18.0",
+ "18.5", "19.0", "19.5", "20.0", "20.5", "21.0", "21.5", "22.0", "22.5", "23.0", "23.5", "24.0", "24.5", "25.0",
+ "25.5", "26.0", "26.5", "27.0", "27.5", "28.0", "28.5", "29.0", "29.5", "30.0", "on"};
int ml = values.length;
picker.setWrapSelectorWheel(false);
picker.setMinValue(0);
picker.setMaxValue(ml - 1);
- for(int y=0; y {
+ if (values[picker.getValue()].equals("on") || values[picker.getValue()].equals("off")) {
+ button.setText(values[picker.getValue()]);
+ } else {
+ button.setText(values[picker.getValue()]);
+ }
- if (values[picker.getValue()].equals("on") || values[picker.getValue()].equals("off")) {
- button.setText(values[picker.getValue()]);
+ Log.d("SollTempGrossraum", "Solltemp" + roomSollTemp + ", Button " + button.getText());
+ if (!roomSollTemp.contentEquals(button.getText())) {
+ if (switchCompat.isChecked()) {
+ Log.d("SollTemp" + room, "Temp zu Auto+Temp geändert");
+ MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/temp", "auto " + button.getText().toString(), 2, false);
} else {
- button.setText(values[picker.getValue()]);
- }
-
- Log.d("SollTempGrossraum", "Solltemp" + roomSollTemp + ", Button " + button.getText());
- if (!roomSollTemp.contentEquals(button.getText()))
- {
- if (switchCompat.isChecked()) {
- Log.d("SollTemp" + room, "Temp zu Auto+Temp geändert");
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/temp", "auto " + button.getText().toString(), 2, false);
- } else {
- Log.d("SollTemp" + room, "Temp geändert");
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/temp", button.getText().toString(), 2, false);
- }
- } else {
- Log.d("SollTemp" + room, "Temp gleich");
+ Log.d("SollTemp" + room, "Temp geändert");
+ MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/temp", button.getText().toString(), 2, false);
}
+ } else {
+ Log.d("SollTemp" + room, "Temp gleich");
}
})
- .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- builder.create().cancel();
- }
- });
+ .setNegativeButton(android.R.string.cancel, (dialog, id) -> builder.create().cancel());
builder.create().show();
}
@@ -184,75 +170,25 @@ public class FragmentHeizkoerper extends Fragment {
btn_HK_Dachboden.setText(sollTempHKDachboden);
- btn_HK_Grossraum.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showNumberPickerDialog(btn_HK_Grossraum, sollTempHKGrossraum, "Grossraum", switch_HK_Grossraum);
- }
- });
+ btn_HK_Grossraum.setOnClickListener(v -> showNumberPickerDialog(btn_HK_Grossraum, sollTempHKGrossraum, "Grossraum", switch_HK_Grossraum));
- btn_HK_Doris.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showNumberPickerDialog(btn_HK_Doris, sollTempHKDoris, "Doris_klein", switch_HK_Doris);
- }
- });
+ btn_HK_Doris.setOnClickListener(v -> showNumberPickerDialog(btn_HK_Doris, sollTempHKDoris, "Doris_klein", switch_HK_Doris));
- btn_HK_Doris_Bad.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showNumberPickerDialog(btn_HK_Doris_Bad, sollTempHKDorisBad, "Doris_Bad", switch_HK_Doris_Bad);
- }
- });
+ btn_HK_Doris_Bad.setOnClickListener(v -> showNumberPickerDialog(btn_HK_Doris_Bad, sollTempHKDorisBad, "Doris_Bad", switch_HK_Doris_Bad));
- btn_HK_Arbeitszimmer.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showNumberPickerDialog(btn_HK_Arbeitszimmer, sollTempHKArbeitszimmer, "Arbeitszimmer", switch_HK_Arbeitszimmer);
- }
- });
+ btn_HK_Arbeitszimmer.setOnClickListener(v -> showNumberPickerDialog(btn_HK_Arbeitszimmer, sollTempHKArbeitszimmer, "Arbeitszimmer", switch_HK_Arbeitszimmer));
- btn_HK_Vorraum.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showNumberPickerDialog(btn_HK_Vorraum, sollTempHKVorraum, "Vorraum", switch_HK_Vorraum);
- }
- });
+ btn_HK_Vorraum.setOnClickListener(v -> showNumberPickerDialog(btn_HK_Vorraum, sollTempHKVorraum, "Vorraum", switch_HK_Vorraum));
- btn_HK_WCEG.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showNumberPickerDialog(btn_HK_WCEG, sollTempHKWCEG, "WC", switch_HK_WCEG);
- }
- });
+ btn_HK_WCEG.setOnClickListener(v -> showNumberPickerDialog(btn_HK_WCEG, sollTempHKWCEG, "WC", switch_HK_WCEG));
- btn_HK_Bad.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showNumberPickerDialog(btn_HK_Bad, sollTempHKBad, "Bad", switch_HK_Bad);
- }
- });
+ btn_HK_Bad.setOnClickListener(v -> showNumberPickerDialog(btn_HK_Bad, sollTempHKBad, "Bad", switch_HK_Bad));
- btn_HK_Florian.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showNumberPickerDialog(btn_HK_Florian, sollTempHKFlorian, "Florian", switch_HK_Florian);
- }
- });
+ btn_HK_Florian.setOnClickListener(v -> showNumberPickerDialog(btn_HK_Florian, sollTempHKFlorian, "Florian", switch_HK_Florian));
- btn_HK_Stefan.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showNumberPickerDialog(btn_HK_Stefan, sollTempHKStefan, "Stefan", switch_HK_Stefan);
- }
- });
+ btn_HK_Stefan.setOnClickListener(v -> showNumberPickerDialog(btn_HK_Stefan, sollTempHKStefan, "Stefan", switch_HK_Stefan));
- btn_HK_Dachboden.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showNumberPickerDialog(btn_HK_Dachboden, sollTempHKDachboden, "Dachboden", switch_HK_Dachboden);
- }
- });
+ btn_HK_Dachboden.setOnClickListener(v -> showNumberPickerDialog(btn_HK_Dachboden, sollTempHKDachboden, "Dachboden", switch_HK_Dachboden));
}
private void handleTextViews() {
@@ -360,179 +296,129 @@ public class FragmentHeizkoerper extends Fragment {
switch_HK_Dachboden.setText(R.string.auto);
}
- switch_HK_Grossraum.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (switch_HK_Grossraum.isChecked()) {
- Log.d("Mode" + modeHKGrossraum, "Mode geändert");
- switch_HK_Grossraum.setText(R.string.auto);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Grossraum/set/mode", "auto", 2, false);
- } else if (!switch_HK_Grossraum.isChecked()){
- Log.d("Mode" + modeHKGrossraum, "Mode geändert");
- switch_HK_Grossraum.setText(R.string.man);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Grossraum/set/mode", "manual", 2, false);
- }
+ switch_HK_Grossraum.setOnClickListener(v -> {
+ if (switch_HK_Grossraum.isChecked()) {
+ Log.d("Mode" + modeHKGrossraum, "Mode geändert");
+ switch_HK_Grossraum.setText(R.string.auto);
+ MqttClient.publish("fhem/Heizung/MAX_Grossraum/set/mode", "auto", 2, false);
+ } else if (!switch_HK_Grossraum.isChecked()) {
+ Log.d("Mode" + modeHKGrossraum, "Mode geändert");
+ switch_HK_Grossraum.setText(R.string.man);
+ MqttClient.publish("fhem/Heizung/MAX_Grossraum/set/mode", "manual", 2, false);
}
});
- switch_HK_Doris.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (switch_HK_Doris.isChecked()) {
- Log.d("Mode" + modeHKDoris, "Mode geändert");
- switch_HK_Doris.setText(R.string.auto);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Doris_klein/set/mode", "auto", 2, false);
- } else if (!switch_HK_Doris.isChecked()){
- Log.d("Mode" + modeHKDoris, "Mode geändert");
- switch_HK_Doris.setText(R.string.man);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Doris_klein/set/mode", "manual", 2, false);
- }
+ switch_HK_Doris.setOnClickListener(v -> {
+ if (switch_HK_Doris.isChecked()) {
+ Log.d("Mode" + modeHKDoris, "Mode geändert");
+ switch_HK_Doris.setText(R.string.auto);
+ MqttClient.publish("fhem/Heizung/MAX_Doris_klein/set/mode", "auto", 2, false);
+ } else if (!switch_HK_Doris.isChecked()) {
+ Log.d("Mode" + modeHKDoris, "Mode geändert");
+ switch_HK_Doris.setText(R.string.man);
+ MqttClient.publish("fhem/Heizung/MAX_Doris_klein/set/mode", "manual", 2, false);
}
});
- switch_HK_Doris_Bad.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (switch_HK_Doris_Bad.isChecked()) {
- Log.d("Mode" + modeHKDorisBad, "Mode auto");
- switch_HK_Doris_Bad.setText(R.string.auto);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Doris_Bad/set/mode", "auto", 2, false);
- } else if (!switch_HK_Doris_Bad.isChecked()){
- Log.d("Mode" + modeHKDorisBad, "Mode manual");
- switch_HK_Doris_Bad.setText(R.string.man);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Doris_Bad/set/mode", "manual", 2, false);
- }
+ switch_HK_Doris_Bad.setOnClickListener(v -> {
+ if (switch_HK_Doris_Bad.isChecked()) {
+ Log.d("Mode" + modeHKDorisBad, "Mode auto");
+ switch_HK_Doris_Bad.setText(R.string.auto);
+ MqttClient.publish("fhem/Heizung/MAX_Doris_Bad/set/mode", "auto", 2, false);
+ } else if (!switch_HK_Doris_Bad.isChecked()) {
+ Log.d("Mode" + modeHKDorisBad, "Mode manual");
+ switch_HK_Doris_Bad.setText(R.string.man);
+ MqttClient.publish("fhem/Heizung/MAX_Doris_Bad/set/mode", "manual", 2, false);
}
});
- switch_HK_Arbeitszimmer.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (switch_HK_Arbeitszimmer.isChecked()) {
- Log.d("Mode" + modeHKArbeitszimmer, "Mode auto");
- switch_HK_Arbeitszimmer.setText(R.string.auto);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Arbeitszimmer/set/mode", "auto", 2, false);
- } else if (!switch_HK_Arbeitszimmer.isChecked()){
- Log.d("Mode" + modeHKArbeitszimmer, "Mode manual");
- switch_HK_Arbeitszimmer.setText(R.string.man);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Arbeitszimmer/set/mode", "manual", 2, false);
- }
+ switch_HK_Arbeitszimmer.setOnClickListener(v -> {
+ if (switch_HK_Arbeitszimmer.isChecked()) {
+ Log.d("Mode" + modeHKArbeitszimmer, "Mode auto");
+ switch_HK_Arbeitszimmer.setText(R.string.auto);
+ MqttClient.publish("fhem/Heizung/MAX_Arbeitszimmer/set/mode", "auto", 2, false);
+ } else if (!switch_HK_Arbeitszimmer.isChecked()) {
+ Log.d("Mode" + modeHKArbeitszimmer, "Mode manual");
+ switch_HK_Arbeitszimmer.setText(R.string.man);
+ MqttClient.publish("fhem/Heizung/MAX_Arbeitszimmer/set/mode", "manual", 2, false);
}
});
- switch_HK_Vorraum.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (switch_HK_Vorraum.isChecked()) {
- Log.d("Mode" + modeHKVorraum, "Mode auto");
- switch_HK_Vorraum.setText(R.string.auto);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Vorraum/set/mode", "auto", 2, false);
- } else if (!switch_HK_Vorraum.isChecked()) {
- Log.d("Mode" + modeHKVorraum, "Mode manual");
- switch_HK_Vorraum.setText(R.string.man);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Vorraum/set/mode", "manual", 2, false);
- }
+ switch_HK_Vorraum.setOnClickListener(v -> {
+ if (switch_HK_Vorraum.isChecked()) {
+ Log.d("Mode" + modeHKVorraum, "Mode auto");
+ switch_HK_Vorraum.setText(R.string.auto);
+ MqttClient.publish("fhem/Heizung/MAX_Vorraum/set/mode", "auto", 2, false);
+ } else if (!switch_HK_Vorraum.isChecked()) {
+ Log.d("Mode" + modeHKVorraum, "Mode manual");
+ switch_HK_Vorraum.setText(R.string.man);
+ MqttClient.publish("fhem/Heizung/MAX_Vorraum/set/mode", "manual", 2, false);
}
});
- switch_HK_WCEG.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (switch_HK_WCEG.isChecked()) {
- Log.d("Mode" + modeHKWCEG, "Mode auto");
- switch_HK_WCEG.setText(R.string.auto);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_WC/set/mode", "auto", 2, false);
- } else if (!switch_HK_WCEG.isChecked()){
- Log.d("Mode" + modeHKWCEG, "Mode manual");
- switch_HK_WCEG.setText(R.string.man);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_WC/set/mode", "manual", 2, false);
- }
+ switch_HK_WCEG.setOnClickListener(v -> {
+ if (switch_HK_WCEG.isChecked()) {
+ Log.d("Mode" + modeHKWCEG, "Mode auto");
+ switch_HK_WCEG.setText(R.string.auto);
+ MqttClient.publish("fhem/Heizung/MAX_WC/set/mode", "auto", 2, false);
+ } else if (!switch_HK_WCEG.isChecked()) {
+ Log.d("Mode" + modeHKWCEG, "Mode manual");
+ switch_HK_WCEG.setText(R.string.man);
+ MqttClient.publish("fhem/Heizung/MAX_WC/set/mode", "manual", 2, false);
}
});
- switch_HK_Bad.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (switch_HK_Bad.isChecked()) {
- Log.d("Mode" + modeHKBad, "Mode auto");
- switch_HK_Bad.setText(R.string.auto);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Bad/set/mode", "auto", 2, false);
- } else if (!switch_HK_Bad.isChecked()){
- Log.d("Mode" + modeHKBad, "Mode manual");
- switch_HK_Bad.setText(R.string.man);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Bad/set/mode", "manual", 2, false);
- }
+ switch_HK_Bad.setOnClickListener(v -> {
+ if (switch_HK_Bad.isChecked()) {
+ Log.d("Mode" + modeHKBad, "Mode auto");
+ switch_HK_Bad.setText(R.string.auto);
+ MqttClient.publish("fhem/Heizung/MAX_Bad/set/mode", "auto", 2, false);
+ } else if (!switch_HK_Bad.isChecked()) {
+ Log.d("Mode" + modeHKBad, "Mode manual");
+ switch_HK_Bad.setText(R.string.man);
+ MqttClient.publish("fhem/Heizung/MAX_Bad/set/mode", "manual", 2, false);
}
});
- switch_HK_Florian.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (switch_HK_Florian.isChecked()) {
- Log.d("Mode" + modeHKFlorian, "Mode geändert");
- switch_HK_Florian.setText(R.string.auto);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Florian/set/mode", "auto", 2, false);
- } else if (!switch_HK_Florian.isChecked()){
- Log.d("Mode" + modeHKFlorian, "Mode geändert");
- switch_HK_Florian.setText(R.string.man);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Florian/set/mode", "manual", 2, false);
- }
+ switch_HK_Florian.setOnClickListener(v -> {
+ if (switch_HK_Florian.isChecked()) {
+ Log.d("Mode" + modeHKFlorian, "Mode geändert");
+ switch_HK_Florian.setText(R.string.auto);
+ MqttClient.publish("fhem/Heizung/MAX_Florian/set/mode", "auto", 2, false);
+ } else if (!switch_HK_Florian.isChecked()) {
+ Log.d("Mode" + modeHKFlorian, "Mode geändert");
+ switch_HK_Florian.setText(R.string.man);
+ MqttClient.publish("fhem/Heizung/MAX_Florian/set/mode", "manual", 2, false);
}
});
- switch_HK_Stefan.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (switch_HK_Stefan.isChecked()) {
- Log.d("Mode" + modeHKStefan, "Mode auto");
- switch_HK_Stefan.setText(R.string.auto);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Stefan/set/mode", "auto", 2, false);
- } else if (!switch_HK_Stefan.isChecked()){
- Log.d("Mode" + modeHKStefan, "Mode manual");
- switch_HK_Stefan.setText(R.string.man);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Stefan/set/mode", "manual", 2, false);
- }
+ switch_HK_Stefan.setOnClickListener(v -> {
+ if (switch_HK_Stefan.isChecked()) {
+ Log.d("Mode" + modeHKStefan, "Mode auto");
+ switch_HK_Stefan.setText(R.string.auto);
+ MqttClient.publish("fhem/Heizung/MAX_Stefan/set/mode", "auto", 2, false);
+ } else if (!switch_HK_Stefan.isChecked()) {
+ Log.d("Mode" + modeHKStefan, "Mode manual");
+ switch_HK_Stefan.setText(R.string.man);
+ MqttClient.publish("fhem/Heizung/MAX_Stefan/set/mode", "manual", 2, false);
}
});
- switch_HK_Dachboden.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (switch_HK_Dachboden.isChecked()) {
- Log.d("Mode" + modeHKDachboden, "Mode auto");
- switch_HK_Dachboden.setText(R.string.auto);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Dachboden/set/mode", "auto", 2, false);
- } else if (!switch_HK_Dachboden.isChecked()){
- Log.d("Mode" + modeHKDachboden, "Mode manual");
- switch_HK_Dachboden.setText(R.string.man);
- //MqttClient.publish("fhem/Heizung/MAX_" + room + "/set/Temp", button.getText().toString(), 2, false);
- MqttClient.publish("fhem/Heizung/MAX_Dachboden/set/mode", "manual", 2, false);
- }
+ switch_HK_Dachboden.setOnClickListener(v -> {
+ if (switch_HK_Dachboden.isChecked()) {
+ Log.d("Mode" + modeHKDachboden, "Mode auto");
+ switch_HK_Dachboden.setText(R.string.auto);
+ MqttClient.publish("fhem/Heizung/MAX_Dachboden/set/mode", "auto", 2, false);
+ } else if (!switch_HK_Dachboden.isChecked()) {
+ Log.d("Mode" + modeHKDachboden, "Mode manual");
+ switch_HK_Dachboden.setText(R.string.man);
+ MqttClient.publish("fhem/Heizung/MAX_Dachboden/set/mode", "manual", 2, false);
}
});
}
private void setTextColor(TextView tv, String temp) {
- if (!temp.equals("")) {
+ if (!temp.isEmpty()) {
double tempDouble = Double.parseDouble(temp);
if (tempDouble >= 25) {
tv.setTextColor(ContextCompat.getColor(context, R.color.twoFive));
@@ -571,26 +457,22 @@ public class FragmentHeizkoerper extends Fragment {
myHandler.post(myRunnable); // updateUI method
}
};
- myTimer.schedule(myTask,0,1000); // TimerTask, delay, period
- Log.d("State", "on Resume");
+ myTimer.schedule(myTask, 0, 1000);
}
@Override
public void onStop() {
super.onStop();
myTask.cancel();
- Log.d("State", "on Stop");
}
@Override
public void onPause() {
super.onPause();
- Log.d("State", "on Pause");
}
@Override
public void onDestroy() {
super.onDestroy();
- // myTimer.cancel();
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/haussteuerung/FragmentHeizung.java b/app/src/main/java/com/haussteuerung/FragmentHeizung.java
index 618b748..be7bf9a 100644
--- a/app/src/main/java/com/haussteuerung/FragmentHeizung.java
+++ b/app/src/main/java/com/haussteuerung/FragmentHeizung.java
@@ -7,6 +7,7 @@ import android.os.Bundle;
import androidx.appcompat.widget.SwitchCompat;
import androidx.fragment.app.Fragment;
+import androidx.lifecycle.ProcessLifecycleOwner;
import android.view.LayoutInflater;
import android.view.View;
@@ -37,131 +38,80 @@ public class FragmentHeizung extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ ProcessLifecycleOwner.get().getLifecycle().addObserver(new AppLifecycleTracker());
+
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_heizung, container, false);
requireActivity().setTitle("Haussteuerung - Heizung");
- // handleSwitch();
- // handleButtons();
- // handleCheckBoxes();
- // sendValues();
return view;
}
public void sendValues() {
Button btn_HzSend = view.findViewById(R.id.btn_HzSend);
- btn_HzSend.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String msgHzZeit1 = "{" +
- "\"DeviceID\":\"" + MainActivity.ID + "\"," +
- "\"CheckHZ1\":" + "\"" + check_hzZeit1.isChecked() + "\"," +
- "\"SilentModeHZ1\":" + "\"" + switch_silentModeHz1.isChecked() + "\"," +
- "\"ZeitHZ1\": " + "\"" + btn_hzZeit1.getText().toString() + "\"," +
- "\"ZeitHZ2\": " + "\"" + btn_hzZeit2.getText().toString() + "\"," +
- "\"TempHZ1\":" + btn_hzVL1.getText().toString() + "," +
- "\"CheckHZ2\":" + "\"" + check_hzZeit2.isChecked() + "\"," +
- "\"SilentModeHZ2\":" + "\"" + switch_silentModeHz2.isChecked() + "\"," +
- "\"ZeitHZ3\": " + "\"" + btn_hzZeit3.getText().toString() + "\"," +
- "\"ZeitHZ4\": " + "\"" + btn_hzZeit4.getText().toString() + "\"," +
- "\"TempHZ2\":" + btn_hzVL2.getText().toString() + "," +
- "\"CheckHZ3\":" + "\"" + check_hzZeit3.isChecked() + "\"," +
- "\"SilentModeHZ3\":" + "\"" + switch_silentModeHz3.isChecked() + "\"," +
- "\"ZeitHZ5\": " + "\"" + btn_hzZeit5.getText().toString() + "\"," +
- "\"ZeitHZ6\": " + "\"" + btn_hzZeit6.getText().toString() + "\"," +
- "\"TempHZ3\": " + btn_hzVL3.getText() +
- "}";
+ btn_HzSend.setOnClickListener(v -> {
+ String msgHzZeit1 = "{" +
+ "\"DeviceID\":\"" + MainActivity.ID + "\"," +
+ "\"CheckHZ1\":" + "\"" + check_hzZeit1.isChecked() + "\"," +
+ "\"SilentModeHZ1\":" + "\"" + switch_silentModeHz1.isChecked() + "\"," +
+ "\"ZeitHZ1\": " + "\"" + btn_hzZeit1.getText().toString() + "\"," +
+ "\"ZeitHZ2\": " + "\"" + btn_hzZeit2.getText().toString() + "\"," +
+ "\"TempHZ1\":" + btn_hzVL1.getText().toString() + "," +
+ "\"CheckHZ2\":" + "\"" + check_hzZeit2.isChecked() + "\"," +
+ "\"SilentModeHZ2\":" + "\"" + switch_silentModeHz2.isChecked() + "\"," +
+ "\"ZeitHZ3\": " + "\"" + btn_hzZeit3.getText().toString() + "\"," +
+ "\"ZeitHZ4\": " + "\"" + btn_hzZeit4.getText().toString() + "\"," +
+ "\"TempHZ2\":" + btn_hzVL2.getText().toString() + "," +
+ "\"CheckHZ3\":" + "\"" + check_hzZeit3.isChecked() + "\"," +
+ "\"SilentModeHZ3\":" + "\"" + switch_silentModeHz3.isChecked() + "\"," +
+ "\"ZeitHZ5\": " + "\"" + btn_hzZeit5.getText().toString() + "\"," +
+ "\"ZeitHZ6\": " + "\"" + btn_hzZeit6.getText().toString() + "\"," +
+ "\"TempHZ3\": " + btn_hzVL3.getText() +
+ "}";
- MqttClient.publish("stat/Haussteuerung/LWP/Heizung", msgHzZeit1, 2, true);
- MqttClient.publish("cmnd/Haussteuerung/LWP/Heizung", "{\"DeviceID\":\"" + MainActivity.ID + "\"}", 2, false);
- requireActivity().onBackPressed();
- }
+ MqttClient.publish("stat/Haussteuerung/LWP/Heizung", msgHzZeit1, 2, true);
+ MqttClient.publish("cmnd/Haussteuerung/LWP/Heizung", "{\"DeviceID\":\"" + MainActivity.ID + "\"}", 2, false);
+ requireActivity().onBackPressed();
});
}
public void handleButtons() {
btn_hzZeit1 = view.findViewById(R.id.btn_hzZeit1);
- btn_hzZeit1.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timePickerDialog(btn_hzZeit1);
- }
- });
+ btn_hzZeit1.setOnClickListener(v -> timePickerDialog(btn_hzZeit1));
btn_hzZeit1.setText(hzZeit1Mqtt.substring(0,5));
btn_hzZeit2 = view.findViewById(R.id.btn_hzZeit2);
- btn_hzZeit2.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timePickerDialog(btn_hzZeit2);
- }
- });
+ btn_hzZeit2.setOnClickListener(v -> timePickerDialog(btn_hzZeit2));
btn_hzZeit2.setText(hzZeit2Mqtt.substring(0,5));
btn_hzZeit3 = view.findViewById(R.id.btn_hzZeit3);
- btn_hzZeit3.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timePickerDialog(btn_hzZeit3);
- }
- });
+ btn_hzZeit3.setOnClickListener(v -> timePickerDialog(btn_hzZeit3));
btn_hzZeit3.setText(hzZeit3Mqtt.substring(0,5));
btn_hzZeit4 = view.findViewById(R.id.btn_hzZeit4);
- btn_hzZeit4.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timePickerDialog(btn_hzZeit4);
- }
- });
+ btn_hzZeit4.setOnClickListener(v -> timePickerDialog(btn_hzZeit4));
btn_hzZeit4.setText(hzZeit4Mqtt.substring(0,5));
btn_hzZeit5 = view.findViewById(R.id.btn_hzZeit5);
- btn_hzZeit5.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timePickerDialog(btn_hzZeit5);
- }
- });
+ btn_hzZeit5.setOnClickListener(v -> timePickerDialog(btn_hzZeit5));
btn_hzZeit5.setText(hzZeit5Mqtt.substring(0,5));
btn_hzZeit6 = view.findViewById(R.id.btn_hzZeit6);
- btn_hzZeit6.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timePickerDialog(btn_hzZeit6);
- }
- });
+ btn_hzZeit6.setOnClickListener(v -> timePickerDialog(btn_hzZeit6));
btn_hzZeit6.setText(hzZeit6Mqtt.substring(0,5));
btn_hzVL1 = view.findViewById(R.id.btn_hzVL1);
- btn_hzVL2 = view.findViewById(R.id.btn_hzVL2);
- btn_hzVL3 = view.findViewById(R.id.btn_hzVL3);
btn_hzVL1.setText(String.valueOf(tempHz1));
+ btn_hzVL1.setOnClickListener(v -> showNumberPickerDialog(btn_hzVL1));
+
+ btn_hzVL2 = view.findViewById(R.id.btn_hzVL2);
btn_hzVL2.setText(String.valueOf(tempHz2));
+ btn_hzVL2.setOnClickListener(v -> showNumberPickerDialog(btn_hzVL2));
+
+ btn_hzVL3 = view.findViewById(R.id.btn_hzVL3);
btn_hzVL3.setText(String.valueOf(tempHz3));
-
- btn_hzVL1.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showNumberPickerDialog(btn_hzVL1);
- }
- });
-
- btn_hzVL2.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showNumberPickerDialog(btn_hzVL2);
- }
- });
-
- btn_hzVL3.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- showNumberPickerDialog(btn_hzVL3);
- }
- });
+ btn_hzVL3.setOnClickListener(v -> showNumberPickerDialog(btn_hzVL3));
}
public void handleCheckBoxes() {
@@ -184,20 +134,17 @@ public class FragmentHeizung extends Fragment {
btn_hzZeit2.setEnabled(false);
btn_hzVL1.setEnabled(false);
}
- check_hzZeit1.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (check_hzZeit1.isChecked()) {
- switch_silentModeHz1.setEnabled(true);
- btn_hzZeit1.setEnabled(true);
- btn_hzZeit2.setEnabled(true);
- btn_hzVL1.setEnabled(true);
- } else {
- switch_silentModeHz1.setEnabled(false);
- btn_hzZeit1.setEnabled(false);
- btn_hzZeit2.setEnabled(false);
- btn_hzVL1.setEnabled(false);
- }
+ check_hzZeit1.setOnClickListener(v -> {
+ if (check_hzZeit1.isChecked()) {
+ switch_silentModeHz1.setEnabled(true);
+ btn_hzZeit1.setEnabled(true);
+ btn_hzZeit2.setEnabled(true);
+ btn_hzVL1.setEnabled(true);
+ } else {
+ switch_silentModeHz1.setEnabled(false);
+ btn_hzZeit1.setEnabled(false);
+ btn_hzZeit2.setEnabled(false);
+ btn_hzVL1.setEnabled(false);
}
});
@@ -212,20 +159,17 @@ public class FragmentHeizung extends Fragment {
btn_hzZeit4.setEnabled(false);
btn_hzVL2.setEnabled(false);
}
- check_hzZeit2.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (check_hzZeit2.isChecked()) {
- switch_silentModeHz2.setEnabled(true);
- btn_hzZeit3.setEnabled(true);
- btn_hzZeit4.setEnabled(true);
- btn_hzVL2.setEnabled(true);
- } else {
- switch_silentModeHz2.setEnabled(false);
- btn_hzZeit3.setEnabled(false);
- btn_hzZeit4.setEnabled(false);
- btn_hzVL2.setEnabled(false);
- }
+ check_hzZeit2.setOnClickListener(v -> {
+ if (check_hzZeit2.isChecked()) {
+ switch_silentModeHz2.setEnabled(true);
+ btn_hzZeit3.setEnabled(true);
+ btn_hzZeit4.setEnabled(true);
+ btn_hzVL2.setEnabled(true);
+ } else {
+ switch_silentModeHz2.setEnabled(false);
+ btn_hzZeit3.setEnabled(false);
+ btn_hzZeit4.setEnabled(false);
+ btn_hzVL2.setEnabled(false);
}
});
@@ -240,20 +184,17 @@ public class FragmentHeizung extends Fragment {
btn_hzZeit6.setEnabled(false);
btn_hzVL3.setEnabled(false);
}
- check_hzZeit3.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (check_hzZeit3.isChecked()) {
- switch_silentModeHz3.setEnabled(true);
- btn_hzZeit5.setEnabled(true);
- btn_hzZeit6.setEnabled(true);
- btn_hzVL3.setEnabled(true);
- } else {
- switch_silentModeHz3.setEnabled(false);
- btn_hzZeit5.setEnabled(false);
- btn_hzZeit6.setEnabled(false);
- btn_hzVL3.setEnabled(false);
- }
+ check_hzZeit3.setOnClickListener(v -> {
+ if (check_hzZeit3.isChecked()) {
+ switch_silentModeHz3.setEnabled(true);
+ btn_hzZeit5.setEnabled(true);
+ btn_hzZeit6.setEnabled(true);
+ btn_hzVL3.setEnabled(true);
+ } else {
+ switch_silentModeHz3.setEnabled(false);
+ btn_hzZeit5.setEnabled(false);
+ btn_hzZeit6.setEnabled(false);
+ btn_hzVL3.setEnabled(false);
}
});
}
@@ -281,26 +222,15 @@ public class FragmentHeizung extends Fragment {
picker.setMinValue(0);
picker.setMaxValue(ml - 1);
for(int y=0; y {
+ button.setText(values[picker.getValue()]);
+ })
+ .setNegativeButton(android.R.string.cancel, (dialog, id) -> builder.create().cancel());
builder.create().show();
}
@@ -308,12 +238,7 @@ public class FragmentHeizung extends Fragment {
LocalTime localTime = LocalTime.parse(button.getText());
int hour = localTime.getHour();
int minute = localTime.getMinute();
- TimePickerDialog.OnTimeSetListener onTimeSetListener = new TimePickerDialog.OnTimeSetListener() {
- @Override
- public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
- button.setText(String.format(Locale.getDefault(), "%02d:%02d", selectedHour, selectedMinute));
- }
- };
+ TimePickerDialog.OnTimeSetListener onTimeSetListener = (timePicker, selectedHour, selectedMinute) -> button.setText(String.format(Locale.getDefault(), "%02d:%02d", selectedHour, selectedMinute));
TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), onTimeSetListener, hour, minute, true);
timePickerDialog.show();
}
diff --git a/app/src/main/java/com/haussteuerung/FragmentWW.java b/app/src/main/java/com/haussteuerung/FragmentWW.java
index 932b509..e4b1c8e 100644
--- a/app/src/main/java/com/haussteuerung/FragmentWW.java
+++ b/app/src/main/java/com/haussteuerung/FragmentWW.java
@@ -5,6 +5,7 @@ import android.os.Bundle;
import androidx.appcompat.widget.SwitchCompat;
import androidx.fragment.app.Fragment;
+import androidx.lifecycle.ProcessLifecycleOwner;
import android.os.Handler;
import android.util.Log;
@@ -45,6 +46,8 @@ public class FragmentWW extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ ProcessLifecycleOwner.get().getLifecycle().addObserver(new AppLifecycleTracker());
+
// Inflate the layout for this fragment
view = inflater.inflate(R.layout.fragment_ww, container, false);
requireActivity().setTitle("Haussteuerung - Warmwasser");
@@ -52,13 +55,6 @@ public class FragmentWW extends Fragment {
tv_boilerObenVal = view.findViewById(R.id.tv_boilerObenVal);
tv_boilerUntenVal = view.findViewById(R.id.tv_boilerUntenVal);
- // handleSwitch();
- // handleTextViews();
- // handleButtons();
- // handleCheckBoxes();
- // handleSeekBars();
- // sendValues();
-
return view;
}
@@ -75,31 +71,28 @@ public class FragmentWW extends Fragment {
public void sendValues() {
Button btn_WwSend = view.findViewById(R.id.btn_HzSend);
- btn_WwSend.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String msgWwZeit1 = "{" +
- "\"DeviceID\":\"" + MainActivity.ID + "\"," +
- "\"CheckWW1\":" + "\"" + check_wwZeit1.isChecked() + "\"," +
- "\"SilentModeWW1\": " + "\"" + switch_silentModeWw1.isChecked() + "\"," +
- "\"ZeitWW1\": " + "\"" + btn_wwZeit1.getText().toString() + "\"," +
- "\"ZeitWW2\": " + "\"" + btn_wwZeit2.getText().toString() + "\"," +
- "\"CheckWW2\":" + "\"" + check_wwZeit2.isChecked() + "\"," +
- "\"SilentModeWW2\": " + "\"" + switch_silentModeWw2.isChecked() + "\"," +
- "\"ZeitWW3\": " + "\"" + btn_wwZeit3.getText().toString() + "\"," +
- "\"ZeitWW4\": " + "\"" + btn_wwZeit4.getText().toString() + "\"," +
- "\"CheckWW3\":" + "\"" + check_wwZeit3.isChecked() + "\"," +
- "\"SilentModeWW3\": " + "\"" + switch_silentModeWw3.isChecked() + "\"," +
- "\"ZeitWW5\": " + "\"" + btn_wwZeit5.getText().toString() + "\"," +
- "\"ZeitWW6\": " + "\"" + btn_wwZeit6.getText().toString() + "\"," +
- "\"TempWW1\": " + tv_WwMinVal.getText() + "," +
- "\"TempWW2\": " + tv_WwMaxVal.getText() +
- "}";
+ btn_WwSend.setOnClickListener(v -> {
+ String msgWwZeit1 = "{" +
+ "\"DeviceID\":\"" + MainActivity.ID + "\"," +
+ "\"CheckWW1\":" + "\"" + check_wwZeit1.isChecked() + "\"," +
+ "\"SilentModeWW1\": " + "\"" + switch_silentModeWw1.isChecked() + "\"," +
+ "\"ZeitWW1\": " + "\"" + btn_wwZeit1.getText().toString() + "\"," +
+ "\"ZeitWW2\": " + "\"" + btn_wwZeit2.getText().toString() + "\"," +
+ "\"CheckWW2\":" + "\"" + check_wwZeit2.isChecked() + "\"," +
+ "\"SilentModeWW2\": " + "\"" + switch_silentModeWw2.isChecked() + "\"," +
+ "\"ZeitWW3\": " + "\"" + btn_wwZeit3.getText().toString() + "\"," +
+ "\"ZeitWW4\": " + "\"" + btn_wwZeit4.getText().toString() + "\"," +
+ "\"CheckWW3\":" + "\"" + check_wwZeit3.isChecked() + "\"," +
+ "\"SilentModeWW3\": " + "\"" + switch_silentModeWw3.isChecked() + "\"," +
+ "\"ZeitWW5\": " + "\"" + btn_wwZeit5.getText().toString() + "\"," +
+ "\"ZeitWW6\": " + "\"" + btn_wwZeit6.getText().toString() + "\"," +
+ "\"TempWW1\": " + tv_WwMinVal.getText() + "," +
+ "\"TempWW2\": " + tv_WwMaxVal.getText() +
+ "}";
- MqttClient.publish("stat/Haussteuerung/LWP/Warmwasser", msgWwZeit1, 2, true);
- MqttClient.publish("cmnd/Haussteuerung/LWP/Warmwasser", "{\"DeviceID\":\"" + MainActivity.ID + "\"}", 2, false);
- requireActivity().onBackPressed();
- }
+ MqttClient.publish("stat/Haussteuerung/LWP/Warmwasser", msgWwZeit1, 2, true);
+ MqttClient.publish("cmnd/Haussteuerung/LWP/Warmwasser", "{\"DeviceID\":\"" + MainActivity.ID + "\"}", 2, false);
+ requireActivity().onBackPressed();
});
}
@@ -115,57 +108,27 @@ public class FragmentWW extends Fragment {
public void handleButtons() {
btn_wwZeit1 = view.findViewById(R.id.btn_wwZeit1);
- btn_wwZeit1.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timePickerDialog(btn_wwZeit1);
- }
- });
+ btn_wwZeit1.setOnClickListener(v -> timePickerDialog(btn_wwZeit1));
btn_wwZeit1.setText(wwZeit1Mqtt.substring(0, 5));
btn_wwZeit2 = view.findViewById(R.id.btn_wwZeit2);
- btn_wwZeit2.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timePickerDialog(btn_wwZeit2);
- }
- });
+ btn_wwZeit2.setOnClickListener(v -> timePickerDialog(btn_wwZeit2));
btn_wwZeit2.setText(wwZeit2Mqtt.substring(0, 5));
btn_wwZeit3 = view.findViewById(R.id.btn_wwZeit3);
- btn_wwZeit3.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timePickerDialog(btn_wwZeit3);
- }
- });
+ btn_wwZeit3.setOnClickListener(v -> timePickerDialog(btn_wwZeit3));
btn_wwZeit3.setText(wwZeit3Mqtt.substring(0, 5));
btn_wwZeit4 = view.findViewById(R.id.btn_wwZeit4);
- btn_wwZeit4.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timePickerDialog(btn_wwZeit4);
- }
- });
+ btn_wwZeit4.setOnClickListener(v -> timePickerDialog(btn_wwZeit4));
btn_wwZeit4.setText(wwZeit4Mqtt.substring(0, 5));
btn_wwZeit5 = view.findViewById(R.id.btn_wwZeit5);
- btn_wwZeit5.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timePickerDialog(btn_wwZeit5);
- }
- });
+ btn_wwZeit5.setOnClickListener(v -> timePickerDialog(btn_wwZeit5));
btn_wwZeit5.setText(wwZeit5Mqtt.substring(0, 5));
btn_wwZeit6 = view.findViewById(R.id.btn_wwZeit6);
- btn_wwZeit6.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timePickerDialog(btn_wwZeit6);
- }
- });
+ btn_wwZeit6.setOnClickListener(v -> timePickerDialog(btn_wwZeit6));
btn_wwZeit6.setText(wwZeit6Mqtt.substring(0, 5));
}
@@ -187,18 +150,15 @@ public class FragmentWW extends Fragment {
btn_wwZeit1.setEnabled(false);
btn_wwZeit2.setEnabled(false);
}
- check_wwZeit1.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (check_wwZeit1.isChecked()) {
- switch_silentModeWw1.setEnabled(true);
- btn_wwZeit1.setEnabled(true);
- btn_wwZeit2.setEnabled(true);
- } else {
- switch_silentModeWw1.setEnabled(false);
- btn_wwZeit1.setEnabled(false);
- btn_wwZeit2.setEnabled(false);
- }
+ check_wwZeit1.setOnClickListener(v -> {
+ if (check_wwZeit1.isChecked()) {
+ switch_silentModeWw1.setEnabled(true);
+ btn_wwZeit1.setEnabled(true);
+ btn_wwZeit2.setEnabled(true);
+ } else {
+ switch_silentModeWw1.setEnabled(false);
+ btn_wwZeit1.setEnabled(false);
+ btn_wwZeit2.setEnabled(false);
}
});
@@ -211,18 +171,15 @@ public class FragmentWW extends Fragment {
btn_wwZeit3.setEnabled(false);
btn_wwZeit4.setEnabled(false);
}
- check_wwZeit2.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (check_wwZeit2.isChecked()) {
- switch_silentModeWw2.setEnabled(true);
- btn_wwZeit3.setEnabled(true);
- btn_wwZeit4.setEnabled(true);
- } else {
- switch_silentModeWw2.setEnabled(false);
- btn_wwZeit3.setEnabled(false);
- btn_wwZeit4.setEnabled(false);
- }
+ check_wwZeit2.setOnClickListener(v -> {
+ if (check_wwZeit2.isChecked()) {
+ switch_silentModeWw2.setEnabled(true);
+ btn_wwZeit3.setEnabled(true);
+ btn_wwZeit4.setEnabled(true);
+ } else {
+ switch_silentModeWw2.setEnabled(false);
+ btn_wwZeit3.setEnabled(false);
+ btn_wwZeit4.setEnabled(false);
}
});
@@ -235,18 +192,15 @@ public class FragmentWW extends Fragment {
btn_wwZeit5.setEnabled(false);
btn_wwZeit6.setEnabled(false);
}
- check_wwZeit3.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (check_wwZeit3.isChecked()) {
- switch_silentModeWw3.setEnabled(true);
- btn_wwZeit5.setEnabled(true);
- btn_wwZeit6.setEnabled(true);
- } else {
- switch_silentModeWw3.setEnabled(false);
- btn_wwZeit5.setEnabled(false);
- btn_wwZeit6.setEnabled(false);
- }
+ check_wwZeit3.setOnClickListener(v -> {
+ if (check_wwZeit3.isChecked()) {
+ switch_silentModeWw3.setEnabled(true);
+ btn_wwZeit5.setEnabled(true);
+ btn_wwZeit6.setEnabled(true);
+ } else {
+ switch_silentModeWw3.setEnabled(false);
+ btn_wwZeit5.setEnabled(false);
+ btn_wwZeit6.setEnabled(false);
}
});
}
@@ -304,12 +258,7 @@ public class FragmentWW extends Fragment {
int hour = localTime.getHour();
int minute = localTime.getMinute();
int hourWwZeit = 0, minuteWwZeit = 0;
- TimePickerDialog.OnTimeSetListener onTimeSetListener = new TimePickerDialog.OnTimeSetListener() {
- @Override
- public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
- button.setText(String.format(Locale.getDefault(), "%02d:%02d", selectedHour, selectedMinute));
- }
- };
+ TimePickerDialog.OnTimeSetListener onTimeSetListener = (timePicker, selectedHour, selectedMinute) -> button.setText(String.format(Locale.getDefault(), "%02d:%02d", selectedHour, selectedMinute));
TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), onTimeSetListener, hourWwZeit, minuteWwZeit, true);
timePickerDialog.updateTime(hour, minute);
timePickerDialog.show();
@@ -330,13 +279,12 @@ public class FragmentWW extends Fragment {
myHandler.post(myRunnable); // updateUI method
}
};
- myTimer.schedule(myTask, 0, 1000); // TimerTask, delay, period
+ myTimer.schedule(myTask, 0, 1000);
}
@Override
public void onStop() {
super.onStop();
myTask.cancel();
- Log.d("State", "on Stop");
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/haussteuerung/MainActivity.java b/app/src/main/java/com/haussteuerung/MainActivity.java
index a3c4dac..bf96d0a 100644
--- a/app/src/main/java/com/haussteuerung/MainActivity.java
+++ b/app/src/main/java/com/haussteuerung/MainActivity.java
@@ -1,7 +1,5 @@
package com.haussteuerung;
-import static android.os.Build.VERSION.SDK_INT;
-
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Context;
@@ -12,7 +10,6 @@ import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
-import android.os.Environment;
import android.provider.Settings;
import android.util.Log;
import android.view.View;
@@ -22,22 +19,22 @@ import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
-import androidx.activity.EdgeToEdge;
+import androidx.annotation.RequiresApi;
+import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
-import androidx.core.graphics.Insets;
-import androidx.core.view.ViewCompat;
-import androidx.core.view.WindowInsetsCompat;
+import androidx.lifecycle.ProcessLifecycleOwner;
import com.google.firebase.messaging.FirebaseMessaging;
import com.google.gson.Gson;
+import com.haussteuerung.helper.Licht;
import org.eclipse.paho.client.mqttv3.MqttException;
-import java.io.File;
+import java.util.Objects;
import java.util.Timer;
import java.util.TimerTask;
@@ -47,56 +44,39 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private TextView tv_mqtt;
private Button buttonAlarm;
public static String ID = "";
- public static boolean pausedMainActivity = true;
public static boolean alarmStatus = false, wm1Status = false, wm2Status = false;
private Context mContext;
Timer myTimer = new Timer();
Gson gson = new Gson();
String msg;
+ @RequiresApi(api = Build.VERSION_CODES.TIRAMISU)
@SuppressLint("HardwareIds")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ ProcessLifecycleOwner.get().getLifecycle().addObserver(new AppLifecycleTracker());
mContext = this;
- pausedMainActivity = false;
-
- Log.d("MainActivityPause", "onCreate true");
-
// Ändern der Statusbar-Farbe
- androidx.appcompat.app.ActionBar actionBar = getSupportActionBar();
+ ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setBackgroundDrawable(AppCompatResources.getDrawable(getApplicationContext(), R.drawable.gradient_titlebar));
setContentView(R.layout.activity_main);
- ID = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
+ String androidId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);
+ ID = "haussteuerung-android-" + Build.MODEL + "-" + androidId;
Log.d("ID", ID);
- int permissionState = ContextCompat.checkSelfPermission(this, android.Manifest.permission.POST_NOTIFICATIONS);
+ int permissionState = 0;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+ permissionState = ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS);
+ }
// If the permission is not granted, request it.
if (permissionState == PackageManager.PERMISSION_DENIED) {
- ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.POST_NOTIFICATIONS}, 1);
- }
-
- // Abfrage am Gerät, ob Speicher verwendet werden darf
- if (SDK_INT >= Build.VERSION_CODES.R) {
- Log.d("Permission", "" + SDK_INT);
- if (!Environment.isExternalStorageManager()) {
- ActivityCompat.requestPermissions(this,
- new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE,
- android.Manifest.permission.MANAGE_EXTERNAL_STORAGE}, 1);//permission request code is just an int
- File file = new File(Environment.getExternalStorageDirectory().getPath() + "/Pictures/Haussteuerung/");
- if (!file.exists()) {
- file.mkdir();
- }
- }
- } else {
- if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this, android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
- ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
- }
+ ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.POST_NOTIFICATIONS}, 1);
}
FirebaseMessaging.getInstance().subscribeToTopic("general");
@@ -108,10 +88,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
} catch (Exception e) {
Log.d("MQTT", "Verbindung fehlgeschlagen");
}
- // Log.d("MQTT", String.valueOf(MqttClient.connSuccess));
- // if (!MqttClient.connSuccess) {
- // MqttClient.connect();
- // }
// Instanzieren der Buttons und TextViews
ImageView imageViewHaus = findViewById(R.id.imageViewHaus);
@@ -135,53 +111,34 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
buttonDorisLicht.setOnClickListener(this);
imageViewHaus.setOnClickListener(this);
- imageViewHaus.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- alertDialogHaus();
- }
+ imageViewHaus.setOnClickListener(view -> alertDialogHaus());
+
+ imageViewHaus.setOnLongClickListener(view -> {
+ alertDialogVersion();
+ return true;
});
- imageViewHaus.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View view) {
- alertDialogVersion();
- return true;
- }
- });
-
- buttonAlarm.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Log.d("Alarm", String.valueOf(alarmStatus));
- if (alarmStatus) {
- // Alarm ein, also ausschalten
- MqttClient.publish("cmnd/Haussteuerung/Alarm", "{\"DeviceID\":\"" + ID + "\",\"Name\":\"Alarm\",\"Zustand\":\"true\"}");
- } else {
- // Alarm aus, also einschalten
- alertDialogAlarm();
- }
+ buttonAlarm.setOnClickListener(view -> {
+ Log.d("Alarm", String.valueOf(alarmStatus));
+ if (alarmStatus) {
+ // Alarm ein, also ausschalten
+ MqttClient.publish("cmnd/Haussteuerung/Alarm", "{\"DeviceID\":\"" + ID + "\",\"Name\":\"Alarm\",\"Zustand\":\"true\"}");
+ } else {
+ // Alarm aus, also einschalten
+ alertDialogAlarm();
}
});
Intent i = getIntent();
if (i.getExtras() != null) {
- if (i.getExtras() != null && i.hasExtra("Time")) {
- Log.d("GlockeZeit", i.getStringExtra("Time"));
- }
if ((i.getExtras() != null) && (i.hasExtra("Time"))) {
Intent iGlocke = new Intent(MainActivity.this, activityGlocke.class);
iGlocke.putExtra("TimeFB", i.getStringExtra("Time"));
- Log.d("GlockeZeit", i.getStringExtra("Time"));
+ Log.d("GlockeZeit", Objects.requireNonNull(i.getStringExtra("Time")));
startActivity(iGlocke);
}
- if ((i.getExtras() != null) && (i.hasExtra("Sky"))) {
- Intent iSky = new Intent(MainActivity.this, activitySky.class);
- Log.d("Sky", i.getStringExtra("Sky"));
- startActivity(iSky);
- }
if ((i.getExtras() != null) && (i.hasExtra("Other"))) {
- Log.d("Other", i.getStringExtra("Other"));
+ Log.d("Other", Objects.requireNonNull(i.getStringExtra("Other")));
alertDialogNotification(i.getStringExtra("Other"));
}
}
@@ -277,27 +234,21 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
alertDialog.setCustomTitle(textView);
AlertDialog alert = alertDialog.create();
- alert.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+ Objects.requireNonNull(alert.getWindow()).setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
Button buttonGarage, buttonSchiebetor;
buttonGarage = customLayout.findViewById(R.id.buttonAlarmJa);
buttonSchiebetor = customLayout.findViewById(R.id.buttonAlarmNein);
- buttonGarage.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- msg = gson.toJson(new Licht(MainActivity.ID, "Garagentor", "Lamp12"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- alert.cancel();
- }
+ buttonGarage.setOnClickListener(view -> {
+ msg = gson.toJson(new Licht(MainActivity.ID, "Garagentor", "Lamp12"));
+ MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
+ alert.cancel();
});
- buttonSchiebetor.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- msg = gson.toJson(new Licht(MainActivity.ID, "Schiebetor", "Lamp31"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);Toast.makeText(mContext, "Schiebetor außer Betrieb", Toast.LENGTH_LONG).show();
- alert.cancel();
- }
+ buttonSchiebetor.setOnClickListener(view -> {
+ msg = gson.toJson(new Licht(MainActivity.ID, "Schiebetor", "Lamp31"));
+ MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
+ alert.cancel();
});
alert.show();
}
@@ -318,48 +269,36 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
alertDialog.setCustomTitle(textView);
AlertDialog alert = alertDialog.create();
- alert.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+ Objects.requireNonNull(alert.getWindow()).setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
Button buttonAlarmJa, buttonAlarmNein;
buttonAlarmJa = customLayout.findViewById(R.id.buttonAlarmJa);
buttonAlarmNein = customLayout.findViewById(R.id.buttonAlarmNein);
- buttonAlarmJa.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (MqttClient.tv_Zustand1.equals("zu") &&
- MqttClient.tv_Zustand2.equals("zu") &&
- MqttClient.tv_Zustand3.equals("zu") &&
- MqttClient.tv_Zustand4.equals("zu") &&
- MqttClient.tv_Zustand5.equals("zu") &&
- MqttClient.tv_Zustand6.equals("zu") &&
- MqttClient.tv_Zustand7.equals("zu") &&
- MqttClient.tv_Zustand9.equals("zu") &&
- MqttClient.tv_Zustand10.equals("zu") &&
- MqttClient.tv_Zustand11.equals("zu") &&
- MqttClient.tv_Zustand12.equals("zu") &&
- MqttClient.tv_Zustand13.equals("zu") &&
- MqttClient.tv_Zustand14.equals("zu") //&&
- //MqttClient.tv_Zustand15.equals("zu") &&
- //MqttClient.tv_Zustand16.equals("zu") &&
- //MqttClient.tv_Zustand17.equals("zu") &&
- //MqttClient.tv_Zustand18.equals("zu")
- ) {
- MqttClient.publish("cmnd/Haussteuerung/Alarm", "{\"DeviceID\":\"" + ID + "\",\"Name\":\"Alarm\",\"Zustand\":\"false\"}");
- alert.cancel();
- } else {
- Toast.makeText(mContext, "Bitte offene Fenster/Türen schließen!", Toast.LENGTH_SHORT).show();
- Intent intent = new Intent(MainActivity.this, activityHaus.class);
- startActivity(intent);
- }
+ buttonAlarmJa.setOnClickListener(view -> {
+ if (MqttClient.tv_Zustand1.equals("zu") &&
+ MqttClient.tv_Zustand2.equals("zu") &&
+ MqttClient.tv_Zustand3.equals("zu") &&
+ MqttClient.tv_Zustand4.equals("zu") &&
+ MqttClient.tv_Zustand5.equals("zu") &&
+ MqttClient.tv_Zustand6.equals("zu") &&
+ MqttClient.tv_Zustand7.equals("zu") &&
+ MqttClient.tv_Zustand9.equals("zu") &&
+ MqttClient.tv_Zustand10.equals("zu") &&
+ MqttClient.tv_Zustand11.equals("zu") &&
+ MqttClient.tv_Zustand12.equals("zu") &&
+ MqttClient.tv_Zustand13.equals("zu") &&
+ MqttClient.tv_Zustand14.equals("zu")
+ ) {
+ MqttClient.publish("cmnd/Haussteuerung/Alarm", "{\"DeviceID\":\"" + ID + "\",\"Name\":\"Alarm\",\"Zustand\":\"false\"}");
+ alert.cancel();
+ } else {
+ Toast.makeText(mContext, "Bitte offene Fenster/Türen schließen!", Toast.LENGTH_SHORT).show();
+ Intent intent = new Intent(MainActivity.this, activityHaus.class);
+ startActivity(intent);
}
});
- buttonAlarmNein.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- alert.cancel();
- }
- });
+ buttonAlarmNein.setOnClickListener(view -> alert.cancel());
alert.show();
}
@@ -379,7 +318,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
alertDialog.setCustomTitle(textView);
AlertDialog alert = alertDialog.create();
- alert.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+ Objects.requireNonNull(alert.getWindow()).setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
alert.show();
}
@@ -401,7 +340,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
alertDialog.setCustomTitle(textView);
AlertDialog alert = alertDialog.create();
- alert.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+ Objects.requireNonNull(alert.getWindow()).setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
TextView textView_adConent, textView_adTimer;
textView_adConent = customLayout.findViewById(R.id.tv_adcontent);
@@ -430,9 +369,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
@Override
protected void onPause() {
super.onPause();
- pausedMainActivity = true;
- Log.d("MainActivityPause", "onPause true");
- // Log.d("1MQTT onPause", String.valueOf(MqttClient.connSuccess));
myTimer.cancel();
Log.d("TimerMainActivity", "Canceled");
}
@@ -440,33 +376,22 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
@Override
protected void onStop() {
super.onStop();
- pausedMainActivity = true;
- Log.d("MainActivityPause", "onStop true");
- // Log.d("1MQTT onStop", String.valueOf(MqttClient.connSuccess));
- // myTimer.cancel();
- // Log.d("TimerMainActivity", "Canceled");
}
@Override
protected void onStart() {
super.onStart();
- Log.d("MainActivityPause", "onStart true");
}
@Override
protected void onRestart() {
super.onRestart();
- Log.d("MainActivityPause", "onRestart true");
}
@Override
protected void onResume() {
super.onResume();
- Log.d("MainActivityPause", "onResume true");
- Log.d("1MQTT onResume", String.valueOf(MqttClient.client.isConnected()));
-
- pausedMainActivity = false;
buttonAlarm.setBackgroundResource(R.drawable.gradient_pressed);
@@ -486,7 +411,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
MqttClient.client.reconnect();
Log.d("1MQTT onResume", "Try to reconnect client");
} catch (MqttException e) {
- e.printStackTrace();
+ Log.d("1MQTT onResume", "Try to reconnect client failed: " + e);
}
}
}
@@ -494,11 +419,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
@Override
protected void onDestroy() {
super.onDestroy();
- pausedMainActivity = true;
- // myTimer.cancel();
- Log.d("MainActivityPause", "onDestroy true");
MqttClient.disconnect();
- // Log.d("1MQTT onDestroy", String.valueOf(MqttClient.connSuccess));
finishAffinity();
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/haussteuerung/MqttClient.java b/app/src/main/java/com/haussteuerung/MqttClient.java
index 22e03a8..bec3ed4 100644
--- a/app/src/main/java/com/haussteuerung/MqttClient.java
+++ b/app/src/main/java/com/haussteuerung/MqttClient.java
@@ -4,10 +4,11 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import android.util.Log;
+import androidx.annotation.NonNull;
+
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import org.eclipse.paho.android.service.MqttAndroidClient;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
@@ -15,15 +16,12 @@ import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
-import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Objects;
import javax.net.ssl.SSLSocketFactory;
public class MqttClient {
-
static org.eclipse.paho.client.mqttv3.MqttClient client = null;
- static boolean connSuccess = false;
static String logContent = "";
static String tv_Zustand1 = "", tv_Zustand2 = "", tv_Zustand3 = "", tv_Zustand4 = "", tv_Zustand5 = "", tv_Zustand6 = "";
static String tv_Zustand7 = "", tv_Zustand8 = "", tv_Zustand9 = "", tv_Zustand10 = "", tv_Zustand11 = "", tv_Zustand12 = "";
@@ -39,25 +37,9 @@ public class MqttClient {
@Override
public void connectionLost(Throwable cause) {
Log.d("MQTT connloss", "client lost connection " + cause);
- Log.d("MQTT connloss", cause.getMessage());
+ Log.d("MQTT connloss", Objects.requireNonNull(cause.getMessage()));
Log.d("MQTT connless", String.valueOf(client.getDebug()));
Log.d("MQTT connloss", String.valueOf(MqttClient.client.isConnected()));
- // MainActivity.tv_mqtt.setTextColor(Color.RED);
- // if (!MqttClient.client.isConnected()) {
- // try {
- // client.reconnect();
- // client.subscribe("stat/Haussteuerung/#");
- // client.subscribe("fhem/temp/#");
- // client.subscribe("fhem/Heizung/#");
- // } catch (MqttException e) {
- // e.printStackTrace();
- // }
- // }
- // Log.d("MQTT connloss2", String.valueOf(MqttClient.client.isConnected()));
- // disconnect();
- // Log.d("MQTT connloss", "client disconnected after connection lost");
-
- // connect();
}
@Override
@@ -66,12 +48,8 @@ public class MqttClient {
if (topic.equals("stat/Haussteuerung/Alarm")) {
JsonObject jsonObject = JsonParser.parseString(message.toString()).getAsJsonObject();
if (jsonObject.get("Zustand").getAsString().equals("true")) {
- // MainActivity.buttonAlarm.setText(R.string.alarm_ein);
- // MainActivity.buttonAlarm.setBackgroundResource(R.drawable.alarm_true);
MainActivity.alarmStatus = true;
} else if (jsonObject.get("Zustand").getAsString().equals("false")) {
- // MainActivity.buttonAlarm.setText(R.string.alarm_aus);
- // MainActivity.buttonAlarm.setBackgroundResource(R.drawable.alarm_false);
MainActivity.alarmStatus = false;
}
}
@@ -79,10 +57,8 @@ public class MqttClient {
if (topic.equals("stat/Haussteuerung/Waschmaschine/WM1")) {
JsonObject jsonObject = JsonParser.parseString(message.toString()).getAsJsonObject();
if (jsonObject.get("Zustand").getAsString().equals("ein")) {
- // MainActivity.tv_WM1.setText(R.string.wm1_laeuft);
MainActivity.wm1Status = true;
} else if (jsonObject.get("Zustand").getAsString().equals("aus")) {
- // MainActivity.tv_WM1.setText(R.string.wm1_aus);
MainActivity.wm1Status = false;
}
}
@@ -90,10 +66,8 @@ public class MqttClient {
if (topic.equals("stat/Haussteuerung/Waschmaschine/WM2")) {
JsonObject jsonObject = JsonParser.parseString(message.toString()).getAsJsonObject();
if (jsonObject.get("Zustand").getAsString().equals("ein")) {
- // MainActivity.tv_WM2.setText(R.string.wm2_laeuft);
MainActivity.wm2Status = true;
} else if (jsonObject.get("Zustand").getAsString().equals("aus")) {
- // MainActivity.tv_WM2.setText(R.string.wm2_aus);
MainActivity.wm2Status = false;
}
}
@@ -133,14 +107,6 @@ public class MqttClient {
activityLicht.checkedGlocke = jsonObject.get("Checkbox").getAsBoolean();
}
- // WEIHNACHTSBELEUCHTUNG
- if (topic.equals("tele/sonoff153/STATE")) {
- JsonObject jsonObject = JsonParser.parseString(message.toString()).getAsJsonObject();
- activityChristmas.power = jsonObject.get("POWER").getAsString();
- activityChristmas.hsbColorArray = new ArrayList<>(Arrays.asList(jsonObject.get("HSBColor").getAsString().split(",")));
- }
- // WEIHNACHTSBELEUCHTUNG
-
handleLWP(topic, message);
fensterZustaende(topic, message);
@@ -152,8 +118,24 @@ public class MqttClient {
}
});
} catch (MqttException e) {
- e.printStackTrace();
+ Log.d("MQTTLOG", "Connect failed: " + e);
}
+ MqttConnectOptions mqttConnectOptions = getMqttConnectOptions();
+ try {
+ client.connect(mqttConnectOptions);
+ subscribe("stat/Haussteuerung/#");
+ subscribe("fhem/temp/#");
+ subscribe("fhem/Heizung/#");
+ subscribe("tele/sonoff153/#");
+ subscribe("growatt/#");
+ Log.d("MQTTLOG", "client connected");
+ } catch (MqttException e) {
+ Log.d("MQTTLOG", "connection failed " + e.getMessage());
+ }
+ }
+
+ @NonNull
+ private static MqttConnectOptions getMqttConnectOptions() {
MqttConnectOptions mqttConnectOptions = new MqttConnectOptions();
mqttConnectOptions.setUserName("steve");
mqttConnectOptions.setPassword("Florian1".toCharArray());
@@ -161,58 +143,33 @@ public class MqttClient {
mqttConnectOptions.setCleanSession(false);
mqttConnectOptions.setKeepAliveInterval(15);
mqttConnectOptions.setConnectionTimeout(30);
- mqttConnectOptions.setSocketFactory(SSLSocketFactory.getDefault()); // using the default socket factory
- try {
- client.connect(mqttConnectOptions);
- // connSuccess = true;
- subscribe("stat/Haussteuerung/#");
- subscribe("fhem/temp/#");
- subscribe("fhem/Heizung/#");
- subscribe("tele/sonoff153/#");
- subscribe("growatt/#");
- Log.d("MQTTLOG", "client connected");
- // MainActivity.tv_mqtt.setTextColor(Color.parseColor("#64DD17"));
- } catch (MqttException e) {
- e.printStackTrace();
- // connSuccess = false;
-
- Log.d("MQTTLOG", "connection failed " + e.getMessage());
- // MainActivity.tv_mqtt.setTextColor(Color.RED);
- }
+ mqttConnectOptions.setSocketFactory(SSLSocketFactory.getDefault());
+ return mqttConnectOptions;
}
public static void subscribe(String topic) {
try {
- // if (!client.isConnected()) {
- // client.reconnect();
- // }
client.subscribe(topic);
} catch (MqttException e) {
- e.printStackTrace();
+ Log.d("MQTTLOG", "Subscribing failed: " + e);
}
}
public static void publish(String topic, String message) {
try {
- // if (!client.isConnected()) {
- // client.reconnect();
- // }
- client.publish(topic, message.getBytes(UTF_8),2, false);
+ client.publish(topic, message.getBytes(UTF_8), 2, false);
Log.d("MQTTLOG", "Message" + message + "published.");
} catch (MqttException e) {
- e.printStackTrace();
+ Log.d("MQTTLOG", "Publish failed: " + e);
}
}
public static void publish(String topic, String message, int qos, boolean retained) {
try {
- // if (!client.isConnected()) {
- // client.reconnect();
- // }
client.publish(topic, message.getBytes(UTF_8), qos, retained);
Log.d("MQTTLOG", "Message" + message + "published.");
} catch (MqttException e) {
- e.printStackTrace();
+ Log.d("MQTTLOG", "Publish failed: " + e);
}
}
@@ -220,9 +177,8 @@ public class MqttClient {
try {
client.disconnect();
} catch (MqttException e) {
- e.printStackTrace();
+ Log.d("MQTTLOG", "Disconnect failed: " + e);
}
- // MainActivity.tv_mqtt.setTextColor(Color.RED);
}
private static void handleLWP(String topic, MqttMessage message) {
diff --git a/app/src/main/java/com/haussteuerung/MyFirebaseMessagingService.java b/app/src/main/java/com/haussteuerung/MyFirebaseMessagingService.java
index fdefea2..419446f 100644
--- a/app/src/main/java/com/haussteuerung/MyFirebaseMessagingService.java
+++ b/app/src/main/java/com/haussteuerung/MyFirebaseMessagingService.java
@@ -5,61 +5,57 @@ import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
+import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
+import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
-import android.media.MediaScannerConnection;
+import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
+import android.provider.MediaStore;
import android.util.Log;
import android.widget.Toast;
+import androidx.annotation.NonNull;
import androidx.core.app.NotificationCompat;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
-import java.io.File;
-import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
import java.util.Map;
import java.util.Objects;
import java.util.Random;
@SuppressLint("MissingFirebaseInstanceTokenRefresh")
public class MyFirebaseMessagingService extends FirebaseMessagingService {
+ String url = "";
+
@Override
- public void onMessageReceived(RemoteMessage remoteMessage) {
+ public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
Log.d("Firebase", remoteMessage.getFrom() + ", " + remoteMessage.getData().get("content"));
// Wenn eine Activity geöffnet ist oder die FB-Nachricht nicht "Es hat gel" enthält, eine Toastbox zeigen, ansonsten eine Notification senden
- if (((!MainActivity.pausedMainActivity)
- || (!activityDoris.pausedDoris)
- || (!activityDorisLicht.pausedDorisLicht)
- || (!activityGlocke.pausedGlocke)
- || (!activityHaus.pausedHaus)
- || (!activityLicht.pausedLicht)
- || (!activityLog.pausedLog)
- || (!activitySky.pausedSky)
- || (!activityLWP.pausedLWP))
- && (!Objects.requireNonNull(remoteMessage.getData().get("content")).contains("Es hat gel"))) {
+ if (AppLifecycleTracker.isAppInForeground()) {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> Toast.makeText(getApplicationContext(), remoteMessage.getData().get("content"), Toast.LENGTH_LONG).show());
} else {
if (Objects.requireNonNull(remoteMessage.getData().get("content")).contains("Es hat gel")) {
- downloadFile(remoteMessage);
+ url = "https://www.klebl.info/cam/" + Objects.requireNonNull(remoteMessage.getData().get("content")).substring(28, 43) + ".jpg";
+ deleteImageFromMediaStore(getApplicationContext(), "cam.jpg");
+ downloadImageToGallery(getApplicationContext(), url, "cam.jpg");
+ downloadImageToGallery(getApplicationContext(), url, Objects.requireNonNull(remoteMessage.getData().get("content")).substring(28, 43) + ".jpg");
try {
- Thread.sleep(700);
+ Thread.sleep(1000);
} catch (InterruptedException e) {
- e.printStackTrace();
+ Log.d("onMessageReceived - Firebase", "1sec timer failed");
}
sendNotification(remoteMessage);
@@ -71,55 +67,39 @@ public class MyFirebaseMessagingService extends FirebaseMessagingService {
}
}
+ public void downloadImageToGallery(Context context, String imageUrl, String filename) {
+ new Thread(() -> {
+ try {
+ InputStream inputStream = new URL(imageUrl).openStream();
- public void downloadFile(RemoteMessage remoteMessage) {
- File fileCam = new File(Environment.getExternalStorageDirectory().getPath() + "/Pictures/Haussteuerung/");
- if (!fileCam.exists()) {
- fileCam.mkdir();
- }
+ ContentValues values = new ContentValues();
+ values.put(MediaStore.Images.Media.DISPLAY_NAME, filename);
+ values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
+ values.put(MediaStore.Images.Media.RELATIVE_PATH, Environment.DIRECTORY_PICTURES);
- if (Objects.requireNonNull(remoteMessage.getData().get("content")).contains("Es hat gel")) {
- Log.d("Foto", remoteMessage.getData().get("content"));
- String url = "https://www.klebl.info/cam/" + Objects.requireNonNull(remoteMessage.getData().get("content")).substring(28, 43) + ".jpg";
- Log.d("Foto", url);
-
- String f1 = Environment.getExternalStorageDirectory().getPath() + "/Pictures/Haussteuerung/" + Objects.requireNonNull(remoteMessage.getData().get("content")).substring(28, 43) + ".jpg";
- String f2 = Environment.getExternalStorageDirectory().getPath() + "/Pictures/Haussteuerung/cam.jpg";
- Handler handler = new Handler(Looper.getMainLooper());
- handler.post(() -> {
- Thread gfgThread = new Thread(() -> {
- try {
- InputStream in = null;
- try {
- in = new URL(url).openStream();
- Log.d("Foto", "Verbindung zum Server erfolgreich. Download wird durchgeführt.");
- } catch (IOException e) {
- // Wenn kein Foto gemacht wurde, hat das Foto 0kb, daher 404 error.
- Log.d("Foto", "Verbindungsfehler. Foto am Server prüfen.");
- }
- try {
- Files.copy(in, Paths.get(f1), StandardCopyOption.REPLACE_EXISTING);
- Log.d("Foto", "Foto 1 Download");
- Thread.sleep(200);
- Files.copy(Paths.get(f1), Paths.get(f2), StandardCopyOption.REPLACE_EXISTING);
- Log.d("Foto", "Foto 2 Download");
- Log.d("Foto", "Download und Speichern erfolgreich.");
- } catch (IOException e) {
- Log.d("Foto", "Download fehlgeschlagen.");
- }
- } catch (Exception e) {
- e.printStackTrace();
+ Uri uri = context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
+ if (uri != null) {
+ OutputStream outputStream = context.getContentResolver().openOutputStream(uri);
+ byte[] buffer = new byte[4096];
+ int bytesRead;
+ while ((bytesRead = inputStream.read(buffer)) != -1) {
+ Objects.requireNonNull(outputStream).write(buffer, 0, bytesRead);
}
- });
- gfgThread.start();
+ Objects.requireNonNull(outputStream).close();
+ inputStream.close();
+ }
+ } catch (Exception e) {
+ Log.d("downloadImageToGallery - Firebase", "Downloading camera picture failed");
+ }
+ }).start();
+ }
- // MediaScanner starten um das Foto in die Gallery zu bringen
- MediaScannerConnection.scanFile(getApplicationContext(), new String[]{f1},
- new String[]{"image/jpg"}, null);
- MediaScannerConnection.scanFile(getApplicationContext(), new String[]{f2},
- new String[]{"image/jpg"}, null);
- });
- }
+ public void deleteImageFromMediaStore(Context context, String filename) {
+ Uri collection = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
+ String selection = MediaStore.Images.Media.DISPLAY_NAME + "=?";
+ String[] selectionArgs = new String[]{filename};
+
+ context.getContentResolver().delete(collection, selection, selectionArgs);
}
public void sendNotification(RemoteMessage remoteMessage) {
@@ -146,30 +126,14 @@ public class MyFirebaseMessagingService extends FirebaseMessagingService {
Intent intent1 = new Intent(this, MainActivity.class);
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- Log.d("GlockeFirebase", Objects.requireNonNull(remoteMessage.getData().get("content")).substring(28, 43));
- // intent1.putExtra("Glocke", "Glocke");
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent1.putExtra("Glocke", "Glocke");
intent1.putExtra("Time", Objects.requireNonNull(remoteMessage.getData().get("content")).substring(28, 43));
+ Log.d("GlockeFirebase", Objects.requireNonNull(remoteMessage.getData().get("content")).substring(28, 43));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
intent1.setIdentifier(Objects.requireNonNull(remoteMessage.getData().get("content")).substring(28, 43));
}
- pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0 /* Request code */, intent1, PendingIntent.FLAG_IMMUTABLE);
-
- } else if (Objects.requireNonNull(remoteMessage.getData().get("content")).contains("Sky")) {
- NOTIFICATION_CHANNEL_ID = "Sky";
-
- Intent intent2 = new Intent(this, MainActivity.class);
- intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
- intent2.putExtra("Sky", "Sky");
- pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent2, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
-
- } else if (Objects.requireNonNull(remoteMessage.getData().get("content")).contains("Update")) {
- NOTIFICATION_CHANNEL_ID = "Update";
-
- Intent intent3 = new Intent(this, FileDownload.class);
- intent3.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
- pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent3, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
+ pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent1, PendingIntent.FLAG_IMMUTABLE);
} else if (Objects.requireNonNull(remoteMessage.getData().get("content")).contains("Waschmaschine")) {
NOTIFICATION_CHANNEL_ID = "Waschmaschine";
@@ -179,11 +143,11 @@ public class MyFirebaseMessagingService extends FirebaseMessagingService {
Intent intent4 = new Intent(this, MainActivity.class);
intent4.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent4.putExtra("Other", remoteMessage.getData().get("content"));
+ Log.d("OtherFirebase", Objects.requireNonNull(remoteMessage.getData().get("content")));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
intent4.setIdentifier(remoteMessage.getData().get("content"));
}
- Log.d("OtherFirebase", Objects.requireNonNull(remoteMessage.getData().get("content")));
- pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0 /* Request code */, intent4, PendingIntent.FLAG_IMMUTABLE);
+ pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent4, PendingIntent.FLAG_IMMUTABLE);
}
String description = "Haussteuerung - " + NOTIFICATION_CHANNEL_ID;
@@ -193,7 +157,6 @@ public class MyFirebaseMessagingService extends FirebaseMessagingService {
channel.setShowBadge(true);
channel.canShowBadge();
channel.enableLights(true);
- channel.setLightColor(getResources().getColor(R.color.gradient_blue));
channel.enableVibration(true);
channel.setVibrationPattern(new long[]{100, 200, 300, 400, 500});
@@ -201,7 +164,16 @@ public class MyFirebaseMessagingService extends FirebaseMessagingService {
Random notification_id = new Random();
- NotificationCompat.Builder notificationBuilder = null;
+ Bitmap bitmap = null;
+ try {
+ InputStream in = new URL(url).openStream();
+ bitmap = BitmapFactory.decodeStream(in);
+ in.close();
+ } catch (Exception e) {
+ Log.d("sendNotification - Firebase", "Loading bitmap cam.jpg from MediaStore failed");
+ }
+
+ NotificationCompat.Builder notificationBuilder;
if (Objects.requireNonNull(remoteMessage.getData().get("content")).contains("Es hat gel")) {
notificationBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
.setDefaults(Notification.DEFAULT_ALL)
@@ -210,9 +182,7 @@ public class MyFirebaseMessagingService extends FirebaseMessagingService {
.setContentText(content)
.setAutoCancel(true)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.haus_icon))
- .setLights(getResources().getColor(R.color.gradient_blue), 1000, 300)
- .setStyle(new NotificationCompat.BigPictureStyle()
- .bigPicture(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory().getPath() + "/Pictures/Haussteuerung/" + Objects.requireNonNull(remoteMessage.getData().get("content")).substring(28, 43) + ".jpg")))
+ .setStyle(new NotificationCompat.BigPictureStyle().bigPicture(bitmap))
.setSmallIcon(R.drawable.haus_icon);
} else {
notificationBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
@@ -222,13 +192,10 @@ public class MyFirebaseMessagingService extends FirebaseMessagingService {
.setContentText(content)
.setAutoCancel(true)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.haus_icon))
- .setLights(getResources().getColor(R.color.gradient_blue), 1000, 300)
.setSmallIcon(R.drawable.haus_icon);
}
-
Log.d("num", String.valueOf(notification_id.nextInt(1000)));
- assert notificationManager != null;
notificationManager.notify(notification_id.nextInt(1000), notificationBuilder.build());
}
}
diff --git a/app/src/main/java/com/haussteuerung/activityChristmas.java b/app/src/main/java/com/haussteuerung/activityChristmas.java
deleted file mode 100644
index 6fa5ad2..0000000
--- a/app/src/main/java/com/haussteuerung/activityChristmas.java
+++ /dev/null
@@ -1,283 +0,0 @@
-package com.haussteuerung;
-
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.widget.Button;
-import android.widget.NumberPicker;
-
-import androidx.activity.EdgeToEdge;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.appcompat.content.res.AppCompatResources;
-import androidx.core.graphics.Insets;
-import androidx.core.view.ViewCompat;
-import androidx.core.view.WindowInsetsCompat;
-
-import java.util.ArrayList;
-
-public class activityChristmas extends AppCompatActivity {
-
- static String power = "OFF";
- private String hsbColorMqtt = "";
- static ArrayList hsbColorArray;
- private Button buttonPower;
- private Button buttonColor1, buttonColor2,
- buttonColor3, buttonColor4,
- buttonColor5,buttonColor6,
- buttonColor7, buttonColor8;
- private NumberPicker picker;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- // Ändern der Statusbar-Farbe
- androidx.appcompat.app.ActionBar actionBar = getSupportActionBar();
- assert actionBar != null;
- actionBar.setBackgroundDrawable(AppCompatResources.getDrawable(getApplicationContext(), R.drawable.gradient_titlebar));
-
- setContentView(R.layout.activity_christmas);
- setTitle("Haussteuerung - Christmas");
-
- Log.d("HSBColor0", hsbColorArray.get(0));
- Log.d("HSBColor1", hsbColorArray.get(1));
- Log.d("HSBColor2", hsbColorArray.get(2));
-
- buttonPower = findViewById(R.id.buttonPower);
- buttonColor1 = findViewById(R.id.buttonColor1);
- buttonColor2 = findViewById(R.id.buttonColor2);
- buttonColor3 = findViewById(R.id.buttonColor3);
- buttonColor4 = findViewById(R.id.buttonColor4);
- buttonColor5 = findViewById(R.id.buttonColor5);
- buttonColor6 = findViewById(R.id.buttonColor6);
- buttonColor7 = findViewById(R.id.buttonColor7);
- buttonColor8 = findViewById(R.id.buttonColor8);
- picker = findViewById(R.id.picker);
-
- handleButton();
- handleNumberPicker();
- }
-
- private void handleButton() {
- if (power.equals("ON")) {
- buttonPower.setText(R.string.on);
- } else if (power.equals("OFF")) {
- buttonPower.setText(R.string.off);
- }
-
- buttonColor1.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- setHSBColor("10");
- Log.d("HSBColorRed", hsbColorMqtt);
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"" + buttonPower.getText() +"\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/HSBColor", hsbColorMqtt);
- }
- });
-
- buttonColor2.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- setHSBColor("50");
- Log.d("HSBColorYellow", hsbColorMqtt);
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"" + buttonPower.getText() +"\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/HSBColor", hsbColorMqtt);
- }
- });
-
- buttonColor3.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- setHSBColor("100");
- Log.d("HSBColorGreen", hsbColorMqtt);
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"" + buttonPower.getText() +"\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/HSBColor", hsbColorMqtt);
- }
- });
-
- buttonColor4.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- setHSBColor("150");
- Log.d("HSBColorLightBlue", hsbColorMqtt);
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"" + buttonPower.getText() +"\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/HSBColor", hsbColorMqtt);
- }
- });
-
- buttonColor5.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- setHSBColor("200");
- Log.d("HSBColorBlue", hsbColorMqtt);
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"" + buttonPower.getText() +"\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/HSBColor", hsbColorMqtt);
- }
- });
-
- buttonColor6.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- setHSBColor("250");
- Log.d("HSBColorPurple", hsbColorMqtt);
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"" + buttonPower.getText() +"\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/HSBColor", hsbColorMqtt);
- }
- });
-
- buttonColor7.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- setHSBColor("300");
- Log.d("HSBColorWhite", hsbColorMqtt);
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"" + buttonPower.getText() +"\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/HSBColor", hsbColorMqtt);
- }
- });
-
- buttonColor8.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- setHSBColor("350");
- Log.d("HSBColorChanging", hsbColorMqtt);
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"" + buttonPower.getText() +"\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/HSBColor", hsbColorMqtt);
- }
- });
-
- buttonPower.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- String hsbColorMqtt = hsbColorArray.get(0) + "," + hsbColorArray.get(1) + "," + hsbColorArray.get(2);
- if (buttonPower.getText().equals("ON")) {
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"OFF\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/POWER", "0");
- buttonPower.setText(R.string.off);
- } else if (buttonPower.getText().equals("OFF")) {
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"ON\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/POWER", "1");
- buttonPower.setText(R.string.on);
- }
- }
- });
- }
-
- private void handleNumberPicker() {
- String[] values = {"Bright (Steady On)","Gradually (Slow Fade)","Star (Sequential)","Flower (In Waves)",
- "Marquee (Chasing / Flash)","Fireworks (Twinkle / Flash)","Meteor","Stream"};
- picker.setWrapSelectorWheel(false);
- picker.setMinValue(0);
- picker.setMaxValue(values.length - 1);
-
- if (Integer.parseInt(hsbColorArray.get(2)) >= 0 && Integer.parseInt(hsbColorArray.get(2)) <= 12) {
- picker.setValue(0);
- }
- if (Integer.parseInt(hsbColorArray.get(2)) >= 13 && Integer.parseInt(hsbColorArray.get(2)) <= 24) {
- picker.setValue(1);
- }
- if (Integer.parseInt(hsbColorArray.get(2)) >= 25 && Integer.parseInt(hsbColorArray.get(2)) <= 37) {
- picker.setValue(2);
- }
- if (Integer.parseInt(hsbColorArray.get(2)) >= 38 && Integer.parseInt(hsbColorArray.get(2)) <= 49) {
- picker.setValue(3);
- }
- if (Integer.parseInt(hsbColorArray.get(2)) >= 50 && Integer.parseInt(hsbColorArray.get(2)) <= 62) {
- picker.setValue(4);
- }
- if (Integer.parseInt(hsbColorArray.get(2)) >= 63 && Integer.parseInt(hsbColorArray.get(2)) <= 74) {
- picker.setValue(5);
- }
- if (Integer.parseInt(hsbColorArray.get(2)) >= 75 && Integer.parseInt(hsbColorArray.get(2)) <= 87) {
- picker.setValue(6);
- }
- if (Integer.parseInt(hsbColorArray.get(2)) >= 88 && Integer.parseInt(hsbColorArray.get(2)) <= 100) {
- picker.setValue(7);
- }
-
- picker.setDisplayedValues(values);
-
- picker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
- @Override
- public void onValueChange(NumberPicker numberPicker, int i, int i1) {
- if (numberPicker.getValue() == 0) {
- String hsbColorMqtt = hsbColorArray.get(0) + ",100,10";
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"" + buttonPower.getText() +"\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/HSBColor", hsbColorMqtt);
- }
- if (numberPicker.getValue() == 1) {
- String hsbColorMqtt = hsbColorArray.get(0) + ",100,20";
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"" + buttonPower.getText() +"\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/HSBColor", hsbColorMqtt);
- }
- if (numberPicker.getValue() == 2) {
- String hsbColorMqtt = hsbColorArray.get(0) + ",100,30";
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"" + buttonPower.getText() +"\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/HSBColor", hsbColorMqtt);
- }
- if (numberPicker.getValue() == 3) {
- String hsbColorMqtt = hsbColorArray.get(0) + ",100,40";
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"" + buttonPower.getText() +"\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/HSBColor", hsbColorMqtt);
- }
- if (numberPicker.getValue() == 4) {
- String hsbColorMqtt = hsbColorArray.get(0) + ",100,50";
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"" + buttonPower.getText() +"\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/HSBColor", hsbColorMqtt);
- }
- if (numberPicker.getValue() == 5) {
- String hsbColorMqtt = hsbColorArray.get(0) + ",100,70";
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"" + buttonPower.getText() +"\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/HSBColor", hsbColorMqtt);
- }
- if (numberPicker.getValue() == 6) {
- String hsbColorMqtt = hsbColorArray.get(0) + ",100,80";
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"" + buttonPower.getText() +"\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/HSBColor", hsbColorMqtt);
- }
- if (numberPicker.getValue() == 7) {
- String hsbColorMqtt = hsbColorArray.get(0) + ",100,90";
- MqttClient.publish("tele/sonoff153/STATE", "{\"POWER\":\"" + buttonPower.getText() +"\",\"HSBColor\":\""+ hsbColorMqtt + "\"}", 2, true);
- MqttClient.publish("cmnd/sonoff153/HSBColor", hsbColorMqtt);
- }
- Log.d("NumberPicker", String.valueOf(numberPicker.getValue()));
- }
- });
- }
-
- private void setHSBColor(String color) {
- if (picker.getValue() == 0) {
- hsbColorMqtt = color + ",100,10";
- }
- if (picker.getValue() == 1) {
- hsbColorMqtt = color + ",100,20";
- }
- if (picker.getValue() == 2) {
- hsbColorMqtt = color + ",100,30";
- }
- if (picker.getValue() == 3) {
- hsbColorMqtt = color + ",100,40";
- }
- if (picker.getValue() == 4) {
- hsbColorMqtt = color + ",100,50";
- }
- if (picker.getValue() == 5) {
- hsbColorMqtt = color + ",100,70";
- }
- if (picker.getValue() == 6) {
- hsbColorMqtt = color + ",100,80";
- }
- if (picker.getValue() == 7) {
- hsbColorMqtt = color + ",100,90";
- }
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/haussteuerung/activityDoris.java b/app/src/main/java/com/haussteuerung/activityDoris.java
index fe49e7b..b0f7246 100644
--- a/app/src/main/java/com/haussteuerung/activityDoris.java
+++ b/app/src/main/java/com/haussteuerung/activityDoris.java
@@ -3,22 +3,18 @@ package com.haussteuerung;
import android.app.TimePickerDialog;
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.TimePicker;
import android.widget.Toast;
-import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
-import androidx.core.graphics.Insets;
-import androidx.core.view.ViewCompat;
-import androidx.core.view.WindowInsetsCompat;
+import androidx.lifecycle.ProcessLifecycleOwner;
import com.google.gson.Gson;
-import com.google.gson.annotations.SerializedName;
+import com.haussteuerung.helper.Blutdruck;
+import com.haussteuerung.helper.Temperatur;
import java.time.LocalDateTime;
import java.time.LocalTime;
@@ -29,25 +25,22 @@ public class activityDoris extends AppCompatActivity {
Button buttonSend, zeitBlutdruck, zeitFiebertemp;
int hourBlutdruck = 0, minuteBlutdruck = 0, hourFiebertemp = 0, minuteFiebertemp = 0;
static String werteBlutdruck = "";
- static String wertFiebertemp = "";
TextView textSYS, textDIA, textFiebertemp;
LocalDateTime datetime = LocalDateTime.now();
DateTimeFormatter dateTimeFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDate = datetime.format(dateTimeFormat);
- public static boolean pausedDoris = true;
Gson gson = new Gson();
String msg;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ ProcessLifecycleOwner.get().getLifecycle().addObserver(new AppLifecycleTracker());
androidx.appcompat.app.ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setBackgroundDrawable(AppCompatResources.getDrawable(getApplicationContext(), R.color.black));
- pausedDoris = false;
-
setContentView(R.layout.activity_doris);
setTitle("Haussteuerung - Doris");
@@ -63,13 +56,7 @@ public class activityDoris extends AppCompatActivity {
hourBlutdruck = datetime.getHour();
minuteBlutdruck = datetime.getMinute();
zeitBlutdruck.setText(String.format(Locale.getDefault(), "%02d:%02d", datetime.getHour(), datetime.getMinute()));
-
- zeitBlutdruck.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timePickerDialog(zeitBlutdruck);
- }
- });
+ zeitBlutdruck.setOnClickListener(v -> timePickerDialog(zeitBlutdruck));
checkBlutdruck.setOnClickListener(view -> {
if (checkBlutdruck.isChecked()) {
@@ -96,13 +83,7 @@ public class activityDoris extends AppCompatActivity {
hourFiebertemp = datetime.getHour();
minuteFiebertemp = datetime.getMinute();
zeitFiebertemp.setText(String.format(Locale.getDefault(), "%02d:%02d", datetime.getHour(), datetime.getMinute()));
-
- zeitFiebertemp.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timePickerDialog(zeitFiebertemp);
- }
- });
+ zeitFiebertemp.setOnClickListener(v -> timePickerDialog(zeitFiebertemp));
checkFiebertemp.setOnClickListener(view -> {
if (checkFiebertemp.isChecked()) {
@@ -127,9 +108,8 @@ public class activityDoris extends AppCompatActivity {
String minute = Integer.toString(minuteBlutdruck);
String sys = textSYS.getText().toString();
String dia = textDIA.getText().toString();
- werteBlutdruck = "{\"DeviceID\":\"" + MainActivity.ID + "\", \"Datum\":" + "\"" + formattedDate + " " + hour + ":" + minute + ":00" + "\"," + "\"SYS\":" + "\"" + sys + "\"," + "\"DIA\":" + "\"" + dia + "\"}";
- Log.d("Doris", werteBlutdruck);
- MqttClient.publish("cmnd/Haussteuerung/Doris/Blutdruck", werteBlutdruck);
+ msg = gson.toJson(new Blutdruck(MainActivity.ID, formattedDate + " " + hour + ":" + minute + ":00", sys, dia));
+ MqttClient.publish("cmnd/Haussteuerung/Doris/Blutdruck", msg);
setBlutdruck = true;
}
@@ -143,9 +123,7 @@ public class activityDoris extends AppCompatActivity {
String fiebertemp = textFiebertemp.getText().toString();
msg = gson.toJson(new Temperatur(MainActivity.ID, formattedDate + " " + hour + ":" + minute + ":00", fiebertemp));
MqttClient.publish("cmnd/Haussteuerung/Doris/Temperatur", msg);
- // wertFiebertemp = "{\"DeviceID\":\"" + MainActivity.ID + "\", \"Datum\":" + "\"" + formattedDate + " " + hour + ":" + minute + ":00" + "\"," + "\"Temperatur\": " + "\"" + fiebertemp + "\"}";
Log.d("Doris", msg);
- // MqttClient.publish("cmnd/Haussteuerung/Doris/Temperatur", wertFiebertemp);
setFiebertemp = true;
}
if (setBlutdruck || setFiebertemp) {
@@ -158,12 +136,7 @@ public class activityDoris extends AppCompatActivity {
LocalTime localTime = LocalTime.parse(button.getText());
int hour = localTime.getHour();
int minute = localTime.getMinute();
- TimePickerDialog.OnTimeSetListener onTimeSetListener = new TimePickerDialog.OnTimeSetListener() {
- @Override
- public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
- button.setText(String.format(Locale.getDefault(), "%02d:%02d", selectedHour, selectedMinute));
- }
- };
+ TimePickerDialog.OnTimeSetListener onTimeSetListener = (timePicker, selectedHour, selectedMinute) -> button.setText(String.format(Locale.getDefault(), "%02d:%02d", selectedHour, selectedMinute));
TimePickerDialog timePickerDialog = new TimePickerDialog(this, onTimeSetListener, hour, minute, true);
timePickerDialog.show();
}
@@ -171,34 +144,16 @@ public class activityDoris extends AppCompatActivity {
@Override
protected void onPause() {
super.onPause();
- pausedDoris = true;
}
@Override
protected void onResume() {
super.onResume();
- pausedDoris = false;
}
@Override
protected void onStop() {
super.onStop();
- pausedDoris = true;
}
}
-class Temperatur {
- @SerializedName("DeviceID")
- private final String deviceId;
- @SerializedName("Datum")
- private final String datum;
- @SerializedName("Temperatur")
- private final String temperatur;
-
-
- public Temperatur(String deviceId, String datum, String temperatur) {
- this.deviceId = deviceId;
- this.datum = datum;
- this.temperatur = temperatur;
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/haussteuerung/activityDorisLicht.java b/app/src/main/java/com/haussteuerung/activityDorisLicht.java
index 6bd3987..7f55192 100644
--- a/app/src/main/java/com/haussteuerung/activityDorisLicht.java
+++ b/app/src/main/java/com/haussteuerung/activityDorisLicht.java
@@ -1,37 +1,38 @@
package com.haussteuerung;
import android.os.Bundle;
+import android.util.Log;
import android.view.View;
import android.widget.Button;
-import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
-import androidx.core.graphics.Insets;
-import androidx.core.view.ViewCompat;
-import androidx.core.view.WindowInsetsCompat;
+import androidx.lifecycle.ProcessLifecycleOwner;
import com.google.gson.Gson;
-import com.google.gson.annotations.SerializedName;
+import com.haussteuerung.helper.Licht;
+import com.haussteuerung.helper.Rollo;
+
+import java.util.HashMap;
+import java.util.Map;
public class activityDorisLicht extends AppCompatActivity implements View.OnClickListener {
// Position 0 = unten
// Position 100 = oben
- public static boolean pausedDorisLicht = true;
+
+ private final Map rolloMap = new HashMap<>();
Gson gson = new Gson();
- String msg;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ ProcessLifecycleOwner.get().getLifecycle().addObserver(new AppLifecycleTracker());
androidx.appcompat.app.ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setBackgroundDrawable(AppCompatResources.getDrawable(getApplicationContext(), R.color.black));
- pausedDorisLicht = false;
-
setContentView(R.layout.activity_doris_licht);
setTitle("Haussteuerung - Doris Licht");
@@ -75,179 +76,73 @@ public class activityDorisLicht extends AppCompatActivity implements View.OnClic
buttonRollo13.setOnClickListener(this);
buttonRollo14.setOnClickListener(this);
buttonRollo15.setOnClickListener(this);
+
+ initRolloMap(MainActivity.ID);
}
@Override
public void onClick(View v) {
- switch (v.getId()) {
- case R.id.buttonDeckenlampe:
- msg = gson.toJson(new Licht(MainActivity.ID, "Doris Deckenlampe", "Lamp21"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- // String msg1 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Doris Deckenlampe" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"power" + "\",\"Message\":\"2\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Licht", msg1);
- break;
+ int id = v.getId();
+ String msg;
+ if (id == R.id.buttonDeckenlampe) {
+ msg = gson.toJson(new Licht(MainActivity.ID, "Doris Deckenlampe", "Lamp21"));
+ MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
+ } else if (id == R.id.buttonStehlampe) {
+ msg = gson.toJson(new Licht(MainActivity.ID, "Doris Stehlampe", "Lamp22"));
+ MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
+ } else if (id == R.id.buttonDeckenlampeBad) {
+ msg = gson.toJson(new Licht(MainActivity.ID, "Doris Bad Deckenlampe", "Lamp23"));
+ MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
+ } else if (id == R.id.buttonWandlampeBad) {
+ msg = gson.toJson(new Licht(MainActivity.ID, "Doris Bad Wandlampe", "Lamp24"));
+ MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
+ }
- case R.id.buttonStehlampe:
- msg = gson.toJson(new Licht(MainActivity.ID, "Doris Stehlampe", "Lamp22"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- // String msg2 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Doris Stehlampe" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"power" + "\",\"Message\":\"2\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Licht", msg2);
- break;
-
- case R.id.buttonDeckenlampeBad:
- msg = gson.toJson(new Licht(MainActivity.ID, "Doris Bad Deckenlampe", "Lamp23"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- // String msg3 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Doris Bad Deckenlampe" + "\",\"Device\":\"" + "sonoff177" + "\",\"Power\":\"power1" + "\",\"Message\":\"2\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Licht", msg3);
- break;
-
- case R.id.buttonWandlampeBad:
- msg = gson.toJson(new Licht(MainActivity.ID, "Doris Bad Wandlampe", "Lamp24"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- // String msg4 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Doris Bad Wandlampe" + "\",\"Device\":\"" + "sonoff177" + "\",\"Power\":\"power2" + "\",\"Message\":\"2\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Licht", msg4);
- break;
-
- case R.id.buttonRollo1:
- msg = gson.toJson(new Rollo(MainActivity.ID, "Alle Rollo", "Rollo1", 100));
- MqttClient.publish("cmnd/Haussteuerung/Rollo", msg);
- // String msg5 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Alle Rollo" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"SHUTTERPOSITION" + "\",\"Message\":\"100\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Rollo", msg5);
- break;
-
- case R.id.buttonRollo2:
- msg = gson.toJson(new Rollo(MainActivity.ID, "Alle Rollo", "Rollo1", 50));
- MqttClient.publish("cmnd/Haussteuerung/Rollo", msg);
- // String msg6 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Alle Rollo" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"SHUTTERPOSITION" + "\",\"Message\":\"50\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Rollo", msg6);
- break;
-
- case R.id.buttonRollo3:
- msg = gson.toJson(new Rollo(MainActivity.ID, "Alle Rollo", "Rollo1", 0));
- MqttClient.publish("cmnd/Haussteuerung/Rollo", msg);
- // String msg7 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Alle Rollo" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"SHUTTERPOSITION" + "\",\"Message\":\"0\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Rollo", msg7);
- break;
-
- case R.id.buttonRollo4:
- msg = gson.toJson(new Rollo(MainActivity.ID, "Terrasse Rollo", "sonoff171", 100));
- MqttClient.publish("cmnd/Haussteuerung/Rollo", msg);
- // String msg8 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Terrasse Rollo" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"SHUTTERPOSITION" + "\",\"Message\":\"100\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Rollo", msg8);
- break;
-
- case R.id.buttonRollo5:
- msg = gson.toJson(new Rollo(MainActivity.ID, "Terrasse Rollo", "sonoff171", 50));
- MqttClient.publish("cmnd/Haussteuerung/Rollo", msg);
- // String msg9 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Terrasse Rollo" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"SHUTTERPOSITION" + "\",\"Message\":\"50\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Rollo", msg9);
- break;
-
- case R.id.buttonRollo6:
- msg = gson.toJson(new Rollo(MainActivity.ID, "Terrasse Rollo", "sonoff171", 0));
- MqttClient.publish("cmnd/Haussteuerung/Rollo", msg);
- // String msg10 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Terrasse Rollo" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"SHUTTERPOSITION" + "\",\"Message\":\"0\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Rollo", msg10);
- break;
-
- case R.id.buttonRollo7:
- msg = gson.toJson(new Rollo(MainActivity.ID, "Rollo Fenster links", "sonoff172", 100));
- MqttClient.publish("cmnd/Haussteuerung/Rollo", msg);
- // String msg11 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Rollo Fenster links" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"SHUTTERPOSITION" + "\",\"Message\":\"100\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Rollo", msg11);
- break;
-
- case R.id.buttonRollo8:
- msg = gson.toJson(new Rollo(MainActivity.ID, "Rollo Fenster links", "sonoff172", 50));
- MqttClient.publish("cmnd/Haussteuerung/Rollo", msg);
- // String msg12 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Rollo Fenster links" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"SHUTTERPOSITION" + "\",\"Message\":\"50\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Rollo", msg12);
- break;
-
- case R.id.buttonRollo9:
- msg = gson.toJson(new Rollo(MainActivity.ID, "Rollo Fenster links", "sonoff172", 0));
- MqttClient.publish("cmnd/Haussteuerung/Rollo", msg);
- // String msg13 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Rollo Fenster links" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"SHUTTERPOSITION" + "\",\"Message\":\"0\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Rollo", msg13);
- break;
-
- case R.id.buttonRollo10:
- msg = gson.toJson(new Rollo(MainActivity.ID, "Rollo Fenster rechts", "sonoff173", 100));
- MqttClient.publish("cmnd/Haussteuerung/Rollo", msg);
- // String msg14 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Rollo Fenster rechts" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"SHUTTERPOSITION" + "\",\"Message\":\"100\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Rollo", msg14);
- break;
-
- case R.id.buttonRollo11:
- msg = gson.toJson(new Rollo(MainActivity.ID, "Rollo Fenster rechts", "sonoff173", 50));
- MqttClient.publish("cmnd/Haussteuerung/Rollo", msg);
- // String msg15 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Rollo Fenster rechts" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"SHUTTERPOSITION" + "\",\"Message\":\"50\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Rollo", msg15);
- break;
-
- case R.id.buttonRollo12:
- msg = gson.toJson(new Rollo(MainActivity.ID, "Rollo Fenster rechts", "sonoff173", 0));
- MqttClient.publish("cmnd/Haussteuerung/Rollo", msg);
- // String msg16 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Rollo Fenster rechts" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"SHUTTERPOSITION" + "\",\"Message\":\"0\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Rollo", msg16);
- break;
-
- case R.id.buttonRollo13:
- msg = gson.toJson(new Rollo(MainActivity.ID, "Bad Rollo", "sonoff174", 100));
- MqttClient.publish("cmnd/Haussteuerung/Rollo", msg);
- // String msg17 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Bad Rollo" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"SHUTTERPOSITION" + "\",\"Message\":\"100\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Rollo", msg17);
- break;
-
- case R.id.buttonRollo14:
- msg = gson.toJson(new Rollo(MainActivity.ID, "Bad Rollo", "sonoff174", 50));
- MqttClient.publish("cmnd/Haussteuerung/Rollo", msg);
- // String msg18 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Bad Rollo" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"SHUTTERPOSITION" + "\",\"Message\":\"50\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Rollo", msg18);
- break;
-
- case R.id.buttonRollo15:
- msg = gson.toJson(new Rollo(MainActivity.ID, "Bad Rollo", "sonoff174", 0));
- MqttClient.publish("cmnd/Haussteuerung/Rollo", msg);
- // String msg19 = "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Bad Rollo" + "\",\"Device\":\"" + v.getTag().toString() + "\",\"Power\":\"SHUTTERPOSITION" + "\",\"Message\":\"0\"}";
- // MqttClient.publish("cmnd/Haussteuerung/Rollo", msg19);
- break;
+ Rollo rollo = rolloMap.get(id);
+ if (rollo != null) {
+ msg = gson.toJson(rollo);
+ MqttClient.publish("cmnd/Haussteuerung/Rollo", msg);
+ } else {
+ Log.w("RolloControl", "Unknown button: " + id);
}
}
+ private void initRolloMap(String androidId) {
+ rolloMap.put(R.id.buttonRollo1, new Rollo(androidId, "Alle Rollo", "Rollo1", 100));
+ rolloMap.put(R.id.buttonRollo2, new Rollo(androidId, "Alle Rollo", "Rollo1", 50));
+ rolloMap.put(R.id.buttonRollo3, new Rollo(androidId, "Alle Rollo", "Rollo1", 0));
+
+ rolloMap.put(R.id.buttonRollo4, new Rollo(androidId, "Terrasse Rollo", "sonoff171", 100));
+ rolloMap.put(R.id.buttonRollo5, new Rollo(androidId, "Terrasse Rollo", "sonoff171", 50));
+ rolloMap.put(R.id.buttonRollo6, new Rollo(androidId, "Terrasse Rollo", "sonoff171", 0));
+
+ rolloMap.put(R.id.buttonRollo7, new Rollo(androidId, "Rollo Fenster links", "sonoff172", 100));
+ rolloMap.put(R.id.buttonRollo8, new Rollo(androidId, "Rollo Fenster links", "sonoff172", 50));
+ rolloMap.put(R.id.buttonRollo9, new Rollo(androidId, "Rollo Fenster links", "sonoff172", 0));
+
+ rolloMap.put(R.id.buttonRollo10, new Rollo(androidId, "Rollo Fenster rechts", "sonoff173", 100));
+ rolloMap.put(R.id.buttonRollo11, new Rollo(androidId, "Rollo Fenster rechts", "sonoff173", 50));
+ rolloMap.put(R.id.buttonRollo12, new Rollo(androidId, "Rollo Fenster rechts", "sonoff173", 0));
+
+ rolloMap.put(R.id.buttonRollo13, new Rollo(androidId, "Bad Rollo", "sonoff174", 100));
+ rolloMap.put(R.id.buttonRollo14, new Rollo(androidId, "Bad Rollo", "sonoff174", 50));
+ rolloMap.put(R.id.buttonRollo15, new Rollo(androidId, "Bad Rollo", "sonoff174", 0));
+ }
+
+
@Override
protected void onPause() {
super.onPause();
- pausedDorisLicht = true;
}
@Override
protected void onResume() {
super.onResume();
- pausedDorisLicht = false;
}
@Override
protected void onStop() {
super.onStop();
- pausedDorisLicht = true;
}
}
-class Rollo {
- @SerializedName("DeviceID")
- private final String deviceId;
- @SerializedName("Name")
- private final String name;
- @SerializedName("Device")
- private final String device;
- @SerializedName("Shutterposition")
- private final int shutterposition;
-
- public Rollo(String deviceId, String name, String device, int shutterposition) {
- this.deviceId = deviceId;
- this.name = name;
- this.device = device;
- this.shutterposition = shutterposition;
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/haussteuerung/activityGlocke.java b/app/src/main/java/com/haussteuerung/activityGlocke.java
index 8fbca65..aebaa9f 100644
--- a/app/src/main/java/com/haussteuerung/activityGlocke.java
+++ b/app/src/main/java/com/haussteuerung/activityGlocke.java
@@ -1,67 +1,55 @@
package com.haussteuerung;
+import android.content.ContentUris;
+import android.content.Context;
import android.content.Intent;
+import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
-import android.os.Environment;
+import android.provider.MediaStore;
import android.util.Log;
import android.widget.Button;
-import android.widget.Toast;
-import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
-import androidx.core.graphics.Insets;
-import androidx.core.view.ViewCompat;
-import androidx.core.view.WindowInsetsCompat;
+import androidx.lifecycle.ProcessLifecycleOwner;
import com.google.gson.Gson;
+import com.haussteuerung.helper.Licht;
import com.ortiz.touchview.TouchImageView;
-import java.io.File;
+import java.io.IOException;
public class activityGlocke extends AppCompatActivity {
-
- public static boolean pausedGlocke = true;
Gson gson = new Gson();
String msg;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ ProcessLifecycleOwner.get().getLifecycle().addObserver(new AppLifecycleTracker());
androidx.appcompat.app.ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setBackgroundDrawable(AppCompatResources.getDrawable(getApplicationContext(), R.color.black));
- pausedGlocke = false;
-
setContentView(R.layout.activity_glocke);
setTitle("Haussteuerung - Glocke");
TouchImageView fotoGlocke = findViewById(R.id.fotoGlocke);
Intent i = getIntent();
- File file = new File(Environment.getExternalStorageDirectory().getPath() + "/Pictures/Haussteuerung/cam.jpg");
- if (i.getExtras() != null) {
- if (i.getExtras() != null && i.hasExtra("TimeFB")) {
- file = new File(Environment.getExternalStorageDirectory().getPath() + "/Pictures/Haussteuerung/" + i.getStringExtra("TimeFB") + ".jpg");
- Log.d("ZeitGlocke", i.getStringExtra("TimeFB"));
- } else {
- file = new File(Environment.getExternalStorageDirectory().getPath() + "/Pictures/Haussteuerung/cam.jpg");
- }
+ Bitmap bitmap;
+ if ((i.getExtras() != null) && (i.hasExtra("TimeFB"))) {
+ bitmap = loadBitmapFromMediaStore(getApplicationContext(), i.getStringExtra("Time") + ".jpg");
+ } else {
+ bitmap = loadBitmapFromMediaStore(getApplicationContext(), "cam.jpg");
}
- if(file.exists()){
- Bitmap myBitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
- Log.d("ImageView", file.getAbsolutePath());
- fotoGlocke.setImageBitmap(myBitmap);
- Log.d("Foto", "ImageView erfolgreich");
- } else {
- Log.d("Foto", "ImageView fehlgeschlagen");
- Toast.makeText(this, "Laden des Fotos fehlgeschlagen", Toast.LENGTH_LONG).show();
+ if (bitmap != null) {
+ fotoGlocke.setImageBitmap(bitmap);
}
Button buttonGlockeDoors = findViewById(R.id.buttonGlockeDoors);
@@ -81,21 +69,40 @@ public class activityGlocke extends AppCompatActivity {
});
}
+ public Bitmap loadBitmapFromMediaStore(Context context, String filename) {
+ Uri collection = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
+ String[] projection = new String[]{MediaStore.Images.Media._ID};
+ String selection = MediaStore.Images.Media.DISPLAY_NAME + "=?";
+ String[] selectionArgs = new String[]{filename};
+
+ Cursor cursor = context.getContentResolver().query(collection, projection, selection, selectionArgs, null);
+ if (cursor != null && cursor.moveToFirst()) {
+ int idColumn = cursor.getColumnIndexOrThrow(MediaStore.Images.Media._ID);
+ long id = cursor.getLong(idColumn);
+ cursor.close();
+
+ Uri imageUri = ContentUris.withAppendedId(collection, id);
+ try {
+ return BitmapFactory.decodeStream(context.getContentResolver().openInputStream(imageUri));
+ } catch (IOException e) {
+ Log.d("loadBitmapFromMediaStore - activityGlocke", "Loading bitmap cam.jpg from MediaStore failed");
+ }
+ }
+ return null;
+ }
+
@Override
protected void onPause() {
super.onPause();
- pausedGlocke = true;
}
@Override
protected void onResume() {
super.onResume();
- pausedGlocke = false;
}
@Override
protected void onStop() {
super.onStop();
- pausedGlocke = true;
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/haussteuerung/activityHaus.java b/app/src/main/java/com/haussteuerung/activityHaus.java
index 15b4f44..a52f364 100644
--- a/app/src/main/java/com/haussteuerung/activityHaus.java
+++ b/app/src/main/java/com/haussteuerung/activityHaus.java
@@ -5,19 +5,14 @@ import android.os.Bundle;
import android.os.Handler;
import android.widget.TextView;
-import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
-import androidx.core.graphics.Insets;
-import androidx.core.view.ViewCompat;
-import androidx.core.view.WindowInsetsCompat;
+import androidx.lifecycle.ProcessLifecycleOwner;
import java.util.Timer;
import java.util.TimerTask;
public class activityHaus extends AppCompatActivity {
-
- public static boolean pausedHaus = true;
private TextView tv_Zustand1;
private TextView tv_Zustand2;
private TextView tv_Zustand3;
@@ -43,13 +38,12 @@ public class activityHaus extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ ProcessLifecycleOwner.get().getLifecycle().addObserver(new AppLifecycleTracker());
androidx.appcompat.app.ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setBackgroundDrawable(AppCompatResources.getDrawable(getApplicationContext(), R.color.black));
- pausedHaus = false;
-
setContentView(R.layout.activity_haus);
setTitle("Haussteuerung - Hausansicht");
@@ -215,14 +209,12 @@ public class activityHaus extends AppCompatActivity {
@Override
protected void onPause() {
super.onPause();
- pausedHaus = true;
myTimer.cancel();
}
@Override
protected void onResume() {
super.onResume();
- pausedHaus = false;
TimerTask myTask = new TimerTask() {
public void run() {
myHandler.post(myRunnable); // updateUI method
@@ -234,7 +226,6 @@ public class activityHaus extends AppCompatActivity {
@Override
protected void onStop() {
super.onStop();
- pausedHaus = true;
myTimer.cancel();
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/haussteuerung/activityLWP.java b/app/src/main/java/com/haussteuerung/activityLWP.java
index 012e6c4..a12040a 100644
--- a/app/src/main/java/com/haussteuerung/activityLWP.java
+++ b/app/src/main/java/com/haussteuerung/activityLWP.java
@@ -1,35 +1,29 @@
package com.haussteuerung;
import android.os.Bundle;
-import android.util.Log;
import android.view.MenuItem;
-import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
-import androidx.core.graphics.Insets;
-import androidx.core.view.ViewCompat;
-import androidx.core.view.WindowInsetsCompat;
+import androidx.lifecycle.ProcessLifecycleOwner;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.navigation.NavigationBarView;
public class activityLWP extends AppCompatActivity implements NavigationBarView.OnItemSelectedListener {
-
- public static boolean pausedLWP = true;
BottomNavigationView bottomNavigationView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ ProcessLifecycleOwner.get().getLifecycle().addObserver(new AppLifecycleTracker());
// Ändern der Statusbar-Farbe
androidx.appcompat.app.ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setBackgroundDrawable(AppCompatResources.getDrawable(getApplicationContext(), R.drawable.gradient_titlebar));
- pausedLWP = false;
setContentView(R.layout.activity_lwp);
setTitle("Haussteuerung - Wärmepumpe");
@@ -64,23 +58,15 @@ public class activityLWP extends AppCompatActivity implements NavigationBarView.
@Override
protected void onPause() {
super.onPause();
- pausedLWP = true;
- Log.d("LWPActivityPause", "true");
}
@Override
protected void onResume() {
super.onResume();
- pausedLWP = false;
- Log.d("LWPActivityPause", "false");
-
-
}
@Override
protected void onStop() {
super.onStop();
- pausedLWP = true;
- Log.d("LWPActivityPause", "true");
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/haussteuerung/activityLicht.java b/app/src/main/java/com/haussteuerung/activityLicht.java
index 56d3552..d6c2cd9 100644
--- a/app/src/main/java/com/haussteuerung/activityLicht.java
+++ b/app/src/main/java/com/haussteuerung/activityLicht.java
@@ -8,19 +8,20 @@ import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
-import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
-import androidx.core.graphics.Insets;
-import androidx.core.view.ViewCompat;
-import androidx.core.view.WindowInsetsCompat;
+import androidx.lifecycle.ProcessLifecycleOwner;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
+import com.haussteuerung.helper.Checkboxen;
+import com.haussteuerung.helper.Licht;
+
+import java.util.HashMap;
+import java.util.Map;
public class activityLicht extends AppCompatActivity implements View.OnClickListener {
-
- public static boolean pausedLicht = true;
+ private final Map lichtMap = new HashMap<>();
private CheckBox checkWM1, checkWM2, checkWM3, checkWM4;
public static String nameTom = "";
public static String nameFlo = "";
@@ -36,16 +37,17 @@ public class activityLicht extends AppCompatActivity implements View.OnClickList
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ ProcessLifecycleOwner.get().getLifecycle().addObserver(new AppLifecycleTracker());
androidx.appcompat.app.ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setBackgroundDrawable(AppCompatResources.getDrawable(getApplicationContext(), R.color.black));
- pausedLicht = false;
-
setContentView(R.layout.activity_licht);
setTitle("Haussteuerung - Licht");
+ initLichtMap(MainActivity.ID);
+
Button buttonLicht1 = findViewById(R.id.buttonLicht1);
Button buttonLicht2 = findViewById(R.id.buttonLicht2);
Button buttonLicht3 = findViewById(R.id.buttonLicht3);
@@ -74,46 +76,42 @@ public class activityLicht extends AppCompatActivity implements View.OnClickList
checkWM1.setChecked(checkedTom);
checkWM1.setOnClickListener(view -> {
if (checkWM1.isChecked()) {
- // msg = gson.toJson(new Checkboxen(MainActivity.ID, "WMTom", true));
- MqttClient.publish("cmnd/Haussteuerung/Waschmaschine/Tom", "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"WMTom\"" + ",\"Checkbox\":\"true\"}");
+ msg = gson.toJson(new Checkboxen(MainActivity.ID, "WMTom", true));
+ MqttClient.publish("cmnd/Haussteuerung/Waschmaschine/Tom", msg);
} else {
- // msg = gson.toJson(new Checkboxen(MainActivity.ID, "WMTom", false));
- MqttClient.publish("cmnd/Haussteuerung/Waschmaschine/Tom", "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"WMTom\"" + ",\"Checkbox\":\"false\"}");
+ msg = gson.toJson(new Checkboxen(MainActivity.ID, "WMTom", false));
+ MqttClient.publish("cmnd/Haussteuerung/Waschmaschine/Tom", msg);
}
- // MqttClient.publish("cmnd/Haussteuerung/Waschmaschine/Tom", msg);
});
checkWM2.setChecked(checkedFlo);
checkWM2.setOnClickListener(view -> {
if (checkWM2.isChecked()) {
- // msg = gson.toJson(new Checkboxen(MainActivity.ID, "WMFlo", true));
- MqttClient.publish("cmnd/Haussteuerung/Waschmaschine/Flo", "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"WMFlo\"" + ",\"Checkbox\":\"true\"}");
+ msg = gson.toJson(new Checkboxen(MainActivity.ID, "WMFlo", true));
+ MqttClient.publish("cmnd/Haussteuerung/Waschmaschine/Flo", msg);
} else {
- // msg = gson.toJson(new Checkboxen(MainActivity.ID, "WMFlo", false));
- MqttClient.publish("cmnd/Haussteuerung/Waschmaschine/Flo", "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"WMFlo\"" + ",\"Checkbox\":\"false\"}");
+ msg = gson.toJson(new Checkboxen(MainActivity.ID, "WMFlo", false));
+ MqttClient.publish("cmnd/Haussteuerung/Waschmaschine/Flo", msg);
}
- // MqttClient.publish("cmnd/Haussteuerung/Waschmaschine/Flo", msg);
});
checkWM3.setChecked(checkedStefan);
checkWM3.setOnClickListener(view -> {
if (checkWM3.isChecked()) {
- // msg = gson.toJson(new Checkboxen(MainActivity.ID, "WMStefan", true));
- MqttClient.publish("cmnd/Haussteuerung/Waschmaschine/Stefan", "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"WMStefan\"" + ",\"Checkbox\":\"true\"}");
+ msg = gson.toJson(new Checkboxen(MainActivity.ID, "WMStefan", true));
+ MqttClient.publish("cmnd/Haussteuerung/Waschmaschine/Stefan", msg);
} else {
- // msg = gson.toJson(new Checkboxen(MainActivity.ID, "WMStefan", false));
- MqttClient.publish("cmnd/Haussteuerung/Waschmaschine/Stefan", "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"WMStefan\"" + ",\"Checkbox\":\"false\"}");
+ msg = gson.toJson(new Checkboxen(MainActivity.ID, "WMStefan", false));
+ MqttClient.publish("cmnd/Haussteuerung/Waschmaschine/Stefan", msg);
}
- // MqttClient.publish("cmnd/Haussteuerung/Waschmaschine/Stefan", msg);
});
checkWM4.setChecked(checkedGlocke);
checkWM4.setOnClickListener(view -> {
if (checkWM4.isChecked()) {
- // msg = gson.toJson(new Checkboxen(MainActivity.ID, "Glocke", true));
- MqttClient.publish("cmnd/Haussteuerung/Glocke", "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Glocke\"" + ",\"Checkbox\":\"true\"}");
+ msg = gson.toJson(new Checkboxen(MainActivity.ID, "Glocke", true));
+ MqttClient.publish("cmnd/Haussteuerung/Glocke", msg);
} else {
- // msg = gson.toJson(new Checkboxen(MainActivity.ID, "Glocke", false));
- MqttClient.publish("cmnd/Haussteuerung/Glocke", "{\"DeviceID\":\"" + MainActivity.ID + "\",\"Name\":\"Glocke\"" + ",\"Checkbox\":\"false\"}");
+ msg = gson.toJson(new Checkboxen(MainActivity.ID, "Glocke", false));
+ MqttClient.publish("cmnd/Haussteuerung/Glocke", msg);
}
- // MqttClient.publish("cmnd/Haussteuerung/Glocke", msg);
});
buttonLicht1.setOnClickListener(this);
@@ -141,125 +139,62 @@ public class activityLicht extends AppCompatActivity implements View.OnClickList
@SuppressLint("NonConstantResourceId")
@Override
public void onClick(View v) {
- switch (v.getId()) {
- case R.id.buttonLicht1:
- msg = gson.toJson(new Licht(MainActivity.ID, "Licht Tom Zimmer", "Lamp01"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht2:
- msg = gson.toJson(new Licht(MainActivity.ID, "Licht Wohnzimmer", "Lamp02"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht3:
- msg = gson.toJson(new Licht(MainActivity.ID, "Stehlampe WZ", "Lamp03"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht4:
- msg = gson.toJson(new Licht(MainActivity.ID, "Licht Esszimmer", "Lamp04"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht5:
- msg = gson.toJson(new Licht(MainActivity.ID, "Licht Küche", "Lamp05"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht6:
- msg = gson.toJson(new Licht(MainActivity.ID, "Licht Gang", "Lamp06"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht7:
- msg = gson.toJson(new Licht(MainActivity.ID, "Licht Stiegenhaus", "Lamp07"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht8:
- msg = gson.toJson(new Licht(MainActivity.ID, "Licht Obergeschoss", "Lamp08"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht9:
- msg = gson.toJson(new Licht(MainActivity.ID, "Licht Schlafzimmer", "Lamp09"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht10:
- msg = gson.toJson(new Licht(MainActivity.ID, "Gartentor", "Lamp10"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht11:
- msg = gson.toJson(new Licht(MainActivity.ID, "Eingangstuer", "Lamp11"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht12:
- msg = gson.toJson(new Licht(MainActivity.ID, "Garagentor", "Lamp12"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht13:
- msg = gson.toJson(new Licht(MainActivity.ID, "Nachtkastl Tom", "Lamp13"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht14:
- msg = gson.toJson(new Licht(MainActivity.ID, "Licht Obergeschoss", "Lamp14"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht15:
- msg = gson.toJson(new Licht(MainActivity.ID, "Licht Obergeschoss", "Lamp15"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht16:
- msg = gson.toJson(new Licht(MainActivity.ID, "vuDuoSZ", "Lamp16"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht17:
- msg = gson.toJson(new Licht(MainActivity.ID, "Zirkulationspumpe", "Lamp17"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht18:
- msg = gson.toJson(new Licht(MainActivity.ID, "PCFlo", "Lamp18"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
- case R.id.buttonLicht19:
- Intent iSky = new Intent(activityLicht.this, activitySky.class);
- startActivity(iSky);
- break;
- case R.id.buttonLicht20:
- msg = gson.toJson(new Licht(MainActivity.ID, "Licht Flo", "Lamp20"));
- MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
- break;
+ int id = v.getId();
+ String msg;
+
+ Licht licht = lichtMap.get(id);
+ if (licht != null) {
+ msg = gson.toJson(licht);
+ MqttClient.publish("cmnd/Haussteuerung/Licht", msg);
+ } else {
+ Log.w("LichtControl", "Unknown button: " + id);
+ }
+
+ if (id == R.id.buttonLicht19) {
+ Intent iSky = new Intent(activityLicht.this, activitySky.class);
+ startActivity(iSky);
}
}
+ private void initLichtMap(String androidId) {
+ lichtMap.put(R.id.buttonLicht1, new Licht(androidId, "Licht Tom Zimmer", "Lamp01"));
+ lichtMap.put(R.id.buttonLicht2, new Licht(androidId, "Licht Wohnzimmer", "Lamp02"));
+ lichtMap.put(R.id.buttonLicht3, new Licht(androidId, "Stehlampe WZ", "Lamp03"));
+ lichtMap.put(R.id.buttonLicht4, new Licht(androidId, "Licht Esszimmer", "Lamp04"));
+
+ lichtMap.put(R.id.buttonLicht5, new Licht(androidId, "Licht Küche", "Lamp05"));
+ lichtMap.put(R.id.buttonLicht6, new Licht(androidId, "Licht Gang", "Lamp06"));
+ lichtMap.put(R.id.buttonLicht7, new Licht(androidId, "Licht Stiegenhaus", "Lamp07"));
+ lichtMap.put(R.id.buttonLicht8, new Licht(androidId, "Licht Obergeschoss", "Lamp08"));
+
+ lichtMap.put(R.id.buttonLicht9, new Licht(androidId, "Licht Schlafzimmer", "Lamp09"));
+ lichtMap.put(R.id.buttonLicht10, new Licht(androidId, "Gartentor", "Lamp10"));
+ lichtMap.put(R.id.buttonLicht11, new Licht(androidId, "Eingangstuer", "Lamp11"));
+ lichtMap.put(R.id.buttonLicht12, new Licht(androidId, "Garagentor", "Lamp12"));
+
+ lichtMap.put(R.id.buttonLicht13, new Licht(androidId, "Nachtkastl Tom", "Lamp13"));
+ lichtMap.put(R.id.buttonLicht14, new Licht(androidId, "vuDuoWZ", "Lamp14"));
+ lichtMap.put(R.id.buttonLicht15, new Licht(androidId, "Glocke", "Lamp15"));
+ lichtMap.put(R.id.buttonLicht16, new Licht(androidId, "vuDuoSZ", "Lamp16"));
+
+ lichtMap.put(R.id.buttonLicht17, new Licht(androidId, "Zirkulationspumpe", "Lamp17"));
+ lichtMap.put(R.id.buttonLicht18, new Licht(androidId, "PC Flo", "Lamp18"));
+ lichtMap.put(R.id.buttonLicht20, new Licht(androidId, "Nachtkastl Flo", "Lamp20"));
+ }
@Override
protected void onPause() {
super.onPause();
- pausedLicht = true;
- Log.d("LichtActivityPause", "true");
}
@Override
protected void onResume() {
super.onResume();
- pausedLicht = false;
- Log.d("LichtActivityPause", "false");
}
@Override
protected void onStop() {
super.onStop();
- pausedLicht = true;
- Log.d("LichtActivityPause", "true");
- }
-}
-
-class Checkboxen {
- @SerializedName("DeviceID")
- private final String deviceId;
- @SerializedName("Name")
- private final String name;
- @SerializedName("Checkbox")
- private final boolean checkbox;
-
- public Checkboxen(String deviceId, String name, boolean checkbox) {
- this.deviceId = deviceId;
- this.name = name;
- this.checkbox = checkbox;
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/haussteuerung/activityLog.java b/app/src/main/java/com/haussteuerung/activityLog.java
index a44d66a..91fe7c3 100644
--- a/app/src/main/java/com/haussteuerung/activityLog.java
+++ b/app/src/main/java/com/haussteuerung/activityLog.java
@@ -4,19 +4,14 @@ import android.os.Bundle;
import android.os.Handler;
import android.widget.TextView;
-import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.content.res.AppCompatResources;
-import androidx.core.graphics.Insets;
-import androidx.core.view.ViewCompat;
-import androidx.core.view.WindowInsetsCompat;
+import androidx.lifecycle.ProcessLifecycleOwner;
import java.util.Timer;
import java.util.TimerTask;
public class activityLog extends AppCompatActivity {
-
- public static boolean pausedLog = true;
private TextView textLog;
final Handler myHandler = new Handler();
final Timer myTimer = new Timer();
@@ -24,13 +19,12 @@ public class activityLog extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ ProcessLifecycleOwner.get().getLifecycle().addObserver(new AppLifecycleTracker());
androidx.appcompat.app.ActionBar actionBar = getSupportActionBar();
assert actionBar != null;
actionBar.setBackgroundDrawable(AppCompatResources.getDrawable(getApplicationContext(), R.color.black));
- pausedLog = false;
-
setContentView(R.layout.activity_log);
setTitle("Haussteuerung - Log");
@@ -47,14 +41,12 @@ public class activityLog extends AppCompatActivity {
@Override
protected void onPause() {
super.onPause();
- pausedLog = true;
myTimer.cancel();
}
@Override
protected void onResume() {
super.onResume();
- pausedLog = false;
TimerTask myTask = new TimerTask() {
public void run() {
myHandler.post(myRunnable); // updateUI method
@@ -66,7 +58,6 @@ public class activityLog extends AppCompatActivity {
@Override
protected void onStop() {
super.onStop();
- pausedLog = true;
myTimer.cancel();
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/haussteuerung/activitySky.java b/app/src/main/java/com/haussteuerung/activitySky.java
index ed22599..49a93f6 100644
--- a/app/src/main/java/com/haussteuerung/activitySky.java
+++ b/app/src/main/java/com/haussteuerung/activitySky.java
@@ -17,6 +17,7 @@ import androidx.core.view.WindowInsetsCompat;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
+import com.haussteuerung.helper.Sky;
import java.time.LocalTime;
import java.util.Locale;
@@ -25,8 +26,8 @@ public class activitySky extends AppCompatActivity {
private Button buttonSkyZeit;
private CheckBox checkSky;
- public static String zeitSky = "", zeitSkyMqtt = "";
- public static boolean isChecked = false, pausedSky = true;
+ public static String zeitSkyMqtt = "";
+ public static boolean isChecked = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -36,8 +37,6 @@ public class activitySky extends AppCompatActivity {
assert actionBar != null;
actionBar.setBackgroundDrawable(AppCompatResources.getDrawable(getApplicationContext(), R.color.black));
- pausedSky = false;
-
setContentView(R.layout.activity_sky);
setTitle("Haussteuerung - Sky");
@@ -48,27 +47,19 @@ public class activitySky extends AppCompatActivity {
buttonSkyZeit.setText(zeitSkyMqtt);
checkSky.setChecked(isChecked);
- buttonSkyZeit.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- timePickerDialog(buttonSkyZeit);
- }
- });
+ buttonSkyZeit.setOnClickListener(v -> timePickerDialog(buttonSkyZeit));
- buttonSkySend.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Gson gson = new Gson();
- String msg;
- if (checkSky.isChecked()) {
- msg = gson.toJson(new Sky(MainActivity.ID, buttonSkyZeit.getText().toString(), true));
- MqttClient.publish("cmnd/Haussteuerung/Sky", msg);
- } else if (!checkSky.isChecked()) {
- msg = gson.toJson(new Sky(MainActivity.ID, buttonSkyZeit.getText().toString(), false));
- MqttClient.publish("cmnd/Haussteuerung/Sky", msg);
- }
- finish();
+ buttonSkySend.setOnClickListener(view -> {
+ Gson gson = new Gson();
+ String msg;
+ if (checkSky.isChecked()) {
+ msg = gson.toJson(new Sky(MainActivity.ID, buttonSkyZeit.getText().toString(), true));
+ MqttClient.publish("cmnd/Haussteuerung/Sky", msg);
+ } else if (!checkSky.isChecked()) {
+ msg = gson.toJson(new Sky(MainActivity.ID, buttonSkyZeit.getText().toString(), false));
+ MqttClient.publish("cmnd/Haussteuerung/Sky", msg);
}
+ finish();
});
Log.d("ActivitySky","Created");
@@ -76,12 +67,7 @@ public class activitySky extends AppCompatActivity {
LocalTime localTime = LocalTime.parse(button.getText());
int hour = localTime.getHour();
int minute = localTime.getMinute();
- TimePickerDialog.OnTimeSetListener onTimeSetListener = new TimePickerDialog.OnTimeSetListener() {
- @Override
- public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
- button.setText(String.format(Locale.getDefault(), "%02d:%02d", selectedHour, selectedMinute));
- }
- };
+ TimePickerDialog.OnTimeSetListener onTimeSetListener = (timePicker, selectedHour, selectedMinute) -> button.setText(String.format(Locale.getDefault(), "%02d:%02d", selectedHour, selectedMinute));
TimePickerDialog timePickerDialog = new TimePickerDialog(this, onTimeSetListener, hour, minute, true);
timePickerDialog.show();
}
@@ -89,39 +75,18 @@ public class activitySky extends AppCompatActivity {
@Override
protected void onPause() {
super.onPause();
- pausedSky = true;
- // Log.d("TimerSkyActivity", "Canceled");
- Log.d("ActivitySky","Paused");
}
@Override
protected void onResume() {
super.onResume();
- pausedSky = false;
buttonSkyZeit.setText(zeitSkyMqtt);
checkSky.setChecked(isChecked);
- Log.d("ActivitySky","Resumed");
}
@Override
protected void onStop() {
super.onStop();
- pausedSky = true;
- Log.d("ActivitySky","Stopped");
}
}
-class Sky {
- @SerializedName("DeviceID")
- private final String deviceId;
- @SerializedName("Datum")
- private final String datum;
- @SerializedName("CheckboxSky")
- private final boolean checkboxSky;
-
- public Sky(String deviceId, String datum, boolean checkboxSky) {
- this.deviceId = deviceId;
- this.datum = datum;
- this.checkboxSky = checkboxSky;
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/haussteuerung/helper/Blutdruck.java b/app/src/main/java/com/haussteuerung/helper/Blutdruck.java
new file mode 100644
index 0000000..ff30f95
--- /dev/null
+++ b/app/src/main/java/com/haussteuerung/helper/Blutdruck.java
@@ -0,0 +1,21 @@
+package com.haussteuerung.helper;
+
+import com.google.gson.annotations.SerializedName;
+
+public class Blutdruck {
+ @SerializedName("DeviceID")
+ private final String deviceId;
+ @SerializedName("Datum")
+ private final String datum;
+ @SerializedName("SYS")
+ private final String sys;
+ @SerializedName("DIA")
+ private final String dia;
+
+ public Blutdruck(String deviceId, String datum, String sys, String dia) {
+ this.deviceId = deviceId;
+ this.datum = datum;
+ this.sys = sys;
+ this.dia = dia;
+ }
+}
diff --git a/app/src/main/java/com/haussteuerung/helper/Checkboxen.java b/app/src/main/java/com/haussteuerung/helper/Checkboxen.java
new file mode 100644
index 0000000..28910ba
--- /dev/null
+++ b/app/src/main/java/com/haussteuerung/helper/Checkboxen.java
@@ -0,0 +1,18 @@
+package com.haussteuerung.helper;
+
+import com.google.gson.annotations.SerializedName;
+
+public class Checkboxen {
+ @SerializedName("DeviceID")
+ private final String deviceId;
+ @SerializedName("Name")
+ private final String name;
+ @SerializedName("Checkbox")
+ private final boolean checkbox;
+
+ public Checkboxen(String deviceId, String name, boolean checkbox) {
+ this.deviceId = deviceId;
+ this.name = name;
+ this.checkbox = checkbox;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/haussteuerung/Licht.java b/app/src/main/java/com/haussteuerung/helper/Licht.java
similarity index 92%
rename from app/src/main/java/com/haussteuerung/Licht.java
rename to app/src/main/java/com/haussteuerung/helper/Licht.java
index 570ed3e..b93d613 100644
--- a/app/src/main/java/com/haussteuerung/Licht.java
+++ b/app/src/main/java/com/haussteuerung/helper/Licht.java
@@ -1,4 +1,4 @@
-package com.haussteuerung;
+package com.haussteuerung.helper;
import com.google.gson.annotations.SerializedName;
diff --git a/app/src/main/java/com/haussteuerung/helper/Rollo.java b/app/src/main/java/com/haussteuerung/helper/Rollo.java
new file mode 100644
index 0000000..ccd17de
--- /dev/null
+++ b/app/src/main/java/com/haussteuerung/helper/Rollo.java
@@ -0,0 +1,21 @@
+package com.haussteuerung.helper;
+
+import com.google.gson.annotations.SerializedName;
+
+public class Rollo {
+ @SerializedName("DeviceID")
+ private final String deviceId;
+ @SerializedName("Name")
+ private final String name;
+ @SerializedName("Device")
+ private final String device;
+ @SerializedName("Shutterposition")
+ private final int shutterposition;
+
+ public Rollo(String deviceId, String name, String device, int shutterposition) {
+ this.deviceId = deviceId;
+ this.name = name;
+ this.device = device;
+ this.shutterposition = shutterposition;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/haussteuerung/helper/Sky.java b/app/src/main/java/com/haussteuerung/helper/Sky.java
new file mode 100644
index 0000000..5cb50d8
--- /dev/null
+++ b/app/src/main/java/com/haussteuerung/helper/Sky.java
@@ -0,0 +1,18 @@
+package com.haussteuerung.helper;
+
+import com.google.gson.annotations.SerializedName;
+
+public class Sky {
+ @SerializedName("DeviceID")
+ private final String deviceId;
+ @SerializedName("Datum")
+ private final String datum;
+ @SerializedName("CheckboxSky")
+ private final boolean checkboxSky;
+
+ public Sky(String deviceId, String datum, boolean checkboxSky) {
+ this.deviceId = deviceId;
+ this.datum = datum;
+ this.checkboxSky = checkboxSky;
+ }
+}
diff --git a/app/src/main/java/com/haussteuerung/helper/Temperatur.java b/app/src/main/java/com/haussteuerung/helper/Temperatur.java
new file mode 100644
index 0000000..da9960a
--- /dev/null
+++ b/app/src/main/java/com/haussteuerung/helper/Temperatur.java
@@ -0,0 +1,19 @@
+package com.haussteuerung.helper;
+
+import com.google.gson.annotations.SerializedName;
+
+public class Temperatur {
+ @SerializedName("DeviceID")
+ private final String deviceId;
+ @SerializedName("Datum")
+ private final String datum;
+ @SerializedName("Temperatur")
+ private final String temperatur;
+
+
+ public Temperatur(String deviceId, String datum, String temperatur) {
+ this.deviceId = deviceId;
+ this.datum = datum;
+ this.temperatur = temperatur;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/haussteuerung/noConnection.java b/app/src/main/java/com/haussteuerung/noConnection.java
deleted file mode 100644
index 58c0d2a..0000000
--- a/app/src/main/java/com/haussteuerung/noConnection.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.haussteuerung;
-
-import android.os.Bundle;
-
-import androidx.activity.EdgeToEdge;
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.core.graphics.Insets;
-import androidx.core.view.ViewCompat;
-import androidx.core.view.WindowInsetsCompat;
-
-public class noConnection extends AppCompatActivity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- EdgeToEdge.enable(this);
- setContentView(R.layout.activity_no_connection);
- ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.activityChristmas), (v, insets) -> {
- Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
- v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
- return insets;
- });
- }
-}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_christmas.xml b/app/src/main/res/layout/activity_christmas.xml
deleted file mode 100644
index fb454a6..0000000
--- a/app/src/main/res/layout/activity_christmas.xml
+++ /dev/null
@@ -1,134 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_file_download.xml b/app/src/main/res/layout/activity_file_download.xml
deleted file mode 100644
index 4893604..0000000
--- a/app/src/main/res/layout/activity_file_download.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_no_connection.xml b/app/src/main/res/layout/activity_no_connection.xml
deleted file mode 100644
index c5ded9d..0000000
--- a/app/src/main/res/layout/activity_no_connection.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 983666a..abe4cd0 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -101,7 +101,7 @@
Boiler\nUnten
38°
44°
- Version 25.531.1
+ Version 25.1006.1
Früh
+2h
Nacht
diff --git a/gradle.properties b/gradle.properties
index 00d252e..5b1c3e4 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -15,6 +15,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
+android.enableJetifier=true
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index f5528d7..08decce 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,18 +1,19 @@
[versions]
agp = "8.3.2"
junit = "4.13.2"
-junitVersion = "1.1.5"
-espressoCore = "3.5.1"
-appcompat = "1.6.1"
+junitVersion = "1.3.0"
+espressoCore = "3.7.0"
+appcompat = "1.7.1"
material = "1.11.0"
pahoMqttv3 = "1.2.5"
pahoMqttService = "1.1.1"
-googleServices = "4.4.1"
-firebaseMessaging = "23.4.1"
+googleServices = "4.4.3"
+firebaseMessaging = "25.0.1"
touchImageView = "3.2.0"
gson = "2.10.1"
activity = "1.9.0"
-constraintlayout = "2.1.4"
+constraintlayout = "2.2.1"
+lifecycleRuntime = "2.9.4"
[libraries]
junit = { group = "junit", name = "junit", version.ref = "junit" }
@@ -28,6 +29,8 @@ touchImageView = { group = "com.github.MikeOrtiz", name = "TouchImageView", vers
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
+lifecycle-process = { module = "androidx.lifecycle:lifecycle-process", version.ref = "lifecycleRuntime" }
+lifecycle-runtime = { module = "androidx.lifecycle:lifecycle-runtime", version.ref = "lifecycleRuntime" }
[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }