From 01ef2476ad6762ee91b00a49bb4fdbf131d7fca2 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Tue, 6 Nov 2018 11:22:45 -0600 Subject: [PATCH] One location per task --- .../java/org/tasks/ui/LocationControlSet.java | 32 ++++++++++--------- .../main/res/layout/control_set_locations.xml | 1 + app/src/main/res/layout/location_details.xml | 4 +-- app/src/main/res/layout/location_row.xml | 2 -- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/org/tasks/ui/LocationControlSet.java b/app/src/main/java/org/tasks/ui/LocationControlSet.java index 6a69202ea..f9d92ffe0 100644 --- a/app/src/main/java/org/tasks/ui/LocationControlSet.java +++ b/app/src/main/java/org/tasks/ui/LocationControlSet.java @@ -28,6 +28,7 @@ import com.google.common.base.Strings; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.data.Task; import java.util.ArrayList; +import java.util.Collection; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -65,6 +66,9 @@ public class LocationControlSet extends TaskEditControlFragment { @BindView(R.id.alert_container) LinearLayout alertContainer; + @BindView(R.id.alarms_add) + View addLocation; + private long taskId; @Nullable @@ -110,10 +114,17 @@ public class LocationControlSet extends TaskEditControlFragment { return TAG; } - private void setup(Iterable locations) { - alertContainer.removeAllViews(); - for (Location location : locations) { - addGeolocationReminder(location); + private void setup(Collection locations) { + if (locations.isEmpty()) { + alertContainer.setVisibility(View.GONE); + addLocation.setVisibility(View.VISIBLE); + } else { + addLocation.setVisibility(View.GONE); + alertContainer.setVisibility(View.VISIBLE); + alertContainer.removeAllViews(); + for (Location location : locations) { + addGeolocationReminder(location); + } } } @@ -145,7 +156,8 @@ public class LocationControlSet extends TaskEditControlFragment { preferences.getIntegerFromString(R.string.p_default_location_reminder_key, 1); place.setArrival(defaultReminders == 1 || defaultReminders == 3); place.setDeparture(defaultReminders == 2 || defaultReminders == 3); - addGeolocationReminder(place); + locations.add(place); + setup(locations); } } else if (requestCode == REQUEST_LOCATION_DETAILS) { if (resultCode == Activity.RESULT_OK) { @@ -183,18 +195,8 @@ public class LocationControlSet extends TaskEditControlFragment { } private void addGeolocationReminder(final Location location) { - addAlarmRow(location); - locations.add(location); - } - - private View addAlarmRow(Location location) { final View alertItem = getActivity().getLayoutInflater().inflate(R.layout.location_row, null); alertContainer.addView(alertItem); - addAlarmRow(alertItem, location); - return alertItem; - } - - private void addAlarmRow(View alertItem, Location location) { String name = location.getDisplayName(); String address = location.getAddress(); if (!Strings.isNullOrEmpty(address) && !address.equals(name)) { diff --git a/app/src/main/res/layout/control_set_locations.xml b/app/src/main/res/layout/control_set_locations.xml index 2ea84da76..34f70e4ee 100644 --- a/app/src/main/res/layout/control_set_locations.xml +++ b/app/src/main/res/layout/control_set_locations.xml @@ -17,6 +17,7 @@ diff --git a/app/src/main/res/layout/location_details.xml b/app/src/main/res/layout/location_details.xml index 5674cd90f..46b920a72 100644 --- a/app/src/main/res/layout/location_details.xml +++ b/app/src/main/res/layout/location_details.xml @@ -67,9 +67,9 @@ android:layout_width="match_parent" android:layout_height="?android:attr/listPreferredItemHeightSmall" android:paddingStart="@dimen/keyline_second" - android:paddingEnd="@dimen/keyline_second" + android:paddingEnd="@dimen/keyline_first" android:paddingLeft="@dimen/keyline_second" - android:paddingRight="@dimen/keyline_second"> + android:paddingRight="@dimen/keyline_first">