[Android] Add AndroidFramework and other dependent stuff.

This commit is contained in:
vng 2011-06-26 02:01:42 +03:00 committed by Alex Zolotarev
parent 8f0ae263e0
commit 67e72bc2d4
11 changed files with 184 additions and 7 deletions

View file

@ -4,6 +4,7 @@
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="7" />
<uses-feature android:glEsVersion="0x00010001" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MWMActivity"

View file

@ -4,18 +4,26 @@ include $(CLEAR_VARS)
LOCAL_MODULE := mapswithme
#LOCAL_CFLAGS := -DANDROID_NDK \
# -DDISABLE_IMPORTGL
LOCAL_HEADER_FILES := \
jni_helper.h \
jni_string.h \
logging.h \
platform.h \
framework.h \
LOCAL_SRC_FILES := \
main_native.cpp \
jni_helper.cpp \
jni_string.cpp \
platform.cpp \
framework.cpp \
logging.cpp \
temp_stubs.cpp \
LOCAL_LDLIBS := -llog \
LOCAL_LDLIBS := -llog -lGLESv1_CM \
-lwords -lmap -lstorage -lversion -lsearch -lindexer -lyg -lplatform \
-lgeometry -lcoding -lbase -lexpat -lfreetype -lfribidi -lzlib -lbzip2 \
-ljansson -ltomcrypt ./obj/local/armeabi/libstdc++.a

35
android/jni/framework.cpp Normal file
View file

@ -0,0 +1,35 @@
#include "framework.h"
#include "jni_helper.h"
#include "../../map/drawer_yg.hpp"
void AndroidFramework::ViewHandle::invalidateImpl()
{
m_parent->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();
}

39
android/jni/framework.h Normal file
View file

@ -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 <jni.h>
class AndroidFramework
{
public:
class ViewHandle : public WindowHandle
{
AndroidFramework * m_parent;
public:
ViewHandle(AndroidFramework * parent) : m_parent(parent) {}
virtual void invalidateImpl();
};
private:
shared_ptr<ViewHandle> m_view;
FrameWork<model::FeaturesFetcher> m_work;
storage::Storage m_storage;
JNIEnv * m_env;
jobject m_parentView;
void CallRepaint();
public:
AndroidFramework();
void SetParentView(JNIEnv * env, jobject view);
void Init();
};

View file

@ -1,3 +1,5 @@
#pragma once
#include <jni.h>
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");

View file

@ -1,3 +1,5 @@
#pragma once
#include <string.h>
#include <jni.h>

30
android/jni/logging.cpp Normal file
View file

@ -0,0 +1,30 @@
#include "logging.h"
#include <android/log.h>
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);
}
}

View file

@ -1,3 +1,8 @@
#include <android/log.h>
#pragma once
#define LOG(...) __android_log_print(ANDROID_LOG_INFO, "mapswithme", __VA_ARGS__)
#include "../../base/logging.hpp"
namespace jni
{
void InitSystemLog();
}

View file

@ -1,10 +1,13 @@
#include "logging.h"
#include "platform.h"
#include "framework.h"
#include <string.h>
#include <jni.h>
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

View file

@ -1,3 +1,5 @@
#pragma once
#include "../../platform/platform.hpp"
#include <jni.h>

View file

@ -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;
}