diff --git a/android/jni/com/mapswithme/maps/editor/Editor.cpp b/android/jni/com/mapswithme/maps/editor/Editor.cpp index e56e6c3752..f87763c007 100644 --- a/android/jni/com/mapswithme/maps/editor/Editor.cpp +++ b/android/jni/com/mapswithme/maps/editor/Editor.cpp @@ -251,10 +251,10 @@ Java_com_mapswithme_maps_editor_Editor_nativeStartEdit(JNIEnv *, jclass) } JNIEXPORT void JNICALL -Java_com_mapswithme_maps_editor_Editor_nativeCreateMapObject(JNIEnv *, jclass, jint featureCategory, jdouble lat, jdouble lon) +Java_com_mapswithme_maps_editor_Editor_nativeCreateMapObject(JNIEnv *, jclass, jint featureCategory) { ::Framework * frm = g_framework->NativeFramework(); - CHECK(frm->CreateMapObject(MercatorBounds::FromLatLon(lat, lon), featureCategory, g_editableMapObject), + CHECK(frm->CreateMapObject(frm->GetViewportCenter(), featureCategory, g_editableMapObject), ("Couldn't create mapobject, wrong coordinates of missing mwm")); } diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 85ffc4e451..39720e7354 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -382,7 +382,7 @@ public class MwmActivity extends BaseMwmFragmentActivity { showPositionChooser(false); if (Framework.nativeIsDownloadedMapAtScreenCenter()) - FeatureCategoryActivity.pick(MwmActivity.this, Framework.nativeGetScreenRectCenter()); + startActivity(new Intent(MwmActivity.this, FeatureCategoryActivity.class)); else // TODO uncomment // UiUtils.showAlertDialog(getActivity(), R.string.message_invalid_feature_position); diff --git a/android/src/com/mapswithme/maps/editor/Editor.java b/android/src/com/mapswithme/maps/editor/Editor.java index 14084ea513..e331ddc03e 100644 --- a/android/src/com/mapswithme/maps/editor/Editor.java +++ b/android/src/com/mapswithme/maps/editor/Editor.java @@ -4,6 +4,7 @@ import android.support.annotation.NonNull; import android.support.annotation.Size; import android.support.annotation.WorkerThread; +import com.mapswithme.maps.Framework; import com.mapswithme.maps.MwmApplication; import com.mapswithme.maps.background.AppBackgroundTracker; import com.mapswithme.maps.background.WorkerService; @@ -105,12 +106,16 @@ public final class Editor */ public static native boolean nativeSaveEditedFeature(); - public static native void nativeCreateMapObject(double lat, double lon, int featureCategory); public static native FeatureCategory[] nativeGetNewFeatureCategories(); - public static void createMapObject(FeatureCategory category, @Size(2) double[] latLon) + /** + * Creates new object on the map. Places it in the center of current viewport. + * {@link Framework#nativeIsDownloadedMapAtScreenCenter()} should be called before + * to check whether new feature can be created on the map. + */ + public static void createMapObject(FeatureCategory category) { - nativeCreateMapObject(category.category, latLon[0], latLon[1]); + nativeCreateMapObject(category.category); } - public static native void nativeCreateMapObject(int categoryId, double lat, double lon); + public static native void nativeCreateMapObject(int categoryId); } diff --git a/android/src/com/mapswithme/maps/editor/FeatureCategoryActivity.java b/android/src/com/mapswithme/maps/editor/FeatureCategoryActivity.java index f645a2e461..b7487d6a91 100644 --- a/android/src/com/mapswithme/maps/editor/FeatureCategoryActivity.java +++ b/android/src/com/mapswithme/maps/editor/FeatureCategoryActivity.java @@ -1,34 +1,14 @@ package com.mapswithme.maps.editor; import android.content.Intent; -import android.os.Bundle; -import android.support.annotation.Size; import android.support.v4.app.Fragment; -import com.mapswithme.maps.MwmActivity; import com.mapswithme.maps.base.BaseToolbarActivity; import com.mapswithme.maps.editor.data.FeatureCategory; public class FeatureCategoryActivity extends BaseToolbarActivity implements FeatureCategoryFragment.FeatureCategoryListener { public static final String EXTRA_FEATURE_CATEGORY = "FeatureCategory"; - public static final String EXTRA_LAT_LON = "LatLon"; - - private double[] mLatLon; - - public static void pick(MwmActivity parent, @Size(2) double[] rect) - { - final Intent intent = new Intent(parent, FeatureCategoryActivity.class); - intent.putExtra(EXTRA_LAT_LON, rect); - parent.startActivity(intent); - } - - @Override - protected void onCreate(Bundle state) - { - super.onCreate(state); - mLatLon = getIntent().getDoubleArrayExtra(EXTRA_LAT_LON); - } @Override protected Class getFragmentClass() @@ -46,7 +26,7 @@ public class FeatureCategoryActivity extends BaseToolbarActivity implements Feat @Override public void onFeatureCategorySelected(FeatureCategory category) { - Editor.createMapObject(category, mLatLon); + Editor.createMapObject(category); final Intent intent = new Intent(this, EditorActivity.class); intent.putExtra(EXTRA_FEATURE_CATEGORY, category); intent.putExtra(EditorActivity.EXTRA_NEW_OBJECT, true);