Skip to content

Commit

Permalink
Merge pull request #1118 from matkoniecz/unsigned_opening_hours
Browse files Browse the repository at this point in the history
allow marking objects as without opening hours sign [prepare for a tag replacement]
  • Loading branch information
westnordost authored Aug 15, 2018
2 parents 616e93d + b17950a commit d11226e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public void testNoTimes()
{
bundle.putBoolean(AddCollectionTimesForm.NO_TIMES_SPECIFIED, true);
verify(
new StringMapEntryAdd("note:collection_times","no times specified on the box"));
new StringMapEntryAdd("collection_times:signed","no"));
}

public void testTimes()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class AddOpeningHours extends SimpleOverpassQuestType
" tourism = information and information = office or" +
" leisure ~ " + TextUtils.join("|",leisures) + " or" +
" office ~ " + TextUtils.join("|",offices) + ")" +
" and !opening_hours and name" +
" and !opening_hours and name and opening_hours:signed != no" +
" and (access !~ private|no)"; // exclude ones without access to general public
}

Expand All @@ -67,6 +67,11 @@ public class AddOpeningHours extends SimpleOverpassQuestType
@Override public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes)
{
String openingHours = answer.getString(AddOpeningHoursForm.OPENING_HOURS);
if(answer.getBoolean(AddOpeningHoursForm.NO_SIGN))
{
changes.add("opening_hours:signed", "no");
return;
}
if(openingHours != null)
{
changes.add("opening_hours", openingHours);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -31,6 +30,7 @@
public class AddOpeningHoursForm extends AbstractQuestFormAnswerFragment
{
public static final String OPENING_HOURS = "opening_hours";
public static final String NO_SIGN = "no_sign";

private static final String OPENING_HOURS_DATA = "oh_data",
IS_ADD_MONTHS_MODE = "oh_add_months";
Expand Down Expand Up @@ -84,6 +84,7 @@ private void initOpeningHoursAdapter(View contentView, Bundle savedInstanceState

private void addOtherAnswers()
{
addOtherAnswer(R.string.quest_openingHours_no_sign, this::confirmNoSign);
addOtherAnswer(R.string.quest_openingHours_answer_no_regular_opening_hours, this::showInputCommentDialog);
addOtherAnswer(R.string.quest_openingHours_answer_247, this::showConfirm24_7Dialog);
addOtherAnswer(R.string.quest_openingHours_answer_seasonal_opening_hours, this::changeToMonthsMode);
Expand Down Expand Up @@ -168,6 +169,20 @@ private void showConfirm24_7Dialog()
.show();
}

private void confirmNoSign()
{
new AlertDialogBuilder(getActivity())
.setTitle(R.string.quest_generic_confirmation_title)
.setPositiveButton(R.string.quest_generic_confirmation_yes, (dialog, which) ->
{
Bundle data = new Bundle();
data.putBoolean(NO_SIGN, true);
applyImmediateAnswer(data);
})
.setNegativeButton(R.string.quest_generic_confirmation_no, null)
.show();
}

private void changeToMonthsMode()
{
isAlsoAddingMonths = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class AddPostboxCollectionTimes extends SimpleOverpassQuestType

@Override protected String getTagFilters()
{
return "nodes with amenity=post_box and !collection_times and !note:collection_times and (access !~ private|no)";
return "nodes with amenity=post_box and !collection_times and collection_times:signed != no and (access !~ private|no)";
}

@Override public AbstractQuestAnswerFragment createForm()
Expand All @@ -31,7 +31,7 @@ public class AddPostboxCollectionTimes extends SimpleOverpassQuestType
boolean noTimes = answer.getBoolean(AddCollectionTimesForm.NO_TIMES_SPECIFIED);
if(noTimes)
{
changes.add("note:collection_times","no times specified on the box");
changes.add("collection_times:signed","no");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ Otherwise, you can download another keyboard in the app store. Popular keyboards
<string name="invalidate_confirmation">Invalidate</string>
<string name="invalidation_dialog_message">Invalidating the cache causes the quests to be updated next time they are downloaded. The quest cache is invalidated automatically after one week and immediately when a quest you solved turns out to be already answered by someone else.</string>
<string name="quest_openingHours_emptyAnswer">You need to describe what is on the sign. If there is no sign, you should ask for the opening hours inside.</string>
<string name="quest_openingHours_no_sign">No opening hours sign</string>
<string name="quest_cycleway_value_none_but_no_oneway">none, but cyclists may use road in both directions</string>
<string name="quest_generic_looks_like_this">Usually looks like this:</string>
<string name="quest_surface_value_metal">Metal</string>
Expand Down Expand Up @@ -610,7 +611,6 @@ Otherwise, you can download another keyboard in the app store. Popular keyboards
<string name="quest_address_answer_no_housenumber_message1">The building was tagged as:</string>
<string name="quest_address_answer_no_housenumber_message2">Is this correct and is it not just part of a building?</string>
<string name="quest_maxspeed_sign_question">What defines the speed limit?</string>

<string name="notification_channel_download">"Download"</string>
<string name="quest_playground_access_title">Is this playground publicly accessible?</string>
<string name="quest_segregated_title">How are the footway and cycleway laid out here?</string>
Expand Down

0 comments on commit d11226e

Please sign in to comment.