diff --git a/app/src/androidTest/java/de/westnordost/streetcomplete/quests/AddPlaceNameTest.java b/app/src/androidTest/java/de/westnordost/streetcomplete/quests/AddPlaceNameTest.java index adaf420eb1..6c422d674f 100644 --- a/app/src/androidTest/java/de/westnordost/streetcomplete/quests/AddPlaceNameTest.java +++ b/app/src/androidTest/java/de/westnordost/streetcomplete/quests/AddPlaceNameTest.java @@ -2,8 +2,8 @@ import de.westnordost.streetcomplete.data.osm.OsmElementQuestType; import de.westnordost.streetcomplete.data.osm.changes.StringMapEntryAdd; +import de.westnordost.streetcomplete.quests.localized_name.AddNameForm; import de.westnordost.streetcomplete.quests.place_name.AddPlaceName; -import de.westnordost.streetcomplete.quests.place_name.AddPlaceNameForm; public class AddPlaceNameTest extends AOsmElementQuestTypeTest { @@ -15,14 +15,14 @@ public class AddPlaceNameTest extends AOsmElementQuestTypeTest public void testNoName() { - bundle.putBoolean(AddPlaceNameForm.NO_NAME, true); + bundle.putBoolean(AddNameForm.NO_NAME, true); verify( new StringMapEntryAdd("noname","yes")); } public void testName() { - bundle.putString(AddPlaceNameForm.NAME, "my name"); + bundle.putString(AddNameForm.NAME, "my name"); verify( new StringMapEntryAdd("name","my name")); } diff --git a/app/src/androidTest/java/de/westnordost/streetcomplete/quests/road_name/AddRoadNameTest.java b/app/src/androidTest/java/de/westnordost/streetcomplete/quests/localized_name/AddRoadNameTest.java similarity index 91% rename from app/src/androidTest/java/de/westnordost/streetcomplete/quests/road_name/AddRoadNameTest.java rename to app/src/androidTest/java/de/westnordost/streetcomplete/quests/localized_name/AddRoadNameTest.java index 660058ea7f..51785085c1 100644 --- a/app/src/androidTest/java/de/westnordost/streetcomplete/quests/road_name/AddRoadNameTest.java +++ b/app/src/androidTest/java/de/westnordost/streetcomplete/quests/localized_name/AddRoadNameTest.java @@ -1,11 +1,11 @@ -package de.westnordost.streetcomplete.quests.road_name; +package de.westnordost.streetcomplete.quests.localized_name; import de.westnordost.streetcomplete.data.osm.OsmElementQuestType; import de.westnordost.streetcomplete.data.osm.changes.StringMapEntryAdd; import de.westnordost.streetcomplete.data.osm.changes.StringMapEntryModify; import de.westnordost.streetcomplete.quests.AOsmElementQuestTypeTest; -import de.westnordost.streetcomplete.quests.road_name.data.PutRoadNameSuggestionsHandler; -import de.westnordost.streetcomplete.quests.road_name.data.RoadNameSuggestionsDao; +import de.westnordost.streetcomplete.quests.localized_name.data.PutRoadNameSuggestionsHandler; +import de.westnordost.streetcomplete.quests.localized_name.data.RoadNameSuggestionsDao; import static org.mockito.Mockito.mock; diff --git a/app/src/androidTest/java/de/westnordost/streetcomplete/quests/road_name/data/RoadNameSuggestionsDaoTest.java b/app/src/androidTest/java/de/westnordost/streetcomplete/quests/localized_name/data/RoadNameSuggestionsDaoTest.java similarity index 96% rename from app/src/androidTest/java/de/westnordost/streetcomplete/quests/road_name/data/RoadNameSuggestionsDaoTest.java rename to app/src/androidTest/java/de/westnordost/streetcomplete/quests/localized_name/data/RoadNameSuggestionsDaoTest.java index 3c1f0d9edc..b88f99b06f 100644 --- a/app/src/androidTest/java/de/westnordost/streetcomplete/quests/road_name/data/RoadNameSuggestionsDaoTest.java +++ b/app/src/androidTest/java/de/westnordost/streetcomplete/quests/localized_name/data/RoadNameSuggestionsDaoTest.java @@ -1,4 +1,4 @@ -package de.westnordost.streetcomplete.quests.road_name.data; +package de.westnordost.streetcomplete.quests.localized_name.data; import java.util.ArrayList; import java.util.HashMap; diff --git a/app/src/main/java/de/westnordost/streetcomplete/ApplicationComponent.java b/app/src/main/java/de/westnordost/streetcomplete/ApplicationComponent.java index aa283b49f4..3aa3be5ac1 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/ApplicationComponent.java +++ b/app/src/main/java/de/westnordost/streetcomplete/ApplicationComponent.java @@ -13,7 +13,7 @@ import de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment; import de.westnordost.streetcomplete.quests.QuestModule; import de.westnordost.streetcomplete.quests.opening_hours.AddOpeningHoursForm; -import de.westnordost.streetcomplete.quests.road_name.AddRoadNameForm; +import de.westnordost.streetcomplete.quests.localized_name.AddRoadNameForm; import de.westnordost.streetcomplete.quests.note_discussion.NoteDiscussionForm; import de.westnordost.streetcomplete.settings.SettingsActivity; import de.westnordost.streetcomplete.settings.SettingsFragment; diff --git a/app/src/main/java/de/westnordost/streetcomplete/data/DbModule.java b/app/src/main/java/de/westnordost/streetcomplete/data/DbModule.java index 427324192a..05dbe79d08 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/data/DbModule.java +++ b/app/src/main/java/de/westnordost/streetcomplete/data/DbModule.java @@ -18,7 +18,7 @@ import de.westnordost.streetcomplete.data.visiblequests.QuestTypeOrderList; import de.westnordost.streetcomplete.data.visiblequests.VisibleQuestTypeDao; import de.westnordost.streetcomplete.data.statistics.QuestStatisticsDao; -import de.westnordost.streetcomplete.quests.road_name.data.RoadNamesTablesHelper; +import de.westnordost.streetcomplete.quests.localized_name.data.RoadNamesTablesHelper; import de.westnordost.streetcomplete.util.KryoSerializer; import de.westnordost.streetcomplete.util.Serializer; import de.westnordost.osmapi.changesets.ChangesetsDao; diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestModule.java b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestModule.java index e8b718f912..55f3630415 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/QuestModule.java +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/QuestModule.java @@ -17,6 +17,7 @@ import de.westnordost.streetcomplete.quests.bikeway.AddCycleway; import de.westnordost.streetcomplete.quests.bridge_structure.AddBridgeStructure; import de.westnordost.streetcomplete.quests.building_levels.AddBuildingLevels; +import de.westnordost.streetcomplete.quests.localized_name.AddBusStopName; import de.westnordost.streetcomplete.quests.bus_stop_shelter.AddBusStopShelter; import de.westnordost.streetcomplete.quests.car_wash_type.AddCarWashType; import de.westnordost.streetcomplete.quests.crossing_type.AddCrossingType; @@ -32,8 +33,8 @@ import de.westnordost.streetcomplete.quests.recycling.AddRecyclingType; import de.westnordost.streetcomplete.quests.religion.AddReligionToPlaceOfWorship; import de.westnordost.streetcomplete.quests.religion.AddReligionToWaysideShrine; -import de.westnordost.streetcomplete.quests.road_name.data.PutRoadNameSuggestionsHandler; -import de.westnordost.streetcomplete.quests.road_name.data.RoadNameSuggestionsDao; +import de.westnordost.streetcomplete.quests.localized_name.data.PutRoadNameSuggestionsHandler; +import de.westnordost.streetcomplete.quests.localized_name.data.RoadNameSuggestionsDao; import de.westnordost.streetcomplete.quests.tactile_paving.AddTactilePavingBusStop; import de.westnordost.streetcomplete.quests.tactile_paving.AddTactilePavingCrosswalk; import de.westnordost.streetcomplete.quests.toilet_availability.AddToiletAvailability; @@ -41,7 +42,7 @@ import de.westnordost.streetcomplete.quests.housenumber.AddHousenumber; import de.westnordost.streetcomplete.quests.max_speed.AddMaxSpeed; import de.westnordost.streetcomplete.quests.opening_hours.AddOpeningHours; -import de.westnordost.streetcomplete.quests.road_name.AddRoadName; +import de.westnordost.streetcomplete.quests.localized_name.AddRoadName; import de.westnordost.streetcomplete.quests.road_surface.AddRoadSurface; import de.westnordost.streetcomplete.quests.roof_shape.AddRoofShape; import de.westnordost.streetcomplete.quests.sport.AddSport; @@ -86,6 +87,7 @@ public class QuestModule new AddInternetAccess(o), new AddParkingAccess(o), new AddParkingFee(o), + new AddBusStopName(o), // ↓ 4. definitely shown as errors in QA tools diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddBusStopName.java b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddBusStopName.java new file mode 100644 index 0000000000..2d67edede1 --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddBusStopName.java @@ -0,0 +1,65 @@ +package de.westnordost.streetcomplete.quests.localized_name; + +import android.os.Bundle; +import android.support.annotation.NonNull; + +import java.util.HashMap; +import java.util.Map; + +import javax.inject.Inject; + +import de.westnordost.streetcomplete.R; +import de.westnordost.streetcomplete.data.osm.SimpleOverpassQuestType; +import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder; +import de.westnordost.streetcomplete.data.osm.download.OverpassMapDataDao; +import de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment; + +public class AddBusStopName extends SimpleOverpassQuestType +{ + + @Inject public AddBusStopName(OverpassMapDataDao overpassServer) { super(overpassServer); } + + @Override protected String getTagFilters() + { + return "nodes with" + + " ((public_transport=platform and (bus=yes or trolleybus=yes or tram=yes))" + + " or" + + " (highway=bus_stop and public_transport!=stop_position))" + + " and !name and noname != yes"; + } + + @Override public AbstractQuestAnswerFragment createForm() + { + return new AddBusStopNameForm(); + } + + @Override public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes) + { + if(answer.getBoolean(AddLocalizedNameForm.NO_NAME)) + { + changes.add("noname", "yes"); + return; + } + + HashMap stopNameByLanguage = AddLocalizedNameForm.toNameByLanguage(answer); + for (Map.Entry e : stopNameByLanguage.entrySet()) + { + if(e.getKey().isEmpty()) + { + changes.add("name", e.getValue()); + } + else + { + changes.add("name:" + e.getKey(), e.getValue()); + } + } + } + + @Override public String getCommitMessage() { return "Determine bus/tram stop names"; } + @Override public int getIcon() { return R.drawable.ic_quest_bus_stop_name; } + @Override public int getTitle(@NonNull Map tags) + { + String tram = tags.get("tram"); + return (tram != null && tram.equals("yes")) ? R.string.quest_tramStopName_title : R.string.quest_busStopName_title; + } +} diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddBusStopNameForm.java b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddBusStopNameForm.java new file mode 100644 index 0000000000..ea60b2eb54 --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddBusStopNameForm.java @@ -0,0 +1,56 @@ +package de.westnordost.streetcomplete.quests.localized_name; + +import android.os.Bundle; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; + +import java.util.ArrayList; + +import de.westnordost.streetcomplete.R; +import de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder; + +public class AddBusStopNameForm extends AddLocalizedNameForm +{ + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) + { + View view = super.onCreateView(inflater, container, savedInstanceState); + + View contentView = setContentView(R.layout.quest_localizedname); + + addOtherAnswers(); + + initLocalizedNameAdapter(contentView, savedInstanceState); + + return view; + } + + private void addOtherAnswers() { + addOtherAnswer(R.string.quest_name_answer_noName, this::confirmNoName); + addOtherAnswer(R.string.quest_streetName_answer_cantType, this::showKeyboardInfo); + } + + @Override + protected void onClickOk() { + this.applyNameAnswer(); + } + + private void confirmNoName() + { + new AlertDialogBuilder(getActivity()) + .setTitle(R.string.quest_name_answer_noName_confirmation_title) + .setPositiveButton(R.string.quest_name_noName_confirmation_positive, (dialog, which) -> + { + Bundle data = new Bundle(); + data.putBoolean(NO_NAME, true); + applyImmediateAnswer(data); + }) + .setNegativeButton(R.string.quest_generic_confirmation_no, null) + .show(); + } +} diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/AddRoadNameAdapter.java b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddLocalizedNameAdapter.java similarity index 64% rename from app/src/main/java/de/westnordost/streetcomplete/quests/road_name/AddRoadNameAdapter.java rename to app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddLocalizedNameAdapter.java index 887ce81820..fbe9ad6ba8 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/AddRoadNameAdapter.java +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddLocalizedNameAdapter.java @@ -1,9 +1,10 @@ -package de.westnordost.streetcomplete.quests.road_name; +package de.westnordost.streetcomplete.quests.localized_name; import android.content.Context; import android.graphics.Typeface; import android.os.AsyncTask; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v7.widget.PopupMenu; import android.support.v7.widget.RecyclerView; import android.text.Editable; @@ -26,30 +27,30 @@ import static android.view.Menu.NONE; -public class AddRoadNameAdapter extends RecyclerView.Adapter +public class AddLocalizedNameAdapter extends RecyclerView.Adapter { - private ArrayList data; + private ArrayList data; private final Context context; private final List languages; private final AbbreviationsByLocale abbreviationsByLocale; - private final List> roadNameSuggestions; + private final List> localizedNameSuggestions; private final Button addLanguageButton; - public AddRoadNameAdapter(ArrayList data, Context context, List languages, - AbbreviationsByLocale abbreviationsByLocale, - List> roadNameSuggestions, Button addLanguageButton) + public AddLocalizedNameAdapter(ArrayList data, Context context, List languages, + @Nullable AbbreviationsByLocale abbreviationsByLocale, + @Nullable List> localizedNameSuggestions, Button addLanguageButton) { if(data.isEmpty()) { - data.add(new RoadName(languages.get(0), "")); + data.add(new LocalizedName(languages.get(0), "")); } this.data = data; this.context = context; this.languages = languages; this.abbreviationsByLocale = abbreviationsByLocale; - this.roadNameSuggestions = roadNameSuggestions; - putDefaultRoadNameSuggestion(); + this.localizedNameSuggestions = localizedNameSuggestions; + putDefaultLocalizedNameSuggestion(); this.addLanguageButton = addLanguageButton; this.addLanguageButton.setOnClickListener(v -> { showLanguageSelectMenu(v, getNotAddedLanguages(), this::add); @@ -58,48 +59,47 @@ public AddRoadNameAdapter(ArrayList data, Context context, List roadNames : roadNameSuggestions) - { - if(roadNames.containsKey("")) - { - // name=A -> name=A, name:de=A (in Germany) - if(!roadNames.containsKey(defaultLanguage)) - { - String defaultName = roadNames.get(""); - roadNames.put(defaultLanguage, defaultName); + if(localizedNameSuggestions != null) { + for (Map names : localizedNameSuggestions) { + if (names.containsKey("")) { + // name=A -> name=A, name:de=A (in Germany) + if (!names.containsKey(defaultLanguage)) { + String defaultName = names.get(""); + names.put(defaultLanguage, defaultName); + } } } } } - private static ArrayList toRoadNameList(Map nameByLanguageMap) + private static ArrayList toLocalizedNameList(Map nameByLanguageMap) { - ArrayList result = new ArrayList<>(); + ArrayList result = new ArrayList<>(); String defaultName = nameByLanguageMap.get(""); for (Map.Entry entry : nameByLanguageMap.entrySet()) { // put default name first // (i.e. name=A, name:en=B, name:de=A -> name:de goes first and name is not shown) - RoadName roadName = new RoadName(entry.getKey(), entry.getValue()); - if(roadName.name.equals(defaultName)) + LocalizedName localizedName = new LocalizedName(entry.getKey(), entry.getValue()); + if(localizedName.name.equals(defaultName)) { - if(!roadName.languageCode.isEmpty()) result.add(0, roadName); + if(!localizedName.languageCode.isEmpty()) result.add(0, localizedName); } else { - result.add(roadName); + result.add(localizedName); } } // this is for the case: name=A, name:de=B, name:en=C -> name goes first if(!result.get(0).name.equals(defaultName)) { - result.add(0, new RoadName("",defaultName)); + result.add(0, new LocalizedName("",defaultName)); } return result; } @@ -107,7 +107,7 @@ private static ArrayList toRoadNameList(Map nameByLang @Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { LayoutInflater inflater = LayoutInflater.from(parent.getContext()); - return new ViewHolder(inflater.inflate(R.layout.quest_roadname_row, parent, false)); + return new ViewHolder(inflater.inflate(R.layout.quest_localizedname_row, parent, false)); } @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) @@ -137,7 +137,7 @@ private void remove(int index) private void add(@NonNull String languageCode) { int insertIndex = getItemCount(); - data.add(new RoadName(languageCode, "")); + data.add(new LocalizedName(languageCode, "")); notifyItemInserted(insertIndex); updateAddLanguageButtonVisibility(); @@ -146,14 +146,14 @@ private void add(@NonNull String languageCode) private List getNotAddedLanguages() { List result = new ArrayList<>(languages); - for (RoadName roadName : data) + for (LocalizedName localizedName : data) { - result.remove(roadName.languageCode); + result.remove(localizedName.languageCode); } return result; } - public ArrayList getData() + public ArrayList getData() { return data; } @@ -205,55 +205,54 @@ private String getLanguageMenuItemTitle(String languageCode) } } - private interface OnRoadNameSuggestionSelected + private interface OnLocalizedNameSuggestionSelected { - void onRoadNameSuggestionSelected(Map selection); + void onLocalizedNameSuggestionSelected(Map selection); } private void showNameSuggestionsMenu(View v, - final Map> roadNameSuggestionsMap, - final OnRoadNameSuggestionSelected callback) + final Map> localizedNameSuggestionsMap, + final OnLocalizedNameSuggestionSelected callback) { PopupMenu m = new PopupMenu(context, v); int i = 0; - for (Map.Entry> entry : roadNameSuggestionsMap.entrySet()) + for (Map.Entry> entry : localizedNameSuggestionsMap.entrySet()) { m.getMenu().add(NONE,i++,NONE, entry.getKey()); } m.setOnMenuItemClickListener(item -> { - Map selected = roadNameSuggestionsMap.get(item.getTitle().toString()); - callback.onRoadNameSuggestionSelected(selected); + Map selected = localizedNameSuggestionsMap.get(item.getTitle().toString()); + callback.onLocalizedNameSuggestionSelected(selected); return true; }); m.show(); } - private Map> getRoadNameSuggestionsByLanguageCode(String languageCode) + private Map> getLocalizedNameSuggestionsByLanguageCode(String languageCode) { - final Map> roadNameSuggestionsMap = new HashMap<>(); - for (Map roadNameSuggestion : roadNameSuggestions) - { - String name = roadNameSuggestion.get(languageCode); - if(name == null) continue; - - // "unspecified language" suggestions - if(languageCode.isEmpty()) - { - int defaultNameOccurances = 0; - for(String other : roadNameSuggestion.values()) - { - if (name.equals(other)) defaultNameOccurances++; + final Map> localizedNameSuggestionsMap = new HashMap<>(); + if(localizedNameSuggestions != null) { + for (Map localizedNameSuggestion : localizedNameSuggestions) { + String name = localizedNameSuggestion.get(languageCode); + if (name == null) continue; + + // "unspecified language" suggestions + if (languageCode.isEmpty()) { + int defaultNameOccurances = 0; + for (String other : localizedNameSuggestion.values()) { + if (name.equals(other)) defaultNameOccurances++; + } + // name=A, name:de=A -> do not consider "A" for "unspecified language" suggestion + if (defaultNameOccurances >= 2) continue; + // only for name=A, name:de=B, name:en=C,... } - // name=A, name:de=A -> do not consider "A" for "unspecified language" suggestion - if (defaultNameOccurances >= 2) continue; - // only for name=A, name:de=B, name:en=C,... + localizedNameSuggestionsMap.put(name, localizedNameSuggestion); } - roadNameSuggestionsMap.put(name, roadNameSuggestion); } - return roadNameSuggestionsMap; + return localizedNameSuggestionsMap; } private class ViewHolder extends RecyclerView.ViewHolder @@ -263,7 +262,7 @@ private class ViewHolder extends RecyclerView.ViewHolder private final TextView deleteButton; private final View nameSuggestionsButton; - private RoadName roadName; + private LocalizedName localizedName; public ViewHolder(View itemView) { @@ -279,10 +278,10 @@ public ViewHolder(View itemView) @Override public void afterTextChanged(Editable s) { String name = s.toString(); - roadName.name = name; + localizedName.name = name; if(name.isEmpty()) { - boolean hasSuggestions = !getRoadNameSuggestionsByLanguageCode(roadName.languageCode).isEmpty(); + boolean hasSuggestions = !getLocalizedNameSuggestionsByLanguageCode(localizedName.languageCode).isEmpty(); nameSuggestionsButton.setVisibility(hasSuggestions ? View.VISIBLE : View.GONE); } else @@ -300,18 +299,18 @@ public ViewHolder(View itemView) }); } - public void update(final int index, RoadName rn) + public void update(final int index, LocalizedName rn) { - this.roadName = rn; + this.localizedName = rn; final boolean isFirst = index == 0; deleteButton.setVisibility(isFirst ? View.INVISIBLE : View.VISIBLE); languageButton.setVisibility(languages.size() > 1 ? View.VISIBLE : View.INVISIBLE); - nameInput.setText(roadName.name); + nameInput.setText(localizedName.name); nameInput.requestFocus(); - languageButton.setText(roadName.languageCode); + languageButton.setText(localizedName.languageCode); // first entry is bold (the first entry is supposed to be the "default language", I // hope that comes across to the users like this. Otherwise, a text hint is necessary) @@ -331,7 +330,7 @@ public void update(final int index, RoadName rn) showLanguageSelectMenu(v, notAddedLanguages, languageCode -> { - roadName.languageCode = languageCode; + localizedName.languageCode = languageCode; languageButton.setText(languageCode); updateAddLanguageButtonVisibility(); updateNameSuggestions(); @@ -345,7 +344,7 @@ public void update(final int index, RoadName rn) { @Override protected Abbreviations doInBackground(Void... params) { - return abbreviationsByLocale.get(new Locale(roadName.languageCode)); + return abbreviationsByLocale != null ? abbreviationsByLocale.get(new Locale(localizedName.languageCode)) : null; } @Override protected void onPostExecute(Abbreviations abbreviations) @@ -357,17 +356,17 @@ public void update(final int index, RoadName rn) private void updateNameSuggestions() { - final Map> roadNameSuggestionsMap = - getRoadNameSuggestionsByLanguageCode(roadName.languageCode); + final Map> localizedNameSuggestionsMap = + getLocalizedNameSuggestionsByLanguageCode(localizedName.languageCode); boolean nameInputNotEmpty = !nameInput.getText().toString().isEmpty(); nameSuggestionsButton.setVisibility( - roadNameSuggestionsMap.isEmpty() || nameInputNotEmpty ? View.GONE : View.VISIBLE); + localizedNameSuggestionsMap.isEmpty() || nameInputNotEmpty ? View.GONE : View.VISIBLE); nameSuggestionsButton.setOnClickListener(v -> { - showNameSuggestionsMenu(v, roadNameSuggestionsMap, selection -> + showNameSuggestionsMenu(v, localizedNameSuggestionsMap, selection -> { - data = toRoadNameList(selection); + data = toLocalizedNameList(selection); notifyDataSetChanged(); updateAddLanguageButtonVisibility(); }); diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddLocalizedNameForm.java b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddLocalizedNameForm.java new file mode 100644 index 0000000000..eb5d19b394 --- /dev/null +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddLocalizedNameForm.java @@ -0,0 +1,194 @@ +package de.westnordost.streetcomplete.quests.localized_name; + +import android.content.Intent; +import android.os.Bundle; +import android.provider.Settings; +import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.RecyclerView; +import android.text.Html; +import android.text.Spanned; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Queue; + +import javax.inject.Inject; + +import de.westnordost.streetcomplete.Injector; +import de.westnordost.streetcomplete.R; +import de.westnordost.streetcomplete.quests.AbstractQuestFormAnswerFragment; +import de.westnordost.streetcomplete.util.Serializer; +import de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder; + +public abstract class AddLocalizedNameForm extends AbstractQuestFormAnswerFragment +{ + protected static final String LOCALIZED_NAMES_DATA = "localized_names_data"; + + public static final String NO_NAME = "no_name"; + private static final String + NAMES = "names", + LANGUAGE_CODES = "language_codes"; + + @Inject Serializer serializer; + + protected AddLocalizedNameAdapter adapter; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) + { + View view = super.onCreateView(inflater, container, savedInstanceState); + + Injector.instance.getApplicationComponent().inject(this); + + return view; + } + + protected void initLocalizedNameAdapter(View contentView, Bundle savedInstanceState) + { + ArrayList data; + if(savedInstanceState != null) + { + data = serializer.toObject(savedInstanceState.getByteArray(LOCALIZED_NAMES_DATA),ArrayList.class); + } + else + { + data = new ArrayList<>(); + } + + Button addLanguageButton = contentView.findViewById(R.id.btn_add); + + adapter = setupNameAdapter(data, addLanguageButton); + RecyclerView recyclerView = contentView.findViewById(R.id.roadnames); + recyclerView.setLayoutManager( + new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false)); + recyclerView.setAdapter(adapter); + recyclerView.setNestedScrollingEnabled(false); + } + + protected AddLocalizedNameAdapter setupNameAdapter(ArrayList data, Button addLanguageButton) { + return new AddLocalizedNameAdapter( + data, getActivity(), getPossibleStreetsignLanguages(), + null, null, addLanguageButton); + } + + protected List getPossibleStreetsignLanguages() + { + List possibleStreetsignLanguages = new ArrayList<>(); + possibleStreetsignLanguages.addAll(getCountryInfo().getOfficialLanguages()); + possibleStreetsignLanguages.addAll(getCountryInfo().getAdditionalStreetsignLanguages()); + // removes duplicates + return new ArrayList<>(new LinkedHashSet<>(possibleStreetsignLanguages)); + } + + @Override public void onSaveInstanceState(Bundle outState) + { + super.onSaveInstanceState(outState); + outState.putByteArray(LOCALIZED_NAMES_DATA, serializer.toBytes(adapter.getData())); + } + + protected void applyNameAnswer() + { + applyFormAnswer(prepareAnswerBundle()); + } + + protected Bundle prepareAnswerBundle() { + Bundle bundle = new Bundle(); + ArrayList data = adapter.getData(); + + String[] names = new String[data.size()]; + String[] languageCodes = new String[data.size()]; + for (int i = 0; i names, final Runnable onConfirmedAll) + { + if(names.isEmpty()) + { + onConfirmedAll.run(); + } + else + { + /* recursively call self on confirm until the list of not-abbreviations to confirm is + through */ + String name = names.remove(); + confirmPossibleAbbreviation(name, + () -> confirmPossibleAbbreviationsIfAny(names, onConfirmedAll)); + } + } + + protected void confirmPossibleAbbreviation(String name, final Runnable onConfirmed) + { + Spanned title = Html.fromHtml(getResources().getString( + R.string.quest_streetName_nameWithAbbreviations_confirmation_title_name, + ""+ Html.escapeHtml(name)+"")); + + new AlertDialogBuilder(getActivity()) + .setTitle(title) + .setMessage(R.string.quest_streetName_nameWithAbbreviations_confirmation_description) + .setPositiveButton(R.string.quest_streetName_nameWithAbbreviations_confirmation_positive, (dialog, which) -> onConfirmed.run()) + .setNegativeButton(R.string.quest_generic_confirmation_no, null) + .show(); + } + + protected void showKeyboardInfo() + { + new AlertDialogBuilder(getActivity()) + .setTitle(R.string.quest_streetName_cantType_title) + .setMessage(R.string.quest_streetName_cantType_description) + .setPositiveButton(R.string.quest_streetName_cantType_open_settings, + (dialog, which) -> startActivity(new Intent(Settings.ACTION_SETTINGS))) + .setNeutralButton(R.string.quest_streetName_cantType_open_store, (dialog, which) -> + { + Intent intent = new Intent(Intent.ACTION_MAIN); + intent.addCategory(Intent.CATEGORY_APP_MARKET); + startActivity(intent); + }) + .setNegativeButton(android.R.string.cancel, null) + .show(); + } + + protected static HashMap toNameByLanguage(Bundle answer) + { + String[] names = answer.getStringArray(NAMES); + String[] languages = answer.getStringArray(LANGUAGE_CODES); + + HashMap result = new HashMap<>(); + result.put("", names[0]); + // add languages only if there is more than one name specified. If there is more than one + // name, the "main" name (name specified in top row) is also added with the language. + if(names.length > 1) + { + for (int i = 0; i < names.length; i++) + { + // (the first) element may have no specific language + if(!languages[i].isEmpty()) + { + result.put(languages[i], names[i]); + } + } + } + return result; + } + + @Override public boolean hasChanges() + { + // 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(); + } +} diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/AddRoadName.java b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddRoadName.java similarity index 83% rename from app/src/main/java/de/westnordost/streetcomplete/quests/road_name/AddRoadName.java rename to app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddRoadName.java index 7daa49c7e6..0c06851550 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/AddRoadName.java +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddRoadName.java @@ -1,4 +1,4 @@ -package de.westnordost.streetcomplete.quests.road_name; +package de.westnordost.streetcomplete.quests.localized_name; import android.os.Bundle; import android.support.annotation.NonNull; @@ -17,15 +17,15 @@ import de.westnordost.streetcomplete.data.osm.Countries; import de.westnordost.streetcomplete.data.osm.ElementGeometry; import de.westnordost.streetcomplete.data.osm.OsmElementQuestType; +import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder; import de.westnordost.streetcomplete.data.osm.download.MapDataWithGeometryHandler; import de.westnordost.streetcomplete.data.osm.download.OverpassMapDataDao; import de.westnordost.streetcomplete.data.osm.tql.FiltersParser; import de.westnordost.streetcomplete.data.osm.tql.OverpassQLUtil; import de.westnordost.streetcomplete.data.osm.tql.TagFilterExpression; import de.westnordost.streetcomplete.quests.AbstractQuestAnswerFragment; -import de.westnordost.streetcomplete.data.osm.changes.StringMapChangesBuilder; -import de.westnordost.streetcomplete.quests.road_name.data.PutRoadNameSuggestionsHandler; -import de.westnordost.streetcomplete.quests.road_name.data.RoadNameSuggestionsDao; +import de.westnordost.streetcomplete.quests.localized_name.data.PutRoadNameSuggestionsHandler; +import de.westnordost.streetcomplete.quests.localized_name.data.RoadNameSuggestionsDao; public class AddRoadName implements OsmElementQuestType { @@ -84,7 +84,7 @@ public AbstractQuestAnswerFragment createForm() public void applyAnswerTo(Bundle answer, StringMapChangesBuilder changes) { - if(answer.getBoolean(AddRoadNameForm.NO_NAME)) + if(answer.getBoolean(AddLocalizedNameForm.NO_NAME)) { changes.add("noname", "yes"); return; @@ -108,10 +108,7 @@ else if(noProperRoad == AddRoadNameForm.IS_LINK) return; } - String[] names = answer.getStringArray(AddRoadNameForm.NAMES); - String[] languages = answer.getStringArray(AddRoadNameForm.LANGUAGE_CODES); - - HashMap roadNameByLanguage = toRoadNameByLanguage(names, languages); + HashMap roadNameByLanguage = AddLocalizedNameForm.toNameByLanguage(answer); for (Map.Entry e : roadNameByLanguage.entrySet()) { if(e.getKey().isEmpty()) @@ -136,26 +133,6 @@ else if(noProperRoad == AddRoadNameForm.IS_LINK) } } - private static HashMap toRoadNameByLanguage(String[] names, String[] languages) - { - HashMap result = new HashMap<>(); - result.put("", names[0]); - // add languages only if there is more than one name specified. If there is more than one - // name, the "main" name (name specified in top row) is also added with the language. - if(names.length > 1) - { - for (int i = 0; i < names.length; i++) - { - // (the first) element may have no specific language - if(!languages[i].isEmpty()) - { - result.put(languages[i], names[i]); - } - } - } - return result; - } - @Nullable @Override public Boolean isApplicableTo(Element element) { return ROADS_WITHOUT_NAMES_TFE.matches(element); diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/AddRoadNameForm.java b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddRoadNameForm.java similarity index 56% rename from app/src/main/java/de/westnordost/streetcomplete/quests/road_name/AddRoadNameForm.java rename to app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddRoadNameForm.java index 0f1eb4486e..54edbd8f14 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/AddRoadNameForm.java +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AddRoadNameForm.java @@ -1,14 +1,10 @@ -package de.westnordost.streetcomplete.quests.road_name; +package de.westnordost.streetcomplete.quests.localized_name; import android.content.DialogInterface; -import android.content.Intent; import android.os.Bundle; -import android.provider.Settings; import android.support.v7.app.AlertDialog; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; -import android.text.Html; -import android.text.Spanned; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -17,12 +13,10 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Queue; import javax.inject.Inject; @@ -32,20 +26,14 @@ import de.westnordost.streetcomplete.data.meta.Abbreviations; import de.westnordost.streetcomplete.data.meta.AbbreviationsByLocale; import de.westnordost.streetcomplete.data.osm.ElementGeometry; -import de.westnordost.streetcomplete.quests.AbstractQuestFormAnswerFragment; -import de.westnordost.streetcomplete.quests.road_name.data.RoadNameSuggestionsDao; -import de.westnordost.streetcomplete.util.Serializer; +import de.westnordost.streetcomplete.quests.localized_name.data.RoadNameSuggestionsDao; import de.westnordost.streetcomplete.view.dialogs.AlertDialogBuilder; -public class AddRoadNameForm extends AbstractQuestFormAnswerFragment +public class AddRoadNameForm extends AddLocalizedNameForm { - private static final String ROAD_NAMES_DATA = "road_names_data"; public static final String - NO_NAME = "no_name", NO_PROPER_ROAD = "no_proper_road", - NAMES = "names", - LANGUAGE_CODES = "language_codes", WAY_ID = "way_id", WAY_GEOMETRY = "way_geometry"; @@ -53,9 +41,6 @@ public class AddRoadNameForm extends AbstractQuestFormAnswerFragment @Inject AbbreviationsByLocale abbreviationsByLocale; @Inject RoadNameSuggestionsDao roadNameSuggestionsDao; - @Inject Serializer serializer; - - private AddRoadNameAdapter adapter; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, @@ -65,43 +50,25 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Injector.instance.getApplicationComponent().inject(this); - View contentView = setContentView(R.layout.quest_roadname); + View contentView = setContentView(R.layout.quest_localizedname); addOtherAnswers(); - initRoadNameAdapter(contentView, savedInstanceState); + initLocalizedNameAdapter(contentView, savedInstanceState); return view; } - private void addOtherAnswers() - { + private void addOtherAnswers() { addOtherAnswer(R.string.quest_name_answer_noName, this::selectNoStreetNameReason); addOtherAnswer(R.string.quest_streetName_answer_cantType, this::showKeyboardInfo); } - private void initRoadNameAdapter(View contentView, Bundle savedInstanceState) - { - ArrayList data; - if(savedInstanceState != null) - { - data = serializer.toObject(savedInstanceState.getByteArray(ROAD_NAMES_DATA),ArrayList.class); - } - else - { - data = new ArrayList<>(); - } - - Button addLanguageButton = contentView.findViewById(R.id.btn_add); - - adapter = new AddRoadNameAdapter( - data, getActivity(), getPossibleStreetsignLanguages(), - abbreviationsByLocale, getRoadnameSuggestions(), addLanguageButton); - RecyclerView recyclerView = contentView.findViewById(R.id.roadnames); - recyclerView.setLayoutManager( - new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false)); - recyclerView.setAdapter(adapter); - recyclerView.setNestedScrollingEnabled(false); + @Override + protected AddLocalizedNameAdapter setupNameAdapter(ArrayList data, Button addLanguageButton) { + return new AddLocalizedNameAdapter( + data, getActivity(), getPossibleStreetsignLanguages(), + abbreviationsByLocale, getRoadnameSuggestions(), addLanguageButton); } private List> getRoadnameSuggestions() @@ -117,35 +84,20 @@ private List> getRoadnameSuggestions() return roadNameSuggestionsDao.getNames(onlyFirstAndLast, AddRoadName.MAX_DIST_FOR_ROAD_NAME_SUGGESTION); } - private List getPossibleStreetsignLanguages() - { - List possibleStreetsignLanguages = new ArrayList<>(); - possibleStreetsignLanguages.addAll(getCountryInfo().getOfficialLanguages()); - possibleStreetsignLanguages.addAll(getCountryInfo().getAdditionalStreetsignLanguages()); - // removes duplicates - return new ArrayList<>(new LinkedHashSet<>(possibleStreetsignLanguages)); - } - - @Override public void onSaveInstanceState(Bundle outState) - { - super.onSaveInstanceState(outState); - outState.putByteArray(ROAD_NAMES_DATA, serializer.toBytes(adapter.getData())); - } - @Override protected void onClickOk() { LinkedList possibleAbbreviations = new LinkedList<>(); - for (RoadName roadName : adapter.getData()) + for (LocalizedName localizedName : adapter.getData()) { - String name = roadName.name; + String name = localizedName.name; if(name.trim().isEmpty()) { Toast.makeText(getActivity(), R.string.quest_generic_error_a_field_empty, - Toast.LENGTH_LONG).show(); + Toast.LENGTH_LONG).show(); return; } - Abbreviations abbr = abbreviationsByLocale.get(new Locale(roadName.languageCode)); + Abbreviations abbr = abbreviationsByLocale.get(new Locale(localizedName.languageCode)); boolean containsAbbreviations = abbr != null && abbr.containsAbbreviations(name); if (name.contains(".") || containsAbbreviations) @@ -157,73 +109,15 @@ private List getPossibleStreetsignLanguages() confirmPossibleAbbreviationsIfAny(possibleAbbreviations, this::applyNameAnswer); } - private void applyNameAnswer() + @Override + protected void applyNameAnswer() { - Bundle bundle = new Bundle(); - ArrayList data = adapter.getData(); - - String[] names = new String[data.size()]; - String[] languageCodes = new String[data.size()]; - for (int i = 0; i names, final Runnable onConfirmedAll) - { - if(names.isEmpty()) - { - onConfirmedAll.run(); - } - else - { - /* recursively call self on confirm until the list of not-abbreviations to confirm is - through */ - String name = names.remove(); - confirmPossibleAbbreviation(name, - () -> confirmPossibleAbbreviationsIfAny(names, onConfirmedAll)); - } - } - - private void confirmPossibleAbbreviation(String name, final Runnable onConfirmed) - { - Spanned title = Html.fromHtml(getResources().getString( - R.string.quest_streetName_nameWithAbbreviations_confirmation_title_name, - ""+ Html.escapeHtml(name)+"")); - - new AlertDialogBuilder(getActivity()) - .setTitle(title) - .setMessage(R.string.quest_streetName_nameWithAbbreviations_confirmation_description) - .setPositiveButton(R.string.quest_streetName_nameWithAbbreviations_confirmation_positive, (dialog, which) -> onConfirmed.run()) - .setNegativeButton(R.string.quest_generic_confirmation_no, null) - .show(); - } - - private void showKeyboardInfo() - { - new AlertDialogBuilder(getActivity()) - .setTitle(R.string.quest_streetName_cantType_title) - .setMessage(R.string.quest_streetName_cantType_description) - .setPositiveButton(R.string.quest_streetName_cantType_open_settings, - (dialog, which) -> startActivity(new Intent(Settings.ACTION_SETTINGS))) - .setNeutralButton(R.string.quest_streetName_cantType_open_store, (dialog, which) -> - { - Intent intent = new Intent(Intent.ACTION_MAIN); - intent.addCategory(Intent.CATEGORY_APP_MARKET); - startActivity(intent); - }) - .setNegativeButton(android.R.string.cancel, null) - .show(); - } - private void selectNoStreetNameReason() { final String diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/AutoCorrectAbbreviationsEditText.java b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AutoCorrectAbbreviationsEditText.java similarity index 98% rename from app/src/main/java/de/westnordost/streetcomplete/quests/road_name/AutoCorrectAbbreviationsEditText.java rename to app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AutoCorrectAbbreviationsEditText.java index 10c6e09ca2..6c4d1ec565 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/AutoCorrectAbbreviationsEditText.java +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/AutoCorrectAbbreviationsEditText.java @@ -1,4 +1,4 @@ -package de.westnordost.streetcomplete.quests.road_name; +package de.westnordost.streetcomplete.quests.localized_name; import android.content.Context; import android.text.Editable; diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/RoadName.java b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/LocalizedName.java similarity index 59% rename from app/src/main/java/de/westnordost/streetcomplete/quests/road_name/RoadName.java rename to app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/LocalizedName.java index a4645b508f..51ad48f01f 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/RoadName.java +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/LocalizedName.java @@ -1,14 +1,14 @@ -package de.westnordost.streetcomplete.quests.road_name; +package de.westnordost.streetcomplete.quests.localized_name; import android.support.annotation.NonNull; /** Carries the data language code + name in that language */ -public class RoadName +public class LocalizedName { @NonNull public String languageCode; @NonNull public String name; - public RoadName(@NonNull String languageCode, @NonNull String name) + public LocalizedName(@NonNull String languageCode, @NonNull String name) { this.languageCode = languageCode; this.name = name; diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/data/PutRoadNameSuggestionsHandler.java b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/data/PutRoadNameSuggestionsHandler.java similarity index 96% rename from app/src/main/java/de/westnordost/streetcomplete/quests/road_name/data/PutRoadNameSuggestionsHandler.java rename to app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/data/PutRoadNameSuggestionsHandler.java index 1c4cf363aa..a9a493a99d 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/data/PutRoadNameSuggestionsHandler.java +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/data/PutRoadNameSuggestionsHandler.java @@ -1,4 +1,4 @@ -package de.westnordost.streetcomplete.quests.road_name.data; +package de.westnordost.streetcomplete.quests.localized_name.data; import android.support.annotation.NonNull; import android.support.annotation.Nullable; diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/data/RoadNameSuggestionsDao.java b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/data/RoadNameSuggestionsDao.java similarity index 98% rename from app/src/main/java/de/westnordost/streetcomplete/quests/road_name/data/RoadNameSuggestionsDao.java rename to app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/data/RoadNameSuggestionsDao.java index 7f1c1e8b99..f61c17f74e 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/data/RoadNameSuggestionsDao.java +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/data/RoadNameSuggestionsDao.java @@ -1,4 +1,4 @@ -package de.westnordost.streetcomplete.quests.road_name.data; +package de.westnordost.streetcomplete.quests.localized_name.data; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/data/RoadNamesTable.java b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/data/RoadNamesTable.java similarity index 84% rename from app/src/main/java/de/westnordost/streetcomplete/quests/road_name/data/RoadNamesTable.java rename to app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/data/RoadNamesTable.java index e2a6e81801..85022b763d 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/data/RoadNamesTable.java +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/data/RoadNamesTable.java @@ -1,4 +1,4 @@ -package de.westnordost.streetcomplete.quests.road_name.data; +package de.westnordost.streetcomplete.quests.localized_name.data; public class RoadNamesTable { diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/data/RoadNamesTablesHelper.java b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/data/RoadNamesTablesHelper.java similarity index 93% rename from app/src/main/java/de/westnordost/streetcomplete/quests/road_name/data/RoadNamesTablesHelper.java rename to app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/data/RoadNamesTablesHelper.java index bbbfc59e5b..b3cd77a337 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/road_name/data/RoadNamesTablesHelper.java +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/localized_name/data/RoadNamesTablesHelper.java @@ -1,4 +1,4 @@ -package de.westnordost.streetcomplete.quests.road_name.data; +package de.westnordost.streetcomplete.quests.localized_name.data; import android.database.sqlite.SQLiteDatabase; diff --git a/app/src/main/java/de/westnordost/streetcomplete/quests/place_name/AddPlaceNameForm.java b/app/src/main/java/de/westnordost/streetcomplete/quests/place_name/AddPlaceNameForm.java index e0b79c28fe..f45eb47981 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/quests/place_name/AddPlaceNameForm.java +++ b/app/src/main/java/de/westnordost/streetcomplete/quests/place_name/AddPlaceNameForm.java @@ -42,15 +42,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, private void confirmNoName() { new AlertDialogBuilder(getActivity()) - .setTitle(R.string.quest_name_answer_noName_confirmation_title) - .setPositiveButton(R.string.quest_name_noName_confirmation_positive, (dialog, which) -> - { - Bundle data = new Bundle(); - data.putBoolean(NO_NAME, true); - applyImmediateAnswer(data); - }) - .setNegativeButton(R.string.quest_generic_confirmation_no, null) - .show(); + .setTitle(R.string.quest_name_answer_noName_confirmation_title) + .setPositiveButton(R.string.quest_name_noName_confirmation_positive, (dialog, which) -> + { + Bundle data = new Bundle(); + data.putBoolean(NO_NAME, true); + applyImmediateAnswer(data); + }) + .setNegativeButton(R.string.quest_generic_confirmation_no, null) + .show(); } @Override public boolean hasChanges() diff --git a/app/src/main/java/de/westnordost/streetcomplete/util/KryoSerializer.java b/app/src/main/java/de/westnordost/streetcomplete/util/KryoSerializer.java index aaf1442fe9..d79a84d35f 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/util/KryoSerializer.java +++ b/app/src/main/java/de/westnordost/streetcomplete/util/KryoSerializer.java @@ -26,7 +26,7 @@ import de.westnordost.streetcomplete.quests.opening_hours.OpeningWeekdays; import de.westnordost.streetcomplete.quests.opening_hours.TimeRange; import de.westnordost.streetcomplete.quests.opening_hours.Weekdays; -import de.westnordost.streetcomplete.quests.road_name.RoadName; +import de.westnordost.streetcomplete.quests.localized_name.LocalizedName; @Singleton public class KryoSerializer implements Serializer @@ -55,7 +55,7 @@ public class KryoSerializer implements Serializer boolean[].class, OpeningMonths.class, OpeningWeekdays.class, - RoadName.class + LocalizedName.class }; diff --git a/app/src/main/res/drawable/ic_quest_bus_stop_name.xml b/app/src/main/res/drawable/ic_quest_bus_stop_name.xml new file mode 100644 index 0000000000..5fa3e7b69b --- /dev/null +++ b/app/src/main/res/drawable/ic_quest_bus_stop_name.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/quest_roadname.xml b/app/src/main/res/layout/quest_localizedname.xml similarity index 100% rename from app/src/main/res/layout/quest_roadname.xml rename to app/src/main/res/layout/quest_localizedname.xml diff --git a/app/src/main/res/layout/quest_roadname_row.xml b/app/src/main/res/layout/quest_localizedname_row.xml similarity index 95% rename from app/src/main/res/layout/quest_roadname_row.xml rename to app/src/main/res/layout/quest_localizedname_row.xml index 5ca13f2a2e..e98bc7047c 100644 --- a/app/src/main/res/layout/quest_roadname_row.xml +++ b/app/src/main/res/layout/quest_localizedname_row.xml @@ -28,7 +28,7 @@ android:paddingEnd="14dp" > - - \ No newline at end of file + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index caf5ef0294..888cebaa4b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -197,6 +197,8 @@ To display the map, vector tiles are retrieved from the <a href=\"https://map "Sett" "Wood" "What is the name of this place?" + "What is the name of this bus stop?" + "What is the name of this tram stop?" "Is there a sidewalk in this street?" "The map is oriented north up." "Only on northern side"