Added feature to send notes to Nightscout in Activity Doris.
This commit is contained in:
@@ -12,7 +12,7 @@ android {
|
||||
minSdk 26
|
||||
targetSdk 34
|
||||
versionCode 1
|
||||
versionName "25.1011.1"
|
||||
versionName "25.1017.1"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
@@ -13,7 +14,6 @@ import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.lifecycle.ProcessLifecycleOwner;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.haussteuerung.helper.Blutdruck;
|
||||
import com.haussteuerung.helper.Temperatur;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@@ -22,13 +22,11 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.Locale;
|
||||
|
||||
public class activityDoris extends AppCompatActivity {
|
||||
Button buttonSend, zeitBlutdruck, zeitFiebertemp;
|
||||
int hourBlutdruck = 0, minuteBlutdruck = 0, hourFiebertemp = 0, minuteFiebertemp = 0;
|
||||
static String werteBlutdruck = "";
|
||||
TextView textSYS, textDIA, textFiebertemp;
|
||||
Button buttonSend, buttonTablette, buttonSendEssen, zeitFiebertemp;
|
||||
int hourFiebertemp = 0, minuteFiebertemp = 0;
|
||||
TextView textFiebertemp;
|
||||
LocalDateTime datetime = LocalDateTime.now();
|
||||
DateTimeFormatter dateTimeFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
String formattedDate = datetime.format(dateTimeFormat);
|
||||
Gson gson = new Gson();
|
||||
String msg;
|
||||
|
||||
@@ -46,34 +44,28 @@ public class activityDoris extends AppCompatActivity {
|
||||
|
||||
buttonSend = findViewById(R.id.buttonSend);
|
||||
|
||||
// Blutdruck ---------------------------------------
|
||||
zeitBlutdruck = findViewById(R.id.zeitBlutdruck);
|
||||
CheckBox checkBlutdruck = findViewById(R.id.checkBlutdruck);
|
||||
textSYS = findViewById(R.id.textSYS);
|
||||
textDIA = findViewById(R.id.textDIA);
|
||||
TextView tv_SYS = findViewById(R.id.tvSYS);
|
||||
TextView tv_DIA = findViewById(R.id.tvDIA);
|
||||
hourBlutdruck = datetime.getHour();
|
||||
minuteBlutdruck = datetime.getMinute();
|
||||
zeitBlutdruck.setText(String.format(Locale.getDefault(), "%02d:%02d", datetime.getHour(), datetime.getMinute()));
|
||||
zeitBlutdruck.setOnClickListener(v -> timePickerDialog(zeitBlutdruck));
|
||||
// Tablette + Essen -------------------------------
|
||||
buttonTablette = findViewById(R.id.buttonTablette);
|
||||
buttonSendEssen = findViewById(R.id.buttonSendEssen);
|
||||
RadioButton doris_fruehstueck = findViewById(R.id.doris_fruehstueck);
|
||||
RadioButton doris_mittagessen = findViewById(R.id.doris_mittagessen);
|
||||
RadioButton doris_abendessen = findViewById(R.id.doris_abendessen);
|
||||
|
||||
checkBlutdruck.setOnClickListener(view -> {
|
||||
if (checkBlutdruck.isChecked()) {
|
||||
zeitBlutdruck.setEnabled(true);
|
||||
tv_SYS.setEnabled(true);
|
||||
tv_DIA.setEnabled(true);
|
||||
textSYS.setEnabled(true);
|
||||
textDIA.setEnabled(true);
|
||||
} else {
|
||||
zeitBlutdruck.setEnabled(false);
|
||||
tv_SYS.setEnabled(false);
|
||||
tv_DIA.setEnabled(false);
|
||||
textSYS.setEnabled(false);
|
||||
textDIA.setEnabled(false);
|
||||
}
|
||||
buttonTablette.setOnClickListener(view -> {
|
||||
MqttClient.publish("cmnd/Haussteuerung/Doris/Tabletten", "Tablette");
|
||||
});
|
||||
|
||||
buttonSendEssen.setOnClickListener(view -> {
|
||||
if (doris_fruehstueck.isChecked()) {
|
||||
MqttClient.publish("cmnd/Haussteuerung/Doris/Tabletten", "Frühstück");
|
||||
} else if (doris_mittagessen.isChecked()) {
|
||||
MqttClient.publish("cmnd/Haussteuerung/Doris/Tabletten", "Mittagessen");
|
||||
} else if (doris_abendessen.isChecked()) {
|
||||
MqttClient.publish("cmnd/Haussteuerung/Doris/Tabletten", "Abendessen");
|
||||
} else {
|
||||
Toast.makeText(activityDoris.this, "Bitte eine Mahlzeit auswählen.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
// Fiebertemperatur --------------------------------
|
||||
zeitFiebertemp = findViewById(R.id.zeitFiebertemp);
|
||||
@@ -98,21 +90,7 @@ public class activityDoris extends AppCompatActivity {
|
||||
});
|
||||
|
||||
// Send-Button -------------------------------------
|
||||
|
||||
buttonSend.setOnClickListener(view -> {
|
||||
boolean setBlutdruck = false;
|
||||
if (checkBlutdruck.isChecked() && (textSYS.getText().length() == 0 || textDIA.getText().length() == 0)) {
|
||||
Toast.makeText(activityDoris.this, "Bitte alle Blutdruck-Werte ausfüllen!", Toast.LENGTH_LONG).show();
|
||||
} else if (checkBlutdruck.isChecked() && (textSYS.getText().length() > 0 || textDIA.getText().length() > 0)) {
|
||||
String hour = Integer.toString(hourBlutdruck);
|
||||
String minute = Integer.toString(minuteBlutdruck);
|
||||
String sys = textSYS.getText().toString();
|
||||
String dia = textDIA.getText().toString();
|
||||
msg = gson.toJson(new Blutdruck(MainActivity.ID, formattedDate + " " + hour + ":" + minute + ":00", sys, dia));
|
||||
MqttClient.publish("cmnd/Haussteuerung/Doris/Blutdruck", msg);
|
||||
setBlutdruck = true;
|
||||
}
|
||||
|
||||
boolean setFiebertemp = false;
|
||||
if (checkFiebertemp.isChecked() && (textFiebertemp.getText().length() == 0)) {
|
||||
Toast.makeText(activityDoris.this, "Bitte einen Temperaturwert eingeben!", Toast.LENGTH_LONG).show();
|
||||
@@ -126,7 +104,7 @@ public class activityDoris extends AppCompatActivity {
|
||||
Log.d("Doris", msg);
|
||||
setFiebertemp = true;
|
||||
}
|
||||
if (setBlutdruck || setFiebertemp) {
|
||||
if (setFiebertemp) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -23,105 +23,79 @@
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/checkBlutdruck"
|
||||
<RadioGroup
|
||||
android:id="@+id/radiogroupEssen"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="90dp"
|
||||
android:layout_height="195dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginTop="7dp"
|
||||
android:text="@string/blutdruck"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="23sp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/zeitBlutdruck"
|
||||
app:layout_constraintEnd_toStartOf="@+id/buttonTablette"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/doris_fruehstueck"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:text="@string/fruehstueck"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/doris_mittagessen"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/mittagessen"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/doris_abendessen"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/abendessen"
|
||||
android:textSize="20sp" />
|
||||
</RadioGroup>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/zeitBlutdruck"
|
||||
android:id="@+id/buttonTablette"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="90dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:background="@drawable/button_ww"
|
||||
android:enabled="false"
|
||||
android:background="@drawable/button_text_color"
|
||||
android:enabled="true"
|
||||
android:text="Tablette"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="30sp"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/checkBlutdruck"
|
||||
app:layout_constraintStart_toEndOf="@+id/radiogroupEssen"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="DuplicateSpeakableTextCheck,SpeakableTextPresentCheck" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSYS"
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/buttonSendEssen"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginTop="35dp"
|
||||
android:enabled="false"
|
||||
android:gravity="center"
|
||||
android:text="@string/sys"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="28sp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textSYS"
|
||||
app:layout_constraintHorizontal_chainStyle="packed"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/checkBlutdruck" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/textSYS"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_marginTop="25dp"
|
||||
android:autofillHints="120"
|
||||
android:backgroundTint="@color/dark_grey"
|
||||
android:ems="10"
|
||||
android:enabled="false"
|
||||
android:hint="@string/_120"
|
||||
android:inputType="phone"
|
||||
android:textColor="@color/black"
|
||||
android:textColorHint="@color/dark_grey"
|
||||
android:textSize="30sp"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tvDIA"
|
||||
app:layout_constraintStart_toEndOf="@+id/tvSYS"
|
||||
app:layout_constraintTop_toBottomOf="@+id/checkBlutdruck"
|
||||
tools:ignore="TextContrastCheck,DuplicateSpeakableTextCheck" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvDIA"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_marginTop="35dp"
|
||||
android:enabled="false"
|
||||
android:gravity="center"
|
||||
android:text="@string/dia"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="28sp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/textDIA"
|
||||
app:layout_constraintStart_toEndOf="@+id/textSYS"
|
||||
app:layout_constraintTop_toBottomOf="@+id/checkBlutdruck" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/textDIA"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_marginTop="25dp"
|
||||
android:layout_height="90dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:autofillHints="80"
|
||||
android:backgroundTint="@color/dark_grey"
|
||||
android:ems="10"
|
||||
android:enabled="false"
|
||||
android:hint="@string/_80"
|
||||
android:inputType="phone"
|
||||
android:textColor="@color/black"
|
||||
android:textColorHint="@color/dark_grey"
|
||||
android:textSize="30sp"
|
||||
android:background="@drawable/button_text_color"
|
||||
android:enabled="true"
|
||||
android:textColor="@color/white"
|
||||
android:text="@string/absenden"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/tvDIA"
|
||||
app:layout_constraintTop_toBottomOf="@+id/zeitBlutdruck"
|
||||
tools:ignore="TextContrastCheck" />
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toEndOf="@+id/radiogroupEssen"
|
||||
app:layout_constraintTop_toBottomOf="@+id/buttonTablette"
|
||||
tools:ignore="DuplicateSpeakableTextCheck,SpeakableTextPresentCheck" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
|
||||
@@ -148,4 +148,7 @@
|
||||
<string name="growatt_ein">Growatt ein.</string>
|
||||
<string name="growatt_aus">Growatt aus.</string>
|
||||
<string name="pc_flo">PC Flo</string>
|
||||
<string name="fruehstueck">Frühstück</string>
|
||||
<string name="mittagessen">Mittagessen</string>
|
||||
<string name="abendessen">Abendessen</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user