Switch to TLS
This commit is contained in:
parent
e3dbd574d0
commit
c5d0d27b5f
6 changed files with 83 additions and 19 deletions
|
@ -27,7 +27,6 @@ public class NameFinderPoiFilter extends PoiFilter {
|
|||
|
||||
List<Amenity> searchedAmenities = new ArrayList<Amenity>();
|
||||
|
||||
|
||||
private String query = ""; //$NON-NLS-1$
|
||||
private String lastError = ""; //$NON-NLS-1$
|
||||
|
||||
|
@ -55,12 +54,24 @@ public class NameFinderPoiFilter extends PoiFilter {
|
|||
@Override
|
||||
protected List<Amenity> searchAmenities(double lat, double lon, double topLatitude,
|
||||
double bottomLatitude, double leftLongitude, double rightLongitude, ResultMatcher<Amenity> matcher) {
|
||||
|
||||
final int deviceApiVersion = android.os.Build.VERSION.SDK_INT;
|
||||
|
||||
String NOMINATIM_API;
|
||||
|
||||
if (deviceApiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD) {
|
||||
NOMINATIM_API = "https://nominatim.openstreetmap.org/search/";
|
||||
}
|
||||
else {
|
||||
NOMINATIM_API = "http://nominatim.openstreetmap.org/search/";
|
||||
}
|
||||
|
||||
searchedAmenities.clear();
|
||||
|
||||
String viewbox = "viewboxlbrt="+((float) leftLongitude)+","+((float) bottomLatitude)+","+((float) rightLongitude)+","+((float) topLatitude);
|
||||
try {
|
||||
lastError = "";
|
||||
String urlq = "http://nominatim.openstreetmap.org/search/"+URLEncoder.encode(query)+ "?format=xml&addressdetails=1&limit="+LIMIT+"&bounded=1&"+viewbox;
|
||||
String urlq = NOMINATIM_API + URLEncoder.encode(query)+ "?format=xml&addressdetails=1&limit="+LIMIT+"&bounded=1&"+viewbox;
|
||||
log.info(urlq);
|
||||
URL url = new URL(urlq); //$NON-NLS-1$
|
||||
InputStream stream = url.openStream();
|
||||
|
|
|
@ -142,6 +142,7 @@ public class SearchAddressOnlineFragment extends SherlockFragment implements Sea
|
|||
}
|
||||
|
||||
protected void searchPlaces(final String search) {
|
||||
|
||||
if(Algorithms.isEmpty(search)){
|
||||
return;
|
||||
}
|
||||
|
@ -154,9 +155,21 @@ public class SearchAddressOnlineFragment extends SherlockFragment implements Sea
|
|||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
try {
|
||||
|
||||
final int deviceApiVersion = android.os.Build.VERSION.SDK_INT;
|
||||
|
||||
String NOMINATIM_API;
|
||||
|
||||
if (deviceApiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD) {
|
||||
NOMINATIM_API = "https://nominatim.openstreetmap.org/search";
|
||||
}
|
||||
else {
|
||||
NOMINATIM_API = "http://nominatim.openstreetmap.org/search";
|
||||
}
|
||||
|
||||
final List<Place> places = new ArrayList<Place>();
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append("http://nominatim.openstreetmap.org/search"); //$NON-NLS-1$
|
||||
b.append(NOMINATIM_API); //$NON-NLS-1$
|
||||
b.append("?format=xml&addressdetails=0&accept-language=").append(Locale.getDefault().getLanguage()); //$NON-NLS-1$
|
||||
b.append("&q=").append(URLEncoder.encode(search, "UTF-8")); //$NON-NLS-1$
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ public class EditingPOIActivity implements DialogProvider {
|
|||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ctx.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://wiki.openstreetmap.org/wiki/Map_Features")));
|
||||
ctx.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://wiki.openstreetmap.org/wiki/Map_Features")));
|
||||
}
|
||||
});
|
||||
linkToOsmDoc.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
|
|
@ -45,9 +45,6 @@ import android.widget.Toast;
|
|||
|
||||
public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
||||
|
||||
// private final static String SITE_API = "http://api06.dev.openstreetmap.org/";
|
||||
private final static String SITE_API = "http://api.openstreetmap.org/"; //$NON-NLS-1$
|
||||
|
||||
private static final long NO_CHANGESET_ID = -1;
|
||||
|
||||
private final OsmandApplication ctx;
|
||||
|
@ -73,7 +70,25 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
|||
return entityInfo;
|
||||
}
|
||||
|
||||
private final static String URL_TO_UPLOAD_GPX = " http://api.openstreetmap.org/api/0.6/gpx/create";
|
||||
private static String getSiteApi()
|
||||
{
|
||||
final int deviceApiVersion = android.os.Build.VERSION.SDK_INT;
|
||||
|
||||
String RETURN_API;
|
||||
|
||||
if (deviceApiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD) {
|
||||
RETURN_API = "https://api.openstreetmap.org/";
|
||||
}
|
||||
else {
|
||||
RETURN_API = "http://api.openstreetmap.org/";
|
||||
}
|
||||
|
||||
// RETURN_API = "http://api06.dev.openstreetmap.org/";
|
||||
|
||||
return RETURN_API;
|
||||
}
|
||||
|
||||
private final static String URL_TO_UPLOAD_GPX = getSiteApi() + "api/0.6/gpx/create";
|
||||
|
||||
public String uploadGPXFile(String tagstring, String description, String visibility, File f) {
|
||||
String url = URL_TO_UPLOAD_GPX;
|
||||
|
@ -178,7 +193,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
|||
} catch (IOException e) {
|
||||
log.error("Unhandled exception", e); //$NON-NLS-1$
|
||||
}
|
||||
String response = sendRequest(SITE_API + "api/0.6/changeset/create/", "PUT", writer.getBuffer().toString(), ctx.getString(R.string.opening_changeset), true); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String response = sendRequest(getSiteApi() + "api/0.6/changeset/create/", "PUT", writer.getBuffer().toString(), ctx.getString(R.string.opening_changeset), true); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (response != null && response.length() > 0) {
|
||||
id = Long.parseLong(response);
|
||||
}
|
||||
|
@ -256,7 +271,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
|||
} catch (IOException e) {
|
||||
log.error("Unhandled exception", e); //$NON-NLS-1$
|
||||
}
|
||||
String res = sendRequest(SITE_API+"api/0.6/changeset/"+changeSetId + "/upload", "POST", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
String res = sendRequest(getSiteApi() + "api/0.6/changeset/"+changeSetId + "/upload", "POST", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
writer.getBuffer().toString(), ctx.getString(R.string.commiting_node), true);
|
||||
log.debug(res+""); //$NON-NLS-1$
|
||||
if (res != null) {
|
||||
|
@ -286,7 +301,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
|||
@Override
|
||||
public void closeChangeSet() {
|
||||
if (changeSetId != NO_CHANGESET_ID) {
|
||||
String response = sendRequest(SITE_API+"api/0.6/changeset/"+changeSetId+"/close", "PUT", "", ctx.getString(R.string.closing_changeset), true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
String response = sendRequest(getSiteApi() + "api/0.6/changeset/"+changeSetId+"/close", "PUT", "", ctx.getString(R.string.closing_changeset), true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||
log.info("Response : " + response); //$NON-NLS-1$
|
||||
changeSetId = NO_CHANGESET_ID;
|
||||
}
|
||||
|
@ -296,7 +311,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
|||
public EntityInfo loadNode(Node n) {
|
||||
long nodeId = n.getId(); // >> 1;
|
||||
try {
|
||||
String res = sendRequest(SITE_API + "api/0.6/node/"+nodeId, "GET", null, ctx.getString(R.string.loading_poi_obj) + nodeId, false); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String res = sendRequest(getSiteApi() + "api/0.6/node/"+nodeId, "GET", null, ctx.getString(R.string.loading_poi_obj) + nodeId, false); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if(res != null){
|
||||
OsmBaseStorage st = new OsmBaseStorage();
|
||||
st.parseOSM(new ByteArrayInputStream(res.getBytes("UTF-8")), null, null, true); //$NON-NLS-1$
|
||||
|
@ -330,7 +345,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
|
|||
}
|
||||
long nodeId = n.getId() >> 1;
|
||||
try {
|
||||
String res = sendRequest(SITE_API+"api/0.6/node/"+nodeId, "GET", null, ctx.getString(R.string.loading_poi_obj) + nodeId, false); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String res = sendRequest(getSiteApi() + "api/0.6/node/"+nodeId, "GET", null, ctx.getString(R.string.loading_poi_obj) + nodeId, false); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if(res != null){
|
||||
OsmBaseStorage st = new OsmBaseStorage();
|
||||
st.parseOSM(new ByteArrayInputStream(res.getBytes("UTF-8")), null, null, true); //$NON-NLS-1$
|
||||
|
|
|
@ -235,9 +235,20 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
|
||||
|
||||
protected List<OpenStreetNote> loadingBugs(double topLatitude, double leftLongitude, double bottomLatitude,double rightLongitude){
|
||||
final int deviceApiVersion = android.os.Build.VERSION.SDK_INT;
|
||||
|
||||
String SITE_API;
|
||||
|
||||
if (deviceApiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD) {
|
||||
SITE_API = "https://api.openstreetmap.org/";
|
||||
}
|
||||
else {
|
||||
SITE_API = "http://api.openstreetmap.org/";
|
||||
}
|
||||
|
||||
List<OpenStreetNote> bugs = new ArrayList<OpenStreetNote>();
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append("http://api.openstreetmap.org/api/0.6/notes?bbox="); //$NON-NLS-1$
|
||||
b.append(SITE_API + "api/0.6/notes?bbox="); //$NON-NLS-1$
|
||||
b.append(leftLongitude); //$NON-NLS-1$
|
||||
b.append(",").append(bottomLatitude); //$NON-NLS-1$
|
||||
b.append(",").append(rightLongitude); //$NON-NLS-1$
|
||||
|
|
|
@ -22,7 +22,21 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
|
|||
|
||||
private static final Log log = PlatformUtil.getLog(OsmBugsRemoteUtil.class);
|
||||
|
||||
private final static String SITE_API = "http://api.openstreetmap.org/api/0.6/notes"; //$NON-NLS-1$
|
||||
static String getNotesApi()
|
||||
{
|
||||
final int deviceApiVersion = android.os.Build.VERSION.SDK_INT;
|
||||
|
||||
String RETURN_API;
|
||||
|
||||
if (deviceApiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD) {
|
||||
RETURN_API = "https://api.openstreetmap.org/api/0.6/notes";
|
||||
}
|
||||
else {
|
||||
RETURN_API = "http://api.openstreetmap.org/api/0.6/notes";
|
||||
}
|
||||
|
||||
return RETURN_API;
|
||||
}
|
||||
|
||||
private OsmandApplication app;
|
||||
private OsmandSettings settings;
|
||||
|
@ -35,7 +49,7 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
|
|||
@Override
|
||||
public String createNewBug(double latitude, double longitude, String text){
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append(SITE_API).append("?"); //$NON-NLS-1$
|
||||
b.append(getNotesApi()).append("?"); //$NON-NLS-1$
|
||||
b.append("lat=").append(latitude); //$NON-NLS-1$
|
||||
b.append("&lon=").append(longitude); //$NON-NLS-1$
|
||||
b.append("&text=").append(URLEncoder.encode(text)); //$NON-NLS-1$
|
||||
|
@ -45,7 +59,7 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
|
|||
@Override
|
||||
public String addingComment(long id, String text){
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append(SITE_API).append("/");
|
||||
b.append(getNotesApi()).append("/");
|
||||
b.append(id); //$NON-NLS-1$
|
||||
b.append("/comment?text=").append(URLEncoder.encode(text)); //$NON-NLS-1$
|
||||
return editingPOI(b.toString(), "POST", "adding comment"); //$NON-NLS-1$
|
||||
|
@ -54,7 +68,7 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
|
|||
@Override
|
||||
public String closingBug(long id, String text){
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append(SITE_API).append("/");
|
||||
b.append(getNotesApi()).append("/");
|
||||
b.append(id); //$NON-NLS-1$
|
||||
b.append("/close?text=").append(URLEncoder.encode(text)); //$NON-NLS-1$
|
||||
return editingPOI(b.toString(), "POST", "close bug") ; //$NON-NLS-1$
|
||||
|
|
Loading…
Reference in a new issue