diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/IPFSImageCard.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/IPFSImageCard.java index 63f02d10fe..64bf146d56 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/IPFSImageCard.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/builders/cards/IPFSImageCard.java @@ -2,11 +2,15 @@ package net.osmand.plus.mapcontextmenu.builders.cards; import android.view.View; + import androidx.core.content.ContextCompat; + import net.osmand.PlatformUtil; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.openplacereviews.OPRConstants; import net.osmand.util.Algorithms; + import org.apache.commons.logging.Log; import org.json.JSONException; import org.json.JSONObject; @@ -22,7 +26,7 @@ public class IPFSImageCard extends ImageCard { } catch (JSONException e) { LOG.error(e); } - String BASE_URL = mapActivity.getString(R.string.opr_base_url) + "api/ipfs/image-ipfs?cid="; + String BASE_URL = OPRConstants.getBaseUrl(mapActivity.getMyApplication()) + "api/ipfs/image-ipfs?cid="; url = BASE_URL + cid; imageHiresUrl = BASE_URL + cid; imageUrl = BASE_URL + cid; diff --git a/OsmAnd/src/net/osmand/plus/openplacereviews/OPRConstants.java b/OsmAnd/src/net/osmand/plus/openplacereviews/OPRConstants.java index a329e48235..a8901e2b0b 100644 --- a/OsmAnd/src/net/osmand/plus/openplacereviews/OPRConstants.java +++ b/OsmAnd/src/net/osmand/plus/openplacereviews/OPRConstants.java @@ -1,9 +1,9 @@ package net.osmand.plus.openplacereviews; -import android.content.Context; +import androidx.annotation.NonNull; -import net.osmand.plus.R; +import net.osmand.plus.OsmandApplication; import net.osmand.plus.osmedit.opr.OpenDBAPI; public class OPRConstants { @@ -11,28 +11,27 @@ public class OPRConstants { private static final String PURPOSE = OpenDBAPI.PURPOSE; private static final String CALLBACK_URL = OPR_OAUTH_PREFIX + "://osmand_opr_auth"; - public static String getBaseUrl(Context ctx) { - return ctx.getString(R.string.opr_base_url); + public static String getBaseUrl(@NonNull OsmandApplication app) { + return app.getSettings().getOprUrl(); } - - public static String getLoginUrl(Context ctx) { - return getBaseUrl(ctx) + "login" + getQueryString(ctx); + public static String getLoginUrl(@NonNull OsmandApplication app) { + return getBaseUrl(app) + "login" + getQueryString(); } - public static String getRegisterUrl(Context ctx) { - return getBaseUrl(ctx) + "signup" + getQueryString(ctx); + public static String getRegisterUrl(@NonNull OsmandApplication app) { + return getBaseUrl(app) + "signup" + getQueryString(); } - public static String getQueryString(Context ctx) { - return "?" + getPurposeParam(ctx) + "&" + getCallbackParam(ctx); + public static String getQueryString() { + return "?" + getPurposeParam() + "&" + getCallbackParam(); } - public static String getPurposeParam(Context ctx) { + public static String getPurposeParam() { return "purpose=" + PURPOSE; } - public static String getCallbackParam(Context ctx) { + public static String getCallbackParam() { return "callback=" + CALLBACK_URL; } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index be347c4558..8ce068b2ae 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -1174,6 +1174,8 @@ public class OsmandSettings { public final OsmandPreference OPR_BLOCKCHAIN_NAME = new StringPreference(this, "opr_blockchain_name", "").makeGlobal(); + public final OsmandPreference OPR_USE_DEV_URL = new BooleanPreference(this, "opr_use_dev_url", false).makeGlobal().makeShared(); + // this value boolean is synchronized with settings_pref.xml preference offline POI/Bugs edition public final OsmandPreference OFFLINE_EDITION = new BooleanPreference(this, "offline_osm_editing", true).makeGlobal().makeShared(); public final OsmandPreference OSM_USE_DEV_URL = new BooleanPreference(this, "use_dev_url", false).makeGlobal().makeShared(); @@ -1188,6 +1190,10 @@ public class OsmandSettings { return osmUrl; } + public String getOprUrl() { + return ctx.getString(OPR_USE_DEV_URL.get() ? R.string.dev_opr_base_url : R.string.opr_base_url); + } + // this value string is synchronized with settings_pref.xml preference name public final CommonPreference DAYNIGHT_MODE = new EnumStringPreference(this, "daynight_mode", DayNightMode.DAY, DayNightMode.values());