[android] Fix checking for available guides.

This commit is contained in:
vng 2013-08-25 02:04:08 +03:00 committed by Alex Zolotarev
parent aee576643d
commit fcf97b04b9
8 changed files with 58 additions and 63 deletions

View file

@ -771,29 +771,4 @@ extern "C"
{
g_framework->NativeFramework()->UpdateSavedDataVersion();
}
JNIEXPORT void JNICALL
Java_com_mapswithme_maps_Framework_updateGuidesData(JNIEnv * env, jclass clazz)
{
g_framework->NativeFramework()->GetGuidesManager().UpdateGuidesData();
}
JNIEXPORT jobject JNICALL
Java_com_mapswithme_maps_Framework_getGuideInfoForCountry(JNIEnv * env, jclass clazz, jstring countryId)
{
guides::GuideInfo info;
guides::GuidesManager & gManager = g_framework->NativeFramework()->GetGuidesManager();
if (gManager.GetGuideInfo(jni::ToNativeString(env, countryId), info))
{
const jclass giClazz = env->FindClass("com/mapswithme/maps/guides/GuideInfo");
const jmethodID constrId = env->GetMethodID(giClazz, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
return env->NewObject(giClazz, constrId,
jni::ToJavaString(env, info.m_appName),
jni::ToJavaString(env, info.m_appId),
jni::ToJavaString(env, info.m_appUrl));
}
return NULL;
}
}

View file

@ -6,6 +6,7 @@
*/
#include "Framework.hpp"
#include "MapStorage.hpp"
#include "../core/jni_helper.hpp"
@ -139,4 +140,22 @@ extern "C"
{
(void)Settings::Set(jni::ToNativeString(env, name), value);
}
JNIEXPORT jobject JNICALL
Java_com_mapswithme_maps_MWMApplication_getGuideInfoForIndex(JNIEnv * env, jclass clazz, jobject index)
{
guides::GuideInfo info;
if (g_framework->NativeFramework()->GetGuideInfo(storage::toNative(index), info))
{
const jclass giClazz = env->FindClass("com/mapswithme/maps/guides/GuideInfo");
const jmethodID constrId = env->GetMethodID(giClazz, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
return env->NewObject(giClazz, constrId,
jni::ToJavaString(env, info.m_appName),
jni::ToJavaString(env, info.m_appId),
jni::ToJavaString(env, info.m_appUrl));
}
return 0;
}
}

View file

@ -2,25 +2,6 @@
#include "Framework.hpp"
namespace storage
{
jobject toJava(storage::TIndex const & idx)
{
JNIEnv * env = jni::GetEnv();
jclass klass = env->FindClass("com/mapswithme/maps/MapStorage$Index");
ASSERT(klass, ());
jmethodID methodID = env->GetMethodID(klass, "<init>", "(III)V");
ASSERT(methodID, ());
return env->NewObject(klass, methodID,
static_cast<jint>(idx.m_group),
static_cast<jint>(idx.m_country),
static_cast<jint>(idx.m_region));
}
}
extern "C"
{
class IndexBinding
@ -196,3 +177,27 @@ extern "C"
return ret;
}
}
namespace storage
{
jobject toJava(TIndex const & idx)
{
JNIEnv * env = jni::GetEnv();
jclass klass = env->FindClass("com/mapswithme/maps/MapStorage$Index");
ASSERT(klass, ());
jmethodID methodID = env->GetMethodID(klass, "<init>", "(III)V");
ASSERT(methodID, ());
return env->NewObject(klass, methodID,
static_cast<jint>(idx.m_group),
static_cast<jint>(idx.m_country),
static_cast<jint>(idx.m_region));
}
TIndex toNative(jobject idx)
{
return IndexBinding(idx).toNative();
}
}

View file

@ -7,5 +7,6 @@
namespace storage
{
jobject toJava(storage::TIndex const & idx);
jobject toJava(TIndex const & idx);
TIndex toNative(jobject idx);
}

View file

@ -645,7 +645,7 @@ public class DownloadResourcesActivity extends MapsWithMeBaseActivity
return "ge0.me".equals(data.getHost());
}
return false;
return false;
}
@Override

View file

@ -1,7 +1,6 @@
package com.mapswithme.maps;
import com.mapswithme.maps.bookmarks.data.DistanceAndAzimut;
import com.mapswithme.maps.guides.GuideInfo;
/**
* This class wraps android::Framework.cpp class
@ -79,10 +78,6 @@ public class Framework
nativeUpdateSavedDataVersion();
}
public static native void updateGuidesData();
public static native GuideInfo getGuideInfoForCountry(String countryId);
/*
* "Implementation" - native methods
*/

View file

@ -84,21 +84,21 @@ public class MWMApplication extends android.app.Application implements MapStorag
}
}
private native GuideInfo getGuideInfoForIndex(Index idx);
private void tryNotifyGuideAvailable(Index idx)
{
if (Utils.hasAnyGoogleStoreInstalled())
if (Utils.hasAnyGoogleStoreInstalled())
{
final GuideInfo info = getGuideInfoForIndex(idx);
if (info != null && !GuidesUtils.isGuideInstalled(info.getAppId(), this))
{
final String countryId = getMapStorage().countryFileNameByIndex(idx);
final GuideInfo info = Framework.getGuideInfoForCountry(countryId);
if (info != null && !GuidesUtils.isGuideInstalled(info.getAppId(), this))
{
final Notifier notifier = new Notifier(this);
notifier.placeGuideAvailable(info.getAppName(),
info.getAppId(),
getMapStorage().countryName(idx));
}
final Notifier notifier = new Notifier(this);
notifier.placeGuideAvailable(info.getAppName(),
info.getAppId(),
getMapStorage().countryName(idx));
}
}
}
@Override

View file

@ -6,4 +6,4 @@
# Main purpose is transparently disable compression
# for given file types inside .zip (.apk) file
${0}2 "$@" -0 txt -0 bin -0 skn -0 html -0 png
${0}2 "$@" -0 txt -0 bin -0 skn -0 html -0 png -0 json