Skip to content

Commit

Permalink
bypass censorship in Russia
Browse files Browse the repository at this point in the history
provide fallback overpas server (thanks to Kumi Systems for providing it!)
fixes streetcomplete#1389
  • Loading branch information
matkoniecz committed Jun 27, 2019
1 parent 1f066da commit 18a1ff5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 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 Down Expand Up @@ -40,7 +43,7 @@ public class OsmModule
{
public static final String
OSM_API_URL = "https://api.openstreetmap.org/api/0.6/",
OVERPASS_API_URL = "https://overpass-api.de/api/",
OVERPASS_API_WITH_ATTIC_DATA_URL = "https://overpass-api.de/api/",
ONEWAY_API_URL = "https://www.westnordost.de/streetcomplete/oneway-data-api/";


Expand All @@ -62,18 +65,18 @@ public static OsmConnection osmConnection(OAuthConsumer consumer)
}

@Provides public static OverpassMapDataDao overpassMapDataDao(
Provider<OverpassMapDataParser> parserProvider)
Provider<OverpassMapDataParser> parserProvider, SharedPreferences prefs)
{
OsmConnection overpassConnection = new OsmConnection(
OVERPASS_API_URL, ApplicationConstants.USER_AGENT, null);
prefs.getString(Prefs.OVERPASS_URL, OVERPASS_API_WITH_ATTIC_DATA_URL), ApplicationConstants.USER_AGENT, null);
return new OverpassMapDataDao(overpassConnection, parserProvider);
}

@Provides public static OverpassOldMapDataDao overpassOldMapDataDao(
Provider<OverpassMapDataParser> parserProvider, String date)
{
OsmConnection overpassConnection = new OsmConnection(
OVERPASS_API_URL, ApplicationConstants.USER_AGENT, null);
OVERPASS_API_WITH_ATTIC_DATA_URL, ApplicationConstants.USER_AGENT, null);
return new OverpassOldMapDataDao(overpassConnection, parserProvider, date);
}

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://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://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 18a1ff5

Please sign in to comment.