diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index b46985f6fa..208e75867f 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -125,7 +125,7 @@ Framework::Framework() m_work.GetTrafficManager().SetStateListener(bind(&Framework::TrafficStateChanged, this, _1)); m_work.GetTransitManager().SetStateListener(bind(&Framework::TransitSchemeStateChanged, this, _1)); m_work.GetIsolinesManager().SetStateListener(bind(&Framework::IsolinesSchemeStateChanged, this, _1)); - m_work.GetGuidesManager().SetStateListener(bind(&Framework::GuidesSchemeStateChanged, this, _1)); + m_work.GetGuidesManager().SetStateListener(bind(&Framework::GuidesLayerStateChanged, this, _1)); m_work.GetPowerManager().Subscribe(this); } @@ -177,7 +177,7 @@ void Framework::IsolinesSchemeStateChanged(IsolinesManager::IsolinesState state) m_onIsolinesStateChangedFn(state); } -void Framework::GuidesSchemeStateChanged(GuidesManager::GuidesState state) +void Framework::GuidesLayerStateChanged(GuidesManager::GuidesState state) { if (m_onGuidesStateChangedFn) m_onGuidesStateChangedFn(state); @@ -1797,12 +1797,11 @@ Java_com_mapswithme_maps_Framework_nativeIsIsolinesLayerEnabled(JNIEnv * env, jc return static_cast(frm()->LoadIsolinesEnabled()); } -JNIEXPORT void JNICALL -Java_com_mapswithme_maps_Framework_nativeSetGuidesLayerEnabled(JNIEnv * env, jclass, jboolean enabled) +JNIEXPORT void JNICALL Java_com_mapswithme_maps_Framework_nativeSetGuidesLayerEnabled( + JNIEnv * env, jclass, jboolean enabled) { - auto const value = static_cast(enabled); - frm()->GetGuidesManager().SetEnabled(value); - frm()->SaveGuidesEnabled(value); + frm()->GetGuidesManager().SetEnabled(static_cast(enabled)); + frm()->SaveGuidesEnabled(static_cast(enabled)); } JNIEXPORT jboolean JNICALL diff --git a/android/jni/com/mapswithme/maps/Framework.hpp b/android/jni/com/mapswithme/maps/Framework.hpp index bc49f76eb2..bc886302fd 100644 --- a/android/jni/com/mapswithme/maps/Framework.hpp +++ b/android/jni/com/mapswithme/maps/Framework.hpp @@ -71,7 +71,7 @@ namespace android void TrafficStateChanged(TrafficManager::TrafficState state); void TransitSchemeStateChanged(TransitReadManager::TransitSchemeState state); void IsolinesSchemeStateChanged(IsolinesManager::IsolinesState state); - void GuidesSchemeStateChanged(GuidesManager::GuidesState state); + void GuidesLayerStateChanged(GuidesManager::GuidesState state); void MyPositionModeChanged(location::EMyPositionMode mode, bool routingActive); diff --git a/android/jni/com/mapswithme/maps/guides/GuidesManager.cpp b/android/jni/com/mapswithme/maps/guides/GuidesManager.cpp index 0da140c9cf..b62b040e89 100644 --- a/android/jni/com/mapswithme/maps/guides/GuidesManager.cpp +++ b/android/jni/com/mapswithme/maps/guides/GuidesManager.cpp @@ -1,36 +1,33 @@ -#include -#include "com/mapswithme/maps/Framework.hpp" #include "com/mapswithme/core/jni_helper.hpp" +#include "com/mapswithme/maps/Framework.hpp" #include "com/mapswithme/platform/Platform.hpp" - +#include using namespace std::placeholders; extern "C" { -static void GuidesStateChanged(GuidesManager::GuidesState state, - std::shared_ptr const & listener) -{ - LOG(LINFO, (static_cast(state))); - JNIEnv * env = jni::GetEnv(); - env->CallVoidMethod(*listener, - jni::GetMethodID(env, *listener, "onStateChanged", "(I)V"), - static_cast(state)); -} + static void GuidesStateChanged(GuidesManager::GuidesState state, + std::shared_ptr const & listener) + { + LOG(LINFO, (static_cast(state))); + JNIEnv * env = jni::GetEnv(); + env->CallVoidMethod(*listener, jni::GetMethodID(env, *listener, "onStateChanged", "(I)V"), + static_cast(state)); + } + JNIEXPORT void JNICALL Java_com_mapswithme_maps_maplayer_guides_GuidesManager_nativeAddListener( + JNIEnv * env, jclass clazz, jobject listener) + { + CHECK(g_framework, ("Framework isn't created yet!")); + g_framework->SetGuidesListener( + std::bind(&GuidesStateChanged, std::placeholders::_1, jni::make_global_ref(listener))); + } -JNIEXPORT void JNICALL -Java_com_mapswithme_maps_maplayer_guides_GuidesManager_nativeAddListener(JNIEnv *env, jclass clazz, jobject listener) -{ - CHECK(g_framework, ("Framework isn't created yet!")); - g_framework->SetGuidesListener(std::bind(&GuidesStateChanged, - std::placeholders::_1, - jni::make_global_ref(listener))); -} - -JNIEXPORT void JNICALL -Java_com_mapswithme_maps_maplayer_guides_GuidesManager_nativeRemoveListener(JNIEnv * env, jclass clazz) -{ - CHECK(g_framework, ("Framework isn't created yet!")); - g_framework->SetGuidesListener(nullptr); -} + JNIEXPORT void JNICALL + Java_com_mapswithme_maps_maplayer_guides_GuidesManager_nativeRemoveListener(JNIEnv * env, + jclass clazz) + { + CHECK(g_framework, ("Framework isn't created yet!")); + g_framework->SetGuidesListener(nullptr); + } } diff --git a/android/res/layout-land/map_navigation_buttons.xml b/android/res/layout-land/map_navigation_buttons.xml index ae748e5bb1..47bde0a689 100644 --- a/android/res/layout-land/map_navigation_buttons.xml +++ b/android/res/layout-land/map_navigation_buttons.xml @@ -10,7 +10,6 @@ @@ -18,7 +17,6 @@ @@ -56,7 +51,6 @@ style="@style/MwmWidget.MapButton" android:layout_above="@+id/my_position" android:layout_alignParentEnd="true" - android:layout_alignParentRight="true" android:background="?nav_background" android:src="@drawable/ic_zoom_out"/> @@ -65,7 +59,6 @@ style="@style/MwmWidget.MapButton" android:layout_alignParentBottom="true" android:layout_alignParentEnd="true" - android:layout_alignParentRight="true" android:layout_marginBottom="@dimen/margin_base_plus" android:background="?nav_background" android:contentDescription="@string/core_my_position" @@ -75,7 +68,6 @@ android:id="@+id/subs_screen_btn_container" android:layout_alignBottom="@id/nav_zoom_out" android:layout_centerVertical="true" - android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_width="wrap_content" android:layout_height="wrap_content"> diff --git a/android/res/layout/map_navigation_buttons.xml b/android/res/layout/map_navigation_buttons.xml index be041bae19..f5785f1de4 100644 --- a/android/res/layout/map_navigation_buttons.xml +++ b/android/res/layout/map_navigation_buttons.xml @@ -10,7 +10,6 @@ @@ -68,14 +62,12 @@ android:src="@drawable/ic_zoom_in" android:layout_marginTop="@dimen/nav_zoom_top" android:layout_alignParentTop="true" - android:layout_alignParentRight="true" android:layout_alignParentEnd="true"/> diff --git a/android/src/com/mapswithme/maps/MwmActivity.java b/android/src/com/mapswithme/maps/MwmActivity.java index 53b88cdc15..5b4c3e0229 100644 --- a/android/src/com/mapswithme/maps/MwmActivity.java +++ b/android/src/com/mapswithme/maps/MwmActivity.java @@ -796,7 +796,11 @@ public class MwmActivity extends BaseMwmFragmentActivity View subway = frame.findViewById(R.id.subway); View isoLines = frame.findViewById(R.id.isolines); View guides = frame.findViewById(R.id.guides); - mToggleMapLayerController = new MapLayerCompositeController(traffic, subway, isoLines, guides, this); + mToggleMapLayerController = new MapLayerCompositeController(traffic, + subway, + isoLines, + guides, + this); mToggleMapLayerController.attachCore(); } diff --git a/android/src/com/mapswithme/maps/maplayer/LayersUtils.java b/android/src/com/mapswithme/maps/maplayer/LayersUtils.java index 3b32f02d4f..2fc9b7cb37 100644 --- a/android/src/com/mapswithme/maps/maplayer/LayersUtils.java +++ b/android/src/com/mapswithme/maps/maplayer/LayersUtils.java @@ -30,6 +30,6 @@ public class LayersUtils Pair> guides = new Pair<>(BottomSheetItem.Guides.makeInstance(context), guidesListener); - return Arrays.asList(traffic, isoLines, subway); + return Arrays.asList(guides, traffic, isoLines, subway); } } diff --git a/android/src/com/mapswithme/maps/maplayer/MapLayerCompositeController.java b/android/src/com/mapswithme/maps/maplayer/MapLayerCompositeController.java index cf719dffc5..571298fde6 100644 --- a/android/src/com/mapswithme/maps/maplayer/MapLayerCompositeController.java +++ b/android/src/com/mapswithme/maps/maplayer/MapLayerCompositeController.java @@ -65,13 +65,14 @@ public class MapLayerCompositeController implements MapLayerController trafficButtonController); ControllerAndMode isoLineEntry = new ControllerAndMode(Mode.ISOLINES, Tutorial.ISOLINES, isoLinesController); - ControllerAndMode guidesEntry = new ControllerAndMode(Mode.GUIDES, Tutorial.ISOLINES, + ControllerAndMode guidesEntry = new ControllerAndMode(Mode.GUIDES, null, guidesController); List entries = new ArrayList<>(); entries.add(subwayEntry); entries.add(isoLineEntry); entries.add(trafficEntry); + entries.add(guidesEntry); return entries; } diff --git a/android/src/com/mapswithme/maps/maplayer/Mode.java b/android/src/com/mapswithme/maps/maplayer/Mode.java index 5ca6054c67..4d30f4dc1d 100644 --- a/android/src/com/mapswithme/maps/maplayer/Mode.java +++ b/android/src/com/mapswithme/maps/maplayer/Mode.java @@ -105,8 +105,7 @@ public enum Mode SubwayManager.from(context).setEnabled(false); } }; - - + public abstract boolean isEnabled(@NonNull Context context); public abstract void setEnabled(@NonNull Context context, boolean isEnabled); diff --git a/android/src/com/mapswithme/maps/maplayer/guides/GuidesErrorDialogListener.java b/android/src/com/mapswithme/maps/maplayer/guides/GuidesErrorDialogListener.java index 7d65f9728f..6eaf901564 100644 --- a/android/src/com/mapswithme/maps/maplayer/guides/GuidesErrorDialogListener.java +++ b/android/src/com/mapswithme/maps/maplayer/guides/GuidesErrorDialogListener.java @@ -5,5 +5,5 @@ import com.mapswithme.maps.maplayer.isolines.IsolinesState; public interface GuidesErrorDialogListener { - void onStateChanged(@NonNull GuidesState type); + void onStateChanged(@NonNull GuidesState state); } diff --git a/android/src/com/mapswithme/maps/maplayer/guides/GuidesManager.java b/android/src/com/mapswithme/maps/maplayer/guides/GuidesManager.java index 694f176f8d..a61dbd6fe8 100644 --- a/android/src/com/mapswithme/maps/maplayer/guides/GuidesManager.java +++ b/android/src/com/mapswithme/maps/maplayer/guides/GuidesManager.java @@ -8,8 +8,6 @@ import androidx.annotation.Nullable; import com.mapswithme.maps.Framework; import com.mapswithme.maps.MwmApplication; import com.mapswithme.maps.base.Initializable; -import com.mapswithme.maps.maplayer.isolines.IsolinesErrorDialogListener; -import com.mapswithme.maps.maplayer.subway.OnIsolinesChangedListener; public class GuidesManager implements Initializable { diff --git a/android/src/com/mapswithme/maps/maplayer/isolines/IsolinesManager.java b/android/src/com/mapswithme/maps/maplayer/isolines/IsolinesManager.java index 9831cbcfd5..761f7d7d4a 100644 --- a/android/src/com/mapswithme/maps/maplayer/isolines/IsolinesManager.java +++ b/android/src/com/mapswithme/maps/maplayer/isolines/IsolinesManager.java @@ -9,7 +9,6 @@ import com.mapswithme.maps.Framework; import com.mapswithme.maps.MwmApplication; import com.mapswithme.maps.base.Detachable; import com.mapswithme.maps.base.Initializable; -import com.mapswithme.maps.maplayer.subway.OnIsolinesChangedListener; public class IsolinesManager implements Initializable, Detachable { diff --git a/android/src/com/mapswithme/maps/maplayer/subway/OnIsolinesChangedListener.java b/android/src/com/mapswithme/maps/maplayer/isolines/OnIsolinesChangedListener.java similarity index 63% rename from android/src/com/mapswithme/maps/maplayer/subway/OnIsolinesChangedListener.java rename to android/src/com/mapswithme/maps/maplayer/isolines/OnIsolinesChangedListener.java index d69e6e3f0f..f547490f28 100644 --- a/android/src/com/mapswithme/maps/maplayer/subway/OnIsolinesChangedListener.java +++ b/android/src/com/mapswithme/maps/maplayer/isolines/OnIsolinesChangedListener.java @@ -1,4 +1,4 @@ -package com.mapswithme.maps.maplayer.subway; +package com.mapswithme.maps.maplayer.isolines; public interface OnIsolinesChangedListener { diff --git a/android/src/com/mapswithme/maps/maplayer/isolines/OnIsolinesChangedListenerImpl.java b/android/src/com/mapswithme/maps/maplayer/isolines/OnIsolinesChangedListenerImpl.java index f3054face1..f0d020e001 100644 --- a/android/src/com/mapswithme/maps/maplayer/isolines/OnIsolinesChangedListenerImpl.java +++ b/android/src/com/mapswithme/maps/maplayer/isolines/OnIsolinesChangedListenerImpl.java @@ -4,7 +4,6 @@ import android.app.Application; import androidx.annotation.NonNull; import com.mapswithme.maps.base.Detachable; -import com.mapswithme.maps.maplayer.subway.OnIsolinesChangedListener; class OnIsolinesChangedListenerImpl implements OnIsolinesChangedListener, Detachable { diff --git a/map/framework.cpp b/map/framework.cpp index 6b05601176..eac3a1472d 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -3031,10 +3031,7 @@ bool Framework::LoadGuidesEnabled() return enabled; } -void Framework::SaveGuidesEnabled(bool enabled) -{ - settings::Set(kGuidesEnabledKey, enabled); -} +void Framework::SaveGuidesEnabled(bool enabled) { settings::Set(kGuidesEnabledKey, enabled); } void Framework::EnableChoosePositionMode(bool enable, bool enableBounds, bool applyPosition, m2::PointD const & position)