forked from organicmaps/organicmaps
[android] My Position with address.
This commit is contained in:
parent
c1c56b8b86
commit
9fa6ab8c9c
8 changed files with 81 additions and 17 deletions
|
@ -774,3 +774,23 @@ namespace android
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//============ GLUE CODE for com.mapswithme.maps.Framework class =============//
|
||||
/* ____
|
||||
* _ |||| _
|
||||
* \\ //
|
||||
* \\ //
|
||||
* \\//
|
||||
* \/
|
||||
*/
|
||||
|
||||
extern "C"
|
||||
{
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeGetNameAndAddress4Point(JNIEnv * env, jclass clazz, jdouble mercatorX, jdouble mercatorY)
|
||||
{
|
||||
m2::PointD globalPoint = m2::PointD(mercatorX, mercatorY);
|
||||
::Framework * nativeFramework = g_framework->NativeFramework();
|
||||
return jni::ToJavaString(env, nativeFramework->GetNameAndAddressAtPoint(globalPoint));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,8 +114,8 @@ extern "C"
|
|||
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_mapswithme_maps_bookmarks_data_Bookmark_encode2Ge0Url(
|
||||
JNIEnv * env, jobject thiz, jint cat, jlong bmk)
|
||||
JNIEnv * env, jobject thiz, jint cat, jlong bmk, jboolean addName)
|
||||
{
|
||||
return jni::ToJavaString(env, frm()->CodeGe0url(getBookmark(cat, bmk)));
|
||||
return jni::ToJavaString(env, frm()->CodeGe0url(getBookmark(cat, bmk), addName));
|
||||
}
|
||||
}
|
||||
|
|
18
android/src/com/mapswithme/maps/Framework.java
Normal file
18
android/src/com/mapswithme/maps/Framework.java
Normal file
|
@ -0,0 +1,18 @@
|
|||
package com.mapswithme.maps;
|
||||
|
||||
/**
|
||||
* This class wrapps android::Framework.cpp class
|
||||
* via static utility methods
|
||||
*/
|
||||
public class Framework
|
||||
{
|
||||
|
||||
public static String getNameAndAddress4Point(double mercatorX, double mercatorY)
|
||||
{
|
||||
return nativeGetNameAndAddress4Point(mercatorX, mercatorY);
|
||||
}
|
||||
|
||||
private native static String nativeGetNameAndAddress4Point(double mercatorX, double mercatorY);
|
||||
|
||||
private Framework() {}
|
||||
}
|
|
@ -211,9 +211,13 @@ public class BookmarkActivity extends AbstractBookmarkActivity
|
|||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu)
|
||||
{
|
||||
MenuItem menuItem = ShareAction.ACTIONS.get(ShareAction.ID_ANY).addToMenuIfSupported(this, menu, true);
|
||||
MenuItem menuItem = ShareAction.getAnyShare().addToMenuIfSupported(this, menu, true);
|
||||
if (menuItem != null)
|
||||
menuItem.setIcon(android.R.drawable.ic_menu_share);
|
||||
|
||||
menuItem = ShareAction.getEmailShare().addToMenuIfSupported(this, menu, true);
|
||||
if (menuItem != null)
|
||||
menuItem.setIcon(android.R.drawable.ic_menu_send);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.mapswithme.maps.bookmarks.data;
|
||||
|
||||
import android.R.bool;
|
||||
import android.content.Context;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
|
@ -49,7 +50,7 @@ public class Bookmark
|
|||
private native String getIcon(int c, long b);
|
||||
|
||||
private native double getScale(int category, long bookmark);
|
||||
private native String encode2Ge0Url(int category, long bookmark);
|
||||
private native String encode2Ge0Url(int category, long bookmark, boolean addName);
|
||||
|
||||
private native void setBookmarkParams(int c, long b, String name, String type, String descr);
|
||||
private native int changeCategory(int oldCat, int newCat, long bmk);
|
||||
|
@ -152,14 +153,14 @@ public class Bookmark
|
|||
return getBookmarkDescription(mCategoryId, mBookmark);
|
||||
}
|
||||
|
||||
public String getGe0Url()
|
||||
public String getGe0Url(boolean addName)
|
||||
{
|
||||
return encode2Ge0Url(mCategoryId, mBookmark);
|
||||
return encode2Ge0Url(mCategoryId, mBookmark, addName);
|
||||
}
|
||||
|
||||
public String getHttpGe0Url()
|
||||
public String getHttpGe0Url(boolean addName)
|
||||
{
|
||||
String url = getGe0Url();
|
||||
String url = getGe0Url(addName);
|
||||
url = url.replaceFirst("ge0://", "http://ge0.me/");
|
||||
return url;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.net.Uri;
|
|||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.mapswithme.maps.Framework;
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.bookmarks.data.Bookmark;
|
||||
|
||||
|
@ -111,9 +112,14 @@ public abstract class ShareAction
|
|||
public void shareBookmark(Activity activity, Bookmark bookmark)
|
||||
{
|
||||
final boolean isMyPosition = activity.getString(R.string.my_position).equals(bookmark.getName());
|
||||
final String body = activity.getString(isMyPosition ? R.string.my_position_share_sms : R.string.bookmark_share_sms,
|
||||
bookmark.getGe0Url(), bookmark.getHttpGe0Url());
|
||||
final String subject = activity.getString(isMyPosition ? R.string.my_position_share_email_subject : R.string.bookmark_share_email_subject);
|
||||
final String body = activity.getString(isMyPosition
|
||||
? R.string.my_position_share_sms
|
||||
: R.string.bookmark_share_sms,
|
||||
bookmark.getGe0Url(false), bookmark.getHttpGe0Url(false));
|
||||
|
||||
final String subject = activity.getString(isMyPosition
|
||||
? R.string.my_position_share_email_subject
|
||||
: R.string.bookmark_share_email_subject);
|
||||
|
||||
shareWithText(activity, body, subject);
|
||||
}
|
||||
|
@ -145,9 +151,24 @@ public abstract class ShareAction
|
|||
public void shareBookmark(Activity activity, Bookmark bookmark)
|
||||
{
|
||||
final boolean isMyPosition = activity.getString(R.string.my_position).equals(bookmark.getName());
|
||||
final String body = activity.getString(isMyPosition ? R.string.my_position_share_email : R.string.bookmark_share_email,
|
||||
bookmark.getName(), bookmark.getGe0Url(), bookmark.getHttpGe0Url());
|
||||
final String subject = activity.getString(isMyPosition ? R.string.my_position_share_email_subject : R.string.bookmark_share_email_subject);
|
||||
|
||||
String name;
|
||||
if (isMyPosition)
|
||||
{
|
||||
name = Framework.getNameAndAddress4Point(bookmark.getPosition().x, bookmark.getPosition().y);
|
||||
bookmark.setParams(name, bookmark.getIcon(), bookmark.getBookmarkDescription());
|
||||
}
|
||||
else
|
||||
name = bookmark.getName();
|
||||
|
||||
final String body = activity.getString(isMyPosition
|
||||
? R.string.my_position_share_email
|
||||
: R.string.bookmark_share_email,
|
||||
name, bookmark.getGe0Url(!isMyPosition), bookmark.getHttpGe0Url(!isMyPosition));
|
||||
|
||||
final String subject = activity.getString(isMyPosition
|
||||
? R.string.my_position_share_email_subject
|
||||
: R.string.bookmark_share_email_subject);
|
||||
|
||||
shareWithText(activity, body, subject);
|
||||
}
|
||||
|
|
|
@ -1607,11 +1607,11 @@ StringsBundle const & Framework::GetStringsBundle()
|
|||
return m_stringsBundle;
|
||||
}
|
||||
|
||||
string Framework::CodeGe0url(Bookmark const * bmk)
|
||||
string Framework::CodeGe0url(Bookmark const * bmk, bool const addName)
|
||||
{
|
||||
double lat = MercatorBounds::YToLat(bmk->GetOrg().y);
|
||||
double lon = MercatorBounds::XToLon(bmk->GetOrg().x);
|
||||
return CodeGe0url(lat, lon, bmk->GetScale(), bmk->GetName());
|
||||
return CodeGe0url(lat, lon, bmk->GetScale(), addName ? bmk->GetName() : "");
|
||||
}
|
||||
|
||||
string Framework::CodeGe0url(double const lat, double const lon, double const zoomLevel, string const & name)
|
||||
|
|
|
@ -452,6 +452,6 @@ public:
|
|||
shared_ptr<location::State> const & GetLocationState() const;
|
||||
|
||||
public:
|
||||
string CodeGe0url(Bookmark const * bmk);
|
||||
string CodeGe0url(Bookmark const * bmk, bool const addName);
|
||||
string CodeGe0url(double const lat, double const lon, double const zoomLevel, string const & name);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue