[drape] Allow controlling viewport restoration on DeactivateMapSelection

Signed-off-by: hemanggs <hemangmanhas@gmail.com>
This commit is contained in:
hemanggs
2025-06-08 19:13:12 +05:30
committed by Konstantin Pastbin
parent fc199252eb
commit 90492e95e6
12 changed files with 32 additions and 23 deletions

View File

@@ -767,9 +767,16 @@ public class MwmActivity extends BaseMwmFragmentActivity
private void showPositionChooser(ChoosePositionMode mode, boolean isBusiness, boolean applyPosition)
{
closeFloatingToolbarsAndPanels(false);
int width = mMapFragment.getView().getWidth();
int height = mMapFragment.getView().getHeight();
Framework.nativeSetVisibleRect(0, 0, width, height);
if (mMapFragment != null)
{
final View mapView = mMapFragment.getView();
if (mapView != null)
{
int width = mapView.getWidth();
int height = mapView.getHeight();
Framework.nativeSetVisibleRect(0, 0, width, height);
}
}
UiUtils.show(mPointChooser);
mMapButtonsViewModel.setButtonsHidden(true);
ChoosePositionMode.set(mode, isBusiness, applyPosition);

View File

@@ -287,7 +287,7 @@ public class PlaceScreen extends BaseMapScreen implements OnBackPressedCallback.
@Override
public void onBuiltRoute()
{
Framework.nativeDeactivateMapSelectionCircle();
Framework.nativeDeactivateMapSelectionCircle(true);
mMapObject = mRoutingController.getEndPoint();
invalidate();
}
@@ -295,7 +295,7 @@ public class PlaceScreen extends BaseMapScreen implements OnBackPressedCallback.
@Override
public void onPlanningCancelled()
{
Framework.nativeDeactivateMapSelectionCircle();
Framework.nativeDeactivateMapSelectionCircle(true);
}
@Override

View File

@@ -163,7 +163,7 @@ public class Framework
public static native @Nullable String nativeGetParsedBackUrl();
public static native void nativeDeactivatePopup();
public static native void nativeDeactivateMapSelectionCircle();
public static native void nativeDeactivateMapSelectionCircle(boolean restoreViewport);
public static native String nativeGetDataFileExt();

View File

@@ -225,10 +225,9 @@ public class PlacePageController
private void onHiddenInternal()
{
if (ChoosePositionMode.get() == ChoosePositionMode.None) {
if (ChoosePositionMode.get() == ChoosePositionMode.None)
Framework.nativeDeactivatePopup();
}
Framework.nativeDeactivateMapSelectionCircle();
Framework.nativeDeactivateMapSelectionCircle(false);
PlacePageUtils.updateMapViewport(mCoordinator, mDistanceToTop, mViewportMinHeight);
resetPlacePageHeightBounds();
removePlacePageFragments();

View File

@@ -621,9 +621,9 @@ void Framework::DeactivatePopup()
m_work.DeactivateMapSelection();
}
void Framework::DeactivateMapSelectionCircle()
void Framework::DeactivateMapSelectionCircle(bool restoreViewport)
{
m_work.DeactivateMapSelectionCircle();
m_work.DeactivateMapSelectionCircle(restoreViewport);
}
/*
@@ -1448,9 +1448,9 @@ Java_app_organicmaps_sdk_Framework_nativeDeactivatePopup(JNIEnv * env, jclass)
}
JNIEXPORT void JNICALL
Java_app_organicmaps_sdk_Framework_nativeDeactivateMapSelectionCircle(JNIEnv * env, jclass)
Java_app_organicmaps_sdk_Framework_nativeDeactivateMapSelectionCircle(JNIEnv * env, jclass, jboolean restoreViewport)
{
return g_framework->DeactivateMapSelectionCircle();
return g_framework->DeactivateMapSelectionCircle(restoreViewport);
}
JNIEXPORT void JNICALL

View File

@@ -171,7 +171,7 @@ namespace android
void ExecuteMapApiRequest();
void DeactivatePopup();
void DeactivateMapSelectionCircle();
void DeactivateMapSelectionCircle(bool restoreViewport);
// std::string GetOutdatedCountriesString();

View File

@@ -562,10 +562,10 @@ void DrapeEngine::SelectObject(SelectionShape::ESelectedObject obj, m2::PointD c
MessagePriority::Normal);
}
void DrapeEngine::DeselectObject()
void DrapeEngine::DeselectObject(bool restoreViewport)
{
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,
make_unique_dp<SelectObjectMessage>(SelectObjectMessage::DismissTag()),
make_unique_dp<SelectObjectMessage>(SelectObjectMessage::DismissTag(), restoreViewport),
MessagePriority::Normal);
}

View File

@@ -173,7 +173,7 @@ public:
void SelectObject(SelectionShape::ESelectedObject obj, m2::PointD const & pt,
FeatureID const & featureID, bool isAnim, bool isGeometrySelectionAllowed,
bool isSelectionShapeVisible);
void DeselectObject();
void DeselectObject(bool restoreViewport);
dp::DrapeID AddSubroute(SubrouteConstPtr subroute);
void RemoveSubroute(dp::DrapeID subrouteId, bool deactivateFollowing);

View File

@@ -1332,7 +1332,7 @@ void FrontendRenderer::ProcessSelection(ref_ptr<SelectObjectMessage> msg)
if (msg->IsDismiss())
{
m_selectionShape->Hide();
if (!m_myPositionController->IsModeChangeViewport() && m_selectionTrackInfo)
if (msg->ShouldRestoreViewport() && !m_myPositionController->IsModeChangeViewport() && m_selectionTrackInfo)
{
AddUserEvent(make_unique_dp<SetAnyRectEvent>(m_selectionTrackInfo->m_startRect,
true /* isAnim */, false /* fitInViewport */,

View File

@@ -534,13 +534,14 @@ class SelectObjectMessage : public Message
public:
struct DismissTag {};
explicit SelectObjectMessage(DismissTag)
explicit SelectObjectMessage(DismissTag, bool restoreViewport)
: m_selected(SelectionShape::OBJECT_EMPTY)
, m_glbPoint(m2::PointD::Zero())
, m_isAnim(false)
, m_isDismiss(true)
, m_isGeometrySelectionAllowed(false)
, m_isSelectionShapeVisible(false)
, m_restoreViewport(restoreViewport)
{}
SelectObjectMessage(SelectionShape::ESelectedObject selectedObject, m2::PointD const & glbPoint,
@@ -565,6 +566,7 @@ public:
bool IsDismiss() const { return m_isDismiss; }
bool IsGeometrySelectionAllowed() const { return m_isGeometrySelectionAllowed; }
bool IsSelectionShapeVisible() const { return m_isSelectionShapeVisible; }
bool ShouldRestoreViewport() const { return m_restoreViewport; }
private:
SelectionShape::ESelectedObject m_selected;
@@ -574,6 +576,7 @@ private:
bool m_isDismiss;
bool m_isGeometrySelectionAllowed;
bool m_isSelectionShapeVisible;
bool m_restoreViewport;
};
class CheckSelectionGeometryMessage : public Message

View File

@@ -2057,14 +2057,14 @@ void Framework::DeactivateMapSelection()
m_currentPlacePageInfo = {};
if (m_drapeEngine != nullptr)
m_drapeEngine->DeselectObject();
m_drapeEngine->DeselectObject(true);
}
}
void Framework::DeactivateMapSelectionCircle()
void Framework::DeactivateMapSelectionCircle(bool restoreViewport)
{
if (m_drapeEngine != nullptr)
m_drapeEngine->DeselectObject();
m_drapeEngine->DeselectObject(restoreViewport);
}
void Framework::SwitchFullScreen()

View File

@@ -310,7 +310,7 @@ private:
public:
void DeactivateMapSelection();
void DeactivateMapSelectionCircle();
void DeactivateMapSelectionCircle(bool restoreViewport);
void SwitchFullScreen();
/// Used to "refresh" UI in some cases (e.g. feature editing).
void UpdatePlacePageInfoForCurrentSelection(