suggesting to tap on the compass arrow to activate auto-follow mode.

This commit is contained in:
rachytski 2012-09-28 18:00:53 +03:00 committed by Alex Zolotarev
parent cf738aceaa
commit 957eb11bb4
4 changed files with 44 additions and 0 deletions

View file

@ -10,6 +10,7 @@
#include "../core/jni_helper.hpp"
#include "../platform/Platform.hpp"
#include "../../../../../platform/settings.hpp"
extern "C"
{
@ -54,4 +55,26 @@ extern "C"
{
g_framework->NativeFramework()->SaveFacebookDialogResult(static_cast<int>(result));
}
JNIEXPORT jboolean JNICALL
Java_com_mapswithme_maps_MWMApplication_nativeGetBoolean(JNIEnv * env,
jobject thiz,
jstring name,
jboolean defaultVal)
{
bool val = static_cast<bool>(defaultVal);
Settings::Get(jni::ToNativeString(env, name), val);
return static_cast<jboolean>(val);
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_MWMApplication_nativeSetBoolean(JNIEnv * env,
jobject thiz,
jstring name,
jboolean val)
{
bool flag = static_cast<bool>(val);
(void)Settings::Set(jni::ToNativeString(env, name), flag);
}
}

View file

@ -22,6 +22,7 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.mapswithme.maps.location.LocationService;
import com.mapswithme.util.ConnectionState;
@ -38,6 +39,8 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
private BroadcastReceiver m_externalStorageReceiver = null;
private AlertDialog m_storageDisconnectedDialog = null;
private boolean m_shouldStartLocationService = false;
private boolean m_hasLocation = false;
private boolean m_suggestAutoFollowMode = false;
private LocationService getLocationService()
{
@ -57,6 +60,7 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
private void stopLocation()
{
m_hasLocation = false;
getLocationService().stopUpdate(this);
// Enable automatic turning screen off while app is idle
Utils.automaticIdleScreen(true, getWindow());
@ -507,7 +511,11 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
public void onLocationStatusChanged(int newStatus)
{
if (newStatus == LocationService.FIRST_EVENT)
{
findViewById(R.id.map_button_myposition).setBackgroundResource(R.drawable.myposition_button_found);
m_hasLocation = true;
m_suggestAutoFollowMode = mApplication.nativeGetBoolean("SuggestAutoFollowMode", true);
}
nativeLocationStatusChanged(newStatus);
@ -571,6 +579,14 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService
trueNorth = LocationService.correctAngle(trueNorth, correction);
nativeCompassUpdated(time, magneticNorth, trueNorth, accuracy);
if (m_hasLocation
&& mApplication.isProVersion()
&& m_suggestAutoFollowMode)
{
Toast.makeText(this, R.string.suggest_auto_follow_mode, Toast.LENGTH_LONG).show();
m_suggestAutoFollowMode = false;
}
}
//@}

View file

@ -179,4 +179,8 @@ public class MWMApplication extends android.app.Application implements MapStorag
/// values of result param should correspond to values defined in map/Framework.hpp
public native void nativeSubmitFacebookDialogResult(int result);
/// @}
/// Dealing with Settings
public native boolean nativeGetBoolean(String name, boolean defaultVal);
public native void nativeSetBoolean(String name, boolean val);
}

View file

@ -508,6 +508,7 @@ namespace location
case EActive:
if (m_hasCompass && IsCentered())
{
(void)Settings::Set("SuggestAutoFollowMode", false);
setState(EPressed);
SetCompassProcessMode(ECompassFollow);
CheckFollowCompass();