Add flag for PRO version in Platform. Return meta server url for downloading due to this flag.

This commit is contained in:
vng 2012-07-09 11:48:08 -07:00 committed by Alex Zolotarev
parent dac15d8d86
commit 6347a62935
9 changed files with 53 additions and 20 deletions

View file

@ -20,14 +20,16 @@ extern "C"
jstring storagePath,
jstring tmpPath,
jstring extTmpPath,
jstring settingsPath)
jstring settingsPath,
jboolean isPro)
{
android::Platform::Instance().Initialize(env,
apkPath,
storagePath,
tmpPath,
extTmpPath,
settingsPath);
settingsPath,
isPro);
if (!g_framework)
g_framework = new android::Framework();

View file

@ -8,6 +8,9 @@
#include "../../../../../std/algorithm.hpp"
#include "../../../../../std/cmath.hpp"
// For the future: It's better to use virtual functions instead of this stuff.
/*
class Platform::PlatformImpl
{
public:
@ -17,10 +20,12 @@ public:
size_t m_preCachingDepth;
};
*/
int Platform::PreCachingDepth() const
{
return m_impl->m_preCachingDepth;
//return m_impl->m_preCachingDepth;
return 3;
}
string Platform::UniqueClientId() const
@ -70,7 +75,7 @@ namespace android
{
Platform::~Platform()
{
delete m_impl;
//delete m_impl;
}
void Platform::Initialize(JNIEnv * env,
@ -78,12 +83,12 @@ namespace android
jstring storagePath,
jstring tmpPath,
jstring extTmpPath,
jstring settingsPath)
jstring settingsPath,
bool isPro)
{
if (m_impl)
delete m_impl;
m_impl = new PlatformImpl();
//if (m_impl)
// delete m_impl;
//m_impl = new PlatformImpl();
m_resourcesDir = jni::ToNativeString(env, apkPath);
m_writableDir = jni::ToNativeString(env, storagePath);
@ -94,6 +99,8 @@ namespace android
// By default use external temporary folder
m_tmpDir = m_externalTmpPath;
m_isPro = isPro;
LOG(LDEBUG, ("Apk path = ", m_resourcesDir));
LOG(LDEBUG, ("Writable path = ", m_writableDir));
LOG(LDEBUG, ("Local tmp path = ", m_localTmpPath));

View file

@ -22,7 +22,8 @@ namespace android
jstring storagePath,
jstring tmpPath,
jstring extTmpPath,
jstring settingsPath);
jstring settingsPath,
bool isPro);
void OnExternalStorageStatusChanged(bool isAvailable);

View file

@ -53,7 +53,8 @@ public class MWMApplication extends android.app.Application
extStoragePath,
getTmpPath(),
extTmpPath,
getSettingsPath());
getSettingsPath(),
mIsProVersion);
}
public LocationService getLocationService()
@ -117,5 +118,6 @@ public class MWMApplication extends android.app.Application
String storagePath,
String tmpPath,
String extTmpPath,
String settingsPath);
String settingsPath,
boolean isPro);
}

View file

@ -216,11 +216,7 @@ static void OnSearchResultCallback(search::Results const & res)
- (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;
return GetPlatform().IsPro();
}
- (void)viewWillAppear:(BOOL)animated

View file

@ -38,12 +38,18 @@ string Platform::ResourcesMetaServerUrl() const
string Platform::MetaServerUrl() const
{
return "http://active.servers.url";
if (m_isPro)
return "http://active.servers.url";
else
return "http://active.servers.url";
}
string Platform::DefaultUrlsJSON() const
{
return "[\"http://1st.default.server/\",\"http://2nd.default.server/\",\"http://3rd.default.server/\"]";
if (m_isPro)
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/\"]";
}
void Platform::GetFontNames(FilesList & res) const

View file

@ -26,6 +26,8 @@ protected:
string m_tmpDir;
/// Writable directory to store persistent application data
string m_settingsDir;
/// Flag that it's a paid PRO version of app.
bool m_isPro;
class PlatformImpl;
/// Used only on those platforms where needed
@ -121,9 +123,13 @@ public:
string UniqueClientId() const;
inline bool IsPro() const { return m_isPro; }
/// @return url for clients to download maps
//@{
string MetaServerUrl() const;
string ResourcesMetaServerUrl() const;
//@}
/// @return JSON-encoded list of urls if metaserver is unreachable
string DefaultUrlsJSON() const;

View file

@ -70,6 +70,10 @@ Platform::Platform()
m_impl->m_scaleEtalonSize = 256 * 1.5 * [[UIScreen mainScreen] scale];
NSString * appID = [[bundle infoDictionary] objectForKey:@"CFBundleIdentifier"];
// .travelguide corresponds to the Lite version without search
m_isPro = ([appID rangeOfString:@"com.mapswithme.travelguide"].location == NSNotFound);
NSLog(@"Device: %@, SystemName: %@, SystemVersion: %@", device.model, device.systemName, device.systemVersion);
[pool release];

View file

@ -61,6 +61,15 @@ int Platform::VideoMemoryLimit() const
///////////////////////////////////////////////////////////////////////////////
extern "C" Platform & GetPlatform()
{
static Platform platform;
class PlatformQt : public Platform
{
public:
PlatformQt()
{
m_isPro = true;
}
};
static PlatformQt platform;
return platform;
}