From fcf97b04b9adb2cd7a6be5866c4fa5b782fb2296 Mon Sep 17 00:00:00 2001 From: vng Date: Sun, 25 Aug 2013 02:04:08 +0300 Subject: [PATCH] [android] Fix checking for available guides. --- android/jni/com/mapswithme/maps/Framework.cpp | 25 ----------- .../com/mapswithme/maps/MWMApplication.cpp | 19 ++++++++ .../jni/com/mapswithme/maps/MapStorage.cpp | 43 +++++++++++-------- .../jni/com/mapswithme/maps/MapStorage.hpp | 3 +- .../maps/DownloadResourcesActivity.java | 2 +- .../src/com/mapswithme/maps/Framework.java | 5 --- .../com/mapswithme/maps/MWMApplication.java | 22 +++++----- tools/android/aapt | 2 +- 8 files changed, 58 insertions(+), 63 deletions(-) diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index 139bd1d2c8..eb0b046c8a 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -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, "", "(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; - } } diff --git a/android/jni/com/mapswithme/maps/MWMApplication.cpp b/android/jni/com/mapswithme/maps/MWMApplication.cpp index 0afee794c6..72721da3d1 100644 --- a/android/jni/com/mapswithme/maps/MWMApplication.cpp +++ b/android/jni/com/mapswithme/maps/MWMApplication.cpp @@ -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, "", "(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; + } } diff --git a/android/jni/com/mapswithme/maps/MapStorage.cpp b/android/jni/com/mapswithme/maps/MapStorage.cpp index d4e59f0262..990a952735 100644 --- a/android/jni/com/mapswithme/maps/MapStorage.cpp +++ b/android/jni/com/mapswithme/maps/MapStorage.cpp @@ -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, "", "(III)V"); - ASSERT(methodID, ()); - - return env->NewObject(klass, methodID, - static_cast(idx.m_group), - static_cast(idx.m_country), - static_cast(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, "", "(III)V"); + ASSERT(methodID, ()); + + return env->NewObject(klass, methodID, + static_cast(idx.m_group), + static_cast(idx.m_country), + static_cast(idx.m_region)); + } + + TIndex toNative(jobject idx) + { + return IndexBinding(idx).toNative(); + } +} diff --git a/android/jni/com/mapswithme/maps/MapStorage.hpp b/android/jni/com/mapswithme/maps/MapStorage.hpp index cba03c1ab1..a6a3833e00 100644 --- a/android/jni/com/mapswithme/maps/MapStorage.hpp +++ b/android/jni/com/mapswithme/maps/MapStorage.hpp @@ -7,5 +7,6 @@ namespace storage { - jobject toJava(storage::TIndex const & idx); + jobject toJava(TIndex const & idx); + TIndex toNative(jobject idx); } diff --git a/android/src/com/mapswithme/maps/DownloadResourcesActivity.java b/android/src/com/mapswithme/maps/DownloadResourcesActivity.java index 8c3b5a0bc3..cdde250e7d 100644 --- a/android/src/com/mapswithme/maps/DownloadResourcesActivity.java +++ b/android/src/com/mapswithme/maps/DownloadResourcesActivity.java @@ -645,7 +645,7 @@ public class DownloadResourcesActivity extends MapsWithMeBaseActivity return "ge0.me".equals(data.getHost()); } - return false; + return false; } @Override diff --git a/android/src/com/mapswithme/maps/Framework.java b/android/src/com/mapswithme/maps/Framework.java index 884c8f05cd..a9dd5e2797 100644 --- a/android/src/com/mapswithme/maps/Framework.java +++ b/android/src/com/mapswithme/maps/Framework.java @@ -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 */ diff --git a/android/src/com/mapswithme/maps/MWMApplication.java b/android/src/com/mapswithme/maps/MWMApplication.java index 1e1fae0d52..8e49873b8b 100644 --- a/android/src/com/mapswithme/maps/MWMApplication.java +++ b/android/src/com/mapswithme/maps/MWMApplication.java @@ -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 diff --git a/tools/android/aapt b/tools/android/aapt index deb2cfabdc..4b8b904905 100755 --- a/tools/android/aapt +++ b/tools/android/aapt @@ -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