From fcb40b8403a83cef023b7872ff060cbd6918009b Mon Sep 17 00:00:00 2001 From: vng Date: Mon, 25 Jun 2012 23:13:39 -0700 Subject: [PATCH] Remove Platform::IsProVersion. --- .../jni/com/mapswithme/maps/MWMActivity.cpp | 6 ----- .../src/com/mapswithme/maps/MWMActivity.java | 27 ++++++------------- .../com/mapswithme/maps/MWMApplication.java | 5 ++++ iphone/Maps/Classes/SearchVC.mm | 23 ++++++++++++---- platform/platform.cpp | 10 ++----- platform/platform.hpp | 4 --- platform/platform_android.cpp | 10 ------- platform/platform_ios.mm | 13 --------- platform/platform_qt.cpp | 7 ----- 9 files changed, 33 insertions(+), 72 deletions(-) diff --git a/android/jni/com/mapswithme/maps/MWMActivity.cpp b/android/jni/com/mapswithme/maps/MWMActivity.cpp index a93f59ce35..5f7cde4d08 100644 --- a/android/jni/com/mapswithme/maps/MWMActivity.cpp +++ b/android/jni/com/mapswithme/maps/MWMActivity.cpp @@ -107,12 +107,6 @@ extern "C" #define PRO_VERSION_CHECK_INTERVAL 2 * 60 * 60 //#define PRO_VERSION_CHECK_INTERVAL 10 - JNIEXPORT jboolean JNICALL - Java_com_mapswithme_maps_MWMActivity_nativeIsProVersion(JNIEnv * env, jobject thiz) - { - return GetPlatform().IsFeatureSupported("search"); - } - JNIEXPORT jstring JNICALL Java_com_mapswithme_maps_MWMActivity_nativeGetProVersionURL(JNIEnv * env, jobject thiz) { diff --git a/android/src/com/mapswithme/maps/MWMActivity.java b/android/src/com/mapswithme/maps/MWMActivity.java index 9f9fd2269f..a26df6af0b 100644 --- a/android/src/com/mapswithme/maps/MWMActivity.java +++ b/android/src/com/mapswithme/maps/MWMActivity.java @@ -16,7 +16,6 @@ import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; -import android.view.Surface; import android.view.View; import android.webkit.WebView; @@ -68,16 +67,10 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService @Override public void run() { + // Run all checks in main thread after rendering is initialized. checkShouldStartLocationService(); - } - }); - - runOnUiThread(new Runnable() - { - @Override - public void run() - { checkMeasurementSystem(); + checkProVersionAvailable(); } }); } @@ -113,7 +106,6 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService private void setMeasurementSystem(int u) { nativeSetMS(u); - checkProVersionAvailable(); } private void checkMeasurementSystem() @@ -191,14 +183,12 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService private void checkProVersionAvailable() { - final boolean isPro = nativeIsProVersion(); - // get pro-version url only for lite-version - final String url = isPro ? "" : nativeGetProVersionURL(); - - if (isPro || (url.length() != 0)) + if (mApplication.isProVersion() || + (nativeGetProVersionURL().length() != 0)) + { findViewById(R.id.map_button_search).setVisibility(View.VISIBLE); - - if (!isPro && (url.length() == 0)) + } + else { if (android.os.Build.MODEL.equals("Kindle Fire")) nativeCheckForProVersion("http://redbutton.mapswithme.com/enable_search_banner_amazon_appstore"); @@ -248,7 +238,7 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService public void onSearchClicked(View v) { - if (!nativeIsProVersion()) + if (!mApplication.isProVersion()) { showProVersionBanner(getString(R.string.search_available_in_pro_version)); } @@ -588,7 +578,6 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService private native void nativeLocationUpdated(long time, double lat, double lon, float accuracy); private native void nativeCompassUpdated(long time, double magneticNorth, double trueNorth, double accuracy); - private native boolean nativeIsProVersion(); private native String nativeGetProVersionURL(); private native void nativeCheckForProVersion(String serverURL); diff --git a/android/src/com/mapswithme/maps/MWMApplication.java b/android/src/com/mapswithme/maps/MWMApplication.java index ba7781e18b..3d8ba3e651 100644 --- a/android/src/com/mapswithme/maps/MWMApplication.java +++ b/android/src/com/mapswithme/maps/MWMApplication.java @@ -64,6 +64,11 @@ public class MWMApplication extends android.app.Application return storagePath.concat(String.format("/Android/data/%s/%s/", PACKAGE_NAME, folder)); } + public boolean isProVersion() + { + return true; + } + private String getTmpPath() { return getCacheDir().getAbsolutePath() + "/"; diff --git a/iphone/Maps/Classes/SearchVC.mm b/iphone/Maps/Classes/SearchVC.mm index ef0cb35fd1..d5c0f0c770 100644 --- a/iphone/Maps/Classes/SearchVC.mm +++ b/iphone/Maps/Classes/SearchVC.mm @@ -7,12 +7,16 @@ #import "MapsAppDelegate.h" #include "Framework.h" -#include "../../geometry/angles.hpp" -#include "../../geometry/distance_on_sphere.hpp" + +#include "../../search/result.hpp" + +#include "../../indexer/mercator.hpp" + #include "../../platform/platform.hpp" #include "../../platform/preferred_languages.hpp" -#include "../../indexer/mercator.hpp" -#include "../../search/result.hpp" + +#include "../../geometry/angles.hpp" +#include "../../geometry/distance_on_sphere.hpp" #define MAPSWITHME_PREMIUM_APPSTORE_URL @"itms://itunes.com/apps/mapswithmepro" @@ -210,10 +214,19 @@ static void OnSearchResultCallback(search::Results const & res) [self dismissModalViewControllerAnimated:YES]; } +- (BOOL)IsProVersion +{ + NSString * appID = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]; + // .travelguide corresponds to the Lite version without search + if ([appID rangeOfString:@"com.mapswithme.travelguide"].location != NSNotFound) + return FALSE; + return TRUE; +} + - (void)viewWillAppear:(BOOL)animated { // Disable search for free version - if (!GetPlatform().IsFeatureSupported("search")) + if (![self IsProVersion]) { // Display banner for paid version UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Search is only available in the full version of MapsWithMe. Would you like to get it now?", @"Search button pressed dialog title in the free version") diff --git a/platform/platform.cpp b/platform/platform.cpp index 732a2be967..4d52fa7a1a 100644 --- a/platform/platform.cpp +++ b/platform/platform.cpp @@ -31,16 +31,10 @@ string Platform::HashUniqueID(string const & s) string Platform::MetaServerUrl() const { - if (IsFeatureSupported("search")) - return "http://active.servers.url"; - else - return "http://active.servers.url"; + return "http://active.servers.url"; } string Platform::DefaultUrlsJSON() const { - if (IsFeatureSupported("search")) - return "[\"http://1st.default.server/\",\"http://2nd.default.server/\",\"http://3rd.default.server/\"]"; - else - return "[\"http://1st.default.server/\",\"http://2nd.default.server/\",\"http://3rd.default.server/\"]"; + return "[\"http://1st.default.server/\",\"http://2nd.default.server/\",\"http://3rd.default.server/\"]"; } diff --git a/platform/platform.hpp b/platform/platform.hpp index cc94a804b3..8cb0c2a3a8 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -114,11 +114,7 @@ public: string UniqueClientId() const; - /// @return true for "search" feature if app needs search functionality - bool IsFeatureSupported(string const & feature) const; - /// @return url for clients to download maps - /// Different urls are returned for versions with and without search support string MetaServerUrl() const; /// @return JSON-encoded list of urls if metaserver is unreachable diff --git a/platform/platform_android.cpp b/platform/platform_android.cpp index 54d1f43add..8046a07e5e 100644 --- a/platform/platform_android.cpp +++ b/platform/platform_android.cpp @@ -169,16 +169,6 @@ bool Platform::GetFileSizeByFullPath(string const & filePath, uint64_t & size) return false; } -bool Platform::IsFeatureSupported(string const & feature) const -{ - if (feature == "search") - { - /// @todo add additional checks for apk, protection, etc ... - return true; - } - return false; -} - void Platform::RunOnGuiThread(TFunctor const & fn) { /// @todo diff --git a/platform/platform_ios.mm b/platform/platform_ios.mm index bb7ec10309..7032985764 100644 --- a/platform/platform_ios.mm +++ b/platform/platform_ios.mm @@ -223,19 +223,6 @@ string Platform::UniqueClientId() const return HashUniqueID(GetMacAddress() + GetDeviceUid()); } -bool Platform::IsFeatureSupported(string const & feature) const -{ - if (feature == "search") - { - NSString * appID = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"]; - // .travelguide corresponds to the Lite version without search - if ([appID rangeOfString:@"com.mapswithme.travelguide"].location != NSNotFound) - return false; - return true; - } - return false; -} - static void PerformImpl(void * obj) { Platform::TFunctor * f = reinterpret_cast(obj); diff --git a/platform/platform_qt.cpp b/platform/platform_qt.cpp index 075cf58f8e..8dff47b7e2 100644 --- a/platform/platform_qt.cpp +++ b/platform/platform_qt.cpp @@ -74,13 +74,6 @@ int Platform::VideoMemoryLimit() const return 20 * 1024 * 1024; } -bool Platform::IsFeatureSupported(string const & feature) const -{ - if (feature == "search") - return true; - return false; -} - /////////////////////////////////////////////////////////////////////////////// extern "C" Platform & GetPlatform() {