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

bypass censorship in Russia #1438

Merged
merged 7 commits into from
Jun 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/", // required for some tests
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
4 changes: 4 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,8 @@
<item>DARK</item>
</string-array>

<string-array name="pref_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 @@ -647,6 +647,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">Requires application restart to apply. 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
11 changes: 11 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@
android:positiveButtonText="@android:string/ok"
android:negativeButtonText="@android:string/cancel"
/>

<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_overpass_url_select"
android:entryValues="@array/pref_overpass_url_select"
android:persistent="true"
/>

</PreferenceCategory>

</PreferenceScreen>