|
2 | 2 |
|
3 | 3 | public class OpenStreetMapConstants { |
4 | 4 |
|
5 | | - private static final boolean DEV_MODE = false; |
| 5 | + public static boolean DEV_MODE = false; |
6 | 6 | private static final String OSM_API_URL_DEV = "https://master.apis.dev.openstreetmap.org"; |
7 | 7 | private static final String OSM_API_URL_PROD = "https://www.openstreetmap.org"; |
8 | | - private static final String OSM_API_URL = (DEV_MODE) ? OSM_API_URL_DEV : OSM_API_URL_PROD; |
| 8 | + public static String OSM_API_URL = (DEV_MODE) ? OSM_API_URL_DEV : OSM_API_URL_PROD; |
9 | 9 |
|
10 | 10 | public static class Api { |
11 | 11 |
|
12 | | - public static final String OSM_API_URL_PATH = OSM_API_URL + "/api/0.6/"; |
| 12 | + public static String OSM_API_URL_PATH = OSM_API_URL + "/api/0.6/"; |
13 | 13 |
|
14 | 14 | } |
15 | 15 |
|
16 | 16 | public static class OAuth2 { |
17 | 17 | public static final String CLIENT_ID_PROD = "6s8TuIQoPeq89ZWUFOXU7EZ-ZaCUVtUoNZFIKCMdU-E"; |
18 | 18 | public static final String CLIENT_ID_DEV = "94Ht-oVBJ2spydzfk18s1RV2z7NS98SBwMfzSCqLQLE"; // DEV |
19 | 19 |
|
20 | | - public static final String CLIENT_ID = (DEV_MODE) ? CLIENT_ID_DEV : CLIENT_ID_PROD; |
| 20 | + public static String CLIENT_ID = (DEV_MODE) ? CLIENT_ID_DEV : CLIENT_ID_PROD; |
21 | 21 |
|
22 | 22 | public static final String SCOPE = "write_gpx write_notes"; |
23 | 23 | public static final String USER_AGENT = "OSMTracker for Android™"; |
24 | 24 |
|
25 | 25 | public static class Urls { |
26 | | - public static final String AUTHORIZATION_ENDPOINT = OSM_API_URL + "/oauth2/authorize"; |
27 | | - public static final String TOKEN_ENDPOINT = OSM_API_URL + "/oauth2/token"; |
| 26 | + public static String AUTHORIZATION_ENDPOINT = OSM_API_URL + "/oauth2/authorize"; |
| 27 | + public static String TOKEN_ENDPOINT = OSM_API_URL + "/oauth2/token"; |
28 | 28 | } |
29 | 29 |
|
30 | 30 | } |
31 | 31 |
|
| 32 | + /** |
| 33 | + * Updates the environment mode and refreshes dependent URL paths. |
| 34 | + * |
| 35 | + * @param enabled True for Dev/Master API, False for Production |
| 36 | + */ |
| 37 | + public static void setDevelopmentMode(boolean enabled) { |
| 38 | + DEV_MODE = enabled; |
| 39 | + OSM_API_URL = (DEV_MODE) ? OSM_API_URL_DEV : OSM_API_URL_PROD; |
| 40 | + |
| 41 | + // Update the nested Api class variable |
| 42 | + Api.OSM_API_URL_PATH = OSM_API_URL + "/api/0.6/"; |
| 43 | + |
| 44 | + // Update OAuth2 constants as well to ensure total environment consistency |
| 45 | + OAuth2.Urls.AUTHORIZATION_ENDPOINT = OSM_API_URL + "/oauth2/authorize"; |
| 46 | + OAuth2.Urls.TOKEN_ENDPOINT = OSM_API_URL + "/oauth2/token"; |
| 47 | + OAuth2.CLIENT_ID = (DEV_MODE) ? OAuth2.CLIENT_ID_DEV : OAuth2.CLIENT_ID_PROD; |
| 48 | + } |
| 49 | + |
32 | 50 |
|
33 | 51 | } |
0 commit comments