Skip to content

Commit

Permalink
revert addition of possibility to only display certain quests during …
Browse files Browse the repository at this point in the history
…night/day (fixes #3248)
  • Loading branch information
westnordost committed Nov 18, 2021
1 parent 7564336 commit 6d315e3
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 110 deletions.
3 changes: 0 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ dependencies {

// opening hours parser
implementation("ch.poole:OpeningHoursParser:0.25.0")

// sunset-sunrise parser for lit quests
implementation("com.luckycatlabs:SunriseSunsetCalculator:1.2")
}

/** Localizations that should be pulled from POEditor etc. */
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ interface QuestType<T> {
/** The quest type can clean it's metadata that is older than the given timestamp here, if any */
fun deleteMetadataOlderThan(timestamp: Long) {}

/** if the quest should only be shown during day-light or night-time hours */
val dayNightVisibility: DayNightCycle get() = DayNightCycle.DAY_AND_NIGHT

/** towards which achievements the quest should count */
val questTypeAchievements: List<QuestTypeAchievement>
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import de.westnordost.streetcomplete.data.osm.osmquests.OsmQuest
import de.westnordost.streetcomplete.data.osm.osmquests.OsmQuestSource
import de.westnordost.streetcomplete.data.osmnotes.notequests.OsmNoteQuest
import de.westnordost.streetcomplete.data.osmnotes.notequests.OsmNoteQuestSource
import de.westnordost.streetcomplete.data.visiblequests.DayNightQuestFilter
import de.westnordost.streetcomplete.data.visiblequests.TeamModeQuestFilter
import de.westnordost.streetcomplete.data.visiblequests.VisibleQuestTypeSource
import java.util.concurrent.CopyOnWriteArrayList
Expand All @@ -18,8 +17,7 @@ import javax.inject.Singleton
private val osmQuestSource: OsmQuestSource,
private val osmNoteQuestSource: OsmNoteQuestSource,
private val visibleQuestTypeSource: VisibleQuestTypeSource,
private val teamModeQuestFilter: TeamModeQuestFilter,
private val dayNightQuestFilter: DayNightQuestFilter,
private val teamModeQuestFilter: TeamModeQuestFilter
) {
interface Listener {
/** Called when given quests in the given group have been added/removed */
Expand Down Expand Up @@ -89,7 +87,7 @@ import javax.inject.Singleton
}

private fun isVisible(quest: Quest): Boolean =
visibleQuestTypeSource.isVisible(quest.type) && teamModeQuestFilter.isVisible(quest) && dayNightQuestFilter.isVisible(quest)
visibleQuestTypeSource.isVisible(quest.type) && teamModeQuestFilter.isVisible(quest)

fun addListener(listener: Listener) {
listeners.add(listener)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ import javax.inject.Singleton
/* ↓ 1. solvable from a distance or while passing by ----------------------------------- */

// bus stop quests
AddBusStopLit(),
AddBusStopShelter(), // used by at least OsmAnd
AddBenchStatusOnBusStop(), // can be seen from across the street
AddBinStatusOnBusStop(), // can be seen from across the street
AddTactilePavingBusStop(), // requires you to be very close to it
AddBusStopName(), // requires text input
AddBusStopRef(), // requires text input
AddBusStopLit(), // at least during day requires to stand in it to see if there is a light in the shelter

AddRailwayCrossingBarrier(), // useful for routing

Expand All @@ -186,7 +186,7 @@ import javax.inject.Singleton
// sport pitches
AddSport(),
AddPitchSurface(),
AddPitchLit(), // Not affected by new DayNight cycle because the lights are usually only on during games
AddPitchLit(),

// parking
AddParkingType(),
Expand Down Expand Up @@ -347,7 +347,6 @@ import javax.inject.Singleton
/* ↓ 5.quests that are very numerous ---------------------------------------------------- */

// roads
AddWayLit(), // used by OsmAnd if "Street lighting" is enabled. (Configure map, Map rendering, Details)
AddSidewalk(), // for any pedestrian routers, needs minimal thinking
AddRoadSurface(), // used by BRouter, OsmAnd, OSRM, graphhopper, HOT map style... - sometimes requires way to be split
AddTracktype(), // widely used in map rendering - OSM Carto, OsmAnd...
Expand All @@ -370,5 +369,8 @@ import javax.inject.Singleton
AddRoofShape(countryInfos),

AddStepCount(), // can only be gathered when walking along this way, also needs the most effort and least useful

/* at the very last because it can be difficult to ascertain during day. used by OsmAnd if "Street lighting" is enabled. (Configure map, Map rendering, Details) */
AddWayLit(),
))
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import de.westnordost.streetcomplete.R
import de.westnordost.streetcomplete.data.meta.updateWithCheckDate
import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapChangesBuilder
import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType
import de.westnordost.streetcomplete.data.quest.DayNightCycle.ONLY_NIGHT
import de.westnordost.streetcomplete.data.user.achievements.QuestTypeAchievement.PEDESTRIAN
import de.westnordost.streetcomplete.ktx.arrayOfNotNull
import de.westnordost.streetcomplete.ktx.containsAnyKey
Expand All @@ -31,7 +30,6 @@ class AddBusStopLit : OsmFilterQuestType<Boolean>() {
override val commitMessage = "Add whether a bus stop is lit"
override val wikiLink = "Key:lit"
override val icon = R.drawable.ic_quest_bus_stop_lit
override val dayNightVisibility = ONLY_NIGHT

override val questTypeAchievements = listOf(PEDESTRIAN)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import de.westnordost.streetcomplete.data.meta.MAXSPEED_TYPE_KEYS
import de.westnordost.streetcomplete.data.meta.updateWithCheckDate
import de.westnordost.streetcomplete.data.osm.edits.update_tags.StringMapChangesBuilder
import de.westnordost.streetcomplete.data.osm.osmquests.OsmFilterQuestType
import de.westnordost.streetcomplete.data.quest.DayNightCycle.ONLY_NIGHT
import de.westnordost.streetcomplete.data.user.achievements.QuestTypeAchievement.PEDESTRIAN

class AddWayLit : OsmFilterQuestType<WayLitOrIsStepsAnswer>() {
Expand Down Expand Up @@ -46,7 +45,6 @@ class AddWayLit : OsmFilterQuestType<WayLitOrIsStepsAnswer>() {
override val wikiLink = "Key:lit"
override val icon = R.drawable.ic_quest_lantern
override val isSplitWayEnabled = true
override val dayNightVisibility = ONLY_NIGHT

override val questTypeAchievements = listOf(PEDESTRIAN)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,6 @@ class QuestSelectionAdapter @Inject constructor(

lateinit var item: QuestVisibility

private val isEnabledOnlyAtNight: Boolean
get() {
return item.questType.dayNightVisibility == DayNightCycle.ONLY_NIGHT
}

private val isEnabledInCurrentCountry: Boolean
get() {
(item.questType as? OsmElementQuestType<*>)?.let { questType ->
Expand Down Expand Up @@ -278,14 +273,12 @@ class QuestSelectionAdapter @Inject constructor(
true
}

binding.disabledText.isGone = isEnabledInCurrentCountry && !isEnabledOnlyAtNight
binding.disabledText.isGone = isEnabledInCurrentCountry
if (!isEnabledInCurrentCountry) {
val cc = if (currentCountryCodes.isEmpty()) "Atlantis" else currentCountryCodes[0]
binding.disabledText.text = binding.disabledText.resources.getString(
R.string.questList_disabled_in_country, Locale("", cc).displayCountry
)
} else if (isEnabledOnlyAtNight) {
binding.disabledText.text = binding.disabledText.resources.getString(R.string.questList_disabled_at_day)
}

updateSelectionStatus()
Expand Down
34 changes: 0 additions & 34 deletions app/src/main/java/de/westnordost/streetcomplete/util/Daylight.kt

This file was deleted.

1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,6 @@ Otherwise, you can download another keyboard in the app store. Popular keyboards
<string name="quest_construction_generic_title">Is this way completed?</string>
<string name="quest_construction_building_title">Is this building completed?</string>
<string name="questList_disabled_in_country">Never shown in %s</string>
<string name="questList_disabled_at_day">Only shown at night</string>
<string name="quest_toiletAvailability_rest_area_title">Does this rest area have restroom facilities?</string>
<string name="quest_maxspeed_name_title2">What is the speed limit for %s here?</string>
<string name="pref_quests_reset">Reset both quest enablement and order to the default?</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import de.westnordost.streetcomplete.data.osm.osmquests.OsmQuest
import de.westnordost.streetcomplete.data.osm.osmquests.OsmQuestSource
import de.westnordost.streetcomplete.data.osmnotes.notequests.OsmNoteQuest
import de.westnordost.streetcomplete.data.osmnotes.notequests.OsmNoteQuestSource
import de.westnordost.streetcomplete.data.visiblequests.DayNightQuestFilter
import de.westnordost.streetcomplete.data.visiblequests.TeamModeQuestFilter
import de.westnordost.streetcomplete.data.visiblequests.VisibleQuestTypeSource
import de.westnordost.streetcomplete.testutils.*
Expand All @@ -22,7 +21,6 @@ class VisibleQuestsSourceTest {
private lateinit var osmNoteQuestSource: OsmNoteQuestSource
private lateinit var visibleQuestTypeSource: VisibleQuestTypeSource
private lateinit var teamModeQuestFilter: TeamModeQuestFilter
private lateinit var dayNightQuestFilter: DayNightQuestFilter
private lateinit var source: VisibleQuestsSource

private lateinit var noteQuestListener: OsmNoteQuestSource.Listener
Expand All @@ -42,7 +40,6 @@ class VisibleQuestsSourceTest {
visibleQuestTypeSource = mock()
teamModeQuestFilter = mock()
questTypeRegistry = QuestTypeRegistry(questTypes)
dayNightQuestFilter = mock()

on(visibleQuestTypeSource.isVisible(any())).thenReturn(true)
on(teamModeQuestFilter.isVisible(any())).thenReturn(true)
Expand All @@ -64,9 +61,7 @@ class VisibleQuestsSourceTest {
Unit
}

on(dayNightQuestFilter.isVisible(any())).thenReturn(true)

source = VisibleQuestsSource(questTypeRegistry, osmQuestSource, osmNoteQuestSource, visibleQuestTypeSource, teamModeQuestFilter, dayNightQuestFilter)
source = VisibleQuestsSource(questTypeRegistry, osmQuestSource, osmNoteQuestSource, visibleQuestTypeSource, teamModeQuestFilter)

listener = mock()
source.addListener(listener)
Expand Down Expand Up @@ -105,15 +100,6 @@ class VisibleQuestsSourceTest {
assertTrue(quests.isEmpty())
}

@Test fun `getAllVisible does not return those that are invisible at day`() {
on(osmQuestSource.getAllVisibleInBBox(bbox, questTypeNames)).thenReturn(listOf(mock()))
on(osmNoteQuestSource.getAllVisibleInBBox(bbox)).thenReturn(listOf(mock()))
on(dayNightQuestFilter.isVisible(any())).thenReturn(false)

val quests = source.getAllVisible(bbox)
assertTrue(quests.isEmpty())
}

@Test fun `osm quests added or removed triggers listener`() {
val quests = listOf(osmQuest(elementId = 1), osmQuest(elementId = 2))
val deleted = listOf(osmQuestKey(elementId = 3), osmQuestKey(elementId = 4))
Expand Down

0 comments on commit 6d315e3

Please sign in to comment.