From 601dd7e75b2658dee05f0552321e5075fc4b8e2c Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Sat, 10 Feb 2018 07:00:20 +0100 Subject: [PATCH 1/4] Discard changes when aborting edit --- .../com/health/openscale/gui/activities/DataEntryActivity.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java b/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java index ef9288eb..c6612694 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java @@ -267,6 +267,9 @@ public class DataEntryActivity extends AppCompatActivity { public void onBackPressed() { if (measurementViewMode == MeasurementView.MeasurementViewMode.EDIT) { setViewMode(MeasurementView.MeasurementViewMode.VIEW); + if (isDirty) { + scaleMeasurement = null; + } updateOnView(); } else { From 24966672506bb257d95cfd59f613f52ed9234b2e Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Sat, 10 Feb 2018 07:04:23 +0100 Subject: [PATCH 2/4] Compare id instead of item string --- .../openscale/gui/activities/DataEntryActivity.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java b/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java index c6612694..1704d24c 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java @@ -191,15 +191,13 @@ public class DataEntryActivity extends AppCompatActivity { final Drawable wrapped = DrawableCompat.wrap(drawable.mutate()); - String menuTitle = item.getTitle().toString(); - - if (menuTitle == getResources().getString(R.string.save)) { + if (item.getItemId() == R.id.saveButton) { DrawableCompat.setTint(wrapped, Color.parseColor("#FFFFFF")); - } else if (menuTitle == getResources().getString(R.string.edit)) { + } else if (item.getItemId() == R.id.editButton) { DrawableCompat.setTint(wrapped, Color.parseColor("#99CC00")); - } else if (menuTitle == getResources().getString(R.string.toggle_expand)) { + } else if (item.getItemId() == R.id.expandButton) { DrawableCompat.setTint(wrapped, Color.parseColor("#FFBB33")); - } else if (menuTitle == getResources().getString(R.string.label_delete)) { + } else if (item.getItemId() == R.id.deleteButton) { DrawableCompat.setTint(wrapped, Color.parseColor("#FF4444")); } From 9c0573dc5cb486ab641cacdf735f3fbbe4513499 Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Sat, 10 Feb 2018 07:07:54 +0100 Subject: [PATCH 3/4] Don't enable left/right button if at start/end --- .../health/openscale/gui/activities/DataEntryActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java b/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java index 1704d24c..10f2c512 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java @@ -345,8 +345,8 @@ public class DataEntryActivity extends AppCompatActivity { btnLeft.setVisibility(View.VISIBLE); btnRight.setVisibility(View.VISIBLE); - btnLeft.setEnabled(true); - btnRight.setEnabled(true); + btnLeft.setEnabled(previousMeasurement != null); + btnRight.setEnabled(nextMeasurement != null); dateTimeVisibility = View.GONE; break; From 735e6bf8c3b0ca2f3f1d87e52f53bb8944e64513 Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Sat, 10 Feb 2018 07:11:20 +0100 Subject: [PATCH 4/4] Avoid having left/right buttons jump back and forth Set a min width so that once it has grown it can't get smaller again. --- .../com/health/openscale/gui/activities/DataEntryActivity.java | 1 + 1 file changed, 1 insertion(+) diff --git a/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java b/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java index 10f2c512..d4e3a475 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/activities/DataEntryActivity.java @@ -328,6 +328,7 @@ public class DataEntryActivity extends AppCompatActivity { measurement.loadFrom(scaleMeasurement, previousMeasurement); } + txtDataNr.setMinWidth(txtDataNr.getWidth()); txtDataNr.setText(DateFormat.getDateTimeInstance( DateFormat.LONG, DateFormat.SHORT).format(scaleMeasurement.getDateTime())); }