diff options
author | vng <viktor.govako@gmail.com> | 2013-09-12 17:58:47 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:01:17 +0300 |
commit | 1f7f812d6a150a2b47b37941ab343f3888ac3d6a (patch) | |
tree | 02285a37585dce1b4d61d7cf43a2ed08176e3a64 | |
parent | 211646b49c2d814df17b4689b0069c583537043f (diff) |
Bookmarks support for MWM Lite in Yota devices.
-rw-r--r-- | android/jni/com/mapswithme/maps/MWMApplication.cpp | 4 | ||||
-rw-r--r-- | android/jni/com/mapswithme/platform/Platform.cpp | 6 | ||||
-rw-r--r-- | android/jni/com/mapswithme/platform/Platform.hpp | 3 | ||||
-rw-r--r-- | android/src/com/mapswithme/maps/MWMActivity.java | 5 | ||||
-rw-r--r-- | android/src/com/mapswithme/maps/MWMApplication.java | 20 | ||||
-rw-r--r-- | android/src/com/mapswithme/maps/MapObjectFragment.java | 2 | ||||
-rw-r--r-- | android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java | 14 | ||||
-rw-r--r-- | android/src/com/mapswithme/util/statistics/Statistics.java | 13 | ||||
-rw-r--r-- | iphone/Maps/Bookmarks/BookmarksRootVC.mm | 2 | ||||
-rw-r--r-- | iphone/Maps/Classes/MapViewController.mm | 2 | ||||
-rw-r--r-- | iphone/Maps/Classes/MapsAppDelegate.mm | 4 | ||||
-rw-r--r-- | iphone/Maps/Classes/PlacePreviewViewController.mm | 2 | ||||
-rw-r--r-- | map/basic_tiling_render_policy.cpp | 2 | ||||
-rw-r--r-- | map/framework.cpp | 2 | ||||
-rw-r--r-- | platform/platform.cpp | 4 | ||||
-rw-r--r-- | platform/platform.hpp | 18 | ||||
-rw-r--r-- | platform/platform_ios.mm | 4 | ||||
-rw-r--r-- | platform/platform_qt.cpp | 2 |
18 files changed, 62 insertions, 47 deletions
diff --git a/android/jni/com/mapswithme/maps/MWMApplication.cpp b/android/jni/com/mapswithme/maps/MWMApplication.cpp index 0afee794c6..6375449d68 100644 --- a/android/jni/com/mapswithme/maps/MWMApplication.cpp +++ b/android/jni/com/mapswithme/maps/MWMApplication.cpp @@ -24,10 +24,10 @@ extern "C" Java_com_mapswithme_maps_MWMApplication_nativeInit( JNIEnv * env, jobject thiz, jstring apkPath, jstring storagePath, jstring tmpPath, jstring obbGooglePath, - jboolean isPro) + jboolean isPro, jboolean isYota) { android::Platform::Instance().Initialize( - env, apkPath, storagePath, tmpPath, obbGooglePath, isPro); + env, apkPath, storagePath, tmpPath, obbGooglePath, isPro, isYota); LOG(LDEBUG, ("Creating android::Framework instance ...")); diff --git a/android/jni/com/mapswithme/platform/Platform.cpp b/android/jni/com/mapswithme/platform/Platform.cpp index af122e59f9..41e18c4b3b 100644 --- a/android/jni/com/mapswithme/platform/Platform.cpp +++ b/android/jni/com/mapswithme/platform/Platform.cpp @@ -58,7 +58,7 @@ namespace android void Platform::Initialize(JNIEnv * env, jstring apkPath, jstring storagePath, jstring tmpPath, jstring obbGooglePath, - bool isPro) + bool isPro, bool isYota) { m_resourcesDir = jni::ToNativeString(env, apkPath); @@ -76,7 +76,9 @@ namespace android m_tmpDir = jni::ToNativeString(env, tmpPath); - m_isPro = isPro; + m_flags[PRO_URL] = isPro; + m_flags[HAS_BOOKMARKS] = isPro || isYota; + m_flags[HAS_ROTATION] = isPro; string const obbPath = jni::ToNativeString(env, obbGooglePath); Platform::FilesList files; diff --git a/android/jni/com/mapswithme/platform/Platform.hpp b/android/jni/com/mapswithme/platform/Platform.hpp index 6d65b92212..38344c02ac 100644 --- a/android/jni/com/mapswithme/platform/Platform.hpp +++ b/android/jni/com/mapswithme/platform/Platform.hpp @@ -9,11 +9,10 @@ namespace android class Platform : public ::Platform { public: - void Initialize(JNIEnv * env, jstring apkPath, jstring storagePath, jstring tmpPath, jstring obbGooglePath, - bool isPro); + bool isPro, bool isYota); void OnExternalStorageStatusChanged(bool isAvailable); diff --git a/android/src/com/mapswithme/maps/MWMActivity.java b/android/src/com/mapswithme/maps/MWMActivity.java index e5305a5582..4b64cf0b04 100644 --- a/android/src/com/mapswithme/maps/MWMActivity.java +++ b/android/src/com/mapswithme/maps/MWMActivity.java @@ -65,6 +65,7 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService private ImageButton mMyPositionButton; private SurfaceView mMapSurface; + // for API private View mTitleBar; private ImageView mAppIcon; @@ -72,8 +73,6 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService // Map tasks that we run AFTER rendering initialized private final Stack<MapTask> mTasks = new Stack<MWMActivity.MapTask>(); - - //showDialog(int, Bundle) available only form API 8 private String mProDialogMessage; @@ -248,7 +247,7 @@ public class MWMActivity extends NvEventQueueActivity implements LocationService public void onBookmarksClicked(View v) { - if (!mApplication.isProVersion()) + if (!mApplication.hasBookmarks()) { showProVersionBanner(getString(R.string.bookmarks_in_pro_version)); } diff --git a/android/src/com/mapswithme/maps/MWMApplication.java b/android/src/com/mapswithme/maps/MWMApplication.java index 1c56744742..3bf8eeda9f 100644 --- a/android/src/com/mapswithme/maps/MWMApplication.java +++ b/android/src/com/mapswithme/maps/MWMApplication.java @@ -38,7 +38,8 @@ public class MWMApplication extends android.app.Application implements MapStorag private final AppStateManager mAppStateManager = new AppStateManager(); - private boolean m_isProVersion = false; + private boolean m_isPro = false; + private boolean m_isYota = false; // Set default string to Google Play page. private final static String m_defaultProURL = "http://play.google.com/store/apps/details?id=com.mapswithme.maps.pro"; @@ -107,14 +108,15 @@ public class MWMApplication extends android.app.Application implements MapStorag { super.onCreate(); - m_isProVersion = getPackageName().contains(".pro"); + m_isPro = getPackageName().contains(".pro"); + m_isYota = Build.DEVICE.equals("yotaphone"); // http://stackoverflow.com/questions/1440957/httpurlconnection-getresponsecode-returns-1-on-second-invocation if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.ECLAIR_MR1) System.setProperty("http.keepAlive", "false"); // get url for PRO version - if (!m_isProVersion) + if (!m_isPro) { final AssetManager assets = getAssets(); InputStream stream = null; @@ -145,7 +147,7 @@ public class MWMApplication extends android.app.Application implements MapStorag // init native framework nativeInit(getApkPath(), extStoragePath, extTmpPath, - getOBBGooglePath(), m_isProVersion); + getOBBGooglePath(), m_isPro, m_isYota); m_slotID = getMapStorage().subscribe(this); @@ -161,7 +163,7 @@ public class MWMApplication extends android.app.Application implements MapStorag nativeAddLocalization("my_position", getString(R.string.my_position)); // init BookmarkManager (automatically loads bookmarks) - if (m_isProVersion) + if (hasBookmarks()) BookmarkManager.getBookmarkManager(getApplicationContext()); } @@ -235,7 +237,11 @@ public class MWMApplication extends android.app.Application implements MapStorag public boolean isProVersion() { - return m_isProVersion; + return m_isPro; + } + public boolean hasBookmarks() + { + return m_isPro || m_isYota; } public String getProVersionURL() @@ -265,7 +271,7 @@ public class MWMApplication extends android.app.Application implements MapStorag private native void nativeInit(String apkPath, String storagePath, String tmpPath, String obbGooglePath, - boolean isPro); + boolean isPro, boolean isYota); public native boolean nativeIsBenchmarking(); diff --git a/android/src/com/mapswithme/maps/MapObjectFragment.java b/android/src/com/mapswithme/maps/MapObjectFragment.java index 7a10e13deb..1debf6c8d4 100644 --- a/android/src/com/mapswithme/maps/MapObjectFragment.java +++ b/android/src/com/mapswithme/maps/MapObjectFragment.java @@ -297,7 +297,7 @@ public class MapObjectFragment extends Fragment private void onAddBookmarkClicked() { - if (MWMApplication.get().isProVersion()) + if (!MWMApplication.get().hasBookmarks()) { // TODO this cast if safe, but style is bad final MapObjectActivity activity = (MapObjectActivity) getActivity(); diff --git a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java index 6ef5dd7b22..b68731f243 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java @@ -3,12 +3,12 @@ package com.mapswithme.maps.bookmarks.data; import java.util.ArrayList; import java.util.List; -import com.mapswithme.util.statistics.Statistics; - import android.content.Context; import android.graphics.Point; import android.util.Pair; +import com.mapswithme.util.statistics.Statistics; + public class BookmarkManager { private static BookmarkManager sManager; @@ -20,25 +20,17 @@ public class BookmarkManager private BookmarkManager(Context context) { mContext = context; - refreshList(); + loadBookmarks(); mIconManager = new BookmarkIconManager(context); } public static BookmarkManager getBookmarkManager(Context context) { if (sManager == null) - { sManager = new BookmarkManager(context.getApplicationContext()); - } - return sManager; } - private void refreshList() - { - loadBookmarks(); - } - private native void loadBookmarks(); public void deleteBookmark(Bookmark bmk) diff --git a/android/src/com/mapswithme/util/statistics/Statistics.java b/android/src/com/mapswithme/util/statistics/Statistics.java index d63bc15a58..c5268042b5 100644 --- a/android/src/com/mapswithme/util/statistics/Statistics.java +++ b/android/src/com/mapswithme/util/statistics/Statistics.java @@ -4,8 +4,8 @@ import android.app.Activity; import android.content.Context; import android.util.Log; -import com.mapswithme.maps.R; import com.mapswithme.maps.MWMApplication; +import com.mapswithme.maps.R; import com.mapswithme.maps.api.ParsedMmwRequest; import com.mapswithme.maps.bookmarks.data.BookmarkManager; import com.mapswithme.util.MathUtils; @@ -201,16 +201,17 @@ public enum Statistics private void collectOneTimeStatistics(Activity activity) { - final EventBuilder eventBuilder = getEventBuilder().reset(); - // Only for PRO - if (MWMApplication.get().isProVersion()) + // Only when bookmarks available. + if (MWMApplication.get().hasBookmarks()) { + final EventBuilder eventBuilder = getEventBuilder().reset(); + // Number of sets final BookmarkManager manager = BookmarkManager.getBookmarkManager(activity); final int categoriesCount = manager.getCategoriesCount(); if (categoriesCount > 0) { - // Calculate average num of bmks in category + // Calculate average number of bookmarks in category final double[] sizes = new double[categoriesCount]; for (int catIndex = 0; catIndex < categoriesCount; catIndex++) sizes[catIndex] = manager.getCategoryById(catIndex).getSize(); @@ -218,12 +219,14 @@ public enum Statistics eventBuilder.addParam("Average number of bmks", String.valueOf(average)); } + eventBuilder.addParam("Categories count", String.valueOf(categoriesCount)) .addParam("Foreground time", String.valueOf(MWMApplication.get().getForegroundTime())) .setName("One time PRO stat"); trackIfEnabled(activity, eventBuilder.getEvent()); } + // TODO add number of maps setStatisticsCollected(activity, true); } diff --git a/iphone/Maps/Bookmarks/BookmarksRootVC.mm b/iphone/Maps/Bookmarks/BookmarksRootVC.mm index f40f6dcbb7..4df43b82cb 100644 --- a/iphone/Maps/Bookmarks/BookmarksRootVC.mm +++ b/iphone/Maps/Bookmarks/BookmarksRootVC.mm @@ -231,7 +231,7 @@ - (void)viewWillAppear:(BOOL)animated { // Disable bookmarks for free version - if (!GetPlatform().IsPro()) + if (!GetPlatform().HasBookmarks()) { // Display banner for paid version UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"bookmarks_in_pro_version", nil) diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index 406b921e29..5ead37c2e5 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -156,7 +156,7 @@ const long long LITE_IDL = 431183278L; return; } else - if (GetPlatform().IsPro()) + if (GetPlatform().HasRotation()) { if (ls->HasCompass()) { diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index d75bc0c115..e7ff0f6db5 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -74,7 +74,7 @@ void InitLocalizedStrings() - (void)applicationDidBecomeActive:(UIApplication *)application { - if (GetPlatform().IsPro() && !m_didOpenedWithUrl) + if (!m_didOpenedWithUrl) { UIPasteboard * pasteboard = [UIPasteboard generalPasteboard]; if (pasteboard.string.length) @@ -179,7 +179,7 @@ void InitLocalizedStrings() m_didOpenedWithUrl = NO; - if (GetPlatform().IsPro()) + if (GetPlatform().HasBookmarks()) { int val = 0; if (Settings::Get("NumberOfBookmarksPerSession", val)) diff --git a/iphone/Maps/Classes/PlacePreviewViewController.mm b/iphone/Maps/Classes/PlacePreviewViewController.mm index cab6abb6e1..77e5606f11 100644 --- a/iphone/Maps/Classes/PlacePreviewViewController.mm +++ b/iphone/Maps/Classes/PlacePreviewViewController.mm @@ -209,7 +209,7 @@ typedef enum {APIPOINT, POI, MYPOSITION} Type; -(void)addToBookmark { - if (!GetPlatform().IsPro()) + if (!GetPlatform().HasBookmarks()) { // Display banner for paid version UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"bookmarks_in_pro_version", nil) diff --git a/map/basic_tiling_render_policy.cpp b/map/basic_tiling_render_policy.cpp index 2467852b48..47ddc0d07c 100644 --- a/map/basic_tiling_render_policy.cpp +++ b/map/basic_tiling_render_policy.cpp @@ -12,7 +12,7 @@ BasicTilingRenderPolicy::BasicTilingRenderPolicy(Params const & p, bool doUseQueuedRenderer) - : RenderPolicy(p, GetPlatform().IsPro(), GetPlatform().CpuCores() + 2), + : RenderPolicy(p, GetPlatform().HasRotation(), GetPlatform().CpuCores() + 2), m_IsEmptyModel(false), m_IsNavigating(false), m_WasAnimatingLastFrame(false), diff --git a/map/framework.cpp b/map/framework.cpp index 45b2a4377d..69cccb7bcf 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -340,7 +340,7 @@ void Framework::RemoveLocalMaps() void Framework::LoadBookmarks() { - if (GetPlatform().IsPro()) + if (GetPlatform().HasBookmarks()) m_bmManager.LoadBookmarks(); } diff --git a/platform/platform.cpp b/platform/platform.cpp index a9681e996f..2eabee06c5 100644 --- a/platform/platform.cpp +++ b/platform/platform.cpp @@ -44,7 +44,7 @@ string Platform::ResourcesMetaServerUrl() const string Platform::MetaServerUrl() const { - if (m_isPro) + if (IsPro()) return "http://active.servers.url"; else return "http://active.servers.url"; @@ -52,7 +52,7 @@ string Platform::MetaServerUrl() const string Platform::DefaultUrlsJSON() const { - if (m_isPro) + if (IsPro()) return "[\"http://v2s-1.mapswithme.com/\",\"http://v2s-2.mapswithme.com/\",\"http://v2s-3.mapswithme.com/\"]"; else return "[\"http://v2-1.mapswithme.com/\",\"http://v2-2.mapswithme.com/\",\"http://v2-3.mapswithme.com/\"]"; diff --git a/platform/platform.hpp b/platform/platform.hpp index 5bc1899fa6..9c24c7e92d 100644 --- a/platform/platform.hpp +++ b/platform/platform.hpp @@ -8,9 +8,11 @@ #include "../std/vector.hpp" #include "../std/utility.hpp" #include "../std/function.hpp" +#include "../std/bitset.hpp" #include "../defines.hpp" + DECLARE_EXCEPTION(FileAbsentException, RootException); DECLARE_EXCEPTION(NotImplementedException, RootException); @@ -26,8 +28,16 @@ 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; + + enum + { + PRO_URL, + HAS_BOOKMARKS, + HAS_ROTATION, + FLAGS_COUNT // should always be the last one + }; + + bitset<FLAGS_COUNT> m_flags; /// Extended resource files. /// Used in Android only (downloaded zip files as a container). @@ -123,7 +133,9 @@ public: string UniqueClientId() const; - inline bool IsPro() const { return m_isPro; } + inline bool IsPro() const { return m_flags[PRO_URL]; } + inline bool HasBookmarks() const { return m_flags[HAS_BOOKMARKS]; } + inline bool HasRotation() const { return m_flags[HAS_ROTATION]; } /// @return url for clients to download maps //@{ diff --git a/platform/platform_ios.mm b/platform/platform_ios.mm index 33727bcdef..13f6b2364b 100644 --- a/platform/platform_ios.mm +++ b/platform/platform_ios.mm @@ -44,8 +44,10 @@ Platform::Platform() m_tmpDir += "/tmp/"; NSString * appID = [[bundle infoDictionary] objectForKey:@"CFBundleIdentifier"]; + // .travelguide corresponds to the Lite version without search - m_isPro = ([appID rangeOfString:@"com.mapswithme.travelguide"].location == NSNotFound); + m_flags[PRO_URL] = ([appID rangeOfString:@"com.mapswithme.travelguide"].location == NSNotFound); + m_flags[HAS_BOOKMARKS] = m_flags[HAS_ROTATION] = m_flags[PRO_URL]; UIDevice * device = [UIDevice currentDevice]; NSLog(@"Device: %@, SystemName: %@, SystemVersion: %@", device.model, device.systemName, device.systemVersion); diff --git a/platform/platform_qt.cpp b/platform/platform_qt.cpp index 25165f59d6..4e6d202245 100644 --- a/platform/platform_qt.cpp +++ b/platform/platform_qt.cpp @@ -66,7 +66,7 @@ extern Platform & GetPlatform() public: PlatformQt() { - m_isPro = true; + m_flags.set(); } }; |