diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 26092098cb..437e2d68e1 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -4,6 +4,7 @@ android:versionCode="1" android:versionName="1.0"> + CallRepaint(); +} + +void AndroidFramework::CallRepaint() +{ + m_env->CallVoidMethod(m_parentView, + jni::GetJavaMethodID(m_env, m_parentView, "requestRender", "()V")); +} + +AndroidFramework::AndroidFramework() +: m_view(new ViewHandle(this)), m_work(m_view, 0) +{ + m_work.InitStorage(m_storage); +} + +void AndroidFramework::SetParentView(JNIEnv * env, jobject view) +{ + m_env = env; + m_parentView = view; +} + +void AndroidFramework::Init() +{ + //initializeGL(); + //m_view->setDrawer(new DrawerYG()); + //m_view->setRenderContext(); +} diff --git a/android/jni/framework.h b/android/jni/framework.h new file mode 100644 index 0000000000..f7c0f1fe23 --- /dev/null +++ b/android/jni/framework.h @@ -0,0 +1,39 @@ +#pragma once + +#include "../../map/framework.hpp" +#include "../../map/feature_vec_model.hpp" +#include "../../map/window_handle.hpp" + +#include "../../storage/storage.hpp" + +#include + + +class AndroidFramework +{ +public: + class ViewHandle : public WindowHandle + { + AndroidFramework * m_parent; + public: + ViewHandle(AndroidFramework * parent) : m_parent(parent) {} + virtual void invalidateImpl(); + }; + +private: + shared_ptr m_view; + FrameWork m_work; + storage::Storage m_storage; + + JNIEnv * m_env; + jobject m_parentView; + + void CallRepaint(); + +public: + AndroidFramework(); + + void SetParentView(JNIEnv * env, jobject view); + + void Init(); +}; diff --git a/android/jni/jni_helper.h b/android/jni/jni_helper.h index 8700c847f9..bde60a7b8c 100644 --- a/android/jni/jni_helper.h +++ b/android/jni/jni_helper.h @@ -1,3 +1,5 @@ +#pragma once + #include namespace jni @@ -15,10 +17,10 @@ namespace jni LOG("Enter callbackFromJNI"); env->CallVoidMethod(thiz, - jni_help::GetJavaMethodID(env, thiz, "callbackVoid", "()V")); + jni::GetJavaMethodID(env, thiz, "callbackVoid", "()V")); env->CallVoidMethod( thiz, - jni_help::GetJavaMethodID(env, thiz, "callbackString", + jni::GetJavaMethodID(env, thiz, "callbackString", "(Ljava/lang/String;)V"), env->NewStringUTF("Pass string from JNI.")); LOG("Leave callbackFromJNI"); diff --git a/android/jni/jni_string.h b/android/jni/jni_string.h index 1d803f9441..1fa4510fc0 100644 --- a/android/jni/jni_string.h +++ b/android/jni/jni_string.h @@ -1,3 +1,5 @@ +#pragma once + #include #include diff --git a/android/jni/logging.cpp b/android/jni/logging.cpp new file mode 100644 index 0000000000..682bf42849 --- /dev/null +++ b/android/jni/logging.cpp @@ -0,0 +1,30 @@ +#include "logging.h" + +#include + +namespace jni { + +using namespace my; + +void AndroidLogMessage(LogLevel l, SrcPoint const & src, string const & s) +{ + android_LogPriority pr = ANDROID_LOG_SILENT; + + switch (l) + { + case LINFO: pr = ANDROID_LOG_INFO; break; + case LDEBUG: pr = ANDROID_LOG_DEBUG; break; + case LWARNING: pr = ANDROID_LOG_WARN; break; + case LERROR: pr = ANDROID_LOG_ERROR; break; + case LCRITICAL: pr = ANDROID_LOG_FATAL; break; + } + + __android_log_print(pr, "mapswithme", s.c_str()); +} + +void InitSystemLog() +{ + SetLogMessageFn(&AndroidLogMessage); +} + +} diff --git a/android/jni/logging.h b/android/jni/logging.h index bac16fc19b..fe1187cdd9 100644 --- a/android/jni/logging.h +++ b/android/jni/logging.h @@ -1,3 +1,8 @@ -#include +#pragma once -#define LOG(...) __android_log_print(ANDROID_LOG_INFO, "mapswithme", __VA_ARGS__) +#include "../../base/logging.hpp" + +namespace jni +{ + void InitSystemLog(); +} diff --git a/android/jni/main_native.cpp b/android/jni/main_native.cpp index 9b53d687d9..34a320463f 100644 --- a/android/jni/main_native.cpp +++ b/android/jni/main_native.cpp @@ -1,10 +1,13 @@ #include "logging.h" #include "platform.h" +#include "framework.h" #include #include +AndroidFramework * g_work; + extern "C" { /////////////////////////////////////////////////////////////////////////////////// @@ -12,9 +15,13 @@ extern "C" /////////////////////////////////////////////////////////////////////////////////// JNIEXPORT void JNICALL - Java_com_mapswithme_maps_MWMActivity_nativeInit(JNIEnv * env, jobject activity, jstring path) + Java_com_mapswithme_maps_MWMActivity_nativeInit(JNIEnv * env, jobject thiz, jstring path) { - GetAndroidPlatform().Initialize(env, activity, path); + jni::InitSystemLog(); + + GetAndroidPlatform().Initialize(env, thiz, path); + + g_work = new AndroidFramework(); } /////////////////////////////////////////////////////////////////////////////////// @@ -24,6 +31,7 @@ extern "C" JNIEXPORT void JNICALL Java_com_mapswithme_maps_MainGLView_nativeInit(JNIEnv * env, jobject thiz) { + g_work->SetParentView(env, thiz); } JNIEXPORT void JNICALL diff --git a/android/jni/platform.h b/android/jni/platform.h index 5418fbdb27..29aa9ea951 100644 --- a/android/jni/platform.h +++ b/android/jni/platform.h @@ -1,3 +1,5 @@ +#pragma once + #include "../../platform/platform.hpp" #include diff --git a/android/jni/temp_stubs.cpp b/android/jni/temp_stubs.cpp new file mode 100644 index 0000000000..a017260521 --- /dev/null +++ b/android/jni/temp_stubs.cpp @@ -0,0 +1,45 @@ +#include "../../platform/concurrent_runner.hpp" + +#include "../../platform/download_manager.hpp" + +namespace threads +{ + ConcurrentRunner::ConcurrentRunner() + { + } + + ConcurrentRunner::~ConcurrentRunner() + { + } + + void ConcurrentRunner::Run(RunnerFuncT const & f) const + { + } + + void ConcurrentRunner::Join() + { + } +} + +class AndroidDownloadManager : public DownloadManager +{ +public: + + virtual void HttpRequest(HttpStartParams const & params) + { + } + + virtual void CancelDownload(string const & url) + { + } + + virtual void CancelAllDownloads() + { + } +}; + +DownloadManager & GetDownloadManager() +{ + static AndroidDownloadManager manager; + return manager; +}