Merge pull request #9 from mapswithme/dev

Pick Point API feature
This commit is contained in:
deathbaba 2013-10-06 14:09:04 -07:00
commit f3b22d0db4
7 changed files with 70 additions and 0 deletions

2
.gitignore vendored
View file

@ -1,7 +1,9 @@
bin/
gen/
build/
.settings/
.DS_Store
.classpath
.cproject
.project

View file

@ -2,4 +2,9 @@
package="com.mapwithme.maps.api"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="18" />
</manifest>

27
lib/build.gradle Normal file
View file

@ -0,0 +1,27 @@
apply plugin: 'android-library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}

View file

@ -34,6 +34,8 @@ public class Const
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 */
@ -42,6 +44,7 @@ public class Const
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 EXTRA_MWM_RESPONSE_ZOOM = AUTHORITY + ".zoom_level";
public static final String ACTION_MWM_REQUEST = AUTHORITY + ".request";

View file

@ -22,12 +22,14 @@
******************************************************************************/
package com.mapswithme.maps.api;
import android.app.DownloadManager.Request;
import android.content.Context;
import android.content.Intent;
public class MWMResponse
{
private MWMPoint mPoint;
private double mZoomLevel;
/**
*
@ -35,6 +37,7 @@ public class MWMResponse
*/
public MWMPoint getPoint() { return mPoint; }
public boolean hasPoint() { return mPoint != null; }
public double getZoomLevel() { return mZoomLevel; }
@Override
public String toString()
@ -58,6 +61,9 @@ public class MWMResponse
final String name = intent.getStringExtra(Const.EXTRA_MWM_RESPONSE_POINT_NAME);
final String id = intent.getStringExtra(Const.EXTRA_MWM_RESPONSE_POINT_ID);
// parse additional info
response.mZoomLevel = intent.getDoubleExtra(Const.EXTRA_MWM_RESPONSE_ZOOM, 9);
if (lat != INVALID_LL && lon != INVALID_LL)
response.mPoint = new MWMPoint(lat, lon, name, id);
else

View file

@ -135,6 +135,15 @@ public final class MapsWithMeApi
sendRequest(caller, request);
}
public static void pickPoint(Activity caller, String title, PendingIntent pi)
{
final MwmRequest request = new MwmRequest()
.setTitle(title)
.setPickPointMode(true)
.setPendingIntent(pi);
sendRequest(caller, request);
}
/**
* Detects if any version (Lite, Pro) of MapsWithMe, which supports API calls
* are installed on the device.

View file

@ -21,14 +21,28 @@ public class MwmRequest
private String mTitle;
private double mZoomLevel = 1;
private boolean mReturnOnBalloonClick;
private boolean mPickPoint = false;
private String mCustomButtonName = "";
// **
public MwmRequest setCustomButtonName(String buttonName)
{
mCustomButtonName = buttonName != null ? buttonName : "";
return this;
}
public MwmRequest setTitle(String title)
{
mTitle = title;
return this;
}
public MwmRequest setPickPointMode(boolean pickPoint)
{
mPickPoint = pickPoint;
return this;
}
public MwmRequest addPoint(MWMPoint point)
{
mPoints.add(point);
@ -75,6 +89,10 @@ public class MwmRequest
mwmIntent.putExtra(Const.EXTRA_TITLE, mTitle);
// more
mwmIntent.putExtra(Const.EXTRA_RETURN_ON_BALLOON_CLICK, mReturnOnBalloonClick);
// pick point
mwmIntent.putExtra(Const.EXTRA_PICK_POINT, mPickPoint);
// custom button name
mwmIntent.putExtra(Const.EXTRA_CUSTOM_BUTTON_NAME, mCustomButtonName);
final boolean hasIntent = mPendingIntent != null;
mwmIntent.putExtra(Const.EXTRA_HAS_PENDING_INTENT, hasIntent);