Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArsentiy Milchakov <milcars@mapswithme.com>2016-12-13 18:24:59 +0300
committerArsentiy Milchakov <milcars@mapswithme.com>2016-12-13 18:24:59 +0300
commite3c7dc9d133646768ed42d89b052af07851424ba (patch)
tree36984da705a00a1b91bb5f96fd9814f36ca34e1e /android
parent7bf549cba13001ffe5416f535d3fd84f89568438 (diff)
[android] revert for merge-commit dd75999 from goblinr:MAPSME-87-ext-fix-editor-restore-state
Diffstat (limited to 'android')
-rw-r--r--android/jni/com/mapswithme/maps/Framework.cpp44
-rw-r--r--android/jni/com/mapswithme/maps/editor/Editor.cpp7
-rw-r--r--android/src/com/mapswithme/maps/Framework.java2
-rw-r--r--android/src/com/mapswithme/maps/MwmActivity.java16
-rw-r--r--android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java35
-rw-r--r--android/src/com/mapswithme/maps/editor/Editor.java2
-rw-r--r--android/src/com/mapswithme/maps/editor/EditorActivity.java32
-rw-r--r--android/src/com/mapswithme/maps/editor/EditorHostFragment.java5
8 files changed, 19 insertions, 124 deletions
diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp
index 1987667f7c..25a80b9904 100644
--- a/android/jni/com/mapswithme/maps/Framework.cpp
+++ b/android/jni/com/mapswithme/maps/Framework.cpp
@@ -677,50 +677,6 @@ Java_com_mapswithme_maps_Framework_nativeSetMapObjectListener(JNIEnv * env, jcla
}
JNIEXPORT void JNICALL
-Java_com_mapswithme_maps_Framework_nativeRestoreMapObject(JNIEnv * env, jclass clazz,
- jobject jMapObject)
-{
- static jmethodID const getMapObjectTypeId =
- jni::GetMethodID(env, jMapObject, "getMapObjectType", "()I");
-
- place_page::Info info;
- jint type = env->CallIntMethod(jMapObject, getMapObjectTypeId);
- switch (type)
- {
- case usermark_helper::kBookmark:
- {
- static jmethodID const getCategoryId =
- jni::GetMethodID(env, jMapObject, "getCategoryId", "()I");
- static jmethodID const getBookmarkId =
- jni::GetMethodID(env, jMapObject, "getBookmarkId", "()I");
- jint categoryId = env->CallIntMethod(jMapObject, getCategoryId);
- jint bookmarkId = env->CallIntMethod(jMapObject, getBookmarkId);
- BookmarkAndCategory bnc = BookmarkAndCategory(bookmarkId, categoryId);
- BookmarkCategory * pCat = frm()->GetBmCategory(categoryId);
- Bookmark const * pBmk = static_cast<Bookmark const *>(pCat->GetUserMark(bookmarkId));
- frm()->FillBookmarkInfo(*pBmk, bnc, info);
- break;
- }
- case usermark_helper::kMyPosition:
- {
- frm()->FillMyPositionInfo(info);
- break;
- }
- default:
- {
- static jmethodID const getLatId = jni::GetMethodID(env, jMapObject, "getLat", "()D");
- static jmethodID const getLonId = jni::GetMethodID(env, jMapObject, "getLon", "()D");
- jdouble lat = env->CallDoubleMethod(jMapObject, getLatId);
- jdouble lon = env->CallDoubleMethod(jMapObject, getLonId);
- frm()->FillPoiInfo(m2::PointD(MercatorBounds::FromLatLon(lat, lon)), info);
- break;
- }
- }
-
- g_framework->SetPlacePageInfo(info);
-}
-
-JNIEXPORT void JNICALL
Java_com_mapswithme_maps_Framework_nativeRemoveMapObjectListener(JNIEnv * env, jclass)
{
frm()->SetMapSelectionListeners({}, {});
diff --git a/android/jni/com/mapswithme/maps/editor/Editor.cpp b/android/jni/com/mapswithme/maps/editor/Editor.cpp
index 2040fee1e2..7a6b075c1e 100644
--- a/android/jni/com/mapswithme/maps/editor/Editor.cpp
+++ b/android/jni/com/mapswithme/maps/editor/Editor.cpp
@@ -417,13 +417,12 @@ Java_com_mapswithme_maps_editor_Editor_nativeClearLocalEdits(JNIEnv * env, jclas
Editor::Instance().ClearAllLocalEdits();
}
-JNIEXPORT void JNICALL Java_com_mapswithme_maps_editor_Editor_nativeStartEdit(JNIEnv *, jclass,
- jint drawScale = -1)
+JNIEXPORT void JNICALL
+Java_com_mapswithme_maps_editor_Editor_nativeStartEdit(JNIEnv *, jclass)
{
::Framework * frm = g_framework->NativeFramework();
place_page::Info const & info = g_framework->GetPlacePageInfo();
- CHECK(frm->GetEditableMapObject(info.GetID(), g_editableMapObject, drawScale),
- ("Invalid feature in the place page."));
+ CHECK(frm->GetEditableMapObject(info.GetID(), g_editableMapObject), ("Invalid feature in the place page."));
}
JNIEXPORT void JNICALL
diff --git a/android/src/com/mapswithme/maps/Framework.java b/android/src/com/mapswithme/maps/Framework.java
index d178b621e5..bddef7a50a 100644
--- a/android/src/com/mapswithme/maps/Framework.java
+++ b/android/src/com/mapswithme/maps/Framework.java
@@ -128,8 +128,6 @@ public class Framework
public static native void nativeRemoveMapObjectListener();
- public static native void nativeRestoreMapObject(@NonNull MapObject mapObject);
-
@UiThread
public static native String nativeGetOutdatedCountriesString();
diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java
index 81b00e1a0c..cbbd550acb 100644
--- a/android/src/com/mapswithme/maps/MwmActivity.java
+++ b/android/src/com/mapswithme/maps/MwmActivity.java
@@ -43,6 +43,7 @@ import com.mapswithme.maps.downloader.MapManager;
import com.mapswithme.maps.downloader.MigrationFragment;
import com.mapswithme.maps.downloader.OnmapDownloader;
import com.mapswithme.maps.editor.AuthDialogFragment;
+import com.mapswithme.maps.editor.Editor;
import com.mapswithme.maps.editor.EditorActivity;
import com.mapswithme.maps.editor.EditorHostFragment;
import com.mapswithme.maps.editor.FeatureCategoryActivity;
@@ -118,7 +119,7 @@ public class MwmActivity extends BaseMwmFragmentActivity
ReportFragment.class.getName() };
// Instance state
private static final String STATE_PP = "PpState";
- public static final String STATE_MAP_OBJECT = "MapObject";
+ private static final String STATE_MAP_OBJECT = "MapObject";
// Map tasks that we run AFTER rendering initialized
private final Stack<MapTask> mTasks = new Stack<>();
@@ -344,11 +345,13 @@ public class MwmActivity extends BaseMwmFragmentActivity
public void showEditor()
{
+ // TODO(yunikkk) think about refactoring. It probably should be called in editor.
+ Editor.nativeStartEdit();
Statistics.INSTANCE.trackEditorLaunch(false);
if (mIsFragmentContainer)
replaceFragment(EditorHostFragment.class, null, null);
else
- EditorActivity.start(this, mPlacePage.getMapObject(), Framework.nativeGetDrawScale());
+ EditorActivity.start(this);
}
private void shareMyLocation()
@@ -787,13 +790,8 @@ public class MwmActivity extends BaseMwmFragmentActivity
if (state != State.HIDDEN)
{
mPlacePageRestored = true;
- MapObject mapObject = savedInstanceState.getParcelable(STATE_MAP_OBJECT);
- if (mapObject != null)
- {
- Framework.nativeRestoreMapObject(mapObject);
- mPlacePage.setMapObject(mapObject, true);
- mPlacePage.setState(state);
- }
+ mPlacePage.setMapObject((MapObject) savedInstanceState.getParcelable(STATE_MAP_OBJECT), true);
+ mPlacePage.setState(state);
}
if (!mIsFragmentContainer && RoutingController.get().isPlanning())
diff --git a/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java b/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java
index 1ca09cb516..44979ab664 100644
--- a/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java
+++ b/android/src/com/mapswithme/maps/bookmarks/data/Bookmark.java
@@ -13,14 +13,11 @@ import com.mapswithme.util.Constants;
@SuppressLint("ParcelCreator")
public class Bookmark extends MapObject
{
- @Nullable
- private Icon mIcon;
+ private final Icon mIcon;
private int mCategoryId;
private int mBookmarkId;
- @Nullable
- private Double mMerX;
- @Nullable
- private Double mMerY;
+ private double mMerX;
+ private double mMerY;
Bookmark(@IntRange(from = 0) int categoryId, @IntRange(from = 0) int bookmarkId, String title,
@Nullable Banner banner)
@@ -29,6 +26,8 @@ public class Bookmark extends MapObject
mCategoryId = categoryId;
mBookmarkId = bookmarkId;
+ mIcon = getIconInternal();
+ initXY();
}
private void initXY()
@@ -54,6 +53,8 @@ public class Bookmark extends MapObject
super(source);
mCategoryId = source.readInt();
mBookmarkId = source.readInt();
+ mIcon = getIconInternal();
+ initXY();
}
@Override
@@ -70,38 +71,16 @@ public class Bookmark extends MapObject
public DistanceAndAzimut getDistanceAndAzimuth(double cLat, double cLon, double north)
{
- if (mMerX == null || mMerY == null)
- initXY();
return Framework.nativeGetDistanceAndAzimuth(mMerX, mMerY, cLat, cLon, north);
}
- @Override
- public double getLat()
- {
- if (mMerX == null || mMerY == null)
- initXY();
- return super.getLat();
- }
-
- @Override
- public double getLon()
- {
- if (mMerX == null || mMerY == null)
- initXY();
- return super.getLon();
- }
-
- @NonNull
private Icon getIconInternal()
{
return BookmarkManager.getIconByType((mCategoryId >= 0) ? nativeGetIcon(mCategoryId, mBookmarkId) : "");
}
- @NonNull
public Icon getIcon()
{
- if (mIcon == null)
- mIcon = getIconInternal();
return mIcon;
}
diff --git a/android/src/com/mapswithme/maps/editor/Editor.java b/android/src/com/mapswithme/maps/editor/Editor.java
index 337acdfac2..274895485c 100644
--- a/android/src/com/mapswithme/maps/editor/Editor.java
+++ b/android/src/com/mapswithme/maps/editor/Editor.java
@@ -140,7 +140,7 @@ public final class Editor
* That method should be called, when user opens editor from place page, so that information in editor
* could refresh.
*/
- public static native void nativeStartEdit(int drawScale);
+ public static native void nativeStartEdit();
/**
* @return true if feature was saved. False if some error occurred (eg. no space)
*/
diff --git a/android/src/com/mapswithme/maps/editor/EditorActivity.java b/android/src/com/mapswithme/maps/editor/EditorActivity.java
index f886c612da..2661b5b1b4 100644
--- a/android/src/com/mapswithme/maps/editor/EditorActivity.java
+++ b/android/src/com/mapswithme/maps/editor/EditorActivity.java
@@ -2,22 +2,14 @@ package com.mapswithme.maps.editor;
import android.app.Activity;
import android.content.Intent;
-import android.os.Bundle;
import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
-import com.mapswithme.maps.Framework;
import com.mapswithme.maps.base.BaseMwmFragmentActivity;
-import com.mapswithme.maps.bookmarks.data.MapObject;
public class EditorActivity extends BaseMwmFragmentActivity
{
public static final String EXTRA_NEW_OBJECT = "ExtraNewMapObject";
- private static final String EXTRA_MAP_OBJECT = "ExtraMapObject";
- public static final String EXTRA_DRAW_SCALE = "ExtraDrawScale";
-
- private int mDrawScale = -1;
@Override
protected Class<? extends Fragment> getFragmentClass()
@@ -25,31 +17,9 @@ public class EditorActivity extends BaseMwmFragmentActivity
return EditorHostFragment.class;
}
- public static void start(@NonNull Activity activity, @NonNull MapObject mapObject, int drawScale)
+ public static void start(@NonNull Activity activity)
{
final Intent intent = new Intent(activity, EditorActivity.class);
- intent.putExtra(EXTRA_MAP_OBJECT, mapObject);
- intent.putExtra(EXTRA_DRAW_SCALE, drawScale);
activity.startActivity(intent);
}
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
-
- Bundle extras = getIntent().getExtras();
- if (extras != null)
- {
- mDrawScale = extras.getInt(EXTRA_DRAW_SCALE);
- MapObject mapObject = extras.getParcelable(EXTRA_MAP_OBJECT);
- if (mapObject != null)
- Framework.nativeRestoreMapObject(mapObject);
- }
- }
-
- public int getDrawScale()
- {
- return mDrawScale;
- }
}
diff --git a/android/src/com/mapswithme/maps/editor/EditorHostFragment.java b/android/src/com/mapswithme/maps/editor/EditorHostFragment.java
index 929bfa1efd..1355a78d6f 100644
--- a/android/src/com/mapswithme/maps/editor/EditorHostFragment.java
+++ b/android/src/com/mapswithme/maps/editor/EditorHostFragment.java
@@ -114,11 +114,6 @@ public class EditorHostFragment extends BaseMwmToolbarFragment
public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
{
super.onViewCreated(view, savedInstanceState);
-
- if (!(getActivity() instanceof EditorActivity))
- Editor.nativeStartEdit(-1);
- else
- Editor.nativeStartEdit(((EditorActivity) getActivity()).getDrawScale());
mToolbarController.findViewById(R.id.save).setOnClickListener(this);
mToolbarController.getToolbar().setNavigationOnClickListener(new View.OnClickListener()
{