Use API from separate git repo

- Also fixed null pointer crash due to new API implementation
This commit is contained in:
Alexander Zolotarev 2013-12-12 16:18:35 +03:00
parent 08463b5a0c
commit 425104d6ff
33 changed files with 7 additions and 954 deletions

5
.gitignore vendored
View file

@ -22,4 +22,7 @@ builder/wikivoyage/*.sql.gz
builder/wikivoyage/images
builder/wikivoyage/articles
builder/wikivoyage/articles_desktop
builder/wikivoyage/Countries
builder/wikivoyage/Countries
# This is separate git repository with MWM API
3rdparty/android-mwm

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>

View file

@ -1,18 +0,0 @@
bin/
gen/
.settings/
resbuilder/
spoon-output/
assets/
obj/
armeabi/
mips/
x86/
armeabi-v7a/
*.class
.classpath
.cproject
.project
local.properties
lint.xml

View file

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>mwm_api_android</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -1,4 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6

View file

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

View file

@ -1,34 +0,0 @@
apply plugin: 'android-library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "19"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}

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>

View file

@ -1,2 +0,0 @@
sdk.dir=/Users/viktor/Developer/android-sdk-macosx
ndk.dir=/Users/viktor/Developer/android-ndk-r8d

View file

@ -1,20 +0,0 @@
# To enable ProGuard in your project, edit project.properties
# to define the proguard.config property as described in that file.
#
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in ${sdk.dir}/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# 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 *;
#}

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-19
android.library=true

View file

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:dither="true"
android:src="@drawable/pattern"
android:tileMode="repeat" />

View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- "background shadow" -->
<item android:drawable="@drawable/shadow"/>
<item
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp"
android:drawable="@drawable/gray"/>
</layer-list>

View file

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- "background shadow" -->
<item android:drawable="@drawable/shadow"/>
<item
android:bottom="2dp"
android:left="1dp"
android:right="1dp"
android:top="1dp"
android:drawable="@drawable/gray"/>
<item android:drawable="@drawable/overflow"/>
</layer-list>

View file

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- "background shadow" -->
<item android:drawable="@drawable/shadow"/>
<item
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp"
android:drawable="@drawable/green"/>
</layer-list>

View file

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- "background shadow" -->
<item android:drawable="@drawable/shadow"/>
<item
android:bottom="2dp"
android:left="1dp"
android:right="1dp"
android:top="1dp"
android:drawable="@drawable/green"/>
<item android:drawable="@drawable/overflow"/>
</layer-list>

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/btn_back_gray_active" android:state_pressed="true"/>
<item android:drawable="@drawable/btn_back_gray"/>
</selector>

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/btn_back_green_active" android:state_pressed="true"/>
<item android:drawable="@drawable/btn_back_green"/>
</selector>

View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient android:type="linear"
android:angle="90"
android:startColor="#D00099CC"
android:centerColor="#D033B5E5"
android:endColor="#D00099CC"/>
<corners android:radius="4dp" />
</shape>

View file

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<!--
<solid android:color="#66CC33" /> -->
<gradient android:type="linear"
android:angle="90"
android:startColor="#D066CC33"
android:centerColor="#D099CC00"
android:endColor="#D066CC33"/>
<corners android:radius="4dp" />
</shape>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#80FFFFFF" />
<corners android:radius="3dp" />
</shape>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="-90"
android:centerX="50%"
android:centerY="50%"
android:gradientRadius="400"
android:startColor="#44000000"
android:endColor="#88000000"
android:type="linear" />
<corners android:radius="4dp" />
</shape>

View file

@ -1,76 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/background_pattern"
android:gravity="center"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<TextView
style="@android:style/TextAppearance.Medium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="0"
android:gravity="center"
android:text="@string/mwm_should_be_installed"
android:textColor="@android:color/black"/>
<Button
android:id="@+id/btn_pro"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:background="@drawable/btn_green_selector"
android:padding="6dp"
android:text="@string/down_pro"
android:textColor="@android:color/white"
android:textStyle="bold"/>
<Button
android:id="@+id/btn_lite"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="@drawable/btn_gray_selector"
android:padding="6dp"
android:text="@string/down_lite"
android:textColor="@android:color/white"
android:textStyle="bold" />
</LinearLayout>
</ScrollView>

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="mwm_should_be_installed">Offline maps are required to proceed. We have partnered with MapsWithMe to provide you with offline maps of the entire world.\nTo continue please download the app:</string>
<string name="down_lite">Download MapsWithMe Lite (free)</string>
<string name="down_pro">Download MapsWithMe Pro</string>
<string name="url_pro">http://mapswith.me/get</string>
<string name="url_lite">http://mapswith.me/app</string>
</resources>

View file

@ -1,51 +0,0 @@
/******************************************************************************
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 com.mapswithme.maps.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";
/* Response extras */
/* Point part-by-part*/
public static final String EXTRA_MWM_RESPONSE_POINT_NAME = AUTHORITY + ".point_name";
public static final String EXTRA_MWM_RESPONSE_POINT_LAT = AUTHORITY + ".point_lat";
public static final String EXTRA_MWM_RESPONSE_POINT_LON = AUTHORITY + ".point_lon";
public static final String EXTRA_MWM_RESPONSE_POINT_ID = AUTHORITY + ".point_id";
public static final String ACTION_MWM_REQUEST = AUTHORITY + ".request";
static final int API_VERSION = 1;
static final String CALLBACK_PREFIX = "mapswithme.client.";
private Const() {}
}

View file

@ -1,65 +0,0 @@
/******************************************************************************
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 com.mapswithme.maps.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 com.mapwithme.maps.api.R;
public class DownloadMapsWithMeDialog extends Dialog implements android.view.View.OnClickListener
{
public DownloadMapsWithMeDialog(Activity activity)
{
super(activity);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.dlg_install_mwm);
findViewById(R.id.btn_lite).setOnClickListener(this);
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(v.getId() == R.id.btn_lite ? R.string.url_lite : R.string.url_pro);
onDownloadButtonClicked(url);
}
}

View file

@ -1,107 +0,0 @@
/******************************************************************************
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 com.mapswithme.maps.api;
import java.io.Serializable;
/**
* POI wrapper object.
* Has it's <code>equals()</code> and <code>hashCode()</code> methods overloaded
* so could be used in Hash(Map/Set/etc) classes.
*/
public final class MWMPoint implements Serializable
{
private static final long serialVersionUID = 1L;
final private double mLat;
final private double mLon;
final private String mName;
private String mId;
public MWMPoint(double lat, double lon, String name)
{
this(lat, lon, name, null);
}
public MWMPoint(double lat, double lon, String name, String id)
{
this.mLat = lat;
this.mLon = lon;
this.mName = name;
this.mId = id;
}
public double getLat() { return mLat; }
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; }
@Override
public String toString()
{
return "MWMPoint [lat=" + mLat + ", lon=" + mLon + ", name=" + mName + ", id=" + mId + "]";
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(mLat);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(mLon);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((mName == null) ? 0 : mName.hashCode());
return result;
}
/**
* Two point are considered
* equal if they have they lat, lon, and name attributes equal.
*/
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final MWMPoint other = (MWMPoint) obj;
if (Double.doubleToLongBits(mLat) != Double.doubleToLongBits(other.mLat))
return false;
if (Double.doubleToLongBits(mLon) != Double.doubleToLongBits(other.mLon))
return false;
return mName == null ? other.mName == null : mName.equals(other.mName);
}
}

View file

@ -1,67 +0,0 @@
/******************************************************************************
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 com.mapswithme.maps.api;
import android.content.Context;
import android.content.Intent;
public class MWMResponse
{
private MWMPoint mPoint;
/**
*
* @return point, for which user requested more information in MapsWithMe application.
*/
public MWMPoint getPoint() { return mPoint; }
public boolean hasPoint() { return mPoint != null; }
@Override
public String toString()
{
return "MWMResponse [SelectedPoint=" + mPoint + "]";
}
/**
* Factory method to extract response data from intent.
*
* @param context
* @param intent
* @return
*/
public static MWMResponse extractFromIntent(Context context, Intent intent)
{
final MWMResponse response = new MWMResponse();
// parse status
// parse point
final double lat = intent.getDoubleExtra(Const.EXTRA_MWM_RESPONSE_POINT_LAT, 0);
final double lon = intent.getDoubleExtra(Const.EXTRA_MWM_RESPONSE_POINT_LON, 0);
final String name = intent.getStringExtra(Const.EXTRA_MWM_RESPONSE_POINT_NAME);
final String id = intent.getStringExtra(Const.EXTRA_MWM_RESPONSE_POINT_ID);
response.mPoint = new MWMPoint(lat, lon, name, id);
return response;
}
private MWMResponse() {}
}

View file

@ -1,215 +0,0 @@
/******************************************************************************
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 com.mapswithme.maps.api;
import java.util.Locale;
import android.annotation.SuppressLint;
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 MapsWithMeApi
{
/**
* Most detailed level, buildings and trees are seen.
*/
public static final double ZOOM_MAX = 19;
/**
* Least detailed level, continents are seen.
*/
public static final double ZOOM_MIN = 1;
/**
* Shows single point on the map.
*
* @param caller
* @param lat
* @param lon
* @param name
*/
public static void showPointOnMap(Activity caller, double lat, double lon, String name)
{
showPointsOnMap(caller, (String)null, (PendingIntent)null, new MWMPoint(lat, lon, name));
}
/**
* Shows single point on the map using specified
* zoom level in range from {@link MapsWithMeApi#ZOOM_MIN} to {@link MapsWithMeApi#ZOOM_MAX}.
*
* @param caller
* @param lat
* @param lon
* @param name
* @param zoomLevel
*/
public static void showPointOnMap(Activity caller, double lat, double lon, String name, double zoomLevel)
{
showPointsOnMap(caller, (String)null, zoomLevel, (PendingIntent)null, new MWMPoint(lat, lon, name));
}
/**
* Shows set of points on the map.
*
* @param caller
* @param title
* @param points
*/
public static void showPointsOnMap(Activity caller, String title, MWMPoint... points)
{
showPointsOnMap(caller, title, null, points);
}
/**
* Shows set of points on the maps
* and allows MapsWithMeApplication to send {@link PendingIntent} provided by client application.
*
* @param caller
* @param title
* @param pendingIntent
* @param points
*/
public static void showPointsOnMap(Activity caller, String title, PendingIntent pendingIntent, MWMPoint ... points)
{
showPointsOnMap(caller, title, -1, pendingIntent, points);
}
public static void showMapsWithMeUrl(Activity caller, PendingIntent pendingIntent, double zoomLevel, String url)
{
final Uri uri = Uri.parse(url);
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 MWMPoint(lat, lon, name, id));
}
/**
* Detects if any version (Lite, Pro) of MapsWithMe, which supports
* API calls are installed on the device.
*
* @param context
* @return
*/
public static boolean isMapsWithMeInstalled(Context context)
{
final Intent intent = new Intent(Const.ACTION_MWM_REQUEST);
return context.getPackageManager().resolveActivity(intent, 0) != null;
}
// Internal only code
private static void showPointsOnMap(Activity caller, String title, double zoomLevel, PendingIntent pendingIntent, MWMPoint... points)
{
final Intent mwmIntent = new Intent(Const.ACTION_MWM_REQUEST);
mwmIntent.putExtra(Const.EXTRA_URL, createMwmUrl(caller, title, zoomLevel, points).toString());
mwmIntent.putExtra(Const.EXTRA_TITLE, title);
final boolean hasIntent = pendingIntent != null;
mwmIntent.putExtra(Const.EXTRA_HAS_PENDING_INTENT, hasIntent);
if (hasIntent)
mwmIntent.putExtra(Const.EXTRA_CALLER_PENDING_INTENT, pendingIntent);
addCommonExtras(caller, mwmIntent);
if (isMapsWithMeInstalled(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 DownloadMapsWithMeDialog(caller)).show();
}
static StringBuilder createMwmUrl(Context context, String title, double zoomLevel, MWMPoint ... points)
{
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 (MWMPoint 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());
}
}
return urlBuilder;
}
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 >= ZOOM_MIN && zoom <= ZOOM_MAX;
}
}

View file

@ -12,5 +12,5 @@
# Project target.
target=android-19
android.library.reference.1=../3rdparty/android-mwm
android.library.reference.1=../3rdparty/android-mwm/lib
android.library.reference.2=3rdparty/expansion_downloader

View file

@ -1,4 +1,4 @@
include ':3rdparty:play_licensing'
include ':3rdparty:expansion_downloader'
include ':android-mwm'
project(':android-mwm').projectDir = new File(settingsDir, '../3rdparty/android-mwm')
project(':android-mwm').projectDir = new File(settingsDir, '../3rdparty/android-mwm/lib')

View file

@ -120,7 +120,7 @@ public class ArticleInfoListActivity extends FragmentActivity
final MWMResponse mwmResponse = MWMResponse.extractFromIntent(this, intent);
final MWMPoint point = mwmResponse.getPoint();
if (point.getId() != null)
if (point != null && point.getId() != null)
{
final String id = point.getId();
Log.d(TAG, id);