├── .github └── FUNDING.yml ├── .gitignore ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lib ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── app │ │ └── organicmaps │ │ └── api │ │ ├── Const.java │ │ ├── CrosshairRequest.java │ │ ├── DownloadDialog.java │ │ ├── MapRequest.java │ │ ├── OrganicMapsApi.java │ │ ├── PickPointResponse.java │ │ └── Point.java │ └── res │ ├── drawable │ ├── background_pattern.xml │ ├── btn_back_gray.xml │ ├── btn_back_gray_active.xml │ ├── btn_back_green.xml │ ├── btn_back_green_active.xml │ ├── btn_gray_selector.xml │ ├── btn_green_selector.xml │ ├── gray.xml │ ├── green.xml │ ├── overflow.xml │ ├── pattern.png │ └── shadow.xml │ ├── layout │ └── dlg_install_mwm.xml │ └── values │ ├── strings.xml │ └── styles.xml ├── sample-app-capitals ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── app │ │ └── organicmaps │ │ └── api │ │ └── sample │ │ └── capitals │ │ ├── CapitalsListActivity.java │ │ ├── City.java │ │ └── CityDetailsActivity.java │ └── res │ ├── drawable │ └── ic_launcher_foreground.xml │ ├── layout │ ├── capitals_list_activity.xml │ └── city_details_activity.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── values-sw720dp-land │ └── dimens.xml │ ├── values-v11 │ └── styles.xml │ ├── values-v14 │ └── styles.xml │ └── values │ ├── dimens.xml │ ├── ic_launcher_background.xml │ ├── strings.xml │ └── styles.xml ├── sample-pick-point ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── app │ │ └── organicmaps │ │ └── api │ │ └── sample │ │ └── pick_point │ │ └── MainActivity.java │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ └── ic_launcher_background.xml │ ├── layout │ └── activity_main.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── mipmap-mdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── mipmap-xhdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── mipmap-xxhdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── mipmap-xxxhdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ └── values │ └── strings.xml ├── settings.gradle └── site └── images └── dlg.png /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: organicmaps 2 | liberapay: OrganicMaps 3 | custom: ["https://organicmaps.app/donate"] 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | .cxx 10 | local.properties 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Organic Maps Android API: Getting Started 2 | 3 | ## Introduction 4 | 5 | Organic Maps Android API (hereinafter referred to as *"API Library"* or just *"library"*) 6 | provides interface for client application to perform next tasks: 7 | 8 | * Show one or more points on offline map of [Organic Maps app][linkOM] 9 | * Come back to the client application after selecting specific point on the map, by sending [PendingIntent][linkPIntent] with point data when user asks for more information by pressing "More Info" button in Organic Maps app 10 | * Map screen branding : your application's icon and name (or custom title) will be placed at the top. 11 | 12 | Thus, you can provide **two way communication between your application and Organic Maps**, 13 | using Organic Maps to show points of interest (POI) and providing more information in your app. 14 | 15 | Please refer to [sample application][linkSampleSource] for demo. 16 | 17 | **Note**: this library provides convenience wrappers for [deep links](https://omaps.app/api). Your application can also use deep links directly without including the library as a dependency. You can look at the library implementation for ideas on how to do that. 18 | 19 | ## Prerequisites 20 | 21 | It is supposed that you are familiar with Android Development. 22 | You should be familiar with concept of [Intents][linkIntents], [library projects][linkLibProj], and [PendingIntents][linkPIntent] (recommended) as well. 23 | 24 | Organic Maps works from *Android SDK version 21 (Android 5)* and above 25 | 26 | ## Integration 27 | First step is to clone [repository][linkRepo] or download it as an archive. 28 | 29 | When your are done you find two folders: *lib* and *sample-app-capitals*. First one is a library project that you should add to your project. 30 | You don't need any additional permissions in your AndroidManifest.xml to use API library, so you can write real code straight away, calling for different `Api` methods (more details below). 31 | 32 | ## Classes Overview and HOW TO 33 | Core classes you will work with are: 34 | 35 | * [app.organicmaps.api.Point][linkPointClass] - model of POI, includes lat, lon, name, id, and style data. 36 | * [app.organicmaps.api.PickPointResponse][linkRespClass] - helps you to extract response from Organic Maps by applying `Response.extractFromIntent(Intent)` to Intent. Contains Point data. 37 | 38 | ### Show Points on the Map 39 | 40 | The simplest usage: 41 | 42 | public class MyPerfectActivity extends Activity { 43 | ... 44 | 45 | void showSomethingOnTheMap(SomeDomainObject arg) 46 | { 47 | // Do some work, create lat, lon, and name for point 48 | final double lat = ...; 49 | final double lon = ...; 50 | final String name = ...; 51 | // Ask Organic Maps to show the point 52 | Api.showPointOnMap(this, lat, lon, name); 53 | } 54 | ... 55 | 56 | } 57 | 58 | For multiple points use [Point][linkPointClass] class: 59 | 60 | void showMultiplePoints(List list) 61 | { 62 | // Convert objects to OM Points 63 | final Point[] points = new Point[list.length]; 64 | for (int i = 0; i < list.size; i++) 65 | { 66 | // Get lat, lon, and name from object and assign it to new Point 67 | points[i] = new Point(lat, lon, name); 68 | } 69 | // Show all point on the map, you could also provide some title 70 | Api.showPointsOnMap(this, "Look at my points, my points are amazing!", points); 71 | } 72 | 73 | 74 | ### Ask Organic Maps to Call my App 75 | 76 | We support PendingIntent interaction (just like Android native 77 | NotificationManager does). You should specify ID for each point to 78 | distinguish it later, and PendingIntent that Organic Maps will send back to 79 | your application when user press "More Info" button : 80 | 81 | // Here is how to pass points with ID ant PendingIntent 82 | void showMultiplePointsWithPendingIntent(List list, PendingIntent pendingIntent) 83 | { 84 | // Convert objects to Points 85 | final Point[] points = new Point[list.length]; 86 | for (int i = 0; i < list.size; i++) 87 | { 88 | // || 89 | // || 90 | // \/ 91 | // Now you should specify string ID for each point 92 | points[i] = new Point(lat, lon, name, id); 93 | } 94 | // Show all points on the map, you could also provide some title 95 | Api.showPointsOnMap(this, "This title says that user should choose some point", pendingIntent, points); 96 | } 97 | 98 | //Code below shows general way to extract response data 99 | @Override 100 | protected void onCreate(Bundle savedInstanceState) { 101 | super.onCreate(savedInstanceState); 102 | setContentView(R.layout.activity_main); 103 | // Handle intent you specified with PandingIntent 104 | // Now it has additional information (Point). 105 | handleIntent(getIntent()); 106 | } 107 | 108 | @Override 109 | protected void onNewIntent(Intent intent) 110 | { 111 | super.onNewIntent(intent); 112 | // if defined your activity as "SingleTop"- you should use onNewIntent callback 113 | handleIntent(intent); 114 | } 115 | 116 | void handleIntent(Intent intent) 117 | { 118 | // Apply Response extraction method to intent 119 | final Response mwmResponse = Response.extractFromIntent(this, intent); 120 | // Here is your point that user selected 121 | final Point point = mwmResponse.getPoint(); 122 | // Now, for instance you can do some work depending on point id 123 | processUserInteraction(point.getId()); 124 | } 125 | 126 | ## FAQ 127 | 128 | #### Which versions of Organic Maps support API calls? 129 | 130 | All versions since 2022-07-26 and above support API calls. 131 | 132 | #### What will happen if I call for `Api.showPoint()` but Organic Maps application is not installed? 133 | 134 | Nothing serious. API library will show simple dialog with gentle offer to download Organic Maps. You can see how it looks like below. 135 | 136 | ![Please install us](site/images/dlg.png) 137 | 138 | ## Sample Code and Application 139 | 140 | * [Sample Application Source Code][linkSampleSource] 141 | 142 | ------------------------------------------------------------------------------- 143 | ## API Code License 144 | 145 | Copyright (c) 2024, Organic Maps OÜ. 146 | 147 | Copyright (c) 2019, MY.COM B.V. 148 | 149 | Copyright (c) 2013, MapsWithMe GmbH. 150 | 151 | All rights reserved. 152 | 153 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 154 | 155 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 156 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 157 | 158 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 159 | 160 | [linkOM]: https://organicmaps.app/ "Organic Maps" 161 | [linkPIntent]: https://developer.android.com/reference/android/app/PendingIntent.html "PendingIntent" 162 | [linkRepo]: https://github.com/organicmaps/api-android "GitHub Repository" 163 | [linkLibProj]: https://developer.android.com/tools/projects/index.html#LibraryProjects "Android Library Project" 164 | [linkIntents]: https://developer.android.com/guide/components/intents-filters.html "Intents and Intent Filters" 165 | [linkApiClass]: lib/src/main/java/app/organicmaps/api/OrganicMapsApi.java "OrganicMapsApi.java" 166 | [linkPointClass]: lib/src/main/java/app/organicmaps/api/Point.java "Point.java" 167 | [linkRespClass]: lib/src/main/java/app/organicmaps/api/PickPointResponse.java "PickPointResponse.java" 168 | [linkSampleSource]: https://github.com/organicmaps/api-android/tree/master/sample-app-capitals "Api Source Code" 169 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | plugins { 3 | id 'com.android.application' version '8.5.1' apply false 4 | id 'com.android.library' version '8.5.1' apply false 5 | } 6 | 7 | project.ext { 8 | minSdkVersion = 21 9 | targetSdkVersion = 34 10 | javaVersion = JavaVersion.VERSION_11 11 | } 12 | 13 | task clean(type: Delete) { 14 | delete rootProject.buildDir 15 | } 16 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Enables namespacing of each library's R class so that its R class includes only the 19 | # resources declared in the library itself and none from the library's dependencies, 20 | # thereby reducing the size of the R class for that library 21 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/organicmaps/api-android/879daa0ef0412050881790e502bbf57e60d7afad/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /lib/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /lib/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | } 4 | 5 | android { 6 | namespace 'app.organicmaps.api' 7 | compileSdk project.targetSdkVersion 8 | 9 | defaultConfig { 10 | minSdk project.minSdkVersion 11 | targetSdk project.targetSdkVersion 12 | 13 | consumerProguardFiles "consumer-rules.pro" 14 | } 15 | 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | compileOptions { 23 | sourceCompatibility project.javaVersion 24 | targetCompatibility project.javaVersion 25 | } 26 | } 27 | 28 | tasks.withType(JavaCompile) { 29 | options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation' 30 | } 31 | 32 | dependencies { 33 | implementation 'androidx.appcompat:appcompat:1.7.0' 34 | implementation 'com.google.android.material:material:1.12.0' 35 | } 36 | -------------------------------------------------------------------------------- /lib/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/organicmaps/api-android/879daa0ef0412050881790e502bbf57e60d7afad/lib/consumer-rules.pro -------------------------------------------------------------------------------- /lib/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /lib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /lib/src/main/java/app/organicmaps/api/Const.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022, Organic Maps OÜ. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list 8 | of conditions and the following disclaimer. Redistributions in binary form must 9 | reproduce the above copyright notice, this list of conditions and the following 10 | disclaimer in the documentation and/or other materials provided with the 11 | distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 12 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 13 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 14 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 15 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 16 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 17 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 18 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 19 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 20 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 21 | OF SUCH DAMAGE. 22 | */ 23 | package app.organicmaps.api; 24 | 25 | public class Const 26 | { 27 | // Common 28 | static final String API_SCHEME = "om://"; 29 | static final String AUTHORITY = "app.organicmaps.api"; 30 | static final String EXTRA_PREFIX = AUTHORITY + ".extra"; 31 | 32 | // Request extras 33 | public static final String EXTRA_PICK_POINT = EXTRA_PREFIX + ".PICK_POINT"; 34 | 35 | // Response extras 36 | public static final String EXTRA_POINT_NAME = EXTRA_PREFIX + ".POINT_NAME"; 37 | public static final String EXTRA_POINT_LAT = EXTRA_PREFIX + ".POINT_LAT"; 38 | public static final String EXTRA_POINT_LON = EXTRA_PREFIX + ".POINT_LON"; 39 | public static final String EXTRA_POINT_ID = EXTRA_PREFIX + ".POINT_ID"; 40 | public static final String EXTRA_ZOOM_LEVEL = EXTRA_PREFIX + ".ZOOM_LEVEL"; 41 | 42 | private Const() {} 43 | } 44 | -------------------------------------------------------------------------------- /lib/src/main/java/app/organicmaps/api/CrosshairRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022, Organic Maps OÜ. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list 8 | of conditions and the following disclaimer. Redistributions in binary form must 9 | reproduce the above copyright notice, this list of conditions and the following 10 | disclaimer in the documentation and/or other materials provided with the 11 | distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 12 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 13 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 14 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 15 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 16 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 17 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 18 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 19 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 20 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 21 | OF SUCH DAMAGE. 22 | */ 23 | package app.organicmaps.api; 24 | 25 | import android.content.Intent; 26 | import android.net.Uri; 27 | 28 | import androidx.annotation.NonNull; 29 | 30 | public class CrosshairRequest 31 | { 32 | private String mAppName; 33 | 34 | public CrosshairRequest setAppName(String appName) 35 | { 36 | mAppName = appName; 37 | return this; 38 | } 39 | 40 | public @NonNull 41 | Intent toIntent() 42 | { 43 | final StringBuilder builder = new StringBuilder(Const.API_SCHEME); 44 | builder.append("crosshair?"); 45 | 46 | // title 47 | if (mAppName != null) 48 | builder.append("appname").append("=").append(Uri.encode(mAppName)).append("&"); 49 | 50 | final Uri uri = Uri.parse(builder.toString()); 51 | final Intent intent = new Intent(Intent.ACTION_VIEW, uri); 52 | intent.putExtra(Const.EXTRA_PICK_POINT, true); 53 | return intent; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/src/main/java/app/organicmaps/api/DownloadDialog.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022, Organic Maps OÜ. All rights reserved. 3 | Copyright (c) 2013, MapsWithMe GmbH. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list 9 | of conditions and the following disclaimer. Redistributions in binary form must 10 | reproduce the above copyright notice, this list of conditions and the following 11 | disclaimer in the documentation and/or other materials provided with the 12 | distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 13 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 14 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 15 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 16 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 17 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 18 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 20 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 22 | OF SUCH DAMAGE. 23 | */ 24 | 25 | package app.organicmaps.api; 26 | 27 | import android.app.Activity; 28 | import android.app.Dialog; 29 | import android.content.Intent; 30 | import android.net.Uri; 31 | import android.view.View; 32 | import android.view.Window; 33 | 34 | public class DownloadDialog extends Dialog implements android.view.View.OnClickListener 35 | { 36 | 37 | public DownloadDialog(Activity activity) 38 | { 39 | super(activity); 40 | 41 | requestWindowFeature(Window.FEATURE_NO_TITLE); 42 | setContentView(R.layout.dlg_install_mwm); 43 | 44 | findViewById(R.id.btn_pro).setOnClickListener(this); 45 | 46 | setOwnerActivity(activity); 47 | } 48 | 49 | 50 | public void onDownloadButtonClicked(String url) 51 | { 52 | Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); 53 | getContext().startActivity(i); 54 | dismiss(); 55 | } 56 | 57 | 58 | @Override 59 | public void onClick(View v) 60 | { 61 | String url = getContext().getString(R.string.url); 62 | onDownloadButtonClicked(url); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /lib/src/main/java/app/organicmaps/api/MapRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022, Organic Maps OÜ. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list 8 | of conditions and the following disclaimer. Redistributions in binary form must 9 | reproduce the above copyright notice, this list of conditions and the following 10 | disclaimer in the documentation and/or other materials provided with the 11 | distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 12 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 13 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 14 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 15 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 16 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 17 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 18 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 19 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 20 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 21 | OF SUCH DAMAGE. 22 | */ 23 | package app.organicmaps.api; 24 | 25 | import android.content.Intent; 26 | import android.net.Uri; 27 | 28 | import androidx.annotation.NonNull; 29 | 30 | import java.util.ArrayList; 31 | import java.util.Collection; 32 | import java.util.List; 33 | import java.util.Locale; 34 | 35 | public class MapRequest 36 | { 37 | private List mPoints = new ArrayList<>(); 38 | private String mAppName; 39 | private double mZoomLevel; 40 | // pick point mode 41 | private boolean mPickPointMode; 42 | 43 | public @NonNull MapRequest 44 | setAppName(String appName) 45 | { 46 | mAppName = appName; 47 | return this; 48 | } 49 | 50 | public @NonNull 51 | MapRequest addPoint(Point point) 52 | { 53 | mPoints.add(point); 54 | return this; 55 | } 56 | 57 | public @NonNull 58 | MapRequest setPoints(Collection points) 59 | { 60 | mPoints = new ArrayList<>(points); 61 | return this; 62 | } 63 | 64 | public @NonNull 65 | MapRequest setZoomLevel(double zoomLevel) 66 | { 67 | mZoomLevel = zoomLevel; 68 | return this; 69 | } 70 | 71 | public @NonNull MapRequest setPickPointMode(boolean pickPointMode) 72 | { 73 | mPickPointMode = pickPointMode; 74 | return this; 75 | } 76 | 77 | public @NonNull 78 | Intent toIntent() 79 | { 80 | final StringBuilder builder = new StringBuilder(Const.API_SCHEME); 81 | builder.append("map?"); 82 | 83 | // title 84 | if (mAppName != null) 85 | builder.append("appname").append("=").append(Uri.encode(mAppName)).append("&"); 86 | // zoom 87 | if (mZoomLevel != 0.0) 88 | builder.append("z").append("=").append(mZoomLevel).append("&"); 89 | 90 | // points 91 | for (final Point point : mPoints) 92 | { 93 | if (point != null) 94 | { 95 | builder.append("ll=").append(String.format(Locale.US, "%f,%f&", point.getLat(), point.getLon())); 96 | if (point.getName() != null) 97 | builder.append("n").append("=").append(Uri.encode(point.getName())).append("&"); 98 | if (point.getId() != null) 99 | builder.append("id").append("=").append(Uri.encode(point.getId())).append("&"); 100 | if (point.getStyle() != null) 101 | builder.append("s").append("=").append(Uri.encode(point.getStyle().getName())).append("&"); 102 | } 103 | } 104 | 105 | final Uri uri = Uri.parse(builder.toString()); 106 | final Intent intent = new Intent(Intent.ACTION_VIEW, uri); 107 | if (mPickPointMode) 108 | intent.putExtra(Const.EXTRA_PICK_POINT, true); 109 | return intent; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /lib/src/main/java/app/organicmaps/api/OrganicMapsApi.java: -------------------------------------------------------------------------------- 1 | package app.organicmaps.api; 2 | 3 | import android.app.Activity; 4 | import android.content.ComponentName; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.content.pm.PackageManager; 8 | 9 | import java.util.ArrayList; 10 | 11 | public class OrganicMapsApi { 12 | 13 | static final String PACKAGE_NAME_RELEASE = "app.organicmaps"; 14 | static final String PACKAGE_NAME_DEBUG = "app.organicmaps.debug"; 15 | static final String PACKAGE_NAME_BETA = "app.organicmaps.beta"; 16 | 17 | private OrganicMapsApi() { 18 | // utility class 19 | } 20 | 21 | public static void showPointOnMap(final Activity activity, final double lat, final double lon, final String name) { 22 | final ArrayList points = new ArrayList<>(1); 23 | points.add(new Point(lat, lon, name)); 24 | showPointsOnMap(activity, name, points); 25 | } 26 | 27 | public static void showPointsOnMap(final Activity activity, final String name, final ArrayList points) { 28 | final Intent intent = new MapRequest() 29 | .setPoints(points) 30 | .setAppName(name) 31 | .toIntent(); 32 | sendRequest(activity, intent); 33 | }; 34 | 35 | public static void sendRequest(final Activity caller, final Intent intent) { 36 | if (canHandleOrganicMapsIntents(caller)) { 37 | caller.startActivity(intent); 38 | } else { 39 | new DownloadDialog(caller).show(); 40 | } 41 | } 42 | 43 | /** 44 | * Detects if any handler for OrganicMaps intents is installed on the device 45 | */ 46 | public static boolean canHandleOrganicMapsIntents(final Context context) { 47 | final ComponentName c = new MapRequest().toIntent().resolveActivity(context.getPackageManager()); 48 | return c != null; 49 | } 50 | 51 | /** 52 | * Detects if one of the specific OrganicMaps packages is installed 53 | */ 54 | public static boolean isOrganicMapsPackageInstalled(final Context context) { 55 | final PackageManager pm = context.getPackageManager(); 56 | return (pm.getLaunchIntentForPackage(PACKAGE_NAME_RELEASE) != null 57 | || pm.getLaunchIntentForPackage(PACKAGE_NAME_BETA) != null 58 | || pm.getLaunchIntentForPackage(PACKAGE_NAME_DEBUG) != null); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /lib/src/main/java/app/organicmaps/api/PickPointResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022, Organic Maps OÜ. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | Redistributions of source code must retain the above copyright notice, this list 8 | of conditions and the following disclaimer. Redistributions in binary form must 9 | reproduce the above copyright notice, this list of conditions and the following 10 | disclaimer in the documentation and/or other materials provided with the 11 | distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 12 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 13 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 14 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 15 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 16 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 17 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 18 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 19 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 20 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 21 | OF SUCH DAMAGE. 22 | */ 23 | package app.organicmaps.api; 24 | 25 | import android.content.Intent; 26 | import android.os.Bundle; 27 | 28 | public class PickPointResponse 29 | { 30 | private Point mPoint; 31 | private double mZoomLevel; 32 | 33 | private PickPointResponse() {} 34 | 35 | /** 36 | * Factory method to extract response from intent. 37 | * 38 | * @param intent an intent to extra data from 39 | * @return PointResponse 40 | */ 41 | public static PickPointResponse extractFromIntent(final Intent intent) 42 | { 43 | final PickPointResponse response = new PickPointResponse(); 44 | final Bundle extras = intent.getExtras(); 45 | final double lat = extras.getDouble(Const.EXTRA_POINT_LAT); 46 | final double lon = extras.getDouble(Const.EXTRA_POINT_LON); 47 | final String name = extras.getString(Const.EXTRA_POINT_NAME); 48 | final String id = extras.getString(Const.EXTRA_POINT_ID); 49 | response.mPoint = new Point(lat, lon, name, id); 50 | response.mZoomLevel = extras.getDouble(Const.EXTRA_ZOOM_LEVEL); 51 | return response; 52 | } 53 | 54 | /** 55 | * @return selected point 56 | */ 57 | public Point getPoint() 58 | { 59 | return mPoint; 60 | } 61 | 62 | /** 63 | * @return current zoom level 64 | */ 65 | public double getZoomLevel() 66 | { 67 | return mZoomLevel; 68 | } 69 | 70 | @Override 71 | public String toString() 72 | { 73 | return "PointResponse [Point=" + mPoint + "]"; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /lib/src/main/java/app/organicmaps/api/Point.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022, Organic Maps OÜ. All rights reserved. 3 | Copyright (c) 2013, MapsWithMe GmbH. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | Redistributions of source code must retain the above copyright notice, this list 9 | of conditions and the following disclaimer. Redistributions in binary form must 10 | reproduce the above copyright notice, this list of conditions and the following 11 | disclaimer in the documentation and/or other materials provided with the 12 | distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 13 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 14 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 15 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 16 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 17 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 18 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 20 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 22 | OF SUCH DAMAGE. 23 | */ 24 | package app.organicmaps.api; 25 | 26 | import androidx.annotation.NonNull; 27 | 28 | import java.io.Serializable; 29 | import java.util.Objects; 30 | 31 | /** 32 | * POI wrapper object. 33 | * Has its equals() and hashCode() methods overloaded 34 | * so could be used in Hash(Map/Set/etc) classes. 35 | */ 36 | public final class Point implements Serializable 37 | { 38 | private static final long serialVersionUID = 1L; 39 | 40 | final private double mLat; 41 | final private double mLon; 42 | final private String mName; 43 | private String mId; 44 | private Style mStyle; 45 | 46 | public Point(double lat, double lon, String name) 47 | { 48 | this(lat, lon, name, null); 49 | } 50 | 51 | public Point(double lat, double lon, String name, String id) 52 | { 53 | this.mLat = lat; 54 | this.mLon = lon; 55 | this.mName = name; 56 | this.mId = id; 57 | } 58 | 59 | public double getLat() {return mLat;} 60 | 61 | public double getLon() {return mLon;} 62 | 63 | public String getName() {return mName;} 64 | 65 | public String getId() {return mId;} 66 | 67 | /** 68 | * Sets string ID for this point. Internally it is not used to distinguish point, 69 | * it's purpose to help clients code to associate point with domain objects of their application. 70 | * 71 | * @param id point id 72 | */ 73 | public void setId(String id) {mId = id;} 74 | 75 | public Style getStyle() {return mStyle;} 76 | 77 | /** 78 | * Sets the style (appearance) for this point. 79 | * 80 | * @param style Style to use, or null for default (violet circle). 81 | */ 82 | public void setStyle(Style style) 83 | { 84 | this.mStyle = style; 85 | } 86 | 87 | @Override 88 | @NonNull 89 | public String toString() 90 | { 91 | return "OMPoint [lat=" + mLat + 92 | ", lon=" + mLon + 93 | ", name=" + mName + 94 | ", id=" + mId + 95 | ", style=" + mStyle + "]"; 96 | } 97 | 98 | @Override 99 | public int hashCode() 100 | { 101 | final int prime = 31; 102 | int result = 1; 103 | long temp; 104 | temp = Double.doubleToLongBits(mLat); 105 | result = prime * result + (int) (temp ^ (temp >>> 32)); 106 | temp = Double.doubleToLongBits(mLon); 107 | result = prime * result + (int) (temp ^ (temp >>> 32)); 108 | result = prime * result + ((mName == null) ? 0 : mName.hashCode()); 109 | return result; 110 | } 111 | 112 | /** 113 | * Two point are considered 114 | * equal if they have they lat, lon, and name attributes equal. 115 | */ 116 | @Override 117 | public boolean equals(Object obj) 118 | { 119 | if (this == obj) 120 | return true; 121 | if (obj == null) 122 | return false; 123 | if (getClass() != obj.getClass()) 124 | return false; 125 | final Point other = (Point) obj; 126 | if (Double.doubleToLongBits(mLat) != Double.doubleToLongBits(other.mLat)) 127 | return false; 128 | if (Double.doubleToLongBits(mLon) != Double.doubleToLongBits(other.mLon)) 129 | return false; 130 | 131 | return Objects.equals(mName, other.mName); 132 | } 133 | 134 | 135 | /** 136 | * Supported styles for Organic Maps. Each appears as a small flag of the appropriate colour. 137 | */ 138 | public enum Style 139 | { 140 | PlacemarkRed("placemark-red"), 141 | PlacemarkBlue("placemark-blue"), 142 | PlacemarkPurple("placemark-purple"), 143 | PlacemarkYellow("placemark-yellow"), 144 | PlacemarkPink("placemark-pink"), 145 | PlacemarkBrown("placemark-brown"), 146 | PlacemarkGreen("placemark-green"), 147 | PlacemarkOrange("placemark-orange"); 148 | // TODO: Add 149 | // placemark-bluegray 150 | // placemark-cyan 151 | // placemark-deeporange 152 | // placemark-deeppurple 153 | // placemark-gray 154 | // placemark-lightblue 155 | // placemark-lime 156 | // placemark-teal 157 | 158 | private final String name; 159 | 160 | Style(String name) 161 | { 162 | this.name = name; 163 | } 164 | 165 | /** 166 | * @return name as it should appear in the MAPS.ME URL. 167 | */ 168 | public String getName() 169 | { 170 | return name; 171 | } 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /lib/src/main/res/drawable/background_pattern.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | -------------------------------------------------------------------------------- /lib/src/main/res/drawable/btn_back_gray.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 13 | -------------------------------------------------------------------------------- /lib/src/main/res/drawable/btn_back_gray_active.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /lib/src/main/res/drawable/btn_back_green.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 13 | 14 | -------------------------------------------------------------------------------- /lib/src/main/res/drawable/btn_back_green_active.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /lib/src/main/res/drawable/btn_gray_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /lib/src/main/res/drawable/btn_green_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /lib/src/main/res/drawable/gray.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /lib/src/main/res/drawable/green.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /lib/src/main/res/drawable/overflow.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /lib/src/main/res/drawable/pattern.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/organicmaps/api-android/879daa0ef0412050881790e502bbf57e60d7afad/lib/src/main/res/drawable/pattern.png -------------------------------------------------------------------------------- /lib/src/main/res/drawable/shadow.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 12 | 13 | -------------------------------------------------------------------------------- /lib/src/main/res/layout/dlg_install_mwm.xml: -------------------------------------------------------------------------------- 1 | 2 | 24 | 27 | 28 | 36 | 37 | 46 | 47 |