forked from organicmaps/organicmaps
[android] Review fixes #2. Always create new feature in the center of the viewport.
This commit is contained in:
parent
cc901082c1
commit
9bfe55ff5c
4 changed files with 13 additions and 28 deletions
|
@ -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"));
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<? extends Fragment> 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);
|
||||
|
|
Loading…
Add table
Reference in a new issue