Added Snack option radio button and Toast notifications in Activity Doris.
This commit is contained in:
@@ -12,7 +12,7 @@ android {
|
||||
minSdk 26
|
||||
targetSdk 34
|
||||
versionCode 1
|
||||
versionName "25.1017.1"
|
||||
versionName "25.1018.1"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -12,7 +12,7 @@
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 1,
|
||||
"versionName": "25.1017.1",
|
||||
"versionName": "25.1018.1",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
],
|
||||
|
||||
@@ -22,13 +22,8 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.Locale;
|
||||
|
||||
public class activityDoris extends AppCompatActivity {
|
||||
Button buttonSend, buttonTablette, buttonSendEssen, zeitFiebertemp;
|
||||
int hourFiebertemp = 0, minuteFiebertemp = 0;
|
||||
TextView textFiebertemp;
|
||||
LocalDateTime datetime = LocalDateTime.now();
|
||||
DateTimeFormatter dateTimeFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
Gson gson = new Gson();
|
||||
String msg;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -42,38 +37,49 @@ public class activityDoris extends AppCompatActivity {
|
||||
setContentView(R.layout.activity_doris);
|
||||
setTitle("Haussteuerung - Doris");
|
||||
|
||||
buttonSend = findViewById(R.id.buttonSend);
|
||||
LocalDateTime datetime = LocalDateTime.now();
|
||||
DateTimeFormatter dateTimeFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
|
||||
// Tablette + Essen -------------------------------
|
||||
buttonTablette = findViewById(R.id.buttonTablette);
|
||||
buttonSendEssen = findViewById(R.id.buttonSendEssen);
|
||||
Button buttonTablette = findViewById(R.id.buttonTablette);
|
||||
Button 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);
|
||||
RadioButton doris_snack = findViewById(R.id.doris_snack);
|
||||
|
||||
buttonTablette.setOnClickListener(view -> {
|
||||
MqttClient.publish("cmnd/Haussteuerung/Doris/Tabletten", "Tablette");
|
||||
Toast.makeText(activityDoris.this, "Tablette genommen. Gespeichert!", Toast.LENGTH_LONG).show();
|
||||
});
|
||||
|
||||
buttonSendEssen.setOnClickListener(view -> {
|
||||
if (doris_fruehstueck.isChecked()) {
|
||||
MqttClient.publish("cmnd/Haussteuerung/Doris/Tabletten", "Frühstück");
|
||||
Toast.makeText(activityDoris.this, "Frühstück. Gespeichert!", Toast.LENGTH_LONG).show();
|
||||
} else if (doris_mittagessen.isChecked()) {
|
||||
MqttClient.publish("cmnd/Haussteuerung/Doris/Tabletten", "Mittagessen");
|
||||
Toast.makeText(activityDoris.this, "Mittagessen. Gespeichert!", Toast.LENGTH_LONG).show();
|
||||
} else if (doris_abendessen.isChecked()) {
|
||||
MqttClient.publish("cmnd/Haussteuerung/Doris/Tabletten", "Abendessen");
|
||||
Toast.makeText(activityDoris.this, "Abendessen. Gespeichert!", Toast.LENGTH_LONG).show();
|
||||
} else if (doris_snack.isChecked()) {
|
||||
MqttClient.publish("cmnd/Haussteuerung/Doris/Tabletten", "Snack");
|
||||
Toast.makeText(activityDoris.this, "Snack. Gespeichert!", Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(activityDoris.this, "Bitte eine Mahlzeit auswählen.", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
// Fiebertemperatur --------------------------------
|
||||
zeitFiebertemp = findViewById(R.id.zeitFiebertemp);
|
||||
Button zeitFiebertemp = findViewById(R.id.zeitFiebertemp);
|
||||
CheckBox checkFiebertemp = findViewById(R.id.checkFiebertemp);
|
||||
TextView tvFiebertemp = findViewById(R.id.tvFiebertemp);
|
||||
textFiebertemp = findViewById(R.id.textFiebertemp);
|
||||
hourFiebertemp = datetime.getHour();
|
||||
minuteFiebertemp = datetime.getMinute();
|
||||
TextView textFiebertemp = findViewById(R.id.textFiebertemp);
|
||||
|
||||
int hourFiebertemp = datetime.getHour();
|
||||
int minuteFiebertemp = datetime.getMinute();
|
||||
|
||||
zeitFiebertemp.setText(String.format(Locale.getDefault(), "%02d:%02d", datetime.getHour(), datetime.getMinute()));
|
||||
zeitFiebertemp.setOnClickListener(v -> timePickerDialog(zeitFiebertemp));
|
||||
|
||||
@@ -90,6 +96,7 @@ public class activityDoris extends AppCompatActivity {
|
||||
});
|
||||
|
||||
// Send-Button -------------------------------------
|
||||
Button buttonSend = findViewById(R.id.buttonSend);
|
||||
buttonSend.setOnClickListener(view -> {
|
||||
boolean setFiebertemp = false;
|
||||
if (checkFiebertemp.isChecked() && (textFiebertemp.getText().length() == 0)) {
|
||||
@@ -99,9 +106,12 @@ public class activityDoris extends AppCompatActivity {
|
||||
String hour = Integer.toString(hourFiebertemp);
|
||||
String minute = Integer.toString(minuteFiebertemp);
|
||||
String fiebertemp = textFiebertemp.getText().toString();
|
||||
msg = gson.toJson(new Temperatur(MainActivity.ID, formattedDate + " " + hour + ":" + minute + ":00", fiebertemp));
|
||||
|
||||
Gson gson = new Gson();
|
||||
String msg = gson.toJson(new Temperatur(MainActivity.ID, formattedDate + " " + hour + ":" + minute + ":00", fiebertemp));
|
||||
|
||||
MqttClient.publish("cmnd/Haussteuerung/Doris/Temperatur", msg);
|
||||
Log.d("Doris", msg);
|
||||
|
||||
setFiebertemp = true;
|
||||
}
|
||||
if (setFiebertemp) {
|
||||
|
||||
@@ -41,32 +41,40 @@
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/doris_fruehstueck"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:text="@string/fruehstueck"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/doris_mittagessen"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:text="@string/mittagessen"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/doris_abendessen"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:text="@string/abendessen"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/doris_snack"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="0dp"
|
||||
android:text="@string/snack"
|
||||
android:textSize="20sp" />
|
||||
</RadioGroup>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/buttonTablette"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="90dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:background="@drawable/button_text_color"
|
||||
@@ -82,7 +90,7 @@
|
||||
<androidx.appcompat.widget.AppCompatButton
|
||||
android:id="@+id/buttonSendEssen"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="90dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:background="@drawable/button_text_color"
|
||||
android:enabled="true"
|
||||
|
||||
@@ -151,4 +151,5 @@
|
||||
<string name="fruehstueck">Frühstück</string>
|
||||
<string name="mittagessen">Mittagessen</string>
|
||||
<string name="abendessen">Abendessen</string>
|
||||
<string name="snack">Snack</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user