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">