Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrachytski <siarhei.rachytski@gmail.com>2012-05-12 20:45:45 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:38:25 +0300
commite8c348f12a3b6ef835f9331f3e3a3bc128c5fbc1 (patch)
tree28c05f34f889849ea6d1c9083a0a6798ca10e2be /android/src/com/mapswithme/maps/MWMApplication.java
parent783a816ad206c53342d190981b09b5eb422670d2 (diff)
added MWMApplication and moved Platform and Framework initialization code into it.
Diffstat (limited to 'android/src/com/mapswithme/maps/MWMApplication.java')
-rw-r--r--android/src/com/mapswithme/maps/MWMApplication.java81
1 files changed, 81 insertions, 0 deletions
diff --git a/android/src/com/mapswithme/maps/MWMApplication.java b/android/src/com/mapswithme/maps/MWMApplication.java
new file mode 100644
index 0000000000..3ed9c375f1
--- /dev/null
+++ b/android/src/com/mapswithme/maps/MWMApplication.java
@@ -0,0 +1,81 @@
+package com.mapswithme.maps;
+
+import java.io.File;
+
+import android.app.Application;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.os.Environment;
+
+public class MWMApplication extends Application
+{
+ public final static String PACKAGE_NAME = "com.mapswithme.maps";
+
+ public void onCreate()
+ {
+ final String extStoragePath = getDataStoragePath();
+ final String extTmpPath = getExtAppDirectoryPath("caches");
+ // Create folders if they don't exist
+ new File(extStoragePath).mkdirs();
+ new File(extTmpPath).mkdirs();
+
+ nativeInit(getApkPath(),
+ extStoragePath,
+ getTmpPath(),
+ extTmpPath,
+ getSettingsPath(),
+ getString(R.string.empty_model));
+
+ super.onCreate();
+ }
+
+ public String getApkPath()
+ {
+ try
+ {
+ return getPackageManager().getApplicationInfo(PACKAGE_NAME, 0).sourceDir;
+ }
+ catch (NameNotFoundException e)
+ {
+ e.printStackTrace();
+ return "";
+ }
+ }
+
+ public String getDataStoragePath()
+ {
+ return Environment.getExternalStorageDirectory().getAbsolutePath() + "/MapsWithMe/";
+ }
+
+ public String getExtAppDirectoryPath(String folder)
+ {
+ final String storagePath = Environment.getExternalStorageDirectory().getAbsolutePath();
+ return storagePath.concat(String.format("/Android/data/%s/%s/", PACKAGE_NAME, folder));
+ }
+
+ private String getTmpPath()
+ {
+ return getCacheDir().getAbsolutePath() + "/";
+ }
+
+ private String getSettingsPath()
+ {
+ return getFilesDir().getAbsolutePath() + "/";
+ }
+
+ public String getPackageName()
+ {
+ return PACKAGE_NAME;
+ }
+
+ static
+ {
+ System.loadLibrary("mapswithme");
+ }
+
+ private native void nativeInit(String apkPath,
+ String storagePath,
+ String tmpPath,
+ String extTmpPath,
+ String settingsPath,
+ String emptyModelMessage);
+}