forked from organicmaps/organicmaps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored Location and Compass observers mechanism.
- Loading branch information
Showing
23 changed files
with
298 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#include "Framework.hpp" | ||
|
||
#include "../core/jni_helper.hpp" | ||
|
||
extern "C" | ||
{ | ||
JNIEXPORT jint JNICALL | ||
Java_com_mapswithme_maps_LocationState_getCompassProcessMode(JNIEnv * env, jobject thiz) | ||
{ | ||
shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState(); | ||
return ls->CompassProcessMode(); | ||
} | ||
|
||
JNIEXPORT void JNICALL | ||
Java_com_mapswithme_maps_LocationState_setCompassProcessMode(JNIEnv * env, jobject thiz, jint mode) | ||
{ | ||
shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState(); | ||
ls->SetCompassProcessMode((location::ECompassProcessMode)mode); | ||
} | ||
|
||
JNIEXPORT jint JNICALL | ||
Java_com_mapswithme_maps_LocationState_getLocationProcessMode(JNIEnv * env, jobject thiz) | ||
{ | ||
shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState(); | ||
return ls->LocationProcessMode(); | ||
} | ||
|
||
JNIEXPORT void JNICALL | ||
Java_com_mapswithme_maps_LocationState_setLocationProcessMode(JNIEnv * env, jobject thiz, jint mode) | ||
{ | ||
shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState(); | ||
return ls->SetLocationProcessMode((location::ELocationProcessMode)mode); | ||
} | ||
|
||
JNIEXPORT void JNICALL | ||
Java_com_mapswithme_maps_LocationState_startCompassFollowing(JNIEnv * env, | ||
jobject thiz) | ||
{ | ||
shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState(); | ||
if (!ls->IsCentered()) | ||
ls->AnimateToPositionAndEnqueueFollowing(); | ||
else | ||
ls->StartCompassFollowing(); | ||
} | ||
|
||
JNIEXPORT void JNICALL | ||
Java_com_mapswithme_maps_LocationState_stopCompassFollowing(JNIEnv * env, | ||
jobject thiz) | ||
{ | ||
shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState(); | ||
ls->StopCompassFollowing(); | ||
} | ||
|
||
void CompassStatusChanged(int mode, shared_ptr<jobject> const & obj) | ||
{ | ||
JNIEnv * env = jni::GetEnv(); | ||
jmethodID methodID = jni::GetJavaMethodID(env, *obj.get(), "OnCompassStatusChanged", "(I)V"); | ||
jint val = static_cast<jint>(mode); | ||
env->CallVoidMethod(*obj.get(), methodID, val); | ||
} | ||
|
||
JNIEXPORT jint JNICALL | ||
Java_com_mapswithme_maps_LocationState_addCompassStatusListener(JNIEnv * env, jobject thiz, jobject obj) | ||
{ | ||
location::State::TCompassStatusListener fn = bind(&CompassStatusChanged, _1, jni::make_global_ref(obj)); | ||
shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState(); | ||
return ls->AddCompassStatusListener(fn); | ||
} | ||
|
||
JNIEXPORT void JNICALL | ||
Java_com_mapswithme_maps_LocationState_removeCompassStatusListener(JNIEnv * env, jobject thiz, jint slotID) | ||
{ | ||
shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState(); | ||
ls->RemoveCompassStatusListener(slotID); | ||
} | ||
|
||
JNIEXPORT jboolean JNICALL | ||
Java_com_mapswithme_maps_LocationState_hasPosition(JNIEnv * env, jobject thiz) | ||
{ | ||
shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState(); | ||
return ls->HasPosition(); | ||
} | ||
|
||
JNIEXPORT jboolean JNICALL | ||
Java_com_mapswithme_maps_LocationState_hasCompass(JNIEnv * env, jobject thiz) | ||
{ | ||
shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState(); | ||
return ls->HasCompass(); | ||
} | ||
|
||
JNIEXPORT void JNICALL | ||
Java_com_mapswithme_maps_LocationState_turnOff(JNIEnv * env, jobject thiz) | ||
{ | ||
shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState(); | ||
return ls->TurnOff(); | ||
} | ||
|
||
JNIEXPORT jboolean JNICALL | ||
Java_com_mapswithme_maps_LocationState_isVisible(JNIEnv * env, jobject thiz) | ||
{ | ||
shared_ptr<location::State> ls = g_framework->NativeFramework()->GetInformationDisplay().locationState(); | ||
return ls->isVisible(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.mapswithme.maps; | ||
|
||
public class LocationState | ||
{ | ||
/// These values should correspond to values of | ||
/// location::ELocationProcessMode defined in map/location_state.hpp | ||
public static final int LOCATION_DO_NOTHING = 0; | ||
public static final int LOCATION_CENTER_AND_SCALE = 1; | ||
public static final int LOCATION_CENTER_ONLY = 2; | ||
|
||
/// These values should correspond to values of | ||
/// location::ECompassProcessMode defined in map/location_state.hpp | ||
public static final int COMPASS_DO_NOTHING = 0; | ||
public static final int COMPASS_FOLLOW = 1; | ||
|
||
public native int getCompassProcessMode(); | ||
public native void setCompassProcessMode(int mode); | ||
|
||
public native int getLocationProcessMode(); | ||
public native void setLocationProcessMode(int mode); | ||
|
||
public native void startCompassFollowing(); | ||
public native void stopCompassFollowing(); | ||
|
||
public native int addCompassStatusListener(Object l); | ||
public native void removeCompassStatusListener(int slotID); | ||
|
||
public native boolean hasPosition(); | ||
public native boolean hasCompass(); | ||
|
||
public native void turnOff(); | ||
public native boolean isVisible(); | ||
} |
Oops, something went wrong.