forked from organicmaps/organicmaps
[android] Added resources and writable paths
This commit is contained in:
parent
10f6297a97
commit
ee90727d8c
4 changed files with 37 additions and 11 deletions
|
@ -15,13 +15,13 @@ extern "C"
|
|||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_MWMActivity_nativeInit(JNIEnv * env, jobject thiz, jstring path)
|
||||
Java_com_mapswithme_maps_MWMActivity_nativeInit(JNIEnv * env, jobject thiz, jstring apkPath, jstring storagePath)
|
||||
{
|
||||
jni::InitSystemLog();
|
||||
jni::InitAssertLog();
|
||||
|
||||
LOG(LDEBUG, ("MWMActivity::Init 1"));
|
||||
GetAndroidPlatform().Initialize(env, thiz, path);
|
||||
GetAndroidPlatform().Initialize(env, thiz, apkPath, storagePath);
|
||||
|
||||
LOG(LDEBUG, ("MWMActivity::Init 2"));
|
||||
g_work = new AndroidFramework();
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
#include "../../base/logging.hpp"
|
||||
|
||||
|
||||
void AndroidPlatform::Initialize(JNIEnv * env, jobject activity, jstring path)
|
||||
void AndroidPlatform::Initialize(JNIEnv * env, jobject activity, jstring apkPath, jstring storagePath)
|
||||
{
|
||||
m_writableDir = m_resourcesDir = jni::ToString(env, path);
|
||||
|
||||
LOG(LDEBUG, ("Resource path = ", m_resourcesDir));
|
||||
m_resourcesDir = jni::ToString(env, apkPath);
|
||||
m_writableDir = jni::ToString(env, storagePath);
|
||||
LOG(LDEBUG, ("Apk path = ", m_resourcesDir));
|
||||
LOG(LDEBUG, ("Writable path = ", m_writableDir));
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
class AndroidPlatform : public BasePlatformImpl
|
||||
{
|
||||
public:
|
||||
void Initialize(JNIEnv * env, jobject activity, jstring path);
|
||||
void Initialize(JNIEnv * env, jobject activity, jstring apkPath, jstring storagePath);
|
||||
|
||||
virtual void GetFontNames(FilesList & res) const;
|
||||
virtual int CpuCores() const;
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
package com.mapswithme.maps;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.mapswithme.maps.MainGLView;
|
||||
import com.mapswithme.maps.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
@ -13,12 +19,25 @@ import android.util.Log;
|
|||
public class MWMActivity extends Activity
|
||||
{
|
||||
private static String TAG = "MWMActivity";
|
||||
private final static String PACKAGE_NAME = "com.mapswithme.maps";
|
||||
|
||||
private MainGLView m_view;
|
||||
|
||||
private String getResourcePath()
|
||||
private String getAppBundlePath() throws NameNotFoundException
|
||||
{
|
||||
return new String("todo: get data path");
|
||||
PackageManager packMgmr = getApplication().getPackageManager();
|
||||
ApplicationInfo appInfo = packMgmr.getApplicationInfo(PACKAGE_NAME, 0);
|
||||
return appInfo.sourceDir;
|
||||
}
|
||||
|
||||
private String getDataStoragePath()
|
||||
{
|
||||
String storagePath = "";
|
||||
storagePath = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
storagePath = storagePath.concat(String.format("/%s", PACKAGE_NAME));
|
||||
File f = new File(storagePath);
|
||||
f.mkdirs();
|
||||
return storagePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +45,14 @@ public class MWMActivity extends Activity
|
|||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
nativeInit(getResourcePath());
|
||||
try
|
||||
{
|
||||
nativeInit(getAppBundlePath(), getDataStoragePath());
|
||||
}
|
||||
catch (NameNotFoundException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
m_view = new MainGLView(getApplication());
|
||||
|
||||
|
@ -77,5 +103,5 @@ public class MWMActivity extends Activity
|
|||
System.loadLibrary("mapswithme");
|
||||
}
|
||||
|
||||
private native void nativeInit(String path);
|
||||
private native void nativeInit(String apkPath, String storagePath);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue