diff --git a/app/src/main/java/org/zephyrsoft/trackworktime/editevent/EventEditActivity.java b/app/src/main/java/org/zephyrsoft/trackworktime/editevent/EventEditActivity.java
index d28f8e1d..85430cf8 100644
--- a/app/src/main/java/org/zephyrsoft/trackworktime/editevent/EventEditActivity.java
+++ b/app/src/main/java/org/zephyrsoft/trackworktime/editevent/EventEditActivity.java
@@ -143,12 +143,15 @@ protected void onCreate(Bundle savedInstanceState) {
OffsetDateTime startDateTime = getCurrentlySetDateTime();
OffsetDateTime endDateTime = getCurrentlySetEndDateTime();
if (startDateTime == null || endDateTime == null) {
- // TODO: Would be better to disable save button, if date/time is not selected
showMsgDateTimeNotSelected();
return;
}
Task selectedTask = (Task) task.getSelectedItem();
+ if (selectedTask == null) {
+ showMsgTaskNotSelected();
+ return;
+ }
Integer taskId = selectedTask.getId();
String textString = text.getText().toString();
@@ -161,15 +164,17 @@ protected void onCreate(Bundle savedInstanceState) {
OffsetDateTime dateTime = getCurrentlySetDateTime();
if (dateTime == null) {
- // TODO: Would be better to disable save button, if date/time is not selected
showMsgDateTimeNotSelected();
return;
}
Task selectedTask = (Task) task.getSelectedItem();
- Integer taskId = ((typeEnum == TypeEnum.CLOCK_OUT || selectedTask == null) ? null :
- selectedTask.getId());
- String textString = (typeEnum == TypeEnum.CLOCK_OUT ? null : text.getText().toString());
+ if (typeEnum == TypeEnum.CLOCK_IN && selectedTask == null) {
+ showMsgTaskNotSelected();
+ return;
+ }
+ Integer taskId = (typeEnum != TypeEnum.CLOCK_IN ? null : selectedTask.getId());
+ String textString = (typeEnum != TypeEnum.CLOCK_IN ? null : text.getText().toString());
if (newEvent) {
Logger.debug("saving new event: {} @ {}", typeEnum.name(), dateTime);
@@ -401,4 +406,8 @@ private void showMsgDateTimeNotSelected() {
Toast.makeText(this, R.string.errorDateOrTimeNotSelected, Toast.LENGTH_LONG).show();
}
+ private void showMsgTaskNotSelected() {
+ Toast.makeText(this, R.string.errorTaskNotSelected, Toast.LENGTH_LONG).show();
+ }
+
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 7c41c73a..60f16fa7 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -237,6 +237,7 @@
Storage Permission
It\'s recommended to let this app write a daily backup of your data to your device or to your SD card (if present).\n\nIf you want that, please allow it in the following dialog.\n\nIf you don\'t see any permission dialog, please just wait some minutes (Android imposes a rate limit on permission requests) or manually grant the permission in Android\'s settings for this app.
Date or time not selected
+ No task selected
Storage Permission
This app needs a little space on your device to save a daily backup of your data and the reports you generate.\n\nPlease choose a directory in the following dialog, e.g. \"Documents\". Of course, you\'re also welcome to create a custom directory.\n\nIf you don\'t want that now, no daily backups will be created and you can\'t generate any reports (you\'ll be asked again if you try).
This feature needs to access your device\'s storage.\n\nPlease choose a directory in the following dialog, e.g. \"Documents\". Of course, you\'re also welcome to create a custom directory.\n\nIf you don\'t want that now, the feature will not be available.