One location per task

pull/757/head
Alex Baker 6 years ago
parent b405e87b49
commit 01ef2476ad

@ -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,12 +114,19 @@ public class LocationControlSet extends TaskEditControlFragment {
return TAG;
}
private void setup(Iterable<Location> locations) {
private void setup(Collection<Location> 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);
}
}
}
@Override
public boolean hasChanges(Task original) {
@ -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)) {

@ -17,6 +17,7 @@
<TextView
android:id="@+id/alarms_add"
style="@style/TaskEditTextPrimary"
android:background="?attr/selectableItemBackgroundBorderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/add_location"/>

@ -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">
<TextView
android:id="@+id/location_radius_value"

@ -2,8 +2,6 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/task_edit_double_padding_top_bottom"
android:paddingBottom="@dimen/task_edit_double_padding_top_bottom"
android:baselineAligned="false"
android:orientation="horizontal">

Loading…
Cancel
Save