[drape] cleanup code

This commit is contained in:
ExMix 2015-06-03 16:02:12 +03:00 committed by r.kuznetsov
parent 7d06c16a36
commit 8e15f79d2d
12 changed files with 63 additions and 224 deletions

View file

@ -395,7 +395,7 @@ bool Framework::ShowMapForURL(string const & url)
void Framework::DeactivatePopup()
{
GetPinClickManager().RemovePin();
m_work.DiactivateUserMark();
}
string Framework::GetOutdatedCountriesString()
@ -697,12 +697,25 @@ extern "C"
env->CallVoidMethod(*obj.get(), methodId, lat, lon);
}
// Dismiss information box
void CallOnDismissListener(shared_ptr<jobject> obj)
{
JNIEnv * env = jni::GetEnv();
static jmethodID const methodId = jni::GetJavaMethodID(env, *obj.get(), "onDismiss", "()V");
ASSERT(methodId, ());
env->CallVoidMethod(*obj.get(), methodId);
}
void CallOnUserMarkActivated(shared_ptr<jobject> obj, unique_ptr<UserMarkCopy> markCopy)
{
if (markCopy == nullptr)
{
CallOnDismissListener(obj);
return;
}
::Framework * fm = frm();
UserMark const * mark = markCopy->GetUserMark();
fm->ActivateUserMark(mark);
switch (mark->GetMarkType())
{
case UserMark::Type::API:
@ -750,15 +763,6 @@ extern "C"
}
}
// Dismiss information box
void CallOnDismissListener(shared_ptr<jobject> obj)
{
JNIEnv * env = jni::GetEnv();
static jmethodID const methodId = jni::GetJavaMethodID(env, *obj.get(), "onDismiss", "()V");
ASSERT(methodId, ());
env->CallVoidMethod(*obj.get(), methodId);
}
void CallRoutingListener(shared_ptr<jobject> obj, int errorCode, vector<storage::TIndex> const & absentCountries, vector<storage::TIndex> const & absentRoutes)
{
JNIEnv * env = jni::GetEnv();
@ -819,17 +823,13 @@ extern "C"
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_Framework_nativeSetBalloonListener(JNIEnv * env, jclass clazz, jobject l)
{
PinClickManager & manager = g_framework->GetPinClickManager();
shared_ptr<jobject> obj = jni::make_global_ref(l);
manager.ConnectUserMarkListener(bind(&CallOnUserMarkActivated, obj, _1));
manager.ConnectDismissListener(bind(&CallOnDismissListener, obj));
frm()->SetUserMarkActivationListener(bind(&CallOnUserMarkActivated, jni::make_global_ref(l), _1));
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_Framework_nativeRemoveBalloonListener(JNIEnv * env, jobject thiz)
{
g_framework->GetPinClickManager().ClearListeners();
frm()->SetUserMarkActivationListener(::Framework::TActivateCallbackFn());
}
JNIEXPORT jstring JNICALL
@ -1186,15 +1186,6 @@ extern "C"
return mapObject;
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_Framework_nativeActivateUserMark(JNIEnv * env, jclass clazz, jdouble lat, jdouble lon)
{
::Framework * fr = frm();
m2::PointD pxPoint = fr->GtoP(MercatorBounds::FromLatLon(lat, lon));
UserMark const * mark = fr->GetUserMark(pxPoint, true);
fr->GetBalloonManager().OnShowMark(mark);
}
JNIEXPORT jstring JNICALL
Java_com_mapswithme_maps_Framework_nativeGetCountryNameIfAbsent(JNIEnv * env, jobject thiz,
jdouble lat, jdouble lon)

View file

@ -124,7 +124,6 @@ namespace android
size_t ChangeBookmarkCategory(BookmarkAndCategory const & ind, size_t newCat);
::Framework * NativeFramework();
PinClickManager & GetPinClickManager() { return m_work.GetBalloonManager(); }
bool IsDownloadingActive();

View file

@ -87,9 +87,7 @@ public class Framework
public native static MapObject nativeGetMapObjectForPoint(double lat, double lon);
public native static void nativeActivateUserMark(double lat, double lon);
public native static void nativeSetBalloonListener(OnBalloonListener listener);
public native static void nativeConnectBalloonListeners(OnBalloonListener listener);
public native static void nativeRemoveBalloonListener();

View file

@ -199,28 +199,6 @@ public class MwmActivity extends BaseMwmFragmentActivity
LocationState.INSTANCE.invalidatePosition();
}
private void checkUserMarkActivation()
{
final Intent intent = getIntent();
if (intent != null && intent.hasExtra(EXTRA_SCREENSHOTS_TASK))
{
final String value = intent.getStringExtra(EXTRA_SCREENSHOTS_TASK);
if (value.equals(SCREENSHOTS_TASK_PPP))
{
final double lat = Double.parseDouble(intent.getStringExtra(EXTRA_LAT));
final double lon = Double.parseDouble(intent.getStringExtra(EXTRA_LON));
mFadeView.getHandler().postDelayed(new Runnable()
{
@Override
public void run()
{
Framework.nativeActivateUserMark(lat, lon);
}
}, 1000);
}
}
}
@Override
public void onRenderingInitialized()
{

View file

@ -482,15 +482,9 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
typedef void (*UserMarkActivatedFnT)(id, SEL, unique_ptr<UserMarkCopy>);
typedef void (*PlacePageDismissedFnT)(id, SEL);
PinClickManager & manager = f.GetBalloonManager();
SEL userMarkSelector = @selector(onUserMarkClicked:);
UserMarkActivatedFnT userMarkFn = (UserMarkActivatedFnT)[self methodForSelector:userMarkSelector];
manager.ConnectUserMarkListener(bind(userMarkFn, self, userMarkSelector, _1));
SEL dismissSelector = @selector(dismissPlacePage);
PlacePageDismissedFnT dismissFn = (PlacePageDismissedFnT)[self methodForSelector:dismissSelector];
manager.ConnectDismissListener(bind(dismissFn, self, dismissSelector));
f.SetUserMarkActivationListener(bind(userMarkFn, self, userMarkSelector, _1));
m_predictor = [[LocationPredictor alloc] initWithObserver:self];
m_StickyThreshold = 10;
@ -556,10 +550,11 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
{
case routing::IRouter::ResultCode::NoError:
{
f.GetBalloonManager().RemovePin();
f.GetBalloonManager().Dismiss();
if (f.GetRouter() == routing::RouterType::Pedestrian)
[self countPedestrianRoute];
self.controlsManager.routeBuildingProgress = 100.;
self.controlsManager.searchHidden = YES;
f.DiactivateUserMark();
[self.searchView setState:SearchViewStateHidden animated:YES];
if (self.forceRoutingStateChange == ForceRoutingStateChangeStartFollowing)
[self.controlsManager routingNavigation];
else
@ -810,12 +805,12 @@ typedef NS_ENUM(NSUInteger, UserTouchesAction)
- (void)countryDownloadingProgressChanged:(LocalAndRemoteSizeT const &)progress atPosition:(int)position inGroup:(ActiveMapsLayout::TGroup const &)group
{
//if (self.searchView.state != SearchViewStateFullscreen)
// return;
//CGFloat const normProgress = (CGFloat)progress.first / (CGFloat)progress.second;
//ActiveMapsLayout & activeMapLayout = GetFramework().GetCountryTree().GetActiveMapLayout();
//NSString * countryName = [NSString stringWithUTF8String:activeMapLayout.GetFormatedCountryName(activeMapLayout.GetCoreIndex(group, position)).c_str()];
//[self.searchView downloadProgress:normProgress countryName:countryName];
if (self.searchView.state != SearchViewStateFullscreen)
return;
CGFloat const normProgress = (CGFloat)progress.first / (CGFloat)progress.second;
ActiveMapsLayout & activeMapLayout = GetFramework().GetCountryTree().GetActiveMapLayout();
NSString * countryName = [NSString stringWithUTF8String:activeMapLayout.GetFormatedCountryName(activeMapLayout.GetCoreIndex(group, position)).c_str()];
[self.searchView downloadProgress:normProgress countryName:countryName];
}
#pragma mark - Public methods
@ -844,12 +839,12 @@ NSInteger compareAddress(id l, id r, void * context)
- (void)showPopover
{
Framework & f = GetFramework();
if (self.popoverVC)
GetFramework().GetBalloonManager().Hide();
f.DiactivateUserMark();
double const sf = self.view.contentScaleFactor;
Framework & f = GetFramework();
m2::PointD tmp = m2::PointD(f.GtoP(m2::PointD(m_popoverPos.x, m_popoverPos.y)));
[self.popoverVC presentPopoverFromRect:CGRectMake(tmp.x / sf, tmp.y / sf, 1, 1) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

View file

@ -181,10 +181,8 @@ void Framework::StopLocationFollow()
}
Framework::Framework()
: m_bmManager(*this),
m_balloonManager(*this),
m_fixedSearchResults(0),
m_locationChangedSlotID(-1)
: m_bmManager(*this)
, m_fixedSearchResults(0)
{
m_activeMaps.reset(new ActiveMapsLayout(*this));
m_globalCntTree = storage::CountryTree(m_activeMaps);
@ -545,7 +543,6 @@ void Framework::ShowBookmark(BookmarkAndCategory const & bnc)
CallDrapeFunction(bind(&df::DrapeEngine::SetModelViewCenter, _1, mark->GetPivot(), scale, true));
ActivateUserMark(mark, true);
m_balloonManager.OnShowMark(mark);
}
void Framework::ShowTrack(Track const & track)
@ -1172,7 +1169,7 @@ void Framework::ShowSearchResult(search::Result const & res)
SearchMarkPoint * mark = static_cast<SearchMarkPoint *>(guard.m_controller.CreateUserMark(center));
mark->SetInfo(info);
m_balloonManager.OnShowMark(mark);
ActivateUserMark(mark, false);
}
size_t Framework::ShowAllSearchResults(search::Results const & results)
@ -1420,7 +1417,7 @@ bool Framework::ShowMapForURL(string const & url)
ResultT result = FAILED;
// always hide current balloon here
m_balloonManager.Hide();
DiactivateUserMark();
using namespace url_scheme;
using namespace strings;
@ -1482,21 +1479,18 @@ bool Framework::ShowMapForURL(string const & url)
{
LOG(LINFO, ("Show API mark:", static_cast<ApiMarkPoint const *>(apiMark)->GetName()));
m_balloonManager.OnShowMark(apiMark);
ActivateUserMark(apiMark, false);
}
else
{
PoiMarkPoint * mark = GetAddressMark(point);
if (!name.empty())
mark->SetName(name);
m_balloonManager.OnShowMark(mark);
ActivateUserMark(mark, false);
}
}
else
{
m_balloonManager.RemovePin();
m_balloonManager.Dismiss();
}
DiactivateUserMark();
return true;
}
@ -1504,23 +1498,6 @@ bool Framework::ShowMapForURL(string const & url)
return false;
}
void Framework::UpdateSelectedMyPosition(m2::PointD const & pt)
{
MyPositionMarkPoint * myPositionMark = UserMarkContainer::UserMarkForMyPostion();
myPositionMark->SetPtOrg(pt);
ActivateUserMark(myPositionMark, false);
}
void Framework::DisconnectMyPositionUpdate()
{
if (m_locationChangedSlotID != -1)
{
///@TODO UVR
//GetLocationState()->RemovePositionChangedListener(m_locationChangedSlotID);
m_locationChangedSlotID = -1;
}
}
bool Framework::GetVisiblePOI(m2::PointD const & glbPoint, search::AddressInfo & info, feature::Metadata & metadata) const
{
ASSERT(m_drapeEngine != nullptr, ());
@ -1649,7 +1626,24 @@ PoiMarkPoint * Framework::GetAddressMark(m2::PointD const & globalPoint) const
void Framework::ActivateUserMark(UserMark const * mark, bool needAnim)
{
m_balloonManager.OnShowMark(mark);
static UserMark const * activeMark = nullptr;
if (m_activateUserMarkFn)
{
bool hasActive = activeMark != nullptr;
activeMark = mark;
if (mark)
m_activateUserMarkFn(mark->Copy());
else
{
if (hasActive)
m_activateUserMarkFn(nullptr);
}
}
}
void Framework::DiactivateUserMark()
{
ActivateUserMark(nullptr, true);
}
void Framework::OnTapEvent(m2::PointD pxPoint, bool isLong, bool isMyPosition, FeatureID feature)

View file

@ -6,7 +6,6 @@
#include "map/country_tree.hpp"
#include "map/feature_vec_model.hpp"
#include "map/mwm_url.hpp"
#include "map/pin_click_manager.hpp"
#include "map/routing_session.hpp"
#include "map/track.hpp"
@ -119,7 +118,6 @@ protected:
void OnMapDeregistered(platform::LocalCountryFile const & localFile);
BookmarkManager m_bmManager;
PinClickManager m_balloonManager;
void ClearAllCaches();
@ -237,13 +235,19 @@ public:
BookmarkManager & GetBookmarkManager() { return m_bmManager; }
void ActivateUserMark(UserMark const * mark, bool needAnim);
void DiactivateUserMark();
PoiMarkPoint * GetAddressMark(m2::PointD const & globalPoint) const;
using TActivateCallbackFn = function<void (unique_ptr<UserMarkCopy> mark)>;
void SetUserMarkActivationListener(TActivateCallbackFn const & fn) { m_activateUserMarkFn = fn; }
private:
void OnTapEvent(m2::PointD pxPoint, bool isLong, bool isMyPosition, FeatureID feature);
UserMark const * OnTapEventImpl(m2::PointD pxPoint, bool isLong, bool isMyPosition, FeatureID feature);
//@}
TActivateCallbackFn m_activateUserMarkFn;
public:
/// @name GPS location updates routine.
@ -408,8 +412,6 @@ public:
StringsBundle const & GetStringsBundle();
PinClickManager & GetBalloonManager() { return m_balloonManager; }
/// [in] lat, lon - last known location
/// [out] lat, lon - predicted location
static void PredictLocation(double & lat, double & lon, double accuracy,
@ -426,11 +428,6 @@ public:
private:
url_scheme::ParsedMapApi m_ParsedMapApi;
void SetViewPortASync(m2::RectD const & rect);
void UpdateSelectedMyPosition(m2::PointD const & pt);
void DisconnectMyPositionUpdate();
int m_locationChangedSlotID;
public:
//@}

View file

@ -20,7 +20,6 @@ HEADERS += \
ge0_parser.hpp \
geourl_process.hpp \
mwm_url.hpp \
pin_click_manager.hpp \
route_track.hpp \
routing_session.hpp \
storage_bridge.hpp \
@ -40,7 +39,6 @@ SOURCES += \
ge0_parser.cpp \
geourl_process.cpp \
mwm_url.cpp \
pin_click_manager.cpp \
route_track.cpp \
routing_session.cpp \
storage_bridge.cpp \

View file

@ -1,53 +0,0 @@
#include "map/pin_click_manager.hpp"
#include "map/framework.hpp"
#include "search/result.hpp"
#include "anim/task.hpp"
#include "anim/controller.hpp"
#include "geometry/transformations.hpp"
PinClickManager::PinClickManager(Framework & f)
: m_f(f)
{}
void PinClickManager::Hide()
{
}
void PinClickManager::OnShowMark(UserMark const * mark)
{
if (mark != nullptr && m_userMarkListener != nullptr)
m_userMarkListener(mark->Copy());
SetBalloonVisible(mark != nullptr);
}
void PinClickManager::SetBalloonVisible(bool isVisible)
{
if (!isVisible)
OnDismiss();
}
void PinClickManager::RemovePin()
{
///@TODO
}
void PinClickManager::Dismiss()
{
OnDismiss();
}
void PinClickManager::ClearListeners()
{
m_userMarkListener = TUserMarkListener();
m_dismissListener = TDismissListener();
}
void PinClickManager::OnDismiss()
{
// Can be called before the listeners will be attached (clearing on activity start).
if (m_dismissListener)
m_dismissListener();
}

View file

@ -1,51 +0,0 @@
#pragma once
#include "map/bookmark.hpp"
#include "geometry/point2d.hpp"
#include "std/function.hpp"
#include "std/shared_ptr.hpp"
#include "std/unique_ptr.hpp"
class Framework;
class PaintEvent;
namespace location { class GpsInfo; }
namespace gui { class Element; }
class PinClickManager
{
Framework & m_f;
void OnDismiss();
void SetBalloonVisible(bool isVisible);
public:
PinClickManager(Framework & f);
void LocationChanged(location::GpsInfo const & info) {}
void OnShowMark(UserMark const * mark);
void Hide();
void RemovePin();
void Dismiss();
private:
/// @name Platform dependent listeners to show special activities.
//@{
// You must delete UserMarkCopy obtained by this callback
typedef function<void (unique_ptr<UserMarkCopy>)> TUserMarkListener;
TUserMarkListener m_userMarkListener;
typedef function<void (void)> TDismissListener;
TDismissListener m_dismissListener;
public:
template <class T> void ConnectUserMarkListener(T const & t) { m_userMarkListener = t; }
template <class T> void ConnectDismissListener(T const & t) { m_dismissListener = t; }
void ClearListeners();
//@}
};

View file

@ -78,11 +78,6 @@ bool IsLocationEmulation(QMouseEvent * e)
QObject::connect(this, SIGNAL(heightChanged(int)), this, SLOT(sizeChanged(int)));
QObject::connect(this, SIGNAL(widthChanged(int)), this, SLOT(sizeChanged(int)));
// Initialize with some stubs for test.
PinClickManager & manager = GetBalloonManager();
manager.ConnectUserMarkListener([](unique_ptr<UserMarkCopy>) {});
manager.ConnectDismissListener(&DummyDismiss);
m_framework->SetRouteBuildingListener([] (routing::IRouter::ResultCode, vector<storage::TIndex> const &)
{
});

View file

@ -98,8 +98,6 @@ namespace qt
bool m_emulatingLocation;
PinClickManager & GetBalloonManager() { return m_framework->GetBalloonManager(); }
void InitRenderPolicy();
};
}