Skip to content

Commit

Permalink
broken implementation of overpass server switching
Browse files Browse the repository at this point in the history
OsmModule has currently no access to preferences (Dagger is unable to inject into static variables)
this is nitial step toward fixing streetcomplete#1389 - preference selection is now working
  • Loading branch information
matkoniecz committed Jun 19, 2019
1 parent 955f75f commit a6c2f95
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/src/main/java/de/westnordost/streetcomplete/Prefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public class Prefs
AUTOSYNC = "autosync",
KEEP_SCREEN_ON = "display.keepScreenOn",
UNGLUE_HINT_TIMES_SHOWN = "unglueHint.shown",
THEME_SELECT = "theme.select";
THEME_SELECT = "theme.select",
OVERPASS_URL = "overpass_url";


// not shown anywhere directly
public static final String
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package de.westnordost.streetcomplete.data;

import android.content.Context;
import android.content.SharedPreferences;

import java.io.File;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import javax.inject.Singleton;
Expand All @@ -12,6 +14,7 @@
import dagger.Provides;
import de.westnordost.osmapi.user.UserDao;
import de.westnordost.streetcomplete.ApplicationConstants;
import de.westnordost.streetcomplete.Prefs;
import de.westnordost.streetcomplete.data.osm.OsmQuestGiver;
import de.westnordost.streetcomplete.data.osm.download.ElementGeometryCreator;
import de.westnordost.streetcomplete.data.osm.download.OsmApiWayGeometrySource;
Expand All @@ -38,9 +41,12 @@
@Module
public class OsmModule
{
@Inject
public static SharedPreferences prefs;

public static final String
OSM_API_URL = "https://api.openstreetmap.org/api/0.6/",
OVERPASS_API_URL = "https://overpass-api.de/api/",
OVERPASS_API_URL = prefs.getString(Prefs.OVERPASS_URL, "https://overpass-api.de/api/"),
ONEWAY_API_URL = "https://www.westnordost.de/streetcomplete/oneway-data-api/";


Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,13 @@
<item>DARK</item>
</string-array>

<string-array name="pref_entries_overpass_url_select" translatable="false">
<item>"https://overpass-api.de/api/"</item>
<item>"https://3.overpass.kumi.systems/api"</item>
</string-array>

<string-array name="pref_entryvalues_overpass_url_select" translatable="false">
<item>"https://overpass-api.de/api/"</item>
<item>"https://3.overpass.kumi.systems/api"</item>
</string-array>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,8 @@ Otherwise, you can download another keyboard in the app store. Popular keyboards
<string name="theme_light">Light</string>
<string name="theme_dark">Dark</string>
<string name="theme_system_default">System default</string>
<string name="pref_title_overpass_url_select">Change Overpass server</string>
<string name="pref_title_overpass_url_info">may bypass censorship, for example in Russia</string>
<string name="quest_accessible_for_pedestrians_separate_sidewalk_explanation">This street was tagged as having no sidewalk on either side. In the case that there is a sidewalk after all but it is displayed as a separate way, please answer \"sidewalk\".</string>
<string name="action_open_location">Open location in another app</string>
<string name="map_application_missing">No other map application installed</string>
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@
android:title="@string/pref_title_quests_restore_hidden"
/>

<ListPreference
android:key="overpass_url"
android:title="@string/pref_title_overpass_url_select"
android:summary="@string/pref_title_overpass_url_info"
android:defaultValue="https://overpass-api.de/api/"
android:entries="@array/pref_entries_overpass_url_select"
android:entryValues="@array/pref_entryvalues_overpass_url_select"
android:persistent="true"
/>
</PreferenceCategory>

</PreferenceScreen>

0 comments on commit a6c2f95

Please sign in to comment.