Skip to content
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

Merged
merged 7 commits into from
Mar 30, 2018
Merged

Quest for bus stop names (see #551) #986

merged 7 commits into from
Mar 30, 2018

Conversation

PanierAvide
Copy link
Contributor

Based on place quest (re-used generic templates).

@rugk
Copy link
Contributor

rugk commented Mar 24, 2018

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; }
Copy link
Contributor

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…

Copy link
Contributor Author

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.

@westnordost
Copy link
Member

westnordost commented Mar 24, 2018 via email

@Override protected String getTagFilters()
{
return " nodes, ways with !name and noname != yes" +
" and ( highway = bus_stop or public_transport = platform )";
Copy link
Contributor

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?

@rugk
Copy link
Contributor

rugk commented Mar 24, 2018

Ah okay, this one:

In the issue, I said:

Of course, this also applies to trams.

So can we extent that to trams, too? Could be problematic with the icon then, but mhh… (Okay, maybe not. The bus is a sign for "public transport" in StreetComplete anyway, as the other quests for public transport also ask about tram stop and do not have a different icon.)

Uhg, forget it, it actually already applies to that as it seems.

@PanierAvide
Copy link
Contributor Author

Can't find anymore the way to define an icon from SVG into drawable for Android. Can you provide some pointers about that ?

@PanierAvide
Copy link
Contributor Author

Found a way to do so (using online converter) so changed the icon. Is there a documentation in the project for this conversion process ?

@ENT8R
Copy link
Contributor

ENT8R commented Mar 25, 2018

I also had some trouble doing this and this is what helped me: #825 (comment)

@westnordost
Copy link
Member

westnordost commented Mar 25, 2018

Found a way to do so (using online converter) so changed the icon. Is there a documentation in the project for this conversion process ?

  1. Put the icon apart from the main quest icons sheet into a separate 128x128 svg. In Inkscape select all and ungroup everything until nothing is grouped anymore to workaround a shortcoming/bug of the Android Studio drawable importer. Then, save it.
  2. In Android Studio, New -> Vector Asset -> Asset type: local file

@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))";
Copy link
Member

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

Copy link
Contributor Author

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 ?

Copy link
Contributor Author

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();
}
}
Copy link
Member

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>
Copy link
Member

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;
Copy link
Member

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

@rugk
Copy link
Contributor

rugk commented Mar 25, 2018

Basically, I've already done 1. 😆 (You may just use the unoptimized version.)
For a "how to" for splitting the SVG file out of the main SVG, see here.

@westnordost
Copy link
Member

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.

@PanierAvide
Copy link
Contributor Author

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...).

@HolgerJeromin
Copy link
Contributor

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))" +
Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does anyone care?

Copy link
Contributor

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.

@westnordost
Copy link
Member

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...).

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.

@PanierAvide
Copy link
Contributor Author

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 LocalizedName class).

Copy link
Member

@westnordost westnordost left a 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;
Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

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;
}
Copy link
Member

@westnordost westnordost Mar 28, 2018

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();
}
Copy link
Member

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)
Copy link
Member

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()
Copy link
Member

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
Copy link
Member

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);
}
Copy link
Member

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);
}
Copy link
Member

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?

@PanierAvide
Copy link
Contributor Author

I have done the requested refactoring, making subclasses lighter :-)


HashMap<String,String> stopNameByLanguage = toStopNameByLanguage(names, languages);
HashMap<String,String> stopNameByLanguage = AddLocalizedNameForm.toNameByLanguage(names, languages);
Copy link
Member

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);
Copy link
Member

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.

@PanierAvide
Copy link
Contributor Author

Refactoring of those two points also done ;-)

@westnordost
Copy link
Member

Great! :-)

@westnordost westnordost merged commit 60f3831 into streetcomplete:master Mar 30, 2018
@rugk
Copy link
Contributor

rugk commented Mar 30, 2018

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?

@PanierAvide
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants