[android] Fixed review notes

This commit is contained in:
Dmitry Donskoy 2020-04-28 20:42:39 +03:00 committed by Aleksandr Zatsepin
parent 529f7fbb9a
commit fc2cac4bf4
15 changed files with 43 additions and 66 deletions

View file

@ -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<jboolean>(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<bool>(enabled);
frm()->GetGuidesManager().SetEnabled(value);
frm()->SaveGuidesEnabled(value);
frm()->GetGuidesManager().SetEnabled(static_cast<bool>(enabled));
frm()->SaveGuidesEnabled(static_cast<bool>(enabled));
}
JNIEXPORT jboolean JNICALL

View file

@ -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);

View file

@ -1,36 +1,33 @@
#include <jni.h>
#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 <jni.h>
using namespace std::placeholders;
extern "C"
{
static void GuidesStateChanged(GuidesManager::GuidesState state,
std::shared_ptr<jobject> const & listener)
{
LOG(LINFO, (static_cast<int>(state)));
JNIEnv * env = jni::GetEnv();
env->CallVoidMethod(*listener,
jni::GetMethodID(env, *listener, "onStateChanged", "(I)V"),
static_cast<jint>(state));
}
static void GuidesStateChanged(GuidesManager::GuidesState state,
std::shared_ptr<jobject> const & listener)
{
LOG(LINFO, (static_cast<int>(state)));
JNIEnv * env = jni::GetEnv();
env->CallVoidMethod(*listener, jni::GetMethodID(env, *listener, "onStateChanged", "(I)V"),
static_cast<jint>(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);
}
}

View file

@ -10,7 +10,6 @@
<ImageButton
android:id="@+id/traffic"
style="@style/MwmWidget.MapButton.Traffic"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:visibility="invisible"/>
@ -18,7 +17,6 @@
<ImageButton
android:id="@+id/subway"
style="@style/MwmWidget.MapButton.Traffic"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="?attr/nav_bg_subway"
@ -27,7 +25,6 @@
<ImageButton
android:id="@+id/isolines"
style="@style/MwmWidget.MapButton.Traffic"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="?nav_bg_isolines"
@ -36,7 +33,6 @@
<ImageButton
android:id="@+id/guides"
style="@style/MwmWidget.MapButton.Traffic"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="?guidesIcon"
@ -47,7 +43,6 @@
style="@style/MwmWidget.MapButton"
android:layout_above="@+id/nav_zoom_out"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:background="?nav_background"
android:src="@drawable/ic_zoom_in"/>
@ -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">

View file

@ -10,7 +10,6 @@
<ImageButton
android:id="@+id/traffic"
style="@style/MwmWidget.MapButton.Traffic"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:visibility="invisible"
@ -19,7 +18,6 @@
<ImageButton
android:id="@+id/subway"
style="@style/MwmWidget.MapButton.Traffic"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:visibility="invisible"
@ -29,7 +27,6 @@
<ImageButton
android:id="@+id/isolines"
style="@style/MwmWidget.MapButton.Traffic"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:visibility="invisible"
@ -38,7 +35,6 @@
<ImageButton
android:id="@+id/guides"
style="@style/MwmWidget.MapButton.Traffic"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:visibility="invisible"
@ -48,7 +44,6 @@
android:id="@+id/my_position"
style="@style/MwmWidget.MapButton"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/nav_my_position_bottom"
android:contentDescription="@string/core_my_position"
@ -58,7 +53,6 @@
android:id="@+id/nav_zoom_out"
style="@style/MwmWidget.MapButton"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/nav_zoom_in"
android:src="@drawable/ic_zoom_out"/>
@ -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"/>
<FrameLayout
android:id="@+id/subs_screen_btn_container"
android:layout_centerVertical="true"
android:layout_alignBottom="@id/nav_zoom_in"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

View file

@ -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();
}

View file

@ -30,6 +30,6 @@ public class LayersUtils
Pair<BottomSheetItem, OnItemClickListener<BottomSheetItem>> guides
= new Pair<>(BottomSheetItem.Guides.makeInstance(context), guidesListener);
return Arrays.asList(traffic, isoLines, subway);
return Arrays.asList(guides, traffic, isoLines, subway);
}
}

View file

@ -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<ControllerAndMode> entries = new ArrayList<>();
entries.add(subwayEntry);
entries.add(isoLineEntry);
entries.add(trafficEntry);
entries.add(guidesEntry);
return entries;
}

View file

@ -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);

View file

@ -5,5 +5,5 @@ import com.mapswithme.maps.maplayer.isolines.IsolinesState;
public interface GuidesErrorDialogListener
{
void onStateChanged(@NonNull GuidesState type);
void onStateChanged(@NonNull GuidesState state);
}

View file

@ -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<Void>
{

View file

@ -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<Void>, Detachable<IsolinesErrorDialogListener>
{

View file

@ -1,4 +1,4 @@
package com.mapswithme.maps.maplayer.subway;
package com.mapswithme.maps.maplayer.isolines;
public interface OnIsolinesChangedListener
{

View file

@ -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<IsolinesErrorDialogListener>
{

View file

@ -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)