Rehydrate

Signed-off-by: Roman Tsisyk <roman@tsisyk.com>
This commit is contained in:
Roman Tsisyk 2022-06-06 10:37:22 +03:00
parent 80069e1acb
commit 24ae18d7c2
77 changed files with 978 additions and 753 deletions

17
.gitignore vendored
View file

@ -1,11 +1,10 @@
bin/
gen/
build/
.settings/
*.iml
.gradle
/local.properties
/.idea
.DS_Store
.classpath
.cproject
.project
/build
/captures
.externalNativeBuild
.cxx
local.properties
lint.xml

View file

@ -25,14 +25,14 @@ Organic Maps works from *Android SDK version 21 (Android 5)* and above
First step is to clone [repository][linkRepo] or download it as an archive.
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.
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 `OrganicMapsApi` methods (more details below).
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).
## Classes Overview and HOW TO
Core classes you will work with are:
* [app.organicmaps.api.OrganicMapsApi][linkApiClass] - static class with methods such as `showPointOnMap(Activity, double, double, String)` etc.
* [app.organicmaps.api.OMPoint][linkPointClass] - model of POI, includes lat, lon, name, id, and style data.
* [app.organicmaps.api.OMResponse][linkRespClass] - helps you to extract response from Organic Maps by applying `OMResponse.extractFromIntent(Intent)` to Intent. Contains OMPoint data.
* [app.organicmaps.api.Api][linkApiClass] - static class with methods such as `showPointOnMap(Activity, double, double, String)` etc.
* [app.organicmaps.api.Point][linkPointClass] - model of POI, includes lat, lon, name, id, and style data.
* [app.organicmaps.api.Response][linkRespClass] - helps you to extract response from Organic Maps by applying `Response.extractFromIntent(Intent)` to Intent. Contains Point data.
### Show Points on the Map
@ -48,25 +48,25 @@ The simplest usage:
final double lon = ...;
final String name = ...;
// Ask Organic Maps to show the point
OrganicMapsApi.showPointOnMap(this, lat, lon, name);
Api.showPointOnMap(this, lat, lon, name);
}
...
}
For multiple points use [OMPoint][linkPointClass] class:
For multiple points use [Point][linkPointClass] class:
void showMultiplePoints(List<SomeDomainObject> list)
{
// Convert objects to MMWPoints
final OMPoint[] points = new OMPoint[list.length];
// Convert objects to OM Points
final Point[] points = new Point[list.length];
for (int i = 0; i < list.size; i++)
{
// Get lat, lon, and name from object and assign it to new MMWPoint
points[i] = new OMPoint(lat, lon, name);
// Get lat, lon, and name from object and assign it to new Point
points[i] = new Point(lat, lon, name);
}
// Show all point on the map, you could also provide some title
OrganicMapsApi.showPointsOnMap(this, "Look at my points, my points are amazing!", points);
Api.showPointsOnMap(this, "Look at my points, my points are amazing!", points);
}
@ -80,18 +80,18 @@ your application when user press "More Info" button :
// Here is how to pass points with ID ant PendingIntent
void showMultiplePointsWithPendingIntent(List<SomeDomainObject> list, PendingIntent pendingIntent)
{
// Convert objects to OMPoints
final OMPoint[] points = new OMPoint[list.length];
// Convert objects to Points
final Point[] points = new Point[list.length];
for (int i = 0; i < list.size; i++)
{
// ||
// ||
// \/
// Now you should specify string ID for each point
points[i] = new OMPoint(lat, lon, name, id);
points[i] = new Point(lat, lon, name, id);
}
// Show all points on the map, you could also provide some title
OrganicMapsApi.showPointsOnMap(this, "This title says that user should choose some point", pendingIntent, points);
Api.showPointsOnMap(this, "This title says that user should choose some point", pendingIntent, points);
}
//Code below shows general way to extract response data
@ -100,7 +100,7 @@ your application when user press "More Info" button :
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Handle intent you specified with PandingIntent
// Now it has additional information (OMPoint).
// Now it has additional information (Point).
handleIntent(getIntent());
}
@ -114,10 +114,10 @@ your application when user press "More Info" button :
void handleIntent(Intent intent)
{
// Apply OMResponse extraction method to intent
final OMResponse mwmResponse = OMResponse.extractFromIntent(this, intent);
// Apply Response extraction method to intent
final Response mwmResponse = Response.extractFromIntent(this, intent);
// Here is your point that user selected
final OMPoint point = mwmResponse.getPoint();
final Point point = mwmResponse.getPoint();
// Now, for instance you can do some work depending on point id
processUserInteraction(point.getId());
}
@ -125,24 +125,26 @@ your application when user press "More Info" button :
## FAQ
#### How should I detect if user has Organic Maps installed?
`OrganicMapsApi.isOrganicMapsInstalled(Context)` will return `true` if user has *Lite* or *Pro* version that supports API call installed.
`Api.isOrganicMapsInstalled(Context)` will return `true` if user has *Lite* or *Pro* version that supports API call installed.
#### Which versions of Organic Maps support API calls?
All versions since 2.4.0 and above support API calls.
#### What will happen if I call for `OrganicMapsApi.showPoint()` but Organic Maps application is not installed?
#### What will happen if I call for `Api.showPoint()` but Organic Maps application is not installed?
Nothing serious. API library will show simple dialog with gentle offer to download Organic Maps. You can see how it looks like below.
![Please install us](site/images/dlg.png)
## Sample Code and Application
* [Sample Application at Google Play][linkSampleGooglePlay]
* [Sample Application Source Code][linkSampleSource]
-------------------------------------------------------------------------------
## API Code License
Copyright (c) 2022, Organic Maps OÜ.
Copyright (c) 2019, MY.COM B.V.
Copyright (c) 2013, MapsWithMe GmbH.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@ -154,12 +156,10 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
[linkOM]: https://organicmaps.app/ "Organic Maps"
[linkPIntent]: http://developer.android.com/reference/android/app/PendingIntent.html "PendingIntent"
[linkRepo]: https://github.com/mapswithme/api-android "GitHub Repository"
[linkRepo]: https://github.com/organicmaps/api-android "GitHub Repository"
[linkLibProj]: http://developer.android.com/tools/projects/index.html#LibraryProjects "Android Library Project"
[linkIntents]: http://developer.android.com/guide/components/intents-filters.html "Intents and Intent Filters"
[linkApiClass]: lib/src/com/mapswithme/maps/api/OrganicMapsApi.java "OrganicMapsApi.java"
[linkPointClass]: lib/src/com/mapswithme/maps/api/OMPoint.java "OMPoint.java"
[linkRespClass]: lib/src/com/mapswithme/maps/api/OMResponse.java "OMResponse.java"
[linkSampleSource]: https://github.com/mapswithme/api-android/tree/master/sample-app-capitals "Api Source Code"
[linkSampleGooglePlay]: http://play.google.com/store/apps/details?id=com.mapswithme.capitals "Api Demo .apk"
[linkTravelGuides]: http://www.guidewithme.com
[linkApiClass]: lib/src/app/organicmaps/api/Api.java "Api.java"
[linkPointClass]: lib/src/app/organicmaps/api/Point.java "Point.java"
[linkRespClass]: lib/src/app/organicmaps/api/Response.java "Response.java"
[linkSampleSource]: https://github.com/organicmaps/api-android/tree/master/sample-app-capitals "Api Source Code"

9
build.gradle Normal file
View file

@ -0,0 +1,9 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}

21
gradle.properties Normal file
View file

@ -0,0 +1,21 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View file

@ -0,0 +1,6 @@
#Mon Jun 06 09:48:49 TRT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

185
gradlew vendored Executable file
View file

@ -0,0 +1,185 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

89
gradlew.bat vendored Normal file
View file

@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

1
lib/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

View file

@ -1,8 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="app.organicmaps.api"
android:versionCode="1"
android:versionName="1.0" >
<application />
</manifest>

View file

@ -1,19 +1,32 @@
apply plugin: 'android-library'
plugins {
id 'com.android.library'
}
android {
// Define these properties in the gradle.properties file in the root project folder
compileSdkVersion propTargetSdkVersion.toInteger()
buildToolsVersion propBuildToolsVersion
compileSdk 32
defaultConfig {
minSdkVersion propMinSdkVersion.toInteger()
targetSdkVersion propTargetSdkVersion.toInteger()
minSdk 21
targetSdk 32
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
sourceSets.main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
}

View file

@ -1,92 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="MwmApi" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

0
lib/consumer-rules.pro Normal file
View file

21
lib/proguard-rules.pro vendored Normal file
View file

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View file

@ -1,15 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-21
android.library=true

View file

@ -1,55 +0,0 @@
/******************************************************************************
Copyright (c) 2022, Organic Maps . All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. 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. 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.
******************************************************************************/
package app.organicmaps.api;
public class Const
{
/* Request extras */
static final String AUTHORITY = "app.organicmaps.api";
public static final String EXTRA_URL = AUTHORITY + ".url";
public static final String EXTRA_TITLE = AUTHORITY + ".title";
public static final String EXTRA_API_VERSION = AUTHORITY + ".version";
public static final String EXTRA_CALLER_APP_INFO = AUTHORITY + ".caller_app_info";
public static final String EXTRA_HAS_PENDING_INTENT = AUTHORITY + ".has_pen_intent";
public static final String EXTRA_CALLER_PENDING_INTENT = AUTHORITY + ".pending_intent";
public static final String EXTRA_RETURN_ON_BALLOON_CLICK = AUTHORITY + ".return_on_balloon_click";
public static final String EXTRA_PICK_POINT = AUTHORITY + ".pick_point";
public static final String EXTRA_CUSTOM_BUTTON_NAME = AUTHORITY + ".custom_button_name";
/* Response extras */
/* Point part-by-part*/
public static final String EXTRA_OM_RESPONSE_POINT_NAME = AUTHORITY + ".point_name";
public static final String EXTRA_OM_RESPONSE_POINT_LAT = AUTHORITY + ".point_lat";
public static final String EXTRA_OM_RESPONSE_POINT_LON = AUTHORITY + ".point_lon";
public static final String EXTRA_OM_RESPONSE_POINT_ID = AUTHORITY + ".point_id";
public static final String EXTRA_OM_RESPONSE_ZOOM = AUTHORITY + ".zoom_level";
public static final String ACTION_OM_REQUEST = AUTHORITY + ".request";
static final int API_VERSION = 2;
static final String CALLBACK_PREFIX = "mapswithme.client.";
private Const() {}
}

View file

@ -1,64 +0,0 @@
/******************************************************************************
Copyright (c) 2022, Organic Maps . All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. 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. 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.
******************************************************************************/
package app.organicmaps.api;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.view.Window;
import app.organicmaps.api.R;
public class DownloadOrganicMapsDialog extends Dialog implements android.view.View.OnClickListener
{
public DownloadOrganicMapsDialog(Activity activity)
{
super(activity);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.dlg_install_mwm);
findViewById(R.id.btn_pro).setOnClickListener(this);
setOwnerActivity(activity);
}
public void onDownloadButtonClicked(String url)
{
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
getContext().startActivity(i);
dismiss();
}
@Override
public void onClick(View v)
{
String url = getContext().getString(R.string.url);
onDownloadButtonClicked(url);
}
}

View file

@ -1,77 +0,0 @@
/******************************************************************************
Copyright (c) 2022, Organic Maps . All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. 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. 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.
******************************************************************************/
package app.organicmaps.api;
import android.content.Context;
import android.content.Intent;
public class OMResponse
{
private OMPoint mPoint;
private double mZoomLevel;
/**
*
* @return point, for which user requested more information in Organic Maps application.
*/
public OMPoint getPoint() { return mPoint; }
public boolean hasPoint() { return mPoint != null; }
public double getZoomLevel() { return mZoomLevel; }
@Override
public String toString()
{
return "OMResponse [SelectedPoint=" + mPoint + "]";
}
/**
* Factory method to extract response data from intent.
*
* @param context
* @param intent
* @return
*/
public static OMResponse extractFromIntent(Context context, Intent intent)
{
final OMResponse response = new OMResponse();
// parse point
final double lat = intent.getDoubleExtra(Const.EXTRA_OM_RESPONSE_POINT_LAT, INVALID_LL);
final double lon = intent.getDoubleExtra(Const.EXTRA_OM_RESPONSE_POINT_LON, INVALID_LL);
final String name = intent.getStringExtra(Const.EXTRA_OM_RESPONSE_POINT_NAME);
final String id = intent.getStringExtra(Const.EXTRA_OM_RESPONSE_POINT_ID);
// parse additional info
response.mZoomLevel = intent.getDoubleExtra(Const.EXTRA_OM_RESPONSE_ZOOM, 9);
if (lat != INVALID_LL && lon != INVALID_LL)
response.mPoint = new OMPoint(lat, lon, name, id);
else
response.mPoint = null;
return response;
}
private final static double INVALID_LL = Double.MIN_VALUE;
private OMResponse() {}
}

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="app.organicmaps.api"
xmlns:android="http://schemas.android.com/apk/res/android">
<queries>
<package android:name="app.organicmaps"/>
<package android:name="com.mapswithme.maps"/>
</queries>
</manifest>

View file

@ -1,24 +1,25 @@
/******************************************************************************
Copyright (c) 2022, Organic Maps . All rights reserved.
Copyright (c) 2022, Organic Maps . All rights reserved.
Copyright (c) 2013, MapsWithMe GmbH. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. 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. 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.
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. 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. 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.
******************************************************************************/
package app.organicmaps.api;
@ -26,11 +27,10 @@ import android.app.Activity;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.net.Uri;
public final class OrganicMapsApi
public final class Api
{
/**
@ -42,32 +42,28 @@ public final class OrganicMapsApi
*/
public static final double ZOOM_MIN = 1;
public static void showOrganicMapsUrl(Activity caller, PendingIntent pendingIntent, double zoomLevel, String url)
{
final Uri uri = Uri.parse(url);
final String latlon[] = uri.getQueryParameter("ll").split(",");
final String[] latlon = uri.getQueryParameter("ll").split(",");
final double lat = Double.parseDouble(latlon[0]);
final double lon = Double.parseDouble(latlon[1]);
final String name = uri.getQueryParameter("n");
final String id = uri.getQueryParameter("id");
showPointsOnMap(caller, name, zoomLevel, pendingIntent, new OMPoint(lat, lon, name, id));
showPointsOnMap(caller, name, zoomLevel, pendingIntent, new Point(lat, lon, name, id));
}
public static void sendRequest(Activity caller, MwmRequest request)
public static void sendRequest(Activity caller, Request request)
{
final Intent mwmIntent = request.toIntent(caller);
if (isOrganicMapsInstalled(caller))
{
// Match activity for intent
final ActivityInfo aInfo = caller.getPackageManager().resolveActivity(mwmIntent, 0).activityInfo;
mwmIntent.setClassName(aInfo.packageName, aInfo.name);
caller.startActivity(mwmIntent);
}
else
(new DownloadOrganicMapsDialog(caller)).show();
(new DownloadDialog(caller)).show();
}
/**
@ -80,12 +76,12 @@ public final class OrganicMapsApi
*/
public static void showPointOnMap(Activity caller, double lat, double lon, String name)
{
showPointsOnMap(caller, (String) null, (PendingIntent) null, new OMPoint(lat, lon, name));
showPointsOnMap(caller, null, (PendingIntent) null, new Point(lat, lon, name));
}
/**
* Shows single point on the map using specified zoom level in range from
* {@link OrganicMapsApi#ZOOM_MIN} to {@link OrganicMapsApi#ZOOM_MAX}.
* {@link Api#ZOOM_MIN} to {@link Api#ZOOM_MAX}.
*
* @param caller
* @param lat
@ -95,7 +91,7 @@ public final class OrganicMapsApi
*/
public static void showPointOnMap(Activity caller, double lat, double lon, String name, double zoomLevel)
{
showPointsOnMap(caller, (String) null, zoomLevel, (PendingIntent) null, new OMPoint(lat, lon, name));
showPointsOnMap(caller, null, zoomLevel, null, new Point(lat, lon, name));
}
/**
@ -105,7 +101,7 @@ public final class OrganicMapsApi
* @param title
* @param points
*/
public static void showPointsOnMap(Activity caller, String title, OMPoint... points)
public static void showPointsOnMap(Activity caller, String title, Point... points)
{
showPointsOnMap(caller, title, null, points);
}
@ -119,34 +115,33 @@ public final class OrganicMapsApi
* @param pendingIntent
* @param points
*/
public static void showPointsOnMap(Activity caller, String title, PendingIntent pendingIntent, OMPoint... points)
public static void showPointsOnMap(Activity caller, String title, PendingIntent pendingIntent, Point... points)
{
showPointsOnMap(caller, title, -1, pendingIntent, points);
}
private static void showPointsOnMap(Activity caller, String title, double zoomLevel, PendingIntent pendingIntent,
OMPoint... points)
Point... points)
{
final MwmRequest request = new MwmRequest()
.setTitle(title)
.setZoomLevel(zoomLevel)
.setPendingIntent(pendingIntent)
.setPoints(points);
final Request request = new Request()
.setTitle(title)
.setZoomLevel(zoomLevel)
.setPendingIntent(pendingIntent)
.setPoints(points);
sendRequest(caller, request);
}
public static void pickPoint(Activity caller, String title, PendingIntent pi)
{
final MwmRequest request = new MwmRequest()
.setTitle(title)
.setPickPointMode(true)
.setPendingIntent(pi);
final Request request = new Request()
.setTitle(title)
.setPickPointMode(true)
.setPendingIntent(pi);
sendRequest(caller, request);
}
/**
* Detects if any version (Lite, Pro) of Organic Maps, which supports API calls
* are installed on the device.
* Detects if Organic Maps is installed on the device.
*
* @param context
* @return

View file

@ -0,0 +1,56 @@
/******************************************************************************
Copyright (c) 2022, Organic Maps . All rights reserved.
Copyright (c) 2013, MapsWithMe GmbH. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. 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. 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.
******************************************************************************/
package app.organicmaps.api;
public class Const
{
/* Request extras */
static final String AUTHORITY = "com.mapswithme.maps.api";
public static final String EXTRA_URL = AUTHORITY + ".url";
public static final String EXTRA_TITLE = AUTHORITY + ".title";
public static final String EXTRA_API_VERSION = AUTHORITY + ".version";
public static final String EXTRA_CALLER_APP_INFO = AUTHORITY + ".caller_app_info";
public static final String EXTRA_HAS_PENDING_INTENT = AUTHORITY + ".has_pen_intent";
public static final String EXTRA_CALLER_PENDING_INTENT = AUTHORITY + ".pending_intent";
public static final String EXTRA_RETURN_ON_BALLOON_CLICK = AUTHORITY + ".return_on_balloon_click";
public static final String EXTRA_PICK_POINT = AUTHORITY + ".pick_point";
public static final String EXTRA_CUSTOM_BUTTON_NAME = AUTHORITY + ".custom_button_name";
/* Response extras */
/* Point part-by-part*/
public static final String EXTRA_OM_RESPONSE_POINT_NAME = AUTHORITY + ".point_name";
public static final String EXTRA_OM_RESPONSE_POINT_LAT = AUTHORITY + ".point_lat";
public static final String EXTRA_OM_RESPONSE_POINT_LON = AUTHORITY + ".point_lon";
public static final String EXTRA_OM_RESPONSE_POINT_ID = AUTHORITY + ".point_id";
public static final String EXTRA_OM_RESPONSE_ZOOM = AUTHORITY + ".zoom_level";
public static final String ACTION_OM_REQUEST = AUTHORITY + ".request";
static final int API_VERSION = 2;
static final String CALLBACK_PREFIX = "mapswithme.client.";
private Const() {}
}

View file

@ -0,0 +1,63 @@
/******************************************************************************
Copyright (c) 2022, Organic Maps . All rights reserved.
Copyright (c) 2013, MapsWithMe GmbH. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. 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. 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.
******************************************************************************/
package app.organicmaps.api;
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.view.Window;
public class DownloadDialog extends Dialog implements android.view.View.OnClickListener
{
public DownloadDialog(Activity activity)
{
super(activity);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.dlg_install_mwm);
findViewById(R.id.btn_pro).setOnClickListener(this);
setOwnerActivity(activity);
}
public void onDownloadButtonClicked(String url)
{
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
getContext().startActivity(i);
dismiss();
}
@Override
public void onClick(View v)
{
String url = getContext().getString(R.string.url);
onDownloadButtonClicked(url);
}
}

View file

@ -1,25 +1,26 @@
/******************************************************************************
Copyright (c) 2022, Organic Maps . All rights reserved.
Copyright (c) 2022, Organic Maps . All rights reserved.
Copyright (c) 2013, MapsWithMe GmbH. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. 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. 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.
******************************************************************************/
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. 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. 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.
******************************************************************************/
package app.organicmaps.api;
import java.io.Serializable;
@ -29,7 +30,7 @@ import java.io.Serializable;
* Has its <code>equals()</code> and <code>hashCode()</code> methods overloaded
* so could be used in Hash(Map/Set/etc) classes.
*/
public final class OMPoint implements Serializable
public final class Point implements Serializable
{
private static final long serialVersionUID = 1L;
@ -39,12 +40,12 @@ public final class OMPoint implements Serializable
private String mId;
private Style mStyle;
public OMPoint(double lat, double lon, String name)
public Point(double lat, double lon, String name)
{
this(lat, lon, name, null);
}
public OMPoint(double lat, double lon, String name, String id)
public Point(double lat, double lon, String name, String id)
{
this.mLat = lat;
this.mLon = lon;
@ -52,7 +53,7 @@ public final class OMPoint implements Serializable
this.mId = id;
}
public OMPoint(double lat, double lon, String name, String id, Style style)
public Point(double lat, double lon, String name, String id, Style style)
{
this.mLat = lat;
this.mLon = lon;
@ -61,20 +62,23 @@ public final class OMPoint implements Serializable
this.mStyle = style;
}
public double getLat() { return mLat; }
public double getLon() { return mLon; }
public String getName() { return mName; }
public String getId() { return mId; }
public Style getStyle() { return mStyle; }
public double getLat() {return mLat;}
public String getStyleForUrl() { return (mStyle == null) ? null : mStyle.getName(); }
public double getLon() {return mLon;}
public String getName() {return mName;}
public String getId() {return mId;}
/**
* Sets string ID for this point. Internally it is not used to distinguish point,
* it's purpose to help clients code to associate point with domain objects of their application.
*
* @param id
*/
public void setId(String id) { mId = id; }
public void setId(String id) {mId = id;}
public Style getStyle() {return mStyle;}
/**
* Sets the style (appearance) for this point.
@ -86,14 +90,16 @@ public final class OMPoint implements Serializable
this.mStyle = style;
}
public String getStyleForUrl() {return (mStyle == null) ? null : mStyle.getName();}
@Override
public String toString()
{
return "OMPoint [lat=" + mLat +
", lon=" + mLon +
", name=" + mName +
", id=" + mId +
", style=" + mStyle + "]";
", lon=" + mLon +
", name=" + mName +
", id=" + mId +
", style=" + mStyle + "]";
}
@Override
@ -111,8 +117,8 @@ public final class OMPoint implements Serializable
}
/**
* Two point are considered
* equal if they have they lat, lon, and name attributes equal.
* Two point are considered
* equal if they have they lat, lon, and name attributes equal.
*/
@Override
public boolean equals(Object obj)
@ -123,7 +129,7 @@ public final class OMPoint implements Serializable
return false;
if (getClass() != obj.getClass())
return false;
final OMPoint other = (OMPoint) obj;
final Point other = (Point) obj;
if (Double.doubleToLongBits(mLat) != Double.doubleToLongBits(other.mLat))
return false;
if (Double.doubleToLongBits(mLon) != Double.doubleToLongBits(other.mLon))
@ -155,9 +161,9 @@ public final class OMPoint implements Serializable
// placemark-lime
// placemark-teal
private String name;
private final String name;
private Style(String name)
Style(String name)
{
this.name = name;
}

View file

@ -1,78 +1,156 @@
/******************************************************************************
Copyright (c) 2022, Organic Maps . All rights reserved.
Copyright (c) 2013, MapsWithMe GmbH. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. 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. 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.
******************************************************************************/
package app.organicmaps.api;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import android.annotation.SuppressLint;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
public class MwmRequest
public class Request
{
// **
private List<OMPoint> mPoints = new ArrayList<OMPoint>();
private PendingIntent mPendingIntent;
private String mTitle;
private double mZoomLevel = 1;
private boolean mReturnOnBalloonClick;
private boolean mPickPoint = false;
private String mCustomButtonName = "";
private List<Point> mPoints = new ArrayList<>();
private PendingIntent mPendingIntent;
private String mTitle;
private double mZoomLevel = 1;
private boolean mReturnOnBalloonClick;
private boolean mPickPoint = false;
private String mCustomButtonName = "";
// **
public MwmRequest setCustomButtonName(String buttonName)
private static StringBuilder createMwmUrl(Context context, String title, double zoomLevel, List<Point> points)
{
final StringBuilder urlBuilder = new StringBuilder("om://map?");
// version
urlBuilder.append("v=").append(Const.API_VERSION).append("&");
// back url, always not null
urlBuilder.append("backurl=").append(getCallbackAction(context)).append("&");
// title
appendIfNotNull(urlBuilder, "appname", title);
// zoom
appendIfNotNull(urlBuilder, "z", isValidZoomLevel(zoomLevel) ? String.valueOf(zoomLevel) : null);
// points
for (final Point point : points)
{
if (point != null)
{
urlBuilder.append("ll=").append(String.format(Locale.US, "%f,%f&", point.getLat(), point.getLon()));
appendIfNotNull(urlBuilder, "n", point.getName());
appendIfNotNull(urlBuilder, "id", point.getId());
appendIfNotNull(urlBuilder, "s", point.getStyleForUrl());
}
}
return urlBuilder;
}
private static String getCallbackAction(Context context)
{
return Const.CALLBACK_PREFIX + context.getPackageName();
}
private static Intent addCommonExtras(Context context, Intent intent)
{
intent.putExtra(Const.EXTRA_CALLER_APP_INFO, context.getApplicationInfo());
intent.putExtra(Const.EXTRA_API_VERSION, Const.API_VERSION);
return intent;
}
private static StringBuilder appendIfNotNull(StringBuilder builder, String key, String value)
{
if (value != null)
builder.append(key).append("=").append(Uri.encode(value)).append("&");
return builder;
}
private static boolean isValidZoomLevel(double zoom)
{
return zoom >= Api.ZOOM_MIN && zoom <= Api.ZOOM_MAX;
}
public Request setCustomButtonName(String buttonName)
{
mCustomButtonName = buttonName != null ? buttonName : "";
return this;
}
public MwmRequest setTitle(String title)
public Request setTitle(String title)
{
mTitle = title;
return this;
}
public MwmRequest setPickPointMode(boolean pickPoint)
public Request setPickPointMode(boolean pickPoint)
{
mPickPoint = pickPoint;
return this;
}
public MwmRequest addPoint(OMPoint point)
public Request addPoint(Point point)
{
mPoints.add(point);
return this;
}
public MwmRequest addPoint(double lat, double lon, String name, String id)
public Request addPoint(double lat, double lon, String name, String id)
{
return addPoint(new OMPoint(lat, lon, name, id));
return addPoint(new Point(lat, lon, name, id));
}
public MwmRequest setPoints(Collection<OMPoint> points)
public Request setPoints(Collection<Point> points)
{
mPoints = new ArrayList<OMPoint>(points);
mPoints = new ArrayList<Point>(points);
return this;
}
public MwmRequest setReturnOnBalloonClick(boolean doReturn)
// Below are utilities from OrganicMapsApi because we are not "Feature Envy"
public Request setReturnOnBalloonClick(boolean doReturn)
{
mReturnOnBalloonClick = doReturn;
return this;
}
public MwmRequest setZoomLevel(double zoomLevel)
public Request setZoomLevel(double zoomLevel)
{
mZoomLevel = zoomLevel;
return this;
}
public MwmRequest setPendingIntent(PendingIntent pi)
public Request setPendingIntent(PendingIntent pi)
{
mPendingIntent = pi;
return this;
@ -105,70 +183,12 @@ public class MwmRequest
}
/**
* @Hidden
* This method is internal only.
* @Hidden This method is internal only.
* Used for compatibility.
*/
MwmRequest setPoints(OMPoint[] points)
Request setPoints(Point[] points)
{
return setPoints(Arrays.asList(points));
}
// Below are utilities from OrganicMapsApi because we are not "Feature Envy"
private static StringBuilder createMwmUrl(Context context, String title, double zoomLevel, List<OMPoint> points)
{
final StringBuilder urlBuilder = new StringBuilder("mapswithme://map?");
// version
urlBuilder.append("v=").append(Const.API_VERSION).append("&");
// back url, always not null
urlBuilder.append("backurl=").append(getCallbackAction(context)).append("&");
// title
appendIfNotNull(urlBuilder, "appname", title);
// zoom
appendIfNotNull(urlBuilder, "z", isValidZoomLevel(zoomLevel) ? String.valueOf(zoomLevel) : null);
// points
for (final OMPoint point : points)
{
if (point != null)
{
urlBuilder.append("ll=").append(String.format(Locale.US, "%f,%f&", point.getLat(), point.getLon()));
appendIfNotNull(urlBuilder, "n", point.getName());
appendIfNotNull(urlBuilder, "id", point.getId());
appendIfNotNull(urlBuilder, "s", point.getStyleForUrl());
}
}
return urlBuilder;
}
private static String getCallbackAction(Context context)
{
return Const.CALLBACK_PREFIX + context.getPackageName();
}
@SuppressLint("NewApi")
private static Intent addCommonExtras(Context context, Intent intent)
{
intent.putExtra(Const.EXTRA_CALLER_APP_INFO, context.getApplicationInfo());
intent.putExtra(Const.EXTRA_API_VERSION, Const.API_VERSION);
return intent;
}
private static StringBuilder appendIfNotNull(StringBuilder builder, String key, String value)
{
if (value != null)
builder.append(key).append("=").append(Uri.encode(value)).append("&");
return builder;
}
private static boolean isValidZoomLevel(double zoom)
{
return zoom >= OrganicMapsApi.ZOOM_MIN && zoom <= OrganicMapsApi.ZOOM_MAX;
}
}

View file

@ -0,0 +1,78 @@
/******************************************************************************
Copyright (c) 2022, Organic Maps . All rights reserved.
Copyright (c) 2013, MapsWithMe GmbH. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. 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. 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.
******************************************************************************/
package app.organicmaps.api;
import android.content.Context;
import android.content.Intent;
public class Response
{
private final static double INVALID_LL = Double.MIN_VALUE;
private Point mPoint;
private double mZoomLevel;
private Response() {}
/**
* Factory method to extract response data from intent.
*
* @param context
* @param intent
* @return
*/
public static Response extractFromIntent(Context context, Intent intent)
{
final Response response = new Response();
// parse point
final double lat = intent.getDoubleExtra(Const.EXTRA_OM_RESPONSE_POINT_LAT, INVALID_LL);
final double lon = intent.getDoubleExtra(Const.EXTRA_OM_RESPONSE_POINT_LON, INVALID_LL);
final String name = intent.getStringExtra(Const.EXTRA_OM_RESPONSE_POINT_NAME);
final String id = intent.getStringExtra(Const.EXTRA_OM_RESPONSE_POINT_ID);
// parse additional info
response.mZoomLevel = intent.getDoubleExtra(Const.EXTRA_OM_RESPONSE_ZOOM, 9);
if (lat != INVALID_LL && lon != INVALID_LL)
response.mPoint = new Point(lat, lon, name, id);
else
response.mPoint = null;
return response;
}
/**
* @return point, for which user requested more information in Organic Maps application.
*/
public Point getPoint() {return mPoint;}
public boolean hasPoint() {return mPoint != null;}
public double getZoomLevel() {return mZoomLevel;}
@Override
public String toString()
{
return "Response [SelectedPoint=" + mPoint + "]";
}
}

View file

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View file

@ -22,9 +22,8 @@
OF SUCH DAMAGE.
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
@ -52,7 +51,7 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/btn_green_selector"
android:text="@string/down_pro" />
android:text="@string/download" />
</LinearLayout>

1
sample-app-capitals/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/build

View file

@ -1,19 +1,35 @@
apply plugin: 'android'
plugins {
id 'com.android.application'
}
android {
// Define these properties in the gradle.properties file in the root project folder
compileSdkVersion propTargetSdkVersion.toInteger()
buildToolsVersion propBuildToolsVersion
compileSdk 32
defaultConfig {
minSdkVersion propMinSdkVersion.toInteger()
targetSdkVersion propTargetSdkVersion.toInteger()
applicationId "app.organicmaps.api.sample.capitals"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
sourceSets.main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation project(path: ':lib')
}

View file

@ -1,92 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="MwmApi" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

21
sample-app-capitals/proguard-rules.pro vendored Normal file
View file

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View file

@ -1,15 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-21
android.library.reference.1=../lib

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

View file

@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2022, Organic Maps OÜ. All rights reserved.
Copyright (c) 2013, MapsWithMe GmbH. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. Redistributions in binary form must
reproduce the above copyright notice, this list of conditions and the following
@ -21,36 +20,29 @@
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mapswithme.capitals"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="21" />
<manifest package="app.organicmaps.api.sample.capitals"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="com.mapswithme.capitals.CapitalsListActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".CapitalsListActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.mapswithme.capitals.CityDetailsActivity"
android:label="@string/app_name" >
android:launchMode="singleTop" >
</activity>
<activity
android:name=".CityDetailsActivity"
android:launchMode="singleTop" />
</application>
</application>
</manifest>
</manifest>

View file

@ -1,5 +1,6 @@
/******************************************************************************
Copyright (c) 2022, Organic Maps . All rights reserved.
Copyright (c) 2022, Organic Maps . All rights reserved.
Copyright (c) 2013, MapsWithMe GmbH. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
@ -20,7 +21,7 @@
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
******************************************************************************/
package com.mapswithme.capitals;
package app.organicmaps.api.sample.capitals;
import android.app.ListActivity;
import android.content.Context;
@ -32,8 +33,8 @@ import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import app.organicmaps.api.OMPoint;
import app.organicmaps.api.OrganicMapsApi;
import app.organicmaps.api.Point;
import app.organicmaps.api.Api;
public class CapitalsListActivity extends ListActivity
{
@ -48,11 +49,7 @@ public class CapitalsListActivity extends ListActivity
mCityAdapter = new CityAdapter(this, City.CAPITALS);
setListAdapter(mCityAdapter);
findViewById(R.id.btn_all).setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) { showCityOnOMMap(City.CAPITALS); }
});
findViewById(R.id.btn_all).setOnClickListener(v -> showCityOnOMMap(City.CAPITALS));
}
@ -64,12 +61,12 @@ public class CapitalsListActivity extends ListActivity
private void showCityOnOMMap(City ... cities)
{
OMPoint[] points = new OMPoint[cities.length];
Point[] points = new Point[cities.length];
for (int i = 0; i < cities.length; i++)
points[i] = cities[i].toOMPoint();
points[i] = cities[i].toPoint();
final String title = cities.length == 1 ? cities[0].getName() : "Capitals of the World";
OrganicMapsApi.showPointsOnMap(this, title, CityDetailsActivity.getPendingIntent(this), points);
Api.showPointsOnMap(this, title, CityDetailsActivity.getPendingIntent(this), points);
}
private static class CityAdapter extends ArrayAdapter<City>
@ -86,9 +83,9 @@ public class CapitalsListActivity extends ListActivity
public View getView(int position, View convertView, ViewGroup parent)
{
final View view = super.getView(position, convertView, parent);
final TextView subText = (TextView) view.findViewById(android.R.id.text2);
final TextView subText = view.findViewById(android.R.id.text2);
final City city = data[position];
subText.setText(city.getCountryCode() + "/" + city.getTimeZone());
subText.setText(String.format("%s/%s", city.getCountryCode(), city.getTimeZone()));
return view;
}
}

View file

@ -1,28 +1,29 @@
/******************************************************************************
Copyright (c) 2022, Organic Maps . All rights reserved.
Copyright (c) 2022, Organic Maps . All rights reserved.
Copyright (c) 2013, MapsWithMe GmbH. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. 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. 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.
******************************************************************************/
package com.mapswithme.capitals;
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. 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. 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.
******************************************************************************/
package app.organicmaps.api.sample.capitals;
import app.organicmaps.api.OMPoint;
import app.organicmaps.api.Point;
import java.util.Arrays;
import java.util.Comparator;
@ -56,7 +57,7 @@ public class City
@Override
public String toString() { return name; }
public OMPoint toOMPoint() { return new OMPoint(lat, lon, name, id); }
public Point toPoint() { return new Point(lat, lon, name, id); }
public String getId() { return id; }
public String getName() { return name; }
@ -69,7 +70,7 @@ public class City
public String getAltNames() { return altNames; }
public static City fromOMPoint(OMPoint point)
public static City fromPoint(Point point)
{
City result = null;
final String id = point.getId();

View file

@ -1,26 +1,27 @@
/******************************************************************************
Copyright (c) 2022, Organic Maps . All rights reserved.
Copyright (c) 2022, Organic Maps . All rights reserved.
Copyright (c) 2013, MapsWithMe GmbH. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. 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. 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.
******************************************************************************/
package com.mapswithme.capitals;
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer. 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. 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.
******************************************************************************/
package app.organicmaps.api.sample.capitals;
import android.app.Activity;
import android.app.PendingIntent;
@ -31,12 +32,12 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import app.organicmaps.api.OMResponse;
import app.organicmaps.api.OrganicMapsApi;
import app.organicmaps.api.Response;
import app.organicmaps.api.Api;
public class CityDetailsActivity extends Activity
{
public static String EXTRA_FROM_OM = "from-maps-with-me";
public static String EXTRA_FROM_ORGANICMAPS = "from-organicmaps";
private TextView mName;
private TextView mAltNames;
@ -54,8 +55,8 @@ public class CityDetailsActivity extends Activity
public static PendingIntent getPendingIntent(Context context)
{
final Intent i = new Intent(context, CityDetailsActivity.class);
i.putExtra(EXTRA_FROM_OM, true);
return PendingIntent.getActivity(context, 0, i, 0);
i.putExtra(EXTRA_FROM_ORGANICMAPS, true);
return PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_IMMUTABLE);
}
@Override
@ -80,9 +81,8 @@ public class CityDetailsActivity extends Activity
@Override
public void onClick(View v)
{
OrganicMapsApi
.showPointsOnMap(CityDetailsActivity.this,mCity.getName(),
CityDetailsActivity.getPendingIntent(CityDetailsActivity.this),mCity.toOMPoint());
Api.showPointsOnMap(CityDetailsActivity.this,mCity.getName(),
CityDetailsActivity.getPendingIntent(CityDetailsActivity.this),mCity.toPoint());
}
});
@ -98,10 +98,10 @@ public class CityDetailsActivity extends Activity
private void handleIntent(Intent intent)
{
if (intent.getBooleanExtra(EXTRA_FROM_OM, false))
if (intent.getBooleanExtra(EXTRA_FROM_ORGANICMAPS, false))
{
final OMResponse response = OMResponse.extractFromIntent(this, intent);
mCity = City.fromOMPoint(response.getPoint());
final Response response = Response.extractFromIntent(this, intent);
mCity = City.fromPoint(response.getPoint());
if (mCity != null)
{

View file

@ -0,0 +1,15 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108"
android:tint="#006C35">
<group android:scaleX="2.931552"
android:scaleY="2.931552"
android:translateX="18.821377"
android:translateY="18.821377">
<path
android:fillColor="@android:color/white"
android:pathData="M14,12l-2,2l-2,-2l2,-2L14,12zM12,6l2.12,2.12l2.5,-2.5L12,1L7.38,5.62l2.5,2.5L12,6zM6,12l2.12,-2.12l-2.5,-2.5L1,12l4.62,4.62l2.5,-2.5L6,12zM18,12l-2.12,2.12l2.5,2.5L23,12l-4.62,-4.62l-2.5,2.5L18,12zM12,18l-2.12,-2.12l-2.5,2.5L12,23l4.62,-4.62l-2.5,-2.5L12,18z"/>
</group>
</vector>

View file

@ -43,6 +43,6 @@
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/show_all"
android:drawableLeft="@drawable/ic_launcher"/>
android:drawableLeft="@mipmap/ic_launcher"/>
</LinearLayout>

View file

@ -39,8 +39,8 @@
android:id="@+id/showOnMap"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/ic_launcher"
android:text="@string/open_with_mapswithme" />
android:drawableLeft="@mipmap/ic_launcher"
android:text="@string/open_with_organicmaps" />
<LinearLayout
android:layout_width="match_parent"

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">maps.me capitals</string>
<string name="show_all">Show all capitals with maps.me</string>
<string name="open_with_mapswithme">Open with maps.me</string>
<string name="app_name">Organic Maps Capitals</string>
<string name="show_all">Show all capitals with Organic Maps</string>
<string name="open_with_organicmaps">Open with Organic Maps</string>
<string name="name">Name:</string>
<string name="alternative_names">Alternative names:</string>
<string name="lat">Lat:</string>

17
settings.gradle Normal file
View file

@ -0,0 +1,17 @@
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "Organic Maps API"
include ':sample-app-capitals'
include ':lib'