-
-
Notifications
You must be signed in to change notification settings - Fork 359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Quest for bus stop names (see #551) #986
Conversation
You can (automatically) let issues close when a PR is merged by using "fixes" instead of "see". (And don't putting it in the title, but in PR description. Then it is also linked by GitHub.) |
} | ||
|
||
@Override public String getCommitMessage() { return "Determine bus stop names"; } | ||
@Override public int getIcon() { return R.drawable.ic_quest_label; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, would not a dedicated icon better? We have a bus and we have this one you chose here. I think one can simply combine them…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we need other opinion on this, I was not sure about the one to choose. It seemed logical to have the same icon as we are asking a name, but also makes sense to show a bus icon.
Actually, I made a special custom icon for this. Perhaps I did not import it from the quests.svg. It is the icon where you see a bus stop
Am 24. März 2018 18:56:51 MEZ schrieb Adrien Pavie <[email protected]>:
…PanierAvide commented on this pull request.
> + }
+
+ @OverRide public void applyAnswerTo(Bundle answer,
StringMapChangesBuilder changes)
+ {
+ if(answer.getBoolean(AddBusStopNameForm.NO_NAME))
+ {
+ changes.add("noname", "yes");
+ return;
+ }
+
+ String name = answer.getString(AddBusStopNameForm.NAME);
+ if(name != null) changes.add("name", name);
+ }
+
+ @OverRide public String getCommitMessage() { return "Determine bus
stop names"; }
+ @OverRide public int getIcon() { return R.drawable.ic_quest_label; }
Well, we need other opinion on this, I was not sure about the one to
choose. It seemed logical to have the same icon as we are asking a
name, but also makes sense to show a bus icon.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#986 (comment)
--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
|
@Override protected String getTagFilters() | ||
{ | ||
return " nodes, ways with !name and noname != yes" + | ||
" and ( highway = bus_stop or public_transport = platform )"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tactile paving quests filters that to only ask when it is not the stop position (i.e. (highway=bus_stop and public_transport!=stop_position)
). So maybe you should do it here, too?
Uhg, forget it, it actually already applies to that as it seems. |
Can't find anymore the way to define an icon from SVG into drawable for Android. Can you provide some pointers about that ? |
Found a way to do so (using online converter) so changed the icon. Is there a documentation in the project for this conversion process ? |
I also had some trouble doing this and this is what helped me: #825 (comment) |
|
@Override protected String getTagFilters() | ||
{ | ||
return " nodes, ways with !name and noname != yes" + | ||
" and (public_transport=platform or (highway=bus_stop and public_transport!=stop_position))"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would include any kind of public transport platform (i.e. also train stations and metro stops).
I think it would make sense if the query is the same as for AddBusStopShelter
:
https://github.com/westnordost/StreetComplete/blob/master/app/src/main/java/de/westnordost/streetcomplete/quests/bus_stop_shelter/AddBusStopShelter.java#L24-L26
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As tram was named in the original issue, it was making sense to include them as well. So is it better to only show bus stops ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well answer is below.
{ | ||
return !nameInput.getText().toString().trim().isEmpty(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this exactly the same as the AddPlaceNameForm? Couldn't that be used instead? (And rename to AddNameForm
perhaps)
android:strokeMiterLimit="4" /> | ||
</group> | ||
</group> | ||
</vector> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will likely have to be reimported using the method I described because I made the experience that Android does not handle groups well.
@Override public int getIcon() { return R.drawable.ic_quest_bus_stop_name; } | ||
@Override public int getTitle(@NonNull Map<String, String> tags) | ||
{ | ||
return R.string.quest_busStopName_title; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now this includes any kind of public transport platform. It would be odd if the quest asked that question for a tram, railway or metro stop. The question should be different for every different type of included public transport platform. I suggest to only include bus and tram stops and then have two strings. See
https://github.com/westnordost/StreetComplete/blob/master/app/src/main/java/de/westnordost/streetcomplete/quests/bus_stop_shelter/AddBusStopShelter.java#L24-L26
Basically, I've already done 1. 😆 (You may just use the unoptimized version.) |
Oh, by the way, I think there is room for a major improvement here. In countries where it is common that street names have a name in two languages, I would expect bus stops to also have two languages. The street quest offers for these cases to input the name of the street in each language, perhaps it would make sense to use the same logic for this quest. |
I started this refactoring, but having an issue when opening input for bus stop name. Will work on this later (or if someone have time to check...). |
Perhaps stops on the other directions have a name. Should / could we provide names from near by stops? |
@Override protected String getTagFilters() | ||
{ | ||
return "nodes with" + | ||
" ((public_transport=platform and (bus=yes or trolleybus=yes or tram=yes))" + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be renamed from "AddBusStopName.java" or trams should not be accepted here (the first solution is probably preferable).
Note that also, question, commit description and icon may require changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Icon does not, in the other quests the bus also stands for any public transport. (see the crossed part in #986 (comment), where I already mentioned that.)
Also still see #986 (comment) BTW, you do not exclude the stop position.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does anyone care?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, it's actually below this line, sorry for the noise. Just did not see this was already resolved.
Hui, cool. Just so you know, I do not require the multi-language thing to be implemented for this PR to be merged, it is just an obvious and reasonable improvement. |
Well, now it works with multi-language support :-) Tried to make code as common as possible between street name and bus stop name quests (introduced |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, that looks a lot. The refactor is very good. It's good to have a common abstract super class rather than having one concrete inherit from the other.
I left some comments, not sure if changes are necessary or I understood somethign wrong.
@@ -0,0 +1,88 @@ | |||
package de.westnordost.streetcomplete.quests.localized_name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the name of the package deliberate? Just wondering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but can be changed if needed.
} | ||
|
||
String[] names = answer.getStringArray(AddRoadNameForm.NAMES); | ||
String[] languages = answer.getStringArray(AddRoadNameForm.LANGUAGE_CODES); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be AddLocalizedNameForm.NAMES
etc?
} | ||
} | ||
return result; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take the last 40+ lines are copied 1:1 from the road name quest? Perhaps this should be outsourced here. Abstraction is not a reasonable option here, but perhaps simply put it into the AddLocalizedNameForm
class as a static helper method to access the answer-bundle?
{ | ||
// either the user added a language or typed something for the street name | ||
return adapter.getData().size() > 1 || !adapter.getData().get(0).name.trim().isEmpty(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this does not need to be overriden. It is already defined in the parent class.
List<Map<String, String>> roadNameSuggestions, Button addLanguageButton) | ||
public AddLocalizedNameAdapter(ArrayList<LocalizedName> data, Context context, List<String> languages, | ||
AbbreviationsByLocale abbreviationsByLocale, | ||
List<Map<String, String>> localizedNameSuggestions, Button addLanguageButton) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the @Nullable
annotations to parameters (and fields) that may explicitly be null will make intelligent IDEs (like Android Studio) be able show an error if you forgot the null-check somewhere. Would you add this annotation? Also good for documenation.
|
||
return view; | ||
} | ||
|
||
private void addOtherAnswers() | ||
protected void addOtherAnswers() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not necessary as you did the refactor properly by using a common super class.
import de.westnordost.streetcomplete.util.Serializer; | ||
import de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder; | ||
|
||
public abstract class AddLocalizedNameForm extends AbstractQuestFormAnswerFragment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
bundle.putStringArray(NAMES, names); | ||
bundle.putStringArray(LANGUAGE_CODES, languageCodes); | ||
applyFormAnswer(bundle); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this already defined in the super class?
new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false)); | ||
recyclerView.setAdapter(adapter); | ||
recyclerView.setNestedScrollingEnabled(false); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this already defined in the super class?
I have done the requested refactoring, making subclasses lighter :-) |
|
||
HashMap<String,String> stopNameByLanguage = toStopNameByLanguage(names, languages); | ||
HashMap<String,String> stopNameByLanguage = AddLocalizedNameForm.toNameByLanguage(names, languages); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, that method could accept a bundle instead. This way, AddLocalizedNameForm.LANGUAGE_CODES
etc. wouldn't even need to be public :-o
@@ -23,7 +23,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, | |||
|
|||
View contentView = setContentView(R.layout.quest_localizedname); | |||
|
|||
addOtherAnswers(); | |||
addOtherAnswers(this::confirmNoName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I find this a bit odd/too much. If it is not the same action, it might just as well be defined in AddBusStopNameForm and not be "injected" into the super class.
Refactoring of those two points also done ;-) |
Great! :-) |
This still does not exclude the stop position. AFAIK it is not very useful to set the name of the stop position, is not it? |
Well, it depends if the stop position is part of a stop area relation. If it is not, it is useful to set the name as well. |
Based on place quest (re-used generic templates).